:root {
  --ink: #202329;
  --muted: #6e737c;
  --line: #e5e7eb;
  --paper: #fff;
  --page: #f6f7f8;
  --red: #e94437;
  --blue: #20a7d5;
  --green: #2c9a60;
  --shadow: 0 14px 38px #22304412;
}

/* Base and viewport */
* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: var(--page);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid #188bb4;
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.page-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.page-shell > header {
  flex-shrink: 0;
}

.page {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  width: 100%;
  max-width: 1080px;
  min-height: 0;
  margin: 0 auto;
  padding: 6px 10px;
  overflow: hidden;
}

.page.game-layout {
  max-width: 1600px;
  padding: 12px;
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

/* Setup */
.setup-screen.hidden {
  display: none;
}

.setup-screen:not(.hidden) {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 0;
  padding: clamp(12px, 2vw, 24px);
  overflow-y: auto;
}

.setup-screen > :not(.units) {
  flex-shrink: 0;
}

.grade-row {
  max-width: calc((100% - 28px) / 3);
  margin-bottom: 20px;
}

.units {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  flex: 1 1 0;
  gap: 8px;
  min-height: 60px;
  padding: 3px;
  overflow-x: hidden;
  overflow-y: auto;
}

.unit-choice {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  min-height: 48px;
  padding: 9px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
  cursor: pointer;
}

.unit-choice:hover {
  background: #f0f9ff;
}

.unit-choice.selected {
  border-color: #0ea5e9;
  background: #e0f2fe;
}

.unit-choice input {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: #0ea5e9;
  cursor: pointer;
}

.unit-label {
  display: flex;
  align-items: center;
  flex: 1;
  gap: 8px;
  min-width: 0;
  cursor: pointer;
}

.unit-name {
  color: #1e293b;
  font-size: 14px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.unit-count {
  margin-left: auto;
  color: #64748b;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.empty-note,
.warning {
  margin: 13px 0 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: #fff8e5;
  color: #765e16;
  font-size: 13px;
}

.warning {
  background: #fff0ed;
  color: #98443a;
}

.settings-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  width: min(100%, 640px);
  margin: 12px 0 0 auto;
}

.select-group {
  display: grid;
  gap: 5px;
}

.select-group label {
  color: #515761;
  font-size: 12px;
  font-weight: 800;
}

.game-select {
  width: 100%;
  min-width: 0;
  padding: 10px 34px 10px 12px;
  border: 1px solid #dfe2e6;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
}

.setup-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.setup-actions .primary {
  min-width: 240px;
  padding-inline: 30px;
}

.primary,
.secondary {
  padding: 12px 22px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 800;
}

.primary {
  background: var(--red);
  color: #fff;
  box-shadow: 0 3px 0 #bd3126;
}

.primary:hover:not(:disabled) {
  background: #d83b30;
}

.primary:disabled {
  opacity: .55;
}

.secondary {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

/* Gameplay */
.play-screen {
  display: none;
}

.play-screen.active {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  gap: 10px;
  min-height: 0;
  overflow: hidden;
}

.players {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  align-items: stretch;
  flex: 1 1 0;
  gap: 12px;
  min-height: 0;
}

.players.single {
  grid-template-columns: minmax(0, 820px) auto;
  justify-content: center;
}

.player {
  --accent: #0284c7;
  --tint: #f0f9ff;

  display: flex;
  flex-direction: column;
  grid-column: 1;
  grid-row: 1;
  gap: 18px;
  min-width: 0;
  min-height: 0;
  padding: clamp(16px, 2vw, 30px);
  border: 1px solid #dbe5ef;
  border-radius: 24px;
  background: linear-gradient(160deg, var(--tint), #fff 45%);
  box-shadow: 0 8px 32px #0f172a08;
  overflow-y: auto;
}

.player ~ .player {
  --accent: #7c3aed;
  --tint: #f5f3ff;

  grid-column: 3;
}

.player-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  gap: 8px;
  padding-bottom: 16px;
  border-bottom: 1px solid #0f172a0d;
  text-align: center;
}

.player-name {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: var(--accent);
  font-size: clamp(16px, 1.5vw, 22px);
  font-weight: 700;
  line-height: 1.2;
}

.dot {
  flex-shrink: 0;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 5px var(--tint);
}

.score {
  color: #0f172a;
  font-size: clamp(40px, 5vw, 76px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  letter-spacing: -.04em;
}

.score::after {
  content: " Puan";
  margin-left: 6px;
  color: #64748b;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
}

.score:has(small)::after {
  content: none;
}

.score small {
  margin-left: 6px;
  color: #64748b;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
}

.answers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  flex: 1 1 0;
  gap: 12px;
  width: 100%;
  min-height: 160px;
  max-height: 440px;
  margin: auto 0;
}

.answer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  min-height: 0;
  padding: clamp(10px, 1.5vw, 22px);
  border: 2px solid #e2e8f0;
  border-radius: 18px;
  background: #fff;
  color: #334155;
  box-shadow: 0 3px 0 #e2e8f0;
  font-size: clamp(18px, 2vw, 30px);
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
  transition: border-color .15s, background-color .15s,
              box-shadow .15s, transform .15s;
}

.answer:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: var(--accent);
  background: var(--tint);
  color: var(--accent);
  box-shadow: 0 5px 14px #0f172a0d;
}

.answer:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: none;
}

