:root {
  --bg: #0f1226;
  --card: #1a1f3d;
  --accent: #ff5d73;
  --accent2: #4dd0e1;
  --ok: #37c871;
  --bad: #ff5252;
  --muted: #8b90b5;
  --text: #f2f3ff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 20% 0%, #23285a 0%, var(--bg) 55%);
  color: var(--text);
  font-family: "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  padding: 16px;
}

.card {
  width: 100%;
  max-width: 440px;
  background: var(--card);
  border-radius: 20px;
  padding: 28px 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

h1 { font-size: 28px; margin: 0 0 8px; }
h2 { margin: 0 0 12px; }
.accent { color: var(--accent); }
.sub { color: var(--muted); font-size: 14px; margin: 4px 0 20px; }
.hidden { display: none !important; }

.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #33396a;
  background: #12162f;
  color: var(--text);
  font-size: 16px;
}
input:focus { outline: 2px solid var(--accent2); }

button {
  border: none;
  border-radius: 12px;
  padding: 13px 16px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
}
.primary { background: var(--accent); color: #fff; }
.secondary { background: var(--accent2); color: #05202a; width: auto; padding: 13px 22px; }
button:disabled { opacity: 0.5; cursor: default; }

.divider { text-align: center; color: var(--muted); margin: 16px 0; font-size: 13px; }
.join-row { display: flex; gap: 10px; }
.join-row input { flex: 1; letter-spacing: 4px; text-align: center; }
.error { color: var(--bad); font-size: 14px; min-height: 20px; margin: 12px 0 0; }

.room-code { font-size: 18px; }
.room-code strong { font-size: 26px; letter-spacing: 6px; color: var(--accent2); }
.players { list-style: none; padding: 0; margin: 16px 0; }
.players li {
  padding: 12px 14px;
  background: #12162f;
  border-radius: 12px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
}
.players .tag { color: var(--muted); font-size: 12px; }

/* 對戰畫面 */
.battle-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.score-box { display: flex; flex-direction: column; align-items: center; min-width: 84px; }
.score-box .who { font-size: 12px; color: var(--muted); max-width: 84px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-box span:last-child { font-size: 30px; font-weight: 800; }
.score-box.me span:last-child { color: var(--accent2); }
.score-box.opp span:last-child { color: var(--accent); }
.progress { font-size: 14px; color: var(--muted); }

.timer-wrap { display: flex; justify-content: center; margin: 8px 0 16px; }
.timer {
  width: 52px; height: 52px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 800;
  background: #12162f; border: 3px solid var(--accent2);
}
.timer.low { border-color: var(--bad); color: var(--bad); }

.question { font-size: 24px; text-align: center; margin: 8px 0 20px; min-height: 60px; }
.choices { display: grid; gap: 10px; }
.choice {
  background: #12162f; color: var(--text);
  border: 1px solid #33396a; text-align: left;
}
.choice:hover:not(:disabled) { border-color: var(--accent2); }
.choice.correct { background: var(--ok); color: #05230f; border-color: var(--ok); }
.choice.wrong { background: var(--bad); color: #2a0606; border-color: var(--bad); }

.opp-status { margin-top: 16px; text-align: center; padding: 10px; border-radius: 12px; font-weight: 700; }
.opp-status.waiting { background: #12162f; color: var(--muted); }
.opp-status.correct { background: rgba(55, 200, 113, 0.18); color: var(--ok); }
.opp-status.wrong { background: rgba(255, 82, 82, 0.18); color: var(--bad); }

.result-scores { font-size: 20px; text-align: center; margin: 12px 0 24px; }

/* 快速喊話 */
.chat-bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; }
.chat-btn {
  width: auto;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 700;
  background: #12162f;
  color: var(--text);
  border: 1px solid #33396a;
  border-radius: 999px;
}
.chat-btn:hover:not(:disabled) { border-color: var(--accent); }
.chat-bar.cooldown .chat-btn { opacity: 0.4; }

.chat-toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  max-width: 80vw;
  padding: 12px 18px;
  border-radius: 16px;
  font-size: 17px;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  animation: pop 0.2s ease-out;
  z-index: 10;
}
.chat-toast .from { font-size: 12px; font-weight: 600; opacity: 0.8; display: block; margin-bottom: 2px; }
.chat-toast.me { background: var(--accent2); color: #05202a; }
.chat-toast.opp { background: var(--accent); color: #fff; }
@keyframes pop { from { transform: translateX(-50%) scale(0.8); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }
