:root {
  color-scheme: light;
  --ink: #13202b;
  --ink-soft: #30414c;
  --navy: #1f3342;
  --navy-deep: #152731;
  --paper: #fbf8f0;
  --paper-warm: #f4efe5;
  --page: #e9e4d9;
  --muted: #68747a;
  --line: #d8d1c4;
  --gold: #f4c95d;
  --gold-soft: #ffe7a0;
  --mint: #8ed8bd;
  --coral: #ef6f5e;
  --coral-dark: #b64439;
  --focus: #1e85a7;
  --radius: 14px;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--page); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--page);
}

button, input, select, textarea { font: inherit; }

button { cursor: pointer; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

::selection { color: var(--paper); background: var(--coral-dark); }

.app-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 26px 0 48px;
}

.topbar,
.score-strip,
.board-section {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 20px;
}

.brand-lockup,
.top-actions,
.score-heading,
.section-heading,
.dialog-topline,
.scoring-heading,
.editor-actions {
  display: flex;
  align-items: center;
}

.brand-lockup { gap: 12px; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: var(--navy);
  background: var(--gold);
  border-radius: 12px;
  font-size: 20px;
  font-weight: 850;
  letter-spacing: -0.06em;
}

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

h1 {
  font-size: 1.2rem;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.brand-lockup p,
.section-heading span,
.score-total,
.save-status,
.scoring-heading span,
.editor-help,
.confirm-copy {
  color: var(--muted);
  font-size: 0.8rem;
}

.brand-lockup p { margin-top: 3px; }

.top-actions { flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.save-status {
  padding-right: 4px;
  white-space: nowrap;
}

.save-status.warn { color: var(--coral-dark); }

.controller-cue {
  max-width: 320px;
  color: var(--ink-soft);
  font-size: 0.72rem;
}

.button,
.add-team,
.icon-button {
  border: 1px solid transparent;
  border-radius: 9px;
  transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.button {
  min-height: 42px;
  padding: 0 13px;
  font-size: 0.82rem;
  font-weight: 750;
}

.button:hover:not(:disabled),
.add-team:hover:not(:disabled) { transform: translateY(-1px); }

.button:active:not(:disabled),
.add-team:active:not(:disabled) { transform: translateY(0); }

.button:disabled { cursor: not-allowed; opacity: 0.45; }

.button-quiet,
.add-team {
  color: var(--ink-soft);
  background: transparent;
  border-color: var(--line);
}

.button-quiet:hover:not(:disabled),
.add-team:hover:not(:disabled) { background: var(--paper-warm); border-color: #bcb3a5; }

.button-primary { color: var(--navy-deep); background: var(--gold); border-color: #deb33e; }
.button-primary:hover:not(:disabled) { background: #f8d978; }

.button-danger { color: #fff9f3; background: var(--coral-dark); border-color: var(--coral-dark); }
.button-danger:hover:not(:disabled) { background: #9f382f; }

.score-strip {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  margin-top: 14px;
  padding: 14px 18px;
}

.score-heading { gap: 10px; }
.score-heading h2,
.section-heading h2 { font-size: 0.9rem; letter-spacing: 0.01em; }
.score-total { white-space: nowrap; }

.teams {
  display: flex;
  justify-content: center;
  gap: 10px;
  min-width: 0;
}

.team {
  display: grid;
  grid-template-columns: minmax(80px, 1fr) auto;
  gap: 8px 12px;
  align-items: center;
  min-width: 154px;
  padding: 9px 10px;
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.team-name {
  min-width: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1px solid transparent;
  font-size: 0.8rem;
  font-weight: 750;
}

.team-name:hover { border-bottom-color: var(--muted); }
.team-name:focus-visible { outline-offset: 1px; }

.team-score {
  justify-self: end;
  color: var(--navy);
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
  font-weight: 850;
}

.team-controls { grid-column: 1 / -1; display: flex; gap: 6px; }

.score-step {
  min-width: 40px;
  min-height: 32px;
  padding: 0 7px;
  color: var(--ink-soft);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 0.74rem;
  font-weight: 750;
}

.score-step:hover { background: #fffdf8; border-color: #bcb3a5; }

.remove-team {
  margin-left: auto;
  padding: 0 3px;
  color: var(--muted);
  background: transparent;
  border: 0;
  font-size: 0.8rem;
}

.board-section { margin-top: 14px; padding: 18px; }

.section-heading { justify-content: space-between; gap: 18px; margin-bottom: 12px; }

.board-scroll {
  overflow-x: auto;
  padding-bottom: 5px;
  scrollbar-color: #a9a092 var(--paper-warm);
  scrollbar-width: thin;
}

.board {
  display: grid;
  grid-template-columns: 58px repeat(5, minmax(132px, 1fr));
  gap: 7px;
  min-width: 760px;
}

.board-corner { min-height: 62px; }

.board-category,
.row-value,
.clue-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border-radius: 10px;
}

.board-category {
  min-height: 62px;
  padding: 8px;
  color: var(--paper);
  background: var(--navy);
  font-size: 0.82rem;
  font-weight: 820;
  letter-spacing: 0.02em;
}

.row-value {
  min-height: 94px;
  color: var(--ink-soft);
  background: var(--paper-warm);
  border: 1px solid var(--line);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  font-weight: 820;
}

.clue-tile {
  position: relative;
  min-height: 94px;
  padding: 12px 7px;
  color: var(--navy-deep);
  background: var(--gold);
  border: 1px solid #ddb83f;
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
  font-weight: 850;
  transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.clue-tile:hover:not(:disabled) { background: #f8d978; border-color: #b98d16; transform: translateY(-2px); }
.clue-tile:active:not(:disabled) { transform: translateY(0); }

[data-gamepad-focus="true"] {
  position: relative;
  z-index: 1;
  outline: 3px solid var(--coral);
  outline-offset: 3px;
}

.clue-tile.used {
  color: #637077;
  background: #dedbd3;
  border-color: #d3cdc1;
  text-decoration: line-through;
}

.clue-tile.used::after {
  content: "played";
  position: absolute;
  bottom: 9px;
  font-size: 0.65rem;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-decoration: none;
}

.storage-warning {
  margin: 12px 2px 0;
  color: var(--coral-dark);
  font-size: 0.78rem;
}

.dialog {
  width: min(540px, calc(100% - 28px));
  max-height: min(760px, calc(100dvh - 28px));
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
}

.dialog::backdrop { background: rgb(19 32 43 / 60%); }

.dialog-card {
  display: grid;
  gap: 18px;
  padding: 22px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 18px 55px rgb(19 32 43 / 24%);
}

.dialog-topline { align-items: flex-start; justify-content: space-between; gap: 14px; }
.dialog-category { color: var(--muted); font-size: 0.72rem; font-weight: 820; letter-spacing: 0.08em; text-transform: uppercase; }

.icon-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  color: var(--ink-soft);
  background: transparent;
  border-color: var(--line);
  font-size: 1.35rem;
  line-height: 1;
}

.icon-button:hover { background: var(--paper-warm); }

.clue-value {
  color: var(--coral-dark);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  font-weight: 850;
}

.clue-question {
  max-width: 34ch;
  font-size: clamp(1.55rem, 4vw, 2.2rem);
  line-height: 1.12;
  letter-spacing: -0.03em;
}

.answer-panel {
  padding: 14px;
  background: #e5f5ef;
  border: 1px solid #b7e5d2;
  border-radius: 11px;
}

.answer-label { color: #257159; font-size: 0.72rem; font-weight: 850; letter-spacing: 0.08em; text-transform: uppercase; }
.answer-panel p { margin-top: 4px; font-size: 1.05rem; font-weight: 780; }
.clue-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.scoring { padding-top: 16px; border-top: 1px solid var(--line); }
.scoring-heading { justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.scoring-heading h3 { font-size: 0.88rem; }
.score-actions { display: grid; gap: 7px; }

.score-award {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
  padding: 5px 6px 5px 10px;
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-radius: 9px;
}

.score-award-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.82rem; font-weight: 780; }
.score-award-buttons { display: flex; gap: 5px; }
.score-award-buttons .button { min-height: 34px; padding: 0 10px; font-size: 0.75rem; }

.editor-card label { display: grid; gap: 6px; color: var(--ink-soft); font-size: 0.76rem; font-weight: 780; }
.editor-card select,
.editor-card textarea {
  width: 100%;
  color: var(--ink);
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.editor-card select { min-height: 42px; padding: 0 10px; }
.editor-card textarea { min-height: 72px; padding: 10px; line-height: 1.4; resize: vertical; }
.editor-actions { justify-content: flex-end; gap: 8px; padding-top: 3px; }

@media (max-width: 960px) {
  .score-strip { grid-template-columns: 1fr auto; }
  .teams { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; overflow-x: auto; padding-bottom: 2px; }
  .add-team { justify-self: end; }
}

@media (max-width: 640px) {
  .app-shell { width: min(100% - 20px, 1440px); padding-top: 10px; }
  .topbar { align-items: flex-start; flex-direction: column; gap: 14px; padding: 15px; }
  .top-actions { width: 100%; justify-content: flex-start; }
  .save-status { width: 100%; }
  .controller-cue { max-width: none; }
  .score-strip, .board-section { padding: 13px; }
  .score-strip { gap: 12px; }
  .score-heading { align-items: flex-start; flex-direction: column; gap: 2px; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 4px; }
  .board { grid-template-columns: 48px repeat(5, minmax(130px, 1fr)); min-width: 730px; }
  .board-category, .row-value { min-height: 58px; }
  .clue-tile { min-height: 88px; }
  .dialog-card { padding: 18px; }
  .clue-question { font-size: 1.6rem; }
}

/* Keep the full board on-screen when a laptop mirrors a 16:9 TV without
   changing the roomy desktop layout at taller/fullscreen resolutions. */
@media (min-width: 961px) and (max-height: 820px) {
  .app-shell { padding-top: 12px; padding-bottom: 16px; }
  .topbar { padding-top: 11px; padding-bottom: 11px; }
  .brand-mark { width: 36px; height: 36px; font-size: 18px; }
  .score-strip { margin-top: 10px; padding-top: 10px; padding-bottom: 10px; }
  .team { padding-top: 7px; padding-bottom: 7px; }
  .board-section { margin-top: 10px; padding: 12px; }
  .section-heading { margin-bottom: 8px; }
  .board-category { min-height: 48px; }
  .board-corner { min-height: 48px; }
  .row-value,
  .clue-tile { min-height: 76px; }
  .clue-tile { padding-top: 8px; padding-bottom: 8px; }
  .clue-tile.used::after { bottom: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