.answer:focus-visible {
  outline-color: var(--accent);
}

.answer:disabled {
  transform: none;
  opacity: .45;
  box-shadow: none;
}

.answer.correct {
  border-color: #10b981;
  background: #ecfdf5;
  color: #047857;
  opacity: 1;
}

.answer.wrong {
  border-color: #f43f5e;
  background: #fff1f2;
  color: #be123c;
  opacity: 1;
}

.answer img {
  width: 100%;
  height: 100px;
  max-height: 100%;
  object-fit: contain;
  border-radius: 7px;
}

.answer .caption {
  display: none;
}

/* Timer works inside the players grid or below it. */
.timer-box {
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  justify-self: center;
  flex-shrink: 0;
  width: 88px;
  padding: 14px 4px;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 4px 18px #0f172a06;
  text-align: center;
}

.timer-label {
  display: block;
  color: #94a3b8;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.timer {
  margin-top: 4px;
  color: #334155;
  font-size: 26px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.04em;
}

.timer.low {
  color: #e11d48;
}

/* Shared toolbar */
.games-header-control-group .games-header-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  min-width: 42px;
  padding: 0;
  border-radius: 12px;
}

.games-header-control-group .games-header-button svg {
  display: block;
  width: 21px;
  height: 21px;
  margin: auto;
}

/* Designer credit floats outside document layout, leaving the page height available. */
.designer {
  position: fixed;
  right: max(10px, env(safe-area-inset-right));
  bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 20;
  display: block;
  margin: 0;
  padding: 0;
  width: max-content;
  pointer-events: none;
}
.designer a { pointer-events: auto; }

.designer a {
  padding: 3px 8px;
  border: 1px solid #e1e3e6;
  border-radius: 99px;
  color: #8c9097;
  font-size: 10px;
  text-decoration: none;
}

.designer a:hover {
  border-color: #aeb3ba;
  color: #333;
}

/* Dialogs and results */
.page-shell.blurred {
  filter: blur(5px);
  pointer-events: none;
  user-select: none;
}

.game-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #27344790;
  backdrop-filter: blur(3px);
}

.game-modal-card {
  width: min(500px, 100%);
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  padding: 26px;
  border: 1px solid #e7e8ea;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 22px 70px #14223355;
  overflow-y: auto;
}

.game-modal-card h2 {
  margin: 2px 0 7px;
  font-size: 25px;
}

.game-modal-card p {
  margin: 0 0 14px;
  color: var(--muted);
}

.game-modal-card ul {
  margin: 0 0 18px;
  padding-left: 20px;
  color: #434850;
  font-size: 14px;
}

.game-modal-card li {
  margin: 5px 0;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
}

.modal-actions button {
  min-width: 120px;
}

.progress-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0 18px;
}

