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

:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #1e2433;
  --sub: #6b7280;
  --primary: #4f6df5;
  --primary-dark: #3b55d9;
  --accent: #ffb020;
  --danger: #ef4444;
  --ok: #16a34a;
  --line: #e5e9f2;
  --radius: 16px;
}

body {
  font-family: 'Pretendard', 'Malgun Gothic', 'Apple SD Gothic Neo', sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

.screen {
  display: none;
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}
.screen.active {
  display: block;
}

h1.logo {
  text-align: center;
  font-size: 2rem;
  padding: 20px 0 4px;
  letter-spacing: -0.5px;
}
h1.logo .dot {
  color: var(--primary);
}
p.tagline {
  text-align: center;
  color: var(--sub);
  margin-bottom: 24px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 2px 10px rgba(30, 40, 80, 0.06);
}
.card.narrow {
  max-width: 420px;
  margin: 0 auto;
}

label.field {
  display: block;
  margin-bottom: 14px;
  font-weight: 600;
  font-size: 0.95rem;
}
label.field span {
  display: block;
  margin-bottom: 6px;
}
input[type='text'],
input[type='number'],
select {
  width: 100%;
  padding: 12px 14px;
  font-size: 1.05rem;
  border: 2px solid var(--line);
  border-radius: 10px;
  outline: none;
  background: #fff;
  font-family: inherit;
}
input:focus,
select:focus {
  border-color: var(--primary);
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  margin-bottom: 12px;
  cursor: pointer;
}
.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.btn {
  display: inline-block;
  width: 100%;
  padding: 14px;
  font-size: 1.1rem;
  font-weight: 700;
  font-family: inherit;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn:hover {
  background: var(--primary-dark);
}
.btn:disabled {
  background: #c3cbe4;
  cursor: not-allowed;
}
.btn.small {
  width: auto;
  padding: 8px 18px;
  font-size: 0.95rem;
}
.btn.ghost {
  background: transparent;
  color: var(--sub);
  border: 2px solid var(--line);
}
.btn.ghost:hover {
  color: var(--danger);
  border-color: var(--danger);
}
.btn.ok {
  background: var(--ok);
}
.btn.danger {
  background: var(--danger);
}

.error-msg {
  color: var(--danger);
  font-weight: 600;
  margin-top: 10px;
  min-height: 1.2em;
  text-align: center;
}

/* ---- 대기실 ---- */
.room-code-box {
  text-align: center;
  margin-bottom: 20px;
}
.room-code-box .label {
  color: var(--sub);
  font-weight: 600;
}
.room-code-box .code {
  font-size: 4.5rem;
  font-weight: 800;
  letter-spacing: 12px;
  color: var(--primary);
}
.player-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin: 16px 0;
}
.player-chip {
  padding: 8px 16px;
  background: #eef1fb;
  border-radius: 999px;
  font-weight: 700;
  font-size: 1.05rem;
}
.player-chip.team-0 {
  background: #e0e9ff;
  color: #2947c9;
}
.player-chip.team-1 {
  background: #ffe9e0;
  color: #c9502e;
}
.player-chip.team-2 {
  background: #e2f7e5;
  color: #1e7d34;
}
.player-chip.team-3 {
  background: #f7e9fb;
  color: #8e30a5;
}
.player-chip.dead {
  opacity: 0.35;
  text-decoration: line-through;
}

/* ---- 게임 화면 ---- */
.game-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.turn-info {
  font-size: 1.25rem;
  font-weight: 700;
}
.turn-info .name {
  color: var(--primary);
}

.word-stage {
  text-align: center;
  padding: 30px 16px;
}
.current-word {
  font-size: clamp(3rem, 9vw, 6rem);
  font-weight: 800;
  letter-spacing: 4px;
}
.current-word .last {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 10px;
}
.next-hint {
  margin-top: 14px;
  font-size: 1.3rem;
  color: var(--sub);
  font-weight: 600;
}
.next-hint b {
  color: var(--primary);
  font-size: 1.6rem;
}

.timer-wrap {
  height: 14px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin: 18px 0;
}
.timer-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--primary), #7d95ff);
  border-radius: 999px;
  transition: width 0.1s linear;
}
.timer-bar.hurry {
  background: linear-gradient(90deg, var(--danger), #ff8a5c);
}
.timer-num {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.input-row {
  display: flex;
  gap: 10px;
  max-width: 520px;
  margin: 0 auto;
}
.input-row input {
  flex: 1;
  font-size: 1.4rem;
  text-align: center;
}
.input-row .btn {
  width: 120px;
}
.feedback {
  text-align: center;
  min-height: 1.5em;
  margin-top: 10px;
  font-weight: 700;
}
.feedback.bad {
  color: var(--danger);
  animation: shake 0.3s;
}
.feedback.good {
  color: var(--ok);
}
.feedback.wait {
  color: var(--accent);
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.history-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
  justify-content: center;
}
.history-chip {
  padding: 6px 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-weight: 600;
}
.history-chip .who {
  color: var(--sub);
  font-size: 0.8rem;
  margin-left: 4px;
}
.history-chip.latest {
  border-color: var(--accent);
  background: #fff8ea;
}

/* ---- 점수판 / 사이드 ---- */
.game-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 18px;
}
@media (max-width: 860px) {
  .game-layout {
    grid-template-columns: 1fr;
  }
}
.scoreboard h3 {
  margin-bottom: 10px;
}
.score-row {
  display: flex;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: 8px;
  font-weight: 600;
}
.score-row.current {
  background: #eef1fb;
}
.score-row.dead {
  opacity: 0.4;
  text-decoration: line-through;
}
.score-row .pts {
  font-weight: 800;
  color: var(--primary);
}
.team-score-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 10px;
  font-weight: 800;
  font-size: 1.15rem;
  margin-bottom: 6px;
}

