/* 剪刀 · 石頭 · 布 - Mobile-first */
:root {
  --bg: #1a1b26;
  --surface: #24283b;
  --text: #c0caf5;
  --text-dim: #565f89;
  --accent: #7aa2f7;
  --accent-join: #9ece6a;
  --accent-host: #f7768e;
  --border: #3b4261;
  --card-bg: #414868;
  --font: 'Noto Sans TC', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 420px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 12px;
  padding-bottom: 24px;
}

/* 1. User bar */
.user-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--surface);
  border-radius: 12px;
  margin-bottom: 12px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--card-bg);
  object-fit: cover;
}

.avatar.placeholder {
  background: linear-gradient(135deg, #7aa2f7 0%, #bb9af7 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: white;
}

#userName {
  font-weight: 600;
  font-size: 1rem;
}

.btn-line {
  background: #06c755;
  color: white;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
}

/* 2. Host / Join */
.actions {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.btn {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-host {
  background: var(--accent-host);
  color: white;
}

.btn-join {
  background: var(--accent-join);
  color: #1a1b26;
}

/* Join prompt */
.join-prompt {
  background: var(--surface);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
}

.join-prompt h3 {
  font-size: 0.95rem;
  margin-bottom: 8px;
  color: var(--text-dim);
}

.join-prompt ul {
  list-style: none;
}

.join-prompt li {
  padding: 10px;
  background: var(--card-bg);
  border-radius: 8px;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.join-prompt li:last-child {
  margin-bottom: 0;
}

.join-prompt .join-game-btn {
  background: var(--accent-join);
  color: #1a1b26;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
}

/* 3. Game area */
.game-area {
  background: var(--surface);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 12px;
  min-height: 200px;
  border: 1px solid var(--border);
}

.game-status {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.95rem;
  margin-bottom: 16px;
  min-height: 1.4em;
}

.countdown {
  text-align: center;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--accent);
  margin: 10px 0;
}

.countdown.big {
  font-size: 3.5rem;
}

.cards {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 16px 0;
}

.card {
  flex: 1;
  min-width: 90px;
  max-width: 110px;
  padding: 16px 10px;
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.1s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.card:hover, .card:focus {
  border-color: var(--accent);
  outline: none;
}

.card.selected {
  border-color: var(--accent);
  background: #3b4261;
  box-shadow: 0 0 0 2px var(--accent);
}

.card .card-emoji {
  font-size: 2rem;
}

.card .card-label {
  font-size: 0.85rem;
  font-weight: 500;
}

.card:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.game-result {
  text-align: center;
  padding: 14px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 1.1rem;
  margin-top: 12px;
}

.game-result.win {
  background: rgba(158, 206, 106, 0.25);
  color: var(--accent-join);
}

.game-result.lose {
  background: rgba(247, 118, 142, 0.25);
  color: var(--accent-host);
}

.game-result.draw {
  background: rgba(122, 162, 247, 0.2);
  color: var(--accent);
}

/* 4. Users panel */
.panel {
  background: var(--surface);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
}

.panel h3 {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.users-list, .history-list {
  list-style: none;
}

.users-list li, .history-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.users-list li:last-child, .history-list li:last-child {
  border-bottom: none;
}

.users-list .avatar, .history-list .avatar {
  width: 32px;
  height: 32px;
  font-size: 14px;
}

/* 5. History */
.history-list li {
  flex-wrap: wrap;
}

.history-list .record {
  color: var(--text-dim);
  font-size: 0.85rem;
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--surface);
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 340px;
  border: 1px solid var(--border);
}

.modal-content h3 {
  margin-bottom: 16px;
  font-size: 1.1rem;
}

.modal-content label {
  display: block;
  margin-bottom: 12px;
}

.modal-content input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  margin-top: 4px;
}

.hint {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  cursor: pointer;
}

.btn-secondary {
  width: 100%;
  padding: 10px;
  background: var(--card-bg);
  color: var(--text);
  border: none;
  border-radius: 8px;
  margin-top: 10px;
  cursor: pointer;
}

#joinModalList {
  list-style: none;
  margin-bottom: 12px;
}

#joinModalList li {
  padding: 12px;
  background: var(--card-bg);
  border-radius: 8px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#joinModalList .join-game-btn {
  background: var(--accent-join);
  color: #1a1b26;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
}

.hidden {
  display: none !important;
}
