/* =====================================================================
   Draw It! — all styling.
   Design tokens live in :root; change them there and the whole game follows.
   The palette is the original's (pink / cyan / yellow / purple on near-black),
   rebuilt on custom properties, Grid and Flexbox.
   ===================================================================== */

:root {
  color-scheme: dark;

  /* Surfaces */
  --bg:        #12101c;
  --bg-2:      #1b1930;
  --surface:   #22203a;
  --surface-2: #2b2848;
  --line:      rgba(255, 255, 255, 0.14);
  --line-soft: rgba(255, 255, 255, 0.08);

  /* Ink */
  --ink:       #f2f1f8;
  --muted:     rgba(242, 241, 248, 0.62);
  --faint:     rgba(242, 241, 248, 0.38);

  /* Accents */
  --pink:   #ff6b9d;
  --cyan:   #4ecdc4;
  --yellow: #ffe66d;
  --purple: #a855f7;
  --blue:   #5a9bff;
  --green:  #35d07f;
  --red:    #ff5c5c;
  --orange: #ffa73d;

  /* Shape and motion */
  --radius:    14px;
  --radius-lg: 22px;
  --radius-sm: 9px;
  --shadow:    0 12px 32px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.3);
  --dur:       0.18s;
  --ease:      cubic-bezier(0.22, 1, 0.36, 1);

  --font-display: 'Bebas Neue', 'Oswald', system-ui, sans-serif;
  --font-label:   'Oswald', system-ui, sans-serif;
  --font-body:    'Lato', system-ui, -apple-system, sans-serif;
  --font-hand:    'Permanent Marker', 'Lato', cursive;

  --tap: 48px;   /* minimum touch target */
}

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

html, body {
  height: 100%;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(ellipse at 18% 12%, rgba(168, 85, 247, 0.13), transparent 52%),
    radial-gradient(ellipse at 82% 20%, rgba(78, 205, 196, 0.10), transparent 46%),
    radial-gradient(ellipse at 50% 92%, rgba(255, 107, 157, 0.09), transparent 46%),
    var(--bg);
  background-attachment: fixed;
}
body { overflow: hidden; -webkit-text-size-adjust: 100%; }

img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }
:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; border-radius: 4px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }

/* ---------- Screens ---------- */
#app { position: relative; width: 100vw; height: 100dvh; }
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  animation: fadeIn 0.28s var(--ease);
}
.screen[hidden] { display: none; }
.screen-center {
  align-items: center; justify-content: center;
  gap: 22px; padding: 28px 20px; text-align: center;
}
.scroll-area { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 20px 16px 40px; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes popIn  { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }
@keyframes riseIn { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@keyframes pulseSoft { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
@keyframes confettiFall { to { transform: translateY(105vh) rotate(720deg); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* =====================================================================
   Buttons
   ===================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 11px 20px;
  font-family: var(--font-label); font-size: 1rem; font-weight: 500; letter-spacing: 0.6px;
  border: 2px solid var(--line); border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.05); color: var(--ink);
  transition: transform var(--dur) var(--ease), background var(--dur), border-color var(--dur), opacity var(--dur);
  text-align: center;
}
.btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.11); transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.42; cursor: not-allowed; }

.btn-primary { background: linear-gradient(135deg, var(--pink), var(--purple)); border-color: transparent; color: #fff; font-weight: 600; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.1); background: linear-gradient(135deg, var(--pink), var(--purple)); }
.btn-danger { border-color: var(--red); color: var(--red); }
.btn-danger:hover:not(:disabled) { background: rgba(255, 92, 92, 0.16); }
.btn-warn { border-color: var(--orange); color: var(--orange); }
.btn-warn:hover:not(:disabled) { background: rgba(255, 167, 61, 0.16); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { color: var(--ink); background: rgba(255, 255, 255, 0.08); }
.btn-sm  { min-height: 38px; padding: 6px 13px; font-size: 0.88rem; }
.btn-lg  { min-height: 56px; padding: 14px 28px; font-size: 1.1rem; }
.btn-xl  { min-height: 64px; padding: 16px 38px; font-size: 1.25rem; }
.btn-block { width: 100%; }
.btn-icon { min-height: 40px; width: 40px; padding: 0; font-size: 1.05rem; }
.btn.is-busy { position: relative; color: transparent !important; }
.btn.is-busy::after {
  content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35); border-top-color: #fff; animation: spin 0.7s linear infinite;
}
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.btn-row-lg { gap: 18px; }
.btn-row-sm { gap: 8px; justify-content: flex-start; }

/* =====================================================================
   Forms
   ===================================================================== */
.field { display: flex; flex-direction: column; gap: 7px; }
.field > span, .field > label, .field-label {
  font-family: var(--font-label); font-size: 0.8rem; letter-spacing: 1.6px;
  text-transform: uppercase; color: var(--muted);
}
.input {
  width: 100%; min-height: var(--tap); padding: 12px 14px;
  background: rgba(0, 0, 0, 0.3); color: var(--ink);
  border: 2px solid var(--line); border-radius: var(--radius);
  transition: border-color var(--dur), background var(--dur);
}
.input:focus { border-color: var(--cyan); background: rgba(0, 0, 0, 0.42); outline: none; }
.input::placeholder { color: var(--faint); }
textarea.input { min-height: 84px; resize: vertical; line-height: 1.45; }
.input-pin {
  font-family: var(--font-display); font-size: 2.2rem; letter-spacing: 10px;
  text-align: center; padding-left: 10px;
}
.field-hint { display: block; line-height: 1.45; }

/* Toggles */
.toggle-list { display: flex; flex-direction: column; gap: 4px; margin-top: 14px; }
.toggle {
  display: flex; align-items: center; gap: 14px; padding: 10px 4px;
  min-height: var(--tap); cursor: pointer; border-radius: var(--radius-sm);
}
.toggle:hover { background: rgba(255, 255, 255, 0.04); }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  flex: 0 0 auto; width: 50px; height: 28px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.15); border: 2px solid var(--line);
  position: relative; transition: background var(--dur), border-color var(--dur);
}
.toggle-track::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px;
  border-radius: 50%; background: var(--ink); transition: transform var(--dur) var(--ease);
}
.toggle input:checked + .toggle-track { background: var(--cyan); border-color: var(--cyan); }
.toggle input:checked + .toggle-track::after { transform: translateX(22px); background: #10202a; }
.toggle input:focus-visible + .toggle-track { outline: 3px solid var(--cyan); outline-offset: 3px; }
.toggle-text { display: flex; flex-direction: column; gap: 2px; text-align: left; }
.toggle-text strong { font-weight: 700; font-size: 0.98rem; }

/* =====================================================================
   Landing
   ===================================================================== */
.brand { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.brand-title {
  font-family: var(--font-hand); font-size: clamp(3rem, 13vw, 6.5rem); line-height: 1;
  background: linear-gradient(120deg, var(--pink), var(--yellow) 45%, var(--cyan));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  transform: rotate(-2deg);
}
.brand-sub { color: var(--muted); max-width: 30ch; line-height: 1.55; }
.landing-foot { position: absolute; bottom: 18px; left: 0; right: 0; }
#relay-health.is-ok { color: var(--green); }
#relay-health.is-warn { color: var(--orange); }
#relay-health.is-error { color: var(--red); }

.resume-box {
  background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius-lg);
  padding: 18px 22px; max-width: 440px; display: flex; flex-direction: column; gap: 12px; align-items: center;
}
.resume-text { color: var(--muted); }

/* =====================================================================
   Bars
   ===================================================================== */
/* The connection pill floats at the top right, so the bar keeps clear of it. */
.bar {
  display: flex; align-items: center; gap: 12px; padding: 10px 118px 10px 16px;
  background: rgba(0, 0, 0, 0.3); border-bottom: 1px solid var(--line-soft);
  backdrop-filter: blur(8px); flex-wrap: wrap;
}
.bar-bottom { padding-right: 16px; border-bottom: none; border-top: 1px solid var(--line-soft); justify-content: space-between; }
.bar-title { font-family: var(--font-label); font-size: 1.05rem; font-weight: 500; letter-spacing: 1.5px; text-transform: uppercase; }
.bar-spacer { flex: 1; }
.bar-tag {
  font-family: var(--font-label); font-size: 0.82rem; letter-spacing: 2px; text-transform: uppercase;
  color: var(--cyan); border: 1px solid rgba(78, 205, 196, 0.4); border-radius: 999px; padding: 4px 12px;
}
.bar-pin { font-family: var(--font-label); letter-spacing: 1.5px; color: var(--muted); }
.bar-pin b { color: var(--yellow); font-size: 1.1rem; letter-spacing: 3px; }
.bar-round { font-family: var(--font-label); letter-spacing: 1px; color: var(--muted); }
.back-link { position: absolute; top: 16px; left: 16px; }

/* =====================================================================
   Setup
   ===================================================================== */
.setup-grid { max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.card {
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-sm);
}
.card-title {
  font-family: var(--font-label); font-size: 1rem; letter-spacing: 2px;
  text-transform: uppercase; color: var(--yellow); margin-bottom: 16px;
}
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }

.mode-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.mode-card {
  display: flex; flex-direction: column; gap: 7px; padding: 18px 16px; text-align: left;
  border: 2px solid var(--line); border-radius: var(--radius); background: rgba(255, 255, 255, 0.04);
  transition: border-color var(--dur), background var(--dur), transform var(--dur) var(--ease);
}
.mode-card:hover { transform: translateY(-2px); background: rgba(255, 255, 255, 0.08); }
.mode-card.is-active { border-color: var(--pink); background: rgba(255, 107, 157, 0.14); }
.mode-icon { font-size: 1.9rem; }
.mode-name { font-family: var(--font-label); font-size: 1.1rem; letter-spacing: 1.4px; text-transform: uppercase; }
.mode-blurb { color: var(--muted); font-size: 0.86rem; line-height: 1.45; }

.chip-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.pick-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 13px; min-height: 40px;
  border: 2px solid var(--line); border-radius: 999px; font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.04); transition: all var(--dur);
}
.pick-chip:hover { background: rgba(255, 255, 255, 0.1); }
.pick-chip.is-on { border-color: var(--cyan); background: rgba(78, 205, 196, 0.18); color: #fff; }
.chip-n { color: var(--faint); font-size: 0.76rem; }

.prompt-list { display: flex; flex-direction: column; gap: 9px; margin: 16px 0 14px; }
.prompt-row { display: flex; align-items: center; gap: 10px; }
.prompt-num {
  flex: 0 0 auto; width: 30px; height: 30px; display: grid; place-items: center;
  font-family: var(--font-display); font-size: 1.05rem; color: var(--bg);
  background: var(--yellow); border-radius: 50%;
}
.prompt-input { flex: 1; min-height: 44px; }
.prompt-pts { flex: 0 0 auto; min-width: 42px; text-align: right; font-family: var(--font-label); }

.setup-actions { display: flex; flex-direction: column; align-items: center; gap: 12px; padding-bottom: 20px; }
.setup-summary { font-family: var(--font-label); letter-spacing: 1px; }

/* =====================================================================
   Lobby
   ===================================================================== */
.lobby { flex: 1; display: grid; grid-template-columns: minmax(280px, 0.85fr) 1.15fr; gap: 24px; padding: 26px; overflow: hidden; }
.lobby-join {
  background: var(--surface); border-radius: var(--radius-lg); border: 1px solid var(--line-soft);
  padding: 28px; display: flex; flex-direction: column; justify-content: center; gap: 6px; text-align: center;
}
.lobby-step { font-family: var(--font-label); font-size: 0.82rem; letter-spacing: 2.4px; text-transform: uppercase; color: var(--muted); margin-top: 12px; }
.lobby-url { font-family: var(--font-label); font-size: clamp(1rem, 2.2vw, 1.5rem); color: var(--cyan); word-break: break-all; }
.lobby-pin {
  font-family: var(--font-display); font-size: clamp(3.4rem, 9vw, 6rem); line-height: 1;
  letter-spacing: 10px; color: var(--yellow); text-shadow: 0 0 40px rgba(255, 230, 109, 0.35);
}
.lobby-players { display: flex; flex-direction: column; gap: 14px; overflow: hidden; }
.lobby-count { font-family: var(--font-label); font-size: 1.15rem; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); }
.lobby-count span { color: var(--pink); font-size: 1.6rem; }
.player-grid { display: flex; flex-wrap: wrap; gap: 10px; align-content: flex-start; overflow-y: auto; padding-right: 4px; }