.progress-stats.single {
  grid-template-columns: 1fr;
}

.progress-player {
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fafbfc;
}

.progress-player-head {
  font-weight: 800;
}

.progress-player-stats {
  display: grid;
  gap: 3px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.progress-player-stats strong {
  color: var(--ink);
  font-size: 14px;
}

#progressModal {
  isolation: isolate;
}

#progressModal .game-modal-card {
  position: relative;
  z-index: 1;
}

.result-confetti {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Short screens */
@media (max-height: 650px) {
  .player {
    gap: 10px;
    padding: 12px;
    border-radius: 18px;
  }

  .player-head {
    gap: 3px;
    padding-bottom: 8px;
  }

  .score {
    font-size: 38px;
  }

  .answers {
    gap: 8px;
    min-height: 112px;
  }

  .answer {
    padding: 8px;
    border-radius: 12px;
    font-size: clamp(15px, 2vw, 22px);
  }
}

/* Phones */
@media (max-width: 700px) {
  .page.game-layout {
    padding: 6px;
  }

  .grade-row {
    max-width: none;
  }
.units,
  .settings-row {
    grid-template-columns: 1fr;
  }

  .settings-row {
    width: 100%;
  }

  .setup-actions .primary {
    width: 100%;
    min-width: 0;
  }

  .players,
  .players.single {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .player {
    flex: 1 1 0;
    gap: 8px;
    padding: 10px;
    border-radius: 18px;
  }

  .player-head {
    flex-direction: row;
    justify-content: space-between;
    gap: 8px;
    padding: 0 2px 8px;
  }

  .player-name {
    font-size: 15px;
  }

  .score {
    font-size: 30px;
  }

  .score::after,
  .score small {
    font-size: 11px;
  }

  .answers {
    gap: 7px;
    min-height: 96px;
    max-height: none;
    margin: 0;
  }

  .answer {
    padding: 7px;
    border-radius: 12px;
    font-size: clamp(14px, 3.5vw, 20px);
  }

  .answer img {
    height: 60px;
  }

  .timer-box {
    order: -1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: auto;
    padding: 4px 14px;
    border-radius: 30px;
  }

  .timer {
    margin: 0;
    font-size: 20px;
  }

  .modal-actions {
    flex-direction: column-reverse;
  }

  .modal-actions button {
    width: 100%;
  }
}

@media (max-width: 500px) {
  .progress-stats {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .answer {
    transition: none;
  }
}
/* Student-friendly setup typography and named units. */
.setup-screen .select-group label { font-size: 15px; }
.setup-screen .game-select { font-size: 17px; min-height: 46px; }
.setup-screen .unit-choice { min-height: 58px; padding: 11px 15px; }
.setup-screen .unit-choice input { width: 19px; height: 19px; }
.setup-screen .unit-label { display:flex; flex:1; justify-content:space-between; gap:14px; }
.setup-screen .unit-name { font-size: clamp(17px, 1.5vw, 21px); flex-shrink:0; }
.setup-screen .unit-title { margin-left:auto; color:#475569; font-size:clamp(15px, 1.35vw, 19px); font-weight:700; text-align:right; overflow-wrap:anywhere; }
.setup-screen .setup-actions button { font-size:19px; }
@media(max-width:700px){ .setup-screen .unit-choice { padding:10px 12px; } .setup-screen .unit-title { font-size:15px; } }

/* Readable live scores and prominently displayed final results. */
.player .score { font-size: clamp(48px, 5.8vw, 88px); }
#progressModal .progress-player-stats { font-size: clamp(17px, 1.7vw, 22px); gap: 9px; }
#progressModal .progress-player-stats strong { font-size: clamp(24px, 2.5vw, 36px); }
#progressModal .progress-player-head { font-size: clamp(19px, 2vw, 27px); }
@media(max-width:700px) { .player .score { font-size: clamp(39px, 7vw, 60px); } }
@media(max-width:420px) { .player .score { font-size: 37px; } }

/* Only show the designer credit on the setup screen. */
.designer[hidden] { display: none !important; }

/* Redesigned results dialog: generous space, clear hierarchy and big score cards. */
#progressModal { padding: clamp(12px, 3vw, 32px); }
#progressModal .game-modal-card {
  width: min(780px, 100%);
  max-height: calc(100dvh - 32px);
  padding: clamp(22px, 3vw, 42px);
  border-radius: 26px;
  border: 1px solid rgba(255,255,255,.85);
  background: linear-gradient(155deg, #fff 0%, #f5f8ff 100%);
  box-shadow: 0 28px 90px rgba(12,29,66,.35);
  text-align: center;
}
#progressModal #progressTitle {
  font-size: clamp(32px, 4.2vw, 50px);
  font-weight: 900;
  letter-spacing: -.035em;
  margin: 0 0 10px;
  color: #172f59;
}
#progressModal #progressMessage {
  font-size: clamp(15px, 1.6vw, 20px);
  line-height: 1.45;
  margin: 0 auto 24px;
  color: #53637e;
}
#progressModal .progress-stats {
  gap: clamp(12px, 2vw, 20px);
  margin: 0 0 28px;
  align-items: stretch;
}
#progressModal .progress-player {
  padding: clamp(20px, 2.8vw, 30px);
  border-radius: 20px;
  border: 1px solid #dbe4f7;
  background: #fff;
  box-shadow: 0 9px 25px rgba(38,72,122,.09);
  text-align: left;
}
#progressModal .progress-player-head {
  font-size: clamp(20px, 2.3vw, 30px);
  color: #1c3764;
  margin-bottom: 12px;
}
#progressModal .progress-player-stats {
  gap: 12px;
  font-size: clamp(16px, 1.6vw, 20px);
  line-height: 1.35;
}
#progressModal .progress-player-stats strong {
  font-size: clamp(25px, 3vw, 40px);
  color: #1b3977;
}
#progressModal .modal-actions {
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}
#progressModal .modal-actions button {
  flex: 1 1 185px;
  max-width: 320px;
  min-height: 54px;
  border-radius: 14px;
  font-size: clamp(16px, 1.7vw, 20px);
  font-weight: 800;
}
@media (max-width: 540px) {
  #progressModal .game-modal-card { padding: 20px 16px; border-radius: 20px; }
  #progressModal .progress-stats { grid-template-columns: 1fr; }
  #progressModal .progress-player { padding: 16px; }
  #progressModal .modal-actions { gap: 10px; }
}
@media (max-height: 650px) {
  #progressModal .game-modal-card { padding-top: 15px; padding-bottom: 15px; }
  #progressModal #progressMessage { margin-bottom: 12px; }
  #progressModal .progress-stats { margin-bottom: 14px; }
  #progressModal .progress-player { padding: 12px; }
}

