:root {
  color-scheme: light;
  --ink: #101820;
  --muted: #64748b;
  --paper: #f7f8fb;
  --panel: #ffffff;
  --line: #d8dee9;
  --explain: #2f7d6d;
  --draw: #d97706;
  --mime: #6d5bd0;
  --danger: #c2410c;
  --success: #1d7a46;
  --shadow: 0 18px 45px rgba(16, 24, 32, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(135deg, rgba(47, 125, 109, 0.14), transparent 36%),
    linear-gradient(315deg, rgba(217, 119, 6, 0.15), transparent 42%),
    var(--paper);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

.hidden {
  display: none !important;
}

.app-shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px;
}

.setup-view {
  display: grid;
  gap: 22px;
  align-content: start;
}

.brand-row,
.setup-toolbar,
.board-topline,
.task-card-top,
.score-heading,
.timer-controls,
.round-actions,
.toolbar-actions,
.draw-tools {
  display: flex;
  align-items: center;
}

.brand-row {
  gap: 18px;
}

.brand-mark {
  display: grid;
  grid-template-columns: repeat(2, 42px);
  width: 92px;
  height: 92px;
  padding: 4px;
  gap: 4px;
  color: #fff;
  font-weight: 900;
  font-size: 31px;
  line-height: 1;
  background: var(--ink);
  border: 4px solid var(--ink);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.brand-mark span {
  display: grid;
  place-items: center;
  border-radius: 6px;
}

.brand-mark span:first-child {
  background: var(--explain);
}

.brand-mark span:last-child {
  background: var(--draw);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 2.4rem;
}

h2 {
  margin-bottom: 2px;
  font-size: 1.35rem;
}

.muted {
  margin-bottom: 0;
  color: var(--muted);
}

.setup-toolbar {
  justify-content: space-between;
  gap: 16px;
  padding-block: 12px;
  border-block: 1px solid var(--line);
}

.toolbar-actions {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.icon-button,
.primary-button,
.secondary-button,
.ghost-button,
.reveal-button {
  min-height: 44px;
  border-radius: 8px;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  padding: 0;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 1.35rem;
  font-weight: 800;
}

.icon-button.small {
  width: 38px;
  min-height: 38px;
  font-size: 1.05rem;
}

.primary-button,
.secondary-button,
.ghost-button,
.reveal-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  font-weight: 800;
}

.primary-button {
  color: #fff;
  background: var(--success);
  box-shadow: 0 10px 24px rgba(29, 122, 70, 0.25);
}

.secondary-button {
  color: #fff;
  background: var(--danger);
  box-shadow: 0 10px 24px rgba(194, 65, 12, 0.22);
}

.ghost-button {
  color: var(--ink);
  background: #eef1f6;
  border: 1px solid var(--line);
}

.wide {
  width: 100%;
}

.icon-button:hover:not(:disabled),
.primary-button:hover:not(:disabled),
.secondary-button:hover:not(:disabled),
.ghost-button:hover:not(:disabled),
.reveal-button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.setup-error {
  min-height: 24px;
  margin: 0;
  color: var(--danger);
  font-weight: 700;
}

.teams-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 14px;
}

.team-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 8px solid var(--team-color);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(16, 24, 32, 0.08);
}

.team-card-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.team-number {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.input-grid {
  display: grid;
  gap: 10px;
}

.field-label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.field-label input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fbfcff;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
}

.field-label input:focus,
.range-label input:focus,
.swatch-label input:focus,
button:focus-visible {
  outline: 3px solid rgba(47, 125, 109, 0.25);
  outline-offset: 2px;
}

.game-view {
  display: grid;
  grid-template-columns: 230px minmax(360px, 1fr) minmax(330px, 390px);
  gap: 18px;
  align-items: start;
}

.score-panel,
.board-section,
.turn-panel {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(16, 24, 32, 0.1);
}

.score-panel {
  display: grid;
  gap: 16px;
  padding: 16px;
  position: sticky;
  top: 24px;
}

.score-heading {
  justify-content: space-between;
  gap: 12px;
}

.score-heading strong {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: #fff;
  background: var(--ink);
  border-radius: 8px;
}

.scoreboard {
  display: grid;
  gap: 10px;
}

.score-row {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-left: 7px solid var(--team-color);
  border-radius: 8px;
  background: #fbfcff;
}

.score-row.active {
  box-shadow: inset 0 0 0 2px var(--team-color);
}

.score-row-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.score-row strong {
  overflow-wrap: anywhere;
}

.score-row span {
  color: var(--muted);
  font-weight: 800;
}

.score-progress {
  height: 8px;
  overflow: hidden;
  background: #e8edf4;
  border-radius: 999px;
}

.score-progress span {
  display: block;
  height: 100%;
  width: var(--progress);
  background: var(--team-color);
}

.board-section {
  padding: 16px;
}