.player-chip {
  display: inline-flex; align-items: center; gap: 9px; padding: 8px 12px 8px 8px;
  background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 999px;
  animation: popIn 0.3s var(--ease); position: relative;
}
.player-chip.is-out { opacity: 0.45; }
.player-chip.is-away { border-style: dashed; opacity: 0.7; }
.chip-name { font-weight: 700; }
.chip-tag { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 1.2px; color: var(--orange); }
.chip-remove {
  width: 22px; height: 22px; border-radius: 50%; color: var(--faint); font-size: 1.1rem; line-height: 1;
  display: grid; place-items: center; transition: all var(--dur);
}
.chip-remove:hover { background: var(--red); color: #fff; }

.avatar {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  font-family: var(--font-label); font-weight: 600; color: #fff; flex: 0 0 auto;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}
.avatar-sm { width: 26px; height: 26px; font-size: 0.85rem; }
.avatar-lg { width: 76px; height: 76px; font-size: 2rem; }

/* =====================================================================
   Host game screen
   ===================================================================== */
.scorebar {
  display: flex; gap: 8px; padding: 10px 16px; overflow-x: auto;
  border-bottom: 1px solid var(--line-soft); background: rgba(0, 0, 0, 0.22);
  scrollbar-width: thin;
}
.score-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px;
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: 999px;
  white-space: nowrap; transition: all var(--dur);
}
.score-chip:hover { border-color: var(--cyan); }
.score-chip.is-leader { border-color: var(--yellow); background: rgba(255, 230, 109, 0.12); }
.score-chip.is-leader::before { content: '👑'; }
.score-chip.is-out { opacity: 0.42; }
.sc-name { font-weight: 700; font-size: 0.92rem; }
.sc-points { font-family: var(--font-label); color: var(--yellow); letter-spacing: 0.6px; }

.host-body { flex: 1; overflow: hidden; display: flex; position: relative; }
.stage-center {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 24px; text-align: center;
}
.stage-kicker { font-family: var(--font-label); font-size: 0.9rem; letter-spacing: 3.5px; text-transform: uppercase; color: var(--muted); }
.stage-title { font-family: var(--font-display); font-size: clamp(1.8rem, 5vw, 3.2rem); letter-spacing: 1px; }
.stage-sub { color: var(--muted); max-width: 48ch; line-height: 1.55; }

.prompt-card {
  font-family: var(--font-hand); font-size: clamp(1.7rem, 5.5vw, 4rem); line-height: 1.25;
  color: var(--yellow); max-width: 20ch; text-wrap: balance;
  animation: riseIn 0.45s var(--ease);
}
.timer-big {
  font-family: var(--font-display); font-size: clamp(3rem, 11vw, 7rem); line-height: 1;
  color: var(--cyan); font-variant-numeric: tabular-nums;
}
.timer-big.is-warning { color: var(--red); animation: pulseSoft 1s infinite; }
.submit-progress { font-family: var(--font-label); letter-spacing: 2px; color: var(--muted); text-transform: uppercase; font-size: 0.9rem; }

.collect-ring {
  width: 130px; height: 130px; border-radius: 50%; display: grid; place-items: center;
  border: 5px solid var(--cyan); font-family: var(--font-display); font-size: 3rem; color: var(--cyan);
  box-shadow: 0 0 40px rgba(78, 205, 196, 0.25);
}

/* ---------- Judging carousel ---------- */
.judge-stage { flex: 1; display: flex; flex-direction: column; gap: 12px; padding: 16px 20px 20px; position: relative; overflow: hidden; }
.judge-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.judge-counter { font-family: var(--font-label); letter-spacing: 2px; color: var(--muted); }
.carousel { flex: 1; position: relative; display: grid; place-items: center; min-height: 0; }
.slide {
  position: absolute; inset: 0; display: none; flex-direction: column; align-items: center;
  justify-content: center; gap: 10px;
}
.slide.is-active { display: flex; animation: popIn 0.3s var(--ease); }
/* The image takes whatever height is left after the name and the reaction
   badges, and shrinks rather than overflowing — a centred flex child that is
   taller than its box spills out of BOTH ends, which used to push a tall
   drawing up over the round heading. */
.slide img {
  flex: 1 1 auto; min-height: 0; max-width: 100%; max-height: 100%;
  object-fit: contain; border-radius: var(--radius); background: #fff; box-shadow: var(--shadow);
}
.slide-name, .slide-reactions { flex: 0 0 auto; }
.slide-name {
  font-family: var(--font-label); font-size: clamp(1rem, 2.4vw, 1.6rem);
  letter-spacing: 2.5px; text-transform: uppercase; color: var(--pink);
}
.slide-reactions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.react-badge {
  background: rgba(0, 0, 0, 0.45); border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 11px; font-size: 0.95rem; animation: popIn 0.25s var(--ease);
}
.carousel-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 3;
  width: 54px; height: 54px; border-radius: 50%; font-size: 2rem; line-height: 1;
  background: rgba(0, 0, 0, 0.5); border: 2px solid var(--line); color: var(--ink);
  transition: all var(--dur);
}
.carousel-nav:hover { background: var(--pink); border-color: var(--pink); color: #fff; }
.carousel-nav.prev { left: 14px; }
.carousel-nav.next { right: 14px; }
.reaction-tally { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; align-items: center; min-height: 34px; }
.tally-label { font-family: var(--font-label); letter-spacing: 2px; color: var(--muted); text-transform: uppercase; font-size: 0.8rem; }
.tally-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px;
  border: 1px solid var(--line-soft); border-radius: 999px; color: var(--muted); font-size: 0.92rem;
}
.tally-pill.has-votes { color: var(--ink); border-color: var(--cyan); background: rgba(78, 205, 196, 0.14); }
.judge-actions { padding-top: 4px; }