/* Prevent selection of game/interface text; keep text inputs usable. */
html,body,button,label,.game-modal,.player,.unit-choice { -webkit-user-select:none;user-select:none; }
input,textarea,[contenteditable="true"] { -webkit-user-select:text;user-select:text; }
.timer-box .question-progress { display:flex;justify-content:center;align-items:center;gap:.5em;margin-top:.45rem;font-weight:700;font-size:clamp(14px,1.5vw,21px);line-height:1.2; }
.timer-box .question-progress strong { font-size:1.1em; }

/* Keep the question progress inside the timer card at every viewport size. */
.timer-box {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 112px;
  min-width: 112px;
  padding: 12px 8px;
}
.timer-box .timer-label,
.timer-box .timer,
.timer-box .question-progress { margin: 0; width: 100%; text-align: center; }
.timer-box .question-progress {
  display: flex;
  flex-wrap: nowrap;
  align-items: baseline;
  justify-content: center;
  gap: 5px;
  white-space: nowrap;
  font-size: 13px;
  line-height: 1.4;
}
.timer-box .question-progress strong { font-size: 15px; }
@media (max-width: 700px) {
  .timer-box { flex-direction: column; width: 112px; min-width: 112px; padding: 11px 8px; gap: 4px; border-radius: 20px; }
  .timer-box .timer { font-size: 25px; }
}


