/* =========================================================
   Quizo – deep blue & gold, big and readable on a projector
   ========================================================= */

:root {
  --blue-950: #030a2e;
  --blue-900: #061546;
  --blue-800: #0a2070;
  --blue-700: #0f2fa0;
  --blue-600: #1a43d1;
  --blue-500: #2a5cf0;
  --gold: #ffc933;
  --gold-deep: #f2a100;
  --gold-soft: rgba(255, 201, 51, .28);
  --ink: #ffffff;
  --muted: #b3c1f2;
  --panel: rgba(4, 12, 62, .62);
  --good: #2fd18b;
  --good-deep: #129a63;
  --bad: #ff5a6e;
  --bad-deep: #c92a42;
  --radius: 1.1rem;

  --font: "Trebuchet MS", "Segoe UI", "Helvetica Neue", Arial, system-ui, sans-serif;
  --font-display: "Arial Black", "Segoe UI Black", Impact, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  /* Scales with the screen: ~25px on a 1080p projector, ~15px on a phone */
  font-size: calc(10px + 0.55vw + 0.4vh);
  -webkit-text-size-adjust: 100%;
}

/* The setup screen is for the teacher, so it uses slightly smaller text
   than the game screens (which are for the projector). */
html.on-setup { font-size: calc(8px + 0.42vw + 0.36vh); }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--ink);
  background-color: var(--blue-900);
  background-image:
    radial-gradient(ellipse 80% 60% at 50% -10%, #1d44c4 0%, rgba(29, 68, 196, 0) 70%),
    radial-gradient(ellipse 100% 80% at 50% 120%, #020825 0%, rgba(2, 8, 37, 0) 70%),
    linear-gradient(180deg, #0a1c70 0%, #061546 55%, #040d36 100%);
  background-attachment: fixed;
  line-height: 1.3;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible {
  outline: 4px solid #fff;
  outline-offset: 3px;
}

.screen { min-height: 100vh; min-height: 100dvh; }

/* ---------- Logo ---------- */
.logo {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 900;
  letter-spacing: .08em;
  line-height: 1;
  color: var(--gold);
  background: linear-gradient(180deg, #fff1b0 0%, var(--gold) 45%, var(--gold-deep) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 .06em 0 #6b4700) drop-shadow(0 .18em .4em rgba(0, 0, 0, .45));
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5em;
  padding: .55em 1.2em;
  border: 0;
  border-radius: 999px;
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: .01em;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
  user-select: none;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.06); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { cursor: not-allowed; opacity: .45; }

.btn-xl { font-size: 1.6rem; padding: .6em 1.6em; }

.btn-gold {
  color: #2a1a00;
  background: linear-gradient(180deg, #ffe27a 0%, var(--gold) 50%, var(--gold-deep) 100%);
  box-shadow: 0 .3rem 0 #8a5a00, 0 .8rem 1.4rem rgba(0, 0, 0, .35);
}
.btn-ghost {
  color: var(--ink);
  background: rgba(255, 255, 255, .08);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .28);
}
.btn-correct {
  color: #032a19;
  background: linear-gradient(180deg, #6bf0b6 0%, var(--good) 100%);
  box-shadow: 0 .3rem 0 var(--good-deep), 0 .8rem 1.4rem rgba(0, 0, 0, .35);
}
.btn-steal {
  color: #1c0b3f;
  background: linear-gradient(180deg, #e2cdff 0%, #c39bff 55%, #9f6df0 100%);
  box-shadow: 0 .3rem 0 #5b33a8, 0 .8rem 1.4rem rgba(0, 0, 0, .35);
}
.btn-wrong {
  color: #fff;
  background: linear-gradient(180deg, #ff8a98 0%, var(--bad) 100%);
  box-shadow: 0 .3rem 0 var(--bad-deep), 0 .8rem 1.4rem rgba(0, 0, 0, .35);
}

.link-btn {
  background: none;
  border: 0;
  padding: .1em .4em;
  color: var(--muted);
  font-size: .85rem;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: .2em;
}
.link-btn:hover { color: var(--gold); }

/* =========================================================
   SETUP
   ========================================================= */
.setup {
  max-width: 78rem;
  margin: 0 auto;
  padding: 1.2rem 1.5rem 2rem;
}

.brand { text-align: center; margin-bottom: 1rem; }
.brand .logo { font-size: 4.6rem; }
.tagline {
  margin: .4rem 0 0;
  color: var(--muted);
  font-size: 1.2rem;
  letter-spacing: .25em;
  text-transform: uppercase;
  font-weight: 700;
}

/* Narrow: one column, in order */
.setup-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "level" "topics" "count" "timer" "teams";
  gap: 1rem;
  align-items: start;
}
.col { display: contents; }   /* wide screens turn these into real columns (below) */
.area-level  { grid-area: level; }
.area-topics { grid-area: topics; }
.area-count  { grid-area: count; }
.area-timer  { grid-area: timer; }
.area-teams  { grid-area: teams; }

/* Medium: two columns */
@media (min-width: 900px) {
  .setup-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "level  teams"
      "topics teams"
      "count  timer";
  }
}

/* Wide (projector): three columns – Level+Topics | Questions+Timer | Teams */
@media (min-width: 1400px) {
  .setup { max-width: 104rem; }
  .setup-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-areas: none;
  }
  .col { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
  .team-inputs { grid-template-columns: minmax(0, 1fr); }
}

.panel {
  background: var(--panel);
  border: 2px solid var(--gold-soft);
  border-radius: var(--radius);
  padding: .9rem 1.2rem 1.1rem;
  box-shadow: 0 .6rem 1.6rem rgba(0, 0, 0, .25);
}
.panel h2 {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin: 0 0 .7rem;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--gold);
}
.step {
  display: inline-grid;
  place-items: center;
  width: 1.7em;
  height: 1.7em;
  border-radius: 50%;
  background: var(--gold);
  color: #2a1a00;
  font-size: .95rem;
  letter-spacing: 0;
}
.panel-tools { margin-left: auto; letter-spacing: 0; text-transform: none; }

.hint { margin: .7rem 0 0; color: var(--muted); font-size: 1rem; min-height: 1.3em; }

/* Chips = big toggle buttons */
.chips { display: flex; flex-wrap: wrap; gap: .6rem; }
.chip {
  display: inline-flex;
  align-items: baseline;
  gap: .5em;
  padding: .5em 1.1em;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, .28);
  background: rgba(255, 255, 255, .07);
  color: var(--ink);
  font-weight: 800;
  font-size: 1.3rem;
  transition: transform .1s ease, background .15s ease, border-color .15s ease;
}
.chip small { font-size: .7em; font-weight: 700; color: var(--muted); }
.chip:hover { transform: translateY(-2px); border-color: rgba(255, 255, 255, .6); }
.chip[aria-pressed="true"] {
  color: #2a1a00;
  border-color: var(--gold);
  background: linear-gradient(180deg, #ffe27a 0%, var(--gold) 55%, var(--gold-deep) 100%);
  box-shadow: 0 .2rem 0 #8a5a00;
}
.chip[aria-pressed="true"] small { color: #5a3d00; }
.chip:disabled { opacity: .35; cursor: not-allowed; transform: none; }

/* Team name inputs */
.team-inputs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .6rem .8rem;
  margin-top: .9rem;
}
.team-field {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .3rem .8rem .3rem .4rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, .28);
  border: 3px solid var(--team);
}
.team-dot {
  flex: none;
  display: grid;
  place-items: center;
  width: 2em;
  height: 2em;
  border-radius: 50%;
  background: var(--team);
  color: #10172e;
  font-weight: 900;
  font-size: 1rem;
}
.team-field input {
  flex: 1;
  min-width: 0;
  width: 100%;
  padding: .25em .2em;
  background: transparent;
  border: 0;
  color: var(--ink);
  font-weight: 800;
  font-size: 1.25rem;
}
.team-field input::placeholder { color: rgba(255, 255, 255, .5); font-weight: 700; }
.team-field input:focus-visible { outline: none; }
.team-field:focus-within { box-shadow: 0 0 0 4px rgba(255, 255, 255, .85); }

.setup-footer {
  position: sticky;
  bottom: 0;
  z-index: 5;
  margin: 1rem -1.5rem 0;
  padding: 1.2rem 1.5rem .8rem;
  text-align: center;
  background: linear-gradient(180deg, rgba(4, 13, 54, 0) 0%, rgba(4, 13, 54, .92) 45%);
}
.setup-footer .hint { text-align: center; margin-top: .4rem; }
.setup-footer .hint:empty { display: none; }
.forget { margin: .5rem 0 0; font-size: .95rem; color: var(--muted); }
@media (min-width: 900px) {
  /* keep the footer the same height: park the small button in the corner */
  .forget { position: absolute; right: 1.5rem; bottom: .9rem; margin: 0; text-align: right; }
}
.forget .link-btn:disabled { opacity: .45; cursor: default; text-decoration: none; }
.forget-note { margin-left: .6rem; color: var(--gold); font-weight: 700; }

/* Long level names (e.g. "English File Intermediate") */
.chips-compact .chip { font-size: 1.1rem; padding: .45em .95em; }

/* Notice (questions.json could not be read) */
.notice {
  max-width: 44rem;
  margin: 1rem auto;
  padding: 1.2rem 1.5rem;
  text-align: center;
  background: var(--panel);
  border: 2px solid var(--gold);
  border-radius: var(--radius);
  font-size: 1.2rem;
}
.notice p { margin: 0 0 1rem; }

/* =========================================================
   GAME LAYOUT
   ========================================================= */
.game {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: .8rem;
  padding: .8rem 1.2rem 1rem;
}

.game-bar {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  flex: none;
}
.logo-small { font-size: 2rem; }
.game-info {
  flex: 1;
  text-align: center;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: .04em;
}
.game-info b { color: var(--gold); }

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ---------- Board ---------- */
.board {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(var(--cols, 5), minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  gap: .8rem;
}

.card {
  position: relative;
  container-type: size;
  display: block;
  padding: 0;
  border-radius: 1.1rem;
  border: 3px solid rgba(255, 201, 51, .6);
  background:
    radial-gradient(ellipse 90% 70% at 50% 0%, rgba(255, 255, 255, .22) 0%, rgba(255, 255, 255, 0) 70%),
    linear-gradient(165deg, var(--blue-500) 0%, var(--blue-700) 55%, var(--blue-800) 100%);
  box-shadow: 0 .45rem 0 #041050, 0 1rem 1.6rem rgba(0, 0, 0, .35);
  color: var(--gold);
  animation: pop .45s cubic-bezier(.2, 1.4, .4, 1) both;
  animation-delay: calc(var(--i, 0) * 35ms);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.card:hover:not(.used) {
  transform: translateY(-.35rem) scale(1.03);
  border-color: var(--gold);
  box-shadow: 0 .45rem 0 #041050, 0 0 2.2rem rgba(255, 201, 51, .55), 0 1.2rem 2rem rgba(0, 0, 0, .4);
}
.card:active:not(.used) { transform: translateY(0) scale(.99); }

.card-points {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 12% 0 16%;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 3.4rem;                     /* fallback */
  font-size: min(34cqw, 40cqh);
  line-height: 1;
  text-shadow: 0 .06em 0 #7a4f00, 0 .12em .3em rgba(0, 0, 0, .5);
}
.card-num {
  position: absolute;
  top: 6%;
  left: 5%;
  display: grid;
  place-items: center;
  min-width: 1.9em;
  height: 1.9em;
  padding: 0 .3em;
  border-radius: 999px;
  background: rgba(3, 10, 46, .55);
  color: #fff;
  font-size: .9rem;
  font-size: min(8cqw, 11cqh);
  font-weight: 800;
}
.card-topic {
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: 7%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  color: var(--muted);
  font-size: .9rem;
  font-size: min(8.5cqw, 11cqh);
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

/* Used card = gray */
.card.used {
  cursor: default;
  color: #8d94ad;
  border-color: #5b627a;
  background: linear-gradient(165deg, #4a5068 0%, #3a4057 100%);
  box-shadow: 0 .45rem 0 #262b3d;
  animation: none;
}
.card.used .card-points { text-shadow: none; opacity: .5; text-decoration: line-through; text-decoration-thickness: .06em; }
.card.used .card-num { background: rgba(0, 0, 0, .25); color: #b9bfd3; }
.card.used .card-topic { color: #aeb5cc; }
.card-result {
  position: absolute;
  left: 6%;
  right: 6%;
  top: 8%;
  display: flex;
  justify-content: flex-end;
}
.card-result span {
  display: inline-flex;
  align-items: center;
  gap: .4em;
  padding: .15em .7em;
  border-radius: 999px;
  background: rgba(0, 0, 0, .35);
  color: #fff;
  font-size: .9rem;
  font-size: min(8cqw, 12cqh);
  font-weight: 800;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
}
.card-result i {
  flex: none;
  width: .8em;
  height: .8em;
  border-radius: 50%;
  background: var(--team);
}

@keyframes pop {
  from { opacity: 0; transform: scale(.7) translateY(1rem); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Scoreboard ---------- */
.scoreboard {
  flex: none;
  display: grid;
  grid-template-columns: repeat(var(--teams, 3), minmax(0, 1fr));
  gap: .8rem;
}
.team-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .1rem;
  padding: .55rem .6rem .5rem;
  border: 0;
  border-top: .4rem solid var(--team);
  border-radius: .9rem;
  background: rgba(4, 12, 62, .75);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .1);
  min-width: 0;
  transition: transform .2s ease, background .2s ease, box-shadow .2s ease;
}
.team-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.3rem;
  font-weight: 800;
}
.team-score {
  font-family: var(--font-display);
  font-size: 2.8rem;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  color: var(--team);
}
.team-turn {
  position: absolute;
  top: -.95rem;
  padding: .1em .8em;
  border-radius: 999px;
  background: var(--gold);
  color: #2a1a00;
  font-size: .8rem;
  font-weight: 900;
  letter-spacing: .1em;
  text-transform: uppercase;
  white-space: nowrap;
}
.team-tile.active {
  transform: translateY(-.25rem);
  background: linear-gradient(180deg, rgba(255, 201, 51, .26), rgba(255, 201, 51, .1));
  box-shadow: inset 0 0 0 3px var(--gold), 0 0 1.8rem rgba(255, 201, 51, .45);
}
.team-tile.bump .team-score { animation: bump .6s ease; }
button.team-tile:not(:disabled):hover { background: rgba(255, 255, 255, .12); }
button.team-tile:disabled { cursor: default; color: inherit; }

@keyframes bump {
  30% { transform: scale(1.35); color: #fff; }
  100% { transform: scale(1); }
}

/* =========================================================
   QUESTION VIEW
   ========================================================= */
.qview {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: .6rem;
  padding: 1rem 1.8rem 1.1rem;
  background: var(--panel);
  border: 3px solid var(--gold);
  border-radius: 1.4rem;
  box-shadow: 0 0 3rem rgba(255, 201, 51, .18), 0 1rem 2rem rgba(0, 0, 0, .35);
  overflow-x: hidden;
  overflow-y: auto;
  animation: rise .3s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(1rem) scale(.98); } to { opacity: 1; transform: none; } }

.q-track {
  position: absolute;
  inset: 0 0 auto 0;
  height: .7rem;
  background: rgba(255, 255, 255, .1);
}
.q-track i {
  display: block;
  height: 100%;
  width: 100%;
  transform-origin: left center;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold));
}
.qview.warn .q-track i { background: linear-gradient(90deg, #ff3b52, #ff7a5c); }

.q-top {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  margin-top: .5rem;
}
.q-points {
  padding: .1em .55em;
  border-radius: .6em;
  background: linear-gradient(180deg, #ffe27a, var(--gold) 55%, var(--gold-deep));
  color: #2a1a00;
  font-family: var(--font-display);
  font-size: clamp(2rem, 6vh, 3rem);
  line-height: 1.15;
  box-shadow: 0 .25rem 0 #8a5a00;
}
.q-meta { display: flex; flex-direction: column; align-items: flex-start; gap: .35rem; min-width: 0; }
.q-topic {
  color: var(--muted);
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.q-turn-row { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
.q-status {
  padding: .2em .9em;
  border-radius: 999px;
  font-size: 1.2rem;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.q-status.is-wrong { background: var(--bad); color: #fff; }
.q-status.is-steal { background: #c39bff; color: #1c0b3f; }
.q-turn {
  display: inline-flex;
  align-items: center;
  gap: .5em;
  padding: .15em .9em .15em .3em;
  border-radius: 999px;
  background: rgba(0, 0, 0, .3);
  border: 3px solid var(--team);
  font-size: clamp(1.1rem, 3vh, 1.5rem);
  font-weight: 800;
}
.q-turn::before {
  content: "";
  width: 1.1em;
  height: 1.1em;
  border-radius: 50%;
  background: var(--team);
}

.q-timer { margin-left: auto; text-align: center; min-width: 6rem; }
.q-time {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(2.6rem, min(4.4rem, 8vh), 4.4rem);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
}
.q-time-label {
  display: block;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.qview.warn .q-time { color: #ff6b7d; }
.qview.up .q-time { color: var(--bad); animation: shake .5s ease; }
.qview.up .q-time-label { color: var(--bad); }
@keyframes shake {
  20%, 60% { transform: translateX(-.25rem) rotate(-3deg); }
  40%, 80% { transform: translateX(.25rem) rotate(3deg); }
}

.q-text {
  flex: 1;
  display: grid;
  place-items: center;
  align-content: center;
  margin: 0;
  padding: 0 1rem;
  text-align: center;
  font-size: clamp(1.8rem, min(4.4vw, 7.5vh), 5.2rem);
  font-weight: 800;
  line-height: 1.2;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

/* Long questions / answers get a smaller font so everything still fits */
.q-text.long { font-size: clamp(1.5rem, min(3.3vw, 5.6vh), 3.8rem); }

.q-answer {
  align-self: center;
  width: min(100%, 60rem);
  padding: .5rem 1.6rem .7rem;
  text-align: center;
  border-radius: 1rem;
  background: linear-gradient(180deg, #ffe27a 0%, var(--gold) 100%);
  color: #2a1a00;
  box-shadow: 0 .3rem 0 #8a5a00;
  visibility: hidden;                 /* keeps layout steady */
  transform: scale(.9);
  opacity: 0;
  transition: transform .25s cubic-bezier(.2, 1.4, .4, 1), opacity .2s ease;
}
.q-answer.show { visibility: visible; transform: none; opacity: 1; }
.q-answer-text.long { font-size: clamp(1.3rem, min(2.4vw, 4.2vh), 2.6rem); }
.q-answer-label {
  font-size: .95rem;
  font-weight: 900;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: #6b4700;
}
.q-answer-text {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, min(3.4vw, 5.5vh), 4rem);
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.q-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
  position: relative;
}
.q-actions .btn-xl { font-size: clamp(1.1rem, 3.6vh, 1.6rem); }
.judge { display: flex; gap: 1.4rem; flex-wrap: wrap; justify-content: center; }
.judge .btn, .q-actions .btn { white-space: nowrap; }

/* =========================================================
   END VIEW
   ========================================================= */
.endview {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  gap: .2rem;
  padding: .5rem 2rem;
  text-align: center;
  background: var(--panel);
  border: 3px solid var(--gold);
  border-radius: 1.4rem;
  box-shadow: 0 0 4rem rgba(255, 201, 51, .25);
  overflow-x: hidden;
  overflow-y: auto;
  animation: rise .4s ease both;
}
.end-kicker {
  margin: 0;
  color: var(--gold);
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: .3em;
  text-transform: uppercase;
}
.end-kicker::before { content: "🏆"; display: block; font-size: clamp(1.8rem, 5vh, 4.2rem); line-height: 1.1; letter-spacing: 0; margin-bottom: .1rem; }
.end-winner {
  margin: 0;
  max-width: 100%;
  font-family: var(--font-display);
  font-size: clamp(2.2rem, min(8vw, 11vh), 9rem);
  line-height: 1.05;
  color: var(--winner, var(--gold));
  text-shadow: 0 .05em 0 rgba(0, 0, 0, .45), 0 0 .6em rgba(255, 201, 51, .4);
  overflow-wrap: anywhere;
  text-wrap: balance;
}
.end-score { margin: 0 0 .2rem; font-size: clamp(1.4rem, 4vh, 2rem); font-weight: 800; color: var(--muted); }
.end-score b { color: var(--gold); }

.ranking {
  list-style: none;
  margin: 0 0 .8rem;
  padding: 0;
  width: min(100%, 48rem);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
  gap: .4rem .8rem;
}
.ranking li {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .12rem 1.1rem .12rem .3rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, .3);
  border: 3px solid var(--team);
  font-size: clamp(1rem, 3vh, 1.4rem);
  font-weight: 800;
  min-width: 0;
}
.ranking .rank {
  flex: none;
  display: grid;
  place-items: center;
  width: 1.8em;
  height: 1.8em;
  border-radius: 50%;
  background: var(--team);
  color: #10172e;
}
.ranking .r-name { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranking .r-score { font-family: var(--font-display); font-variant-numeric: tabular-nums; }
.end-actions { display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap; justify-content: center; }
.end-actions .btn-xl { font-size: clamp(1.1rem, 3.4vh, 1.6rem); }

/* Confetti */
.confetti {
  position: fixed;
  top: -2rem;
  width: .7rem;
  height: 1.2rem;
  border-radius: .12rem;
  pointer-events: none;
  z-index: 50;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translate3d(var(--dx, 0), 110vh, 0) rotate(var(--rot, 720deg)); }
}

/* =========================================================
   DIALOG
   ========================================================= */
.dialog {
  padding: 1.6rem 2rem;
  border: 3px solid var(--gold);
  border-radius: 1.3rem;
  background: var(--blue-900);
  color: var(--ink);
  text-align: center;
  max-width: min(90vw, 30rem);
}
.dialog::backdrop { background: rgba(2, 6, 30, .75); }
.dialog h2 { margin: 0 0 .4rem; font-size: 1.8rem; color: var(--gold); }
.dialog p { margin: 0 0 1.2rem; font-size: 1.2rem; color: var(--muted); }
.dialog-actions { display: flex; gap: .8rem; justify-content: center; flex-wrap: wrap; }

/* =========================================================
   SMALL SCREENS (phone preview of the design)
   ========================================================= */
@media (max-width: 1300px) {
  .q-actions { flex-wrap: wrap; }
  .q-actions #back-btn { position: static; }
}
@media (max-width: 900px) {
  .setup-grid { grid-template-columns: 1fr; }
  .brand .logo { font-size: 3.4rem; }
  .q-text { font-size: clamp(1.8rem, 6vw, 3rem); }
  .q-top { flex-wrap: wrap; }
  .q-actions { flex-wrap: wrap; }
  .q-actions #back-btn { position: static; }
  .judge { flex-wrap: wrap; justify-content: center; }
  .btn-xl { font-size: 1.3rem; }
  .team-score { font-size: 2rem; }
}
@media (max-width: 560px) {
  .team-inputs { grid-template-columns: 1fr; }
  .game { padding: .5rem; }
  .board { gap: .5rem; }
  .scoreboard { gap: .4rem; }
  .team-name { font-size: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