/* ---------- Caption mode (host) ---------- */
.caption-stage .caption-art img { max-height: 42vh; border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.caption-judge { flex: 1; display: grid; grid-template-columns: minmax(240px, 0.9fr) 1.1fr; gap: 22px; padding: 20px; overflow: hidden; }
.cj-art { display: flex; flex-direction: column; gap: 10px; align-items: center; justify-content: center; }
.cj-art img { max-height: 58vh; border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.cj-list { display: flex; flex-direction: column; gap: 14px; overflow: hidden; }
.caption-cards { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; flex: 1; padding-right: 4px; }
.caption-card {
  display: flex; flex-direction: column; gap: 5px; text-align: left; padding: 14px 16px;
  border: 2px solid var(--line); border-radius: var(--radius); background: rgba(255, 255, 255, 0.05);
  transition: all var(--dur);
}
.caption-card:hover { background: rgba(255, 255, 255, 0.1); transform: translateX(3px); }
.caption-card.is-selected { border-color: var(--yellow); background: rgba(255, 230, 109, 0.14); }
.caption-card.is-winner { border-color: var(--green); background: rgba(53, 208, 127, 0.16); }
.cc-text { font-size: 1.06rem; line-height: 1.45; }
.cc-author { font-family: var(--font-label); letter-spacing: 1.5px; color: var(--cyan); font-size: 0.85rem; }

/* ---------- Results ---------- */
.results-stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 24px; overflow-y: auto; }
.results-title { font-family: var(--font-display); font-size: clamp(2rem, 6vw, 4rem); letter-spacing: 1.5px; text-align: center; }
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 14px; flex-wrap: wrap; }
.podium-place { display: flex; flex-direction: column; align-items: center; gap: 7px; animation: riseIn 0.5s var(--ease) backwards; }
.podium-place.place-1 { animation-delay: 0.25s; }
.podium-place.place-2 { animation-delay: 0.05s; }
.podium-place.place-3 { animation-delay: 0.4s; }
.podium-medal { font-size: 2.1rem; }
.podium-name { font-family: var(--font-label); letter-spacing: 1.4px; font-size: 1.05rem; }
.podium-score { font-family: var(--font-display); font-size: 1.7rem; color: var(--yellow); }
.podium-block { width: 108px; border-radius: 10px 10px 0 0; background: linear-gradient(180deg, var(--surface-2), var(--surface)); border: 1px solid var(--line-soft); border-bottom: none; }
.place-1 .podium-block { height: 128px; background: linear-gradient(180deg, rgba(255, 230, 109, 0.4), var(--surface)); }
.place-2 .podium-block { height: 92px; }
.place-3 .podium-block { height: 66px; }
.result-list, .final-list { width: 100%; max-width: 460px; display: flex; flex-direction: column; gap: 6px; }
.result-row {
  display: flex; align-items: center; gap: 11px; padding: 9px 14px;
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius);
}
.result-row.is-me { border-color: var(--cyan); background: rgba(78, 205, 196, 0.12); }
.rr-rank { font-family: var(--font-display); color: var(--muted); min-width: 24px; }
.rr-name { flex: 1; font-weight: 700; }
.rr-score { font-family: var(--font-label); color: var(--yellow); }

.gallery-modal { display: flex; flex-direction: column; gap: 22px; max-height: 68vh; overflow-y: auto; }
.gal-round h3 { font-family: var(--font-label); letter-spacing: 1.4px; color: var(--yellow); margin-bottom: 10px; }
.gal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.gal-grid figure { display: flex; flex-direction: column; gap: 5px; }
.gal-grid img { border-radius: var(--radius-sm); background: #fff; }
.gal-grid figcaption { font-size: 0.82rem; color: var(--muted); text-align: center; }

/* =====================================================================
   Player: join + lobby
   ===================================================================== */
.join-title { font-family: var(--font-display); font-size: clamp(2rem, 8vw, 3rem); letter-spacing: 2px; }
.join-form { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 16px; }
.join-error { color: var(--red); font-size: 0.92rem; }
.player-name { font-family: var(--font-display); font-size: clamp(2rem, 9vw, 3.4rem); letter-spacing: 2px; }
.pulse-dots { display: flex; gap: 9px; }
.pulse-dots span { width: 11px; height: 11px; border-radius: 50%; background: var(--cyan); animation: pulseSoft 1.3s infinite; }
.pulse-dots span:nth-child(2) { animation-delay: 0.2s; }
.pulse-dots span:nth-child(3) { animation-delay: 0.4s; }

/* =====================================================================
   Player: drawing
   ===================================================================== */
#screen-player-draw { padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); gap: 7px; }
.draw-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 6px 0 6px; }
.draw-round { font-family: var(--font-label); letter-spacing: 2px; text-transform: uppercase; color: var(--muted); font-size: 0.82rem; }
.draw-timer { font-family: var(--font-display); font-size: 1.9rem; color: var(--cyan); font-variant-numeric: tabular-nums; }
.draw-timer.is-warning { color: var(--red); animation: pulseSoft 1s infinite; }
.draw-prompt {
  font-family: var(--font-hand); font-size: clamp(1.05rem, 4.6vw, 1.5rem); text-align: center;
  color: var(--yellow); padding: 0 8px; line-height: 1.3;
}