/* --- Colorful refresh for setup and play screens --- */
:root {
  --page: linear-gradient(180deg, #f0f9ff 0%, #eef2ff 48%, #fff8e7 100%);
  --paper: rgba(255,255,255,.88);
  --line: rgba(255,255,255,.65);
  --shadow: 0 24px 60px rgba(31, 41, 55, .14);
}

body {
  background: linear-gradient(135deg, #4cc9f0 0%, #6c63ff 42%, #ff7b54 100%);
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

.page-shell {
  position: relative;
  background:
    radial-gradient(circle at 12% 16%, rgba(255,255,255,.28) 0 70px, transparent 71px),
    radial-gradient(circle at 88% 18%, rgba(255,255,255,.16) 0 95px, transparent 96px),
    radial-gradient(circle at 84% 82%, rgba(255,255,255,.18) 0 110px, transparent 111px),
    linear-gradient(160deg, rgba(255,255,255,.12), rgba(255,255,255,.04));
}

.page {
  max-width: 1180px;
  padding: 12px;
}

.card {
  border: 1px solid rgba(255,255,255,.6);
  box-shadow: 0 22px 58px rgba(15, 23, 42, .18);
}

.setup-screen:not(.hidden) {
  position: relative;
  isolation: isolate;
  gap: 14px;
  padding: clamp(18px, 2.6vw, 30px);
  border-radius: 28px;
  background:
    radial-gradient(circle at top left, rgba(255,255,255,.62), transparent 32%),
    radial-gradient(circle at 100% 100%, rgba(255,216,109,.28), transparent 30%),
    linear-gradient(140deg, rgba(255,255,255,.92), rgba(255,255,255,.82));
  overflow: hidden;
}

.setup-screen::before,
.setup-screen::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}

.setup-screen::before {
  width: 240px;
  height: 240px;
  top: -70px;
  right: -60px;
  background: radial-gradient(circle, rgba(91, 192, 235, .22), rgba(91, 192, 235, 0));
}

.setup-screen::after {
  width: 220px;
  height: 220px;
  bottom: -90px;
  left: -80px;
  background: radial-gradient(circle, rgba(255, 140, 66, .20), rgba(255, 140, 66, 0));
}

.setup-screen > * {
  position: relative;
  z-index: 1;
}

.grade-row {
  max-width: 240px;
  margin-bottom: 0;
}

.select-group {
  gap: 8px;
}

.select-group label {
  color: #374151;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.game-select {
  min-height: 50px;
  padding: 12px 40px 12px 14px;
  border: 1px solid rgba(37, 99, 235, .14);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(241,245,249,.98));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.75), 0 8px 20px rgba(15, 23, 42, .05);
  font-weight: 800;
}

.units {
  gap: 12px;
  padding: 4px;
}

.unit-choice {
  position: relative;
  align-items: flex-start;
  gap: 12px;
  min-height: 72px;
  padding: 14px 16px;
  border: 1px solid rgba(129, 140, 248, .16);
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(255,255,255,.98), rgba(239,246,255,.95));
  box-shadow: 0 12px 24px rgba(15, 23, 42, .06);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, background-color .18s ease;
}

.unit-choice::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 7px;
  border-radius: 18px 0 0 18px;
  background: linear-gradient(180deg, #38bdf8, #8b5cf6);
  opacity: .85;
}

