:root {
  --bg: #101820;
  --panel: #162430;
  --panel-2: #1e3140;
  --line: #35505e;
  --text: #f7fbf7;
  --muted: #b8c9c6;
  --paper: #f2ead7;
  --paper-ink: #263134;
  --red: #d94a4a;
  --blue: #3b82c4;
  --neutral: #b7a27b;
  --assassin: #161b1f;
  --green: #71d69d;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.34);
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(217, 74, 74, 0.12), transparent 34%),
    linear-gradient(225deg, rgba(59, 130, 196, 0.15), transparent 38%),
    var(--bg);
  color: var(--text);
}

button,
input {
  border: 0;
  color: inherit;
  font: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.app-shell {
  width: min(720px, 100%);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 12px max(18px, env(safe-area-inset-bottom));
}

.topbar {
  display: grid;
  grid-template-columns: 48px 1fr 44px;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.game-mark {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

h1,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.9rem, 8vw, 3rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.topbar p,
.status-text,
.players,
.label,
.clue-panel small {
  color: var(--muted);
}

.topbar p {
  margin-top: 3px;
  font-size: 0.88rem;
}

.icon-button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  font-weight: 900;
}

.status-band,
.score-strip,
.action-dock,
.clue-form {
  display: grid;
  gap: 10px;
}

.status-band {
  grid-template-columns: 1fr auto;
  align-items: center;
  min-height: 78px;
  padding: 13px;
  border: 1px solid rgba(113, 214, 157, 0.24);
  border-radius: 16px;
  background: rgba(22, 36, 48, 0.9);
  box-shadow: var(--shadow);
}

.status-label,
.label {
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status-label {
  color: var(--green);
}

.status-text {
  margin-top: 3px;
  line-height: 1.32;
}

.turn-chip {
  min-width: 88px;
  padding: 9px 11px;
  border-radius: 999px;
  background: var(--panel-2);
  text-align: center;
  font-size: 0.84rem;
  font-weight: 900;
}

.turn-chip.red {
  background: rgba(217, 74, 74, 0.22);
  color: #ffd8d8;
}

.turn-chip.blue {
  background: rgba(59, 130, 196, 0.24);
  color: #d8ebff;
}

.score-strip {
  grid-template-columns: 1fr 1.1fr 1fr;
  margin: 10px 0;
}

.team-card,
.clue-panel,
.players-panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(22, 36, 48, 0.8);
}

.team-card {
  min-height: 70px;
  display: grid;
  place-items: center;
  gap: 2px;
  font-weight: 900;
}

.team-card strong {
  font-size: 1.55rem;
  line-height: 1;
}

.team-card.red.active {
  border-color: rgba(217, 74, 74, 0.8);
  box-shadow: inset 0 0 0 1px rgba(217, 74, 74, 0.3);
}

.team-card.blue.active {
  border-color: rgba(59, 130, 196, 0.9);
  box-shadow: inset 0 0 0 1px rgba(59, 130, 196, 0.32);
}

.clue-panel {
  min-width: 0;
  padding: 10px;
  text-align: center;
}

.clue-panel strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board-panel {
  padding: 10px;
  border: 1px solid rgba(242, 234, 215, 0.26);
  border-radius: 20px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    rgba(10, 17, 22, 0.62);
  background-size: 22px 22px;
  box-shadow: var(--shadow);
}

.board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(6px, 1.6vw, 10px);
}

.word-card {
  position: relative;
  min-width: 0;
  aspect-ratio: 1.42;
  padding: 6px;
  border: 1px solid rgba(48, 41, 30, 0.2);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.48), rgba(255, 255, 255, 0)),
    var(--paper);
  color: var(--paper-ink);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
  font-size: clamp(0.62rem, 2.5vw, 0.95rem);
  font-weight: 950;
  letter-spacing: 0;
  line-height: 1;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.word-card::after {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(38, 49, 52, 0.14);
  border-radius: 5px;
  pointer-events: none;
}

.word-card.revealed,
.word-card.spy-red,
.word-card.spy-blue,
.word-card.spy-neutral,
.word-card.spy-assassin {
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.42);
}

.word-card.revealed {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.12), transparent), #4b5960;
}

.word-card.revealed.red,
.word-card.spy-red {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.18), transparent), var(--red);
}

.word-card.revealed.blue,
.word-card.spy-blue {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.18), transparent), var(--blue);
}

.word-card.revealed.neutral,
.word-card.spy-neutral {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.16), transparent), var(--neutral);
}

.word-card.revealed.assassin,
.word-card.spy-assassin {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.12), transparent), var(--assassin);
}

.word-card:disabled:not(.revealed) {
  opacity: 0.82;
}

.action-dock {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 10px;
}

.clue-form {
  grid-template-columns: 1fr 72px auto;
  margin-top: 10px;
}

.primary,
.secondary,
.clue-form button,
.clue-form input {
  min-height: 44px;
  border-radius: 12px;
  font-weight: 900;
}

.primary {
  background: var(--green);
  color: #0b1713;
}

.secondary,
.clue-form button {
  border: 1px solid var(--line);
  background: var(--panel-2);
}

.clue-form input {
  min-width: 0;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: rgba(7, 14, 18, 0.72);
}

.players-panel {
  margin-top: 10px;
  padding: 11px;
}

.players {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 6px;
  margin-top: 8px;
  font-size: 0.88rem;
}

.player-pill {
  min-width: 0;
  padding: 8px 9px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
}

.player-pill.red {
  border-left: 4px solid var(--red);
}

.player-pill.blue {
  border-left: 4px solid var(--blue);
}

@media (max-width: 430px) {
  .status-band {
    grid-template-columns: 1fr;
  }

  .score-strip {
    grid-template-columns: 1fr 1fr;
  }

  .clue-panel {
    grid-column: 1 / -1;
    order: -1;
  }

  .action-dock {
    grid-template-columns: 1fr;
  }

  .clue-form {
    grid-template-columns: 1fr 64px;
  }

  .clue-form button {
    grid-column: 1 / -1;
  }
}