.canvas-wrap {
  position: relative; flex: 1; min-height: 180px; width: 100%;
  border-radius: var(--radius); overflow: hidden; background: #fff;
  box-shadow: var(--shadow-sm); touch-action: none;
}
.canvas-wrap canvas { position: absolute; inset: 0; touch-action: none; }
.dib-preview { background: transparent; }
.dib-text-input {
  position: absolute; z-index: 5; min-width: 120px; padding: 2px 6px;
  background: rgba(255, 255, 255, 0.92); border: 2px dashed var(--pink);
  border-radius: 4px; font-family: var(--font-body); font-weight: 700; color: inherit;
}

.toolbar { display: flex; flex-direction: column; gap: 6px; }
.tool-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center; }
.tool-btn {
  width: 44px; height: 44px; display: grid; place-items: center; font-size: 1.18rem;
  border: 2px solid var(--line); border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05); transition: all var(--dur);
}
.tool-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.12); }
.tool-btn.is-active { border-color: var(--pink); background: rgba(255, 107, 157, 0.22); }
.tool-btn.is-danger { border-color: rgba(255, 92, 92, 0.5); }
.tool-btn:disabled { opacity: 0.32; }
.tool-gap { width: 10px; }

.swatches { gap: 7px; }
.swatch {
  width: 34px; height: 34px; border-radius: 50%; background: var(--sw);
  border: 3px solid transparent; box-shadow: 0 0 0 1px var(--line); transition: transform var(--dur) var(--ease);
}
.swatch:hover { transform: scale(1.12); }
.swatch.is-active { border-color: var(--cyan); transform: scale(1.15); }
.swatch.is-white { box-shadow: 0 0 0 1px var(--muted); }
.swatch-custom { position: relative; overflow: hidden; display: grid; place-items: center; background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red); }
.swatch-custom input { position: absolute; inset: -20%; width: 140%; height: 140%; opacity: 0; cursor: pointer; }

.sliders { gap: 16px; }
.slider { display: flex; align-items: center; gap: 8px; font-size: 0.78rem; color: var(--muted); font-family: var(--font-label); letter-spacing: 1.2px; text-transform: uppercase; }
.slider input[type=range] { width: 92px; accent-color: var(--pink); height: 28px; }
.slider b { color: var(--ink); min-width: 24px; text-align: right; font-variant-numeric: tabular-nums; }

.draw-foot { display: flex; flex-direction: column; gap: 5px; }
.submit-note { text-align: center; font-size: 0.85rem; color: var(--muted); min-height: 1.1em; }
.submit-note.is-ok { color: var(--green); }
.submit-note.is-error { color: var(--red); }

/* =====================================================================
   Player: caption
   ===================================================================== */