.board-topline {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.winner-banner {
  padding: 10px 12px;
  color: #fff;
  background: var(--success);
  border-radius: 8px;
  font-weight: 900;
  text-align: right;
}

.board {
  display: grid;
  grid-template-columns: repeat(6, minmax(54px, 1fr));
  gap: 8px;
}

.field {
  position: relative;
  display: grid;
  min-width: 0;
  aspect-ratio: 1;
  padding: 8px;
  overflow: hidden;
  color: #fff;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.field.start {
  color: var(--ink);
  background: #f1f5f9;
}

.field.explain {
  background: var(--explain);
}

.field.draw {
  background: var(--draw);
}

.field.mime {
  background: var(--mime);
}

.field.final {
  background: var(--ink);
}

.field-index {
  font-weight: 900;
  font-size: 0.82rem;
}

.field-mode {
  align-self: end;
  font-size: 0.75rem;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.token-stack {
  position: absolute;
  inset: auto 6px 6px auto;
  display: grid;
  grid-template-columns: repeat(2, 16px);
  gap: 4px;
}

.team-token {
  width: 16px;
  height: 16px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--team-color);
  box-shadow: 0 1px 5px rgba(16, 24, 32, 0.34);
}

.turn-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
  position: sticky;
  top: 24px;
}

.turn-heading h2 {
  margin-bottom: 4px;
  overflow-wrap: anywhere;
}

.mode-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.mode-chip,
.mode-badge {
  display: inline-grid;
  place-items: center;
  min-height: 34px;
  padding: 6px 8px;
  color: #fff;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 900;
  text-align: center;
}

.mode-chip.explain,
.mode-badge.explain {
  background: var(--explain);
}

.mode-chip.draw,
.mode-badge.draw {
  background: var(--draw);
}

.mode-chip.mime,
.mode-badge.mime {
  background: var(--mime);
}

.mode-badge.final {
  background: var(--ink);
}

.task-card {
  display: grid;
  gap: 14px;
  min-height: 245px;
  padding: 16px;
  background: #fbfcff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.task-card-top {
  justify-content: space-between;
  gap: 12px;
}

.reveal-button {
  width: 100%;
  min-height: 124px;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(47, 125, 109, 0.16), rgba(217, 119, 6, 0.16)),
    #fff;
  border: 1px dashed #a5b4c3;
  font-size: 1.2rem;
}

.card-content {
  display: grid;
  gap: 12px;
}

.task-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

#wordText {
  margin: 0;
  font-size: 2rem;
  overflow-wrap: anywhere;
}

.taboo-panel {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid #f0c7b3;
  border-radius: 8px;
  background: #fff7ed;
}

.taboo-panel p {
  margin: 0;
  color: var(--danger);
  font-weight: 900;
}

.taboo-panel ul {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.taboo-panel li {
  padding: 6px 9px;
  color: #7c2d12;
  background: #ffedd5;
  border-radius: 8px;
  font-weight: 800;
}

.drawing-zone {
  display: grid;
  gap: 10px;
}

#drawingCanvas {
  width: 100%;
  height: 270px;
  touch-action: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(16, 24, 32, 0.04);
}

.draw-tools {
  flex-wrap: wrap;
  gap: 10px;
}

.swatch-label,
.range-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 10px;
  color: var(--muted);
  background: #f4f7fb;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
}

.swatch-label input {
  width: 36px;
  height: 28px;
  padding: 0;
  background: transparent;
  border: 0;
}

.range-label {
  flex: 1 1 155px;
}

.range-label input {
  width: 100%;
  accent-color: var(--ink);
}

.timer-section {
  display: grid;
  gap: 10px;
}

.timer-readout {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  font-weight: 900;
}

.timer-readout span:first-child {
  font-size: 3rem;
  line-height: 1;
}

.timer-bar {
  height: 12px;
  overflow: hidden;
  background: #e8edf4;
  border-radius: 999px;
}

.timer-bar span {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--success), var(--draw), var(--danger));
  transform-origin: left center;
  transform: scaleX(var(--timer-progress, 1));
  transition: transform 180ms linear;
}

.timer-controls,
.round-actions {
  justify-content: center;
  gap: 10px;
}

.round-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

@media (max-width: 1100px) {
  .game-view {
    grid-template-columns: 220px 1fr;
  }

  .turn-panel {
    grid-column: 1 / -1;
    position: static;
  }

  .score-panel {
    position: static;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 14px;
  }

  .brand-row,
  .setup-toolbar,
  .board-topline {
    align-items: flex-start;
  }

  .setup-toolbar,
  .board-topline,
  .team-card-header {
    flex-direction: column;
  }

  .toolbar-actions {
    width: 100%;
    justify-content: stretch;
  }

  .toolbar-actions .primary-button {
    flex: 1;
  }

  .teams-list,
  .game-view {
    grid-template-columns: 1fr;
  }

  .board {
    grid-template-columns: repeat(4, minmax(58px, 1fr));
    gap: 7px;
  }

  .score-panel,
  .turn-panel {
    position: static;
  }

  h1 {
    font-size: 2rem;
  }

  #wordText {
    font-size: 1.7rem;
  }
}

@media (max-width: 430px) {
  .brand-mark {
    grid-template-columns: repeat(2, 34px);
    width: 76px;
    height: 76px;
    font-size: 25px;
  }

  .mode-strip,
  .round-actions {
    grid-template-columns: 1fr;
  }

  .board {
    grid-template-columns: repeat(3, minmax(60px, 1fr));
  }

  .field {
    padding: 6px;
  }
}