/* ---- 이의제기 ---- */
.appeal-card {
  border: 2px solid var(--accent);
  background: #fff8ea;
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  animation: pop 0.25s;
}
@keyframes pop {
  from { transform: scale(0.94); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.appeal-card .word {
  font-size: 2rem;
  font-weight: 800;
}
.appeal-card .who {
  color: var(--sub);
  margin-bottom: 12px;
}
.appeal-actions {
  display: flex;
  gap: 10px;
}

/* ---- 결과 ---- */
.result-box {
  text-align: center;
  padding: 40px 16px;
}
.result-box .trophy {
  font-size: 4rem;
}
.result-box .winner {
  font-size: 2.4rem;
  font-weight: 800;
  margin: 10px 0 4px;
}
.result-box .sub {
  color: var(--sub);
  margin-bottom: 24px;
}

.eliminated-banner {
  text-align: center;
  background: #fef2f2;
  border: 2px solid var(--danger);
  color: var(--danger);
  font-weight: 800;
  font-size: 1.2rem;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 14px;
}

.host-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 12px;
}
.settings-summary {
  text-align: center;
  color: var(--sub);
  font-weight: 600;
  margin-bottom: 16px;
}
.badge {
  display: inline-block;
  background: #eef1fb;
  color: var(--primary);
  border-radius: 999px;
  padding: 4px 12px;
  margin: 2px;
  font-size: 0.9rem;
}

/* ---- 도움말 ---- */
.hint-text {
  display: block;
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--sub);
  margin-top: 4px;
  line-height: 1.5;
}
.check .hint-text {
  margin: 0 0 0 26px;
}
.check-wrap {
  margin-bottom: 12px;
}
.check-wrap .check {
  margin-bottom: 2px;
}
details.help {
  max-width: 420px;
  margin: 0 auto 18px;
  background: #fffbef;
  border: 1px solid #f3e3b3;
  border-radius: 12px;
  padding: 12px 16px;
}
details.help.wide {
  max-width: 100%;
}
details.help summary {
  cursor: pointer;
  font-weight: 700;
  color: #8a6d1a;
}
details.help ol,
details.help ul {
  margin: 10px 0 4px 20px;
  line-height: 1.7;
  color: var(--ink);
}
details.help li b {
  color: var(--primary);
}
.game-guide {
  text-align: center;
  color: var(--sub);
  font-size: 0.9rem;
  margin-bottom: 10px;
}