#screen-player-caption { padding: 10px 12px calc(12px + env(safe-area-inset-bottom)); gap: 10px; }
.caption-art-box { flex: 1; min-height: 0; display: grid; place-items: center; }
.caption-art-box img { max-height: 100%; max-width: 100%; object-fit: contain; border-radius: var(--radius); background: #fff; }
.caption-prompt { text-align: center; }
.caption-entry { display: flex; flex-direction: column; gap: 9px; }

/* =====================================================================
   Player: waiting / gallery / results
   ===================================================================== */
#screen-player-wait { padding: 18px 14px calc(18px + env(safe-area-inset-bottom)); gap: 14px; overflow-y: auto; }
.wait-head { text-align: center; display: flex; flex-direction: column; gap: 6px; }
.wait-title { font-family: var(--font-display); font-size: clamp(1.6rem, 7vw, 2.6rem); letter-spacing: 1.5px; }
.wait-sub { color: var(--muted); line-height: 1.5; }
.wait-extra { display: flex; flex-direction: column; gap: 14px; }
.wait-timer { font-family: var(--font-display); font-size: 3rem; color: var(--cyan); text-align: center; }
.wait-art img { max-height: 40vh; margin: 0 auto; border-radius: var(--radius); background: #fff; }
.spectate-note { color: var(--muted); text-align: center; line-height: 1.5; }

.gallery { display: flex; flex-direction: column; gap: 16px; }
.gal-entry {
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 10px; display: flex; flex-direction: column; gap: 8px;
}
/* Cap the height so a class of thirty is a scroll, not an expedition. */
.gal-img img { width: 100%; max-height: 42vh; object-fit: contain; border-radius: var(--radius-sm); background: #fff; }
.gal-missing { padding: 34px; text-align: center; color: var(--faint); background: rgba(0, 0, 0, 0.25); border-radius: var(--radius-sm); }
.gal-name { font-family: var(--font-label); letter-spacing: 1.4px; text-align: center; color: var(--pink); }
.self-tag { color: var(--cyan); font-size: 0.75rem; }
.react-row { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.react-btn {
  display: inline-flex; align-items: center; gap: 5px; min-height: 42px; padding: 6px 12px;
  border: 2px solid var(--line); border-radius: 999px; background: rgba(255, 255, 255, 0.05);
  font-size: 1.05rem; transition: all var(--dur);
}
.react-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.12); transform: translateY(-1px); }
.react-btn.is-mine { border-color: var(--cyan); background: rgba(78, 205, 196, 0.2); }
.react-btn.has-votes .react-count { color: var(--yellow); }
.react-count { font-family: var(--font-label); font-size: 0.85rem; color: var(--muted); }

.cj-list { display: flex; flex-direction: column; gap: 9px; }
.cj-card {
  padding: 12px 14px; background: var(--surface); border: 2px solid var(--line-soft);
  border-radius: var(--radius); display: flex; flex-direction: column; gap: 5px;
}
.cj-card.is-winner { border-color: var(--green); background: rgba(53, 208, 127, 0.14); }
.cj-card.is-mine { border-style: dashed; }
.cj-text { line-height: 1.45; }
.cj-author { font-family: var(--font-label); letter-spacing: 1.4px; color: var(--cyan); font-size: 0.84rem; }

.elim-vote { background: var(--surface); border: 2px solid var(--purple); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.elim-title { font-family: var(--font-label); letter-spacing: 2px; text-transform: uppercase; font-size: 0.95rem; text-align: center; }
.elim-list { display: flex; flex-direction: column; gap: 7px; }
.elim-btn {
  min-height: var(--tap); padding: 10px 14px; border: 2px solid var(--line);
  border-radius: var(--radius); background: rgba(255, 255, 255, 0.05); font-weight: 700; transition: all var(--dur);
}
.elim-btn:hover:not(:disabled) { border-color: var(--red); background: rgba(255, 92, 92, 0.14); }
.elim-btn.is-mine { border-color: var(--purple); background: rgba(168, 85, 247, 0.22); }
.elim-btn:disabled { opacity: 0.45; }

.final-score { font-family: var(--font-display); font-size: clamp(2.4rem, 12vw, 4rem); color: var(--yellow); text-align: center; }

/* =====================================================================
   Overlays: toasts, modals, interstitial, status
   ===================================================================== */
.toast-stack { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(92vw, 460px); }
.toast {
  padding: 12px 18px; border-radius: var(--radius); background: var(--surface-2);
  border: 1px solid var(--line); box-shadow: var(--shadow); font-size: 0.94rem;
  animation: riseIn 0.26s var(--ease); text-align: center; width: fit-content; max-width: 100%;
}
.toast.is-leaving { opacity: 0; transform: translateY(8px); transition: all 0.3s; }
.toast.is-success { border-color: var(--green); }
.toast.is-error { border-color: var(--red); }
.toast.is-warn { border-color: var(--orange); }

.modal-overlay {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px;
  background: rgba(0, 0, 0, 0.68); backdrop-filter: blur(4px); animation: fadeIn 0.2s;
}
.modal {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 24px; width: min(94vw, 460px); box-shadow: var(--shadow); animation: popIn 0.25s var(--ease);
  max-height: 88vh; overflow-y: auto;
}
.modal-wide { width: min(96vw, 940px); }
.modal h2 { font-family: var(--font-label); font-size: 1.15rem; letter-spacing: 1.6px; text-transform: uppercase; color: var(--yellow); margin-bottom: 14px; }
.modal-body { display: flex; flex-direction: column; gap: 12px; line-height: 1.55; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 20px; }

.interstitial {
  position: fixed; inset: 0; z-index: 95; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px; text-align: center; padding: 24px;
  background: rgba(12, 10, 22, 0.94); opacity: 0; pointer-events: none;
  transition: opacity 0.36s var(--ease);
}
.interstitial.show { opacity: 1; }
.int-icon { font-size: clamp(3rem, 12vw, 6rem); }
.int-text { font-family: var(--font-display); font-size: clamp(2rem, 9vw, 5rem); letter-spacing: 2px; }
.int-sub { font-family: var(--font-hand); font-size: clamp(1.1rem, 4vw, 2rem); color: var(--yellow); max-width: 26ch; line-height: 1.35; }

.conn-pill {
  position: fixed; top: 10px; right: 12px; z-index: 80; padding: 5px 12px; border-radius: 999px;
  font-family: var(--font-label); font-size: 0.72rem; letter-spacing: 1.6px; text-transform: uppercase;
  border: 1px solid var(--line); background: rgba(0, 0, 0, 0.55); color: var(--muted);
}
.conn-pill.online { color: var(--green); border-color: rgba(53, 208, 127, 0.4); }
.conn-pill.connecting, .conn-pill.reconnecting { color: var(--orange); border-color: rgba(255, 167, 61, 0.4); }
.conn-pill.offline { color: var(--red); border-color: rgba(255, 92, 92, 0.4); }

.conn-banner { padding: 10px 16px; text-align: center; font-family: var(--font-label); letter-spacing: 1.4px; background: var(--orange); color: #1a1400; }
.conn-banner.is-error { background: var(--red); color: #fff; }

.confetti-piece { position: fixed; top: -20px; z-index: 96; pointer-events: none; animation: confettiFall linear forwards; }

/* =====================================================================
   Themed dropdowns (the browser draws a <select>'s list itself and ignores
   the page's styling, which on Windows is a white panel with blue rows)
   ===================================================================== */
.dd { position: relative; }
select.dd-native {
  position: absolute; opacity: 0; pointer-events: none;
  width: 1px; height: 1px; min-height: 0; padding: 0; margin: 0; border: 0;
}
.dd-trigger {
  width: 100%; min-height: var(--tap); padding: 12px 40px 12px 14px; text-align: left;
  background: rgba(0, 0, 0, 0.3); border: 2px solid var(--line); border-radius: var(--radius);
  position: relative; transition: border-color var(--dur);
}
.dd-trigger:hover { border-color: var(--line); background: rgba(0, 0, 0, 0.4); }
.dd-trigger[aria-expanded="true"] { border-color: var(--cyan); }
.dd-trigger::after {
  content: ''; position: absolute; right: 15px; top: 50%; width: 9px; height: 9px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: translateY(-70%) rotate(45deg); transition: transform var(--dur);
}
.dd-trigger[aria-expanded="true"]::after { transform: translateY(-30%) rotate(225deg); }
.dd-panel {
  position: fixed; z-index: 120; max-height: 320px; overflow-y: auto;
  background: var(--surface-2); border: 2px solid var(--cyan); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 5px; animation: popIn 0.14s var(--ease);
}
.dd-option {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 11px 12px;
  border-radius: var(--radius-sm); text-align: left; min-height: 44px; transition: background var(--dur);
}
.dd-option:hover, .dd-option.is-focus { background: rgba(255, 255, 255, 0.12); }
.dd-option.is-selected { color: var(--cyan); }
.dd-option.is-selected::before { content: '✓'; }
.dd-option:not(.is-selected)::before { content: ''; width: 0.85em; }

/* =====================================================================
   Responsive
   ===================================================================== */
@media (max-width: 900px) {
  .lobby { grid-template-columns: 1fr; gap: 16px; padding: 16px; overflow-y: auto; }
  .caption-judge { grid-template-columns: 1fr; overflow-y: auto; }
  .cj-art img { max-height: 32vh; }
  .carousel-nav { width: 46px; height: 46px; font-size: 1.6rem; }
}
@media (max-width: 620px) {
  /* On a phone the status pill shrinks to a coloured dot, so it never covers
     the countdown in the corner of the drawing screen. */
  .conn-pill { width: 14px; height: 14px; padding: 0; border-radius: 50%; overflow: hidden; text-indent: -99px; }
  .conn-pill.online { background: var(--green); }
  .conn-pill.connecting, .conn-pill.reconnecting { background: var(--orange); }
  .conn-pill.offline { background: var(--red); }
  .draw-head { padding-right: 26px; }
  .bar { padding: 8px 12px; gap: 8px; }
  .bar-title { font-size: 0.95rem; }
  .card { padding: 16px; }
  .settings-grid { grid-template-columns: 1fr; }
  .mode-grid { grid-template-columns: 1fr; }
  .podium-block { width: 84px; }
  .slider input[type=range] { width: 74px; }
  .tool-btn { width: 40px; height: 40px; font-size: 1.05rem; }
  .swatch { width: 30px; height: 30px; }
}
@media (max-height: 700px) and (orientation: landscape) {
  .draw-prompt { font-size: 1rem; }
  .toolbar { gap: 4px; }
  .tool-btn { width: 38px; height: 38px; }
}

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

@media print { body { background: #fff; color: #000; } .screen { position: static; } }