.unit-choice:hover {
  transform: translateY(-2px);
  border-color: rgba(59, 130, 246, .42);
  background: linear-gradient(145deg, #ffffff, #f5faff);
  box-shadow: 0 16px 34px rgba(59, 130, 246, .12);
}

.unit-choice.selected {
  border-color: rgba(37, 99, 235, .46);
  background: linear-gradient(145deg, #ffffff, #eef6ff 72%);
  box-shadow: 0 18px 34px rgba(37, 99, 235, .16);
}

.unit-choice input {
  width: 20px;
  height: 20px;
  margin-top: 4px;
  accent-color: #6366f1;
}

.unit-label {
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.unit-name {
  color: #1f2937;
  font-size: clamp(18px, 1.55vw, 22px);
  font-weight: 900;
}

.unit-title {
  color: #546277;
  font-size: clamp(14px, 1.25vw, 18px);
  font-weight: 700;
  text-align: right;
}

.settings-row {
  width: 100%;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 2px;
}

.settings-row > .select-group {
  padding: 14px;
  border: 1px solid rgba(148, 163, 184, .18);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,.92), rgba(248,250,252,.88));
  box-shadow: 0 12px 28px rgba(15, 23, 42, .05);
}

.setup-actions {
  margin-top: 8px;
}

.primary, .secondary {
  border-radius: 16px;
  font-weight: 900;
  transition: transform .18s ease, box-shadow .18s ease, background-color .18s ease;
}

.primary {
  background: linear-gradient(135deg, #ff7b54, #ef4444);
  color: #fff;
  box-shadow: 0 10px 0 #c5362b, 0 20px 30px rgba(239, 68, 68, .20);
}

.primary:hover:not(:disabled) {
  transform: translateY(-2px);
  background: linear-gradient(135deg, #ff8d5f, #f14a5d);
}

.primary:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 4px 0 #c5362b, 0 10px 20px rgba(239,68,68,.18);
}

.secondary {
  border-color: rgba(148, 163, 184, .34);
  background: linear-gradient(180deg, #fff, #f7f8fb);
}

.play-screen.active {
  position: relative;
  gap: 14px;
  padding: 18px;
  border-radius: 28px;
  background:
    radial-gradient(circle at 0% 0%, rgba(255,255,255,.22), transparent 18%),
    radial-gradient(circle at 100% 100%, rgba(255,255,255,.18), transparent 20%),
    linear-gradient(135deg, #0ea5e9 0%, #6366f1 48%, #f97316 100%);
  box-shadow: 0 24px 64px rgba(30, 41, 59, .24);
  overflow: hidden;
}

.play-screen.active::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 12% 24%, rgba(255,255,255,.14) 0 10px, transparent 11px),
    radial-gradient(circle at 21% 68%, rgba(255,255,255,.10) 0 8px, transparent 9px),
    radial-gradient(circle at 82% 18%, rgba(255,255,255,.10) 0 9px, transparent 10px),
    linear-gradient(115deg, transparent 0 16%, rgba(255,255,255,.07) 16% 20%, transparent 20% 36%, rgba(255,255,255,.06) 36% 40%, transparent 40%);
  pointer-events: none;
}

.players, .timer-box {
  position: relative;
  z-index: 1;
}

.players {
  gap: 16px;
}

.player {
  position: relative;
  gap: 16px;
  padding: clamp(16px, 2vw, 24px);
  border: 1px solid rgba(255,255,255,.55);
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(255,255,255,.95), rgba(255,255,255,.88));
  box-shadow: 0 20px 45px rgba(15,23,42,.18);
  backdrop-filter: blur(10px);
}

.player::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 8px;
  border-radius: 28px 28px 0 0;
  background: linear-gradient(90deg, #22d3ee, #3b82f6);
}

.player ~ .player::before {
  background: linear-gradient(90deg, #a855f7, #ec4899);
}

.player-head {
  gap: 10px;
  padding: 14px 16px 18px;
  border-radius: 22px;
  border-bottom: 0;
  background: linear-gradient(135deg, rgba(14,165,233,.12), rgba(59,130,246,.08));
}

.player ~ .player .player-head {
  background: linear-gradient(135deg, rgba(168,85,247,.12), rgba(236,72,153,.08));
}

.player-name {
  font-family: "Fredoka", sans-serif;
  font-size: clamp(20px, 1.95vw, 30px);
  font-weight: 700;
}

.dot {
  width: 12px;
  height: 12px;
  box-shadow: 0 0 0 8px rgba(34, 211, 238, .16);
}

.player ~ .player .dot {
  box-shadow: 0 0 0 8px rgba(168, 85, 247, .14);
}

.score {
  color: #0f172a;
  text-shadow: 0 4px 16px rgba(59,130,246,.10);
}

.score::after {
  color: #64748b;
  font-weight: 800;
}

.answers {
  gap: 14px;
  min-height: 180px;
  max-height: none;
}

.answer {
  position: relative;
  border: 0;
  border-radius: 22px;
  color: #1f2937;
  box-shadow: 0 12px 0 rgba(0,0,0,.10), 0 18px 24px rgba(15, 23, 42, .12);
  font-family: "Plus Jakarta Sans", "Segoe UI", Arial, sans-serif;
  font-weight: 800;
  font-size: clamp(20px, 2vw, 32px);
  letter-spacing: -.01em;
  text-shadow: 0 1px 0 rgba(255,255,255,.35);
  transition: transform .14s ease, box-shadow .14s ease, filter .14s ease;
}

.answer::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.72), inset 0 -8px 18px rgba(0,0,0,.08);
  pointer-events: none;
}

.answers .answer:nth-child(4n+1) { background: linear-gradient(180deg, #ffe08a, #ffc857); }
.answers .answer:nth-child(4n+2) { background: linear-gradient(180deg, #b7f4db, #67d39a); }
.answers .answer:nth-child(4n+3) { background: linear-gradient(180deg, #c7d7ff, #8ab6ff); }
.answers .answer:nth-child(4n+4) { background: linear-gradient(180deg, #ffd0ea, #ff9bc2); }

.answer:hover:not(:disabled) {
  transform: translateY(-4px) scale(1.01);
  color: #111827;
  box-shadow: 0 16px 0 rgba(0,0,0,.10), 0 24px 28px rgba(15, 23, 42, .16);
  filter: saturate(1.04) brightness(1.02);
}

.answer:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 6px 0 rgba(0,0,0,.10), 0 10px 18px rgba(15, 23, 42, .14);
}

.answer:disabled {
  opacity: .65;
}

.answer.correct {
  color: #fff;
  background: linear-gradient(180deg, #3ddc84, #169c57) !important;
  box-shadow: 0 12px 0 rgba(5, 122, 85, .55), 0 18px 24px rgba(21,128,61,.25);
}

.answer.wrong {
  color: #fff;
  background: linear-gradient(180deg, #fb7185, #e11d48) !important;
  box-shadow: 0 12px 0 rgba(159, 18, 57, .5), 0 18px 24px rgba(190,24,93,.25);
}

.timer-box {
  width: 130px;
  min-width: 130px;
  padding: 16px 10px;
  border: 1px solid rgba(255,255,255,.52);
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(255,255,255,.96), rgba(255,255,255,.88));
  box-shadow: 0 20px 42px rgba(15, 23, 42, .18);
}

.timer-label {
  color: #64748b;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
}

.timer {
  color: #1d4ed8;
  font-family: "Fredoka", sans-serif;
  font-size: 34px;
}

.timer.low {
  color: #e11d48;
}

.timer-box .question-progress {
  font-family: "Fredoka", sans-serif;
  color: #334155;
  font-size: 14px;
}

.game-modal {
  background: rgba(15, 23, 42, .45);
}

.game-modal:not(#progressModal) .game-modal-card {
  border-radius: 24px;
  border: 1px solid rgba(255,255,255,.8);
  background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(247,250,255,.96));
}

.designer a {
  border-color: rgba(255,255,255,.35);
  background: rgba(255,255,255,.18);
  color: rgba(255,255,255,.94);
  backdrop-filter: blur(10px);
}

.designer a:hover {
  border-color: rgba(255,255,255,.5);
  color: #fff;
}

@media (max-width: 900px) {
  .units { grid-template-columns: 1fr; }
  .settings-row { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .page { padding: 8px; }
  .setup-screen:not(.hidden) { padding: 12px; gap: 10px; }
  .play-screen.active { padding: 10px; border-radius: 22px; }
  .player { border-radius: 22px; }
  .player-head { padding: 12px 14px; border-radius: 18px; }
  .answer { border-radius: 16px; font-size: clamp(16px, 4.4vw, 22px); }
  .timer-box { width: 120px; min-width: 120px; padding: 12px 8px; }
}
