/* ==========================================================================
   Birdsong Trivia — Queen City Dolphins red / black / white
   ========================================================================== */
:root {
  --red: #e3121b;
  --red-hi: #ff3b42;
  --red-lo: #8f0910;
  --ink: #09090b;
  --ink-2: #111115;
  --panel: #16161b;
  --panel-2: #1f1f26;
  --line: rgba(255, 255, 255, 0.1);
  --white: #ffffff;
  --muted: #a3a3af;
  --good: #1fcb6b;
  --good-lo: #0b7a3e;
  --gold: #ffc531;
  --silver: #dfe3ea;
  --bronze: #e38b4f;
  --display: 'Lilita One', 'Rubik', system-ui, sans-serif;
  --body: 'Rubik', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --radius: 20px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--ink);
  color: var(--white);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
img { max-width: 100%; }
[hidden] { display: none !important; }

/* ---------- animated background: red glow, lane stripes, bubbles, waves ---------- */
.bg {
  position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none;
  background:
    radial-gradient(1100px 650px at 88% -12%, rgba(227, 18, 27, 0.42), transparent 62%),
    radial-gradient(900px 600px at -12% 112%, rgba(227, 18, 27, 0.32), transparent 60%),
    linear-gradient(180deg, #0c0c0f, #050506);
}
.bg::before {
  content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.022) 0 2px, transparent 2px 26px);
}
.bubble {
  position: absolute; bottom: -80px; border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  background: radial-gradient(circle at 32% 30%, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0.03) 55%);
  animation: rise linear infinite;
}
@keyframes rise {
  0% { transform: translate(0, 0); opacity: 0; }
  10% { opacity: 1; }
  100% { transform: translate(var(--drift, 30px), -118vh); opacity: 0.2; }
}
.wave {
  position: absolute; left: 0; right: 0; bottom: 0; height: 110px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 800 110' preserveAspectRatio='none'%3E%3Cpath d='M0 55 Q100 15 200 55 T400 55 T600 55 T800 55 V110 H0Z' fill='%23e3121b'/%3E%3C/svg%3E") repeat-x;
  background-size: 800px 110px;
  opacity: 0.22;
  animation: wave 16s linear infinite;
}
.wave.w2 { height: 80px; opacity: 0.16; animation-duration: 10s; animation-direction: reverse; }
@keyframes wave { to { background-position-x: 800px; } }

/* ---------- type ---------- */
.display { font-family: var(--display); letter-spacing: 0.01em; }
.title {
  font-family: var(--display); text-transform: uppercase; line-height: 0.9; margin: 0;
  font-size: clamp(3rem, 9vw, 6.5rem);
  text-shadow: 0 5px 0 rgba(0, 0, 0, 0.6), 0 0 40px rgba(227, 18, 27, 0.45);
}
.title span { color: var(--red); -webkit-text-stroke: 2px #fff; paint-order: stroke fill; }
.kicker {
  font-family: var(--display); text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--red-hi); font-size: clamp(1rem, 2vw, 1.5rem);
}
.muted { color: var(--muted); }

.logo {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-family: var(--display); font-size: 1.35rem; text-transform: uppercase; letter-spacing: 0.02em;
  color: #fff; text-decoration: none;
}
.logo .fin {
  display: grid; place-items: center; width: 2.1rem; height: 2.1rem; border-radius: 50%;
  background: var(--red); box-shadow: 0 0 0 3px #fff, 0 6px 18px rgba(227, 18, 27, 0.5); font-size: 1.15rem;
}
.logo b { color: var(--red); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5em;
  font-family: var(--display); font-size: 1.2rem; letter-spacing: 0.03em; text-transform: uppercase;
  border: 0; border-radius: 999px; padding: 0.8em 1.7em; cursor: pointer; text-decoration: none;
  background: linear-gradient(180deg, var(--red-hi), var(--red));
  color: #fff;
  box-shadow: 0 6px 0 var(--red-lo), 0 14px 30px rgba(227, 18, 27, 0.35);
  transition: transform 0.08s, box-shadow 0.08s, filter 0.2s, opacity 0.2s;
  user-select: none;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--red-lo), 0 6px 14px rgba(227, 18, 27, 0.3); }
.btn[disabled] { opacity: 0.35; cursor: not-allowed; filter: grayscale(0.5); transform: none; }
.btn.white { background: #fff; color: var(--ink); box-shadow: 0 6px 0 #b8b8c2, 0 14px 30px rgba(0, 0, 0, 0.4); }
.btn.white:active { box-shadow: 0 2px 0 #b8b8c2; }
.btn.ghost { background: transparent; border: 2px solid rgba(255, 255, 255, 0.28); box-shadow: none; }
.btn.ghost:active { transform: translateY(2px); }
.btn.sm { font-size: 0.9rem; padding: 0.55em 1.1em; box-shadow: 0 4px 0 var(--red-lo); }
.btn.sm.ghost { box-shadow: none; }
.btn.xl { font-size: clamp(1.3rem, 2.2vw, 2rem); padding: 0.75em 2.1em; }
.btn.block { width: 100%; }
.btn.pulse:not([disabled]) { animation: btnPulse 1.8s ease-in-out infinite; }
@keyframes btnPulse {
  0%, 100% { box-shadow: 0 6px 0 var(--red-lo), 0 0 0 0 rgba(227, 18, 27, 0.6); }
  50% { box-shadow: 0 6px 0 var(--red-lo), 0 0 0 16px rgba(227, 18, 27, 0); }
}
.icon-btn {
  display: grid; place-items: center; width: 2.6rem; height: 2.6rem; border-radius: 50%;
  border: 2px solid var(--line); background: rgba(255, 255, 255, 0.05); cursor: pointer; font-size: 1.1rem;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.12); }
.link-btn { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; padding: 0.5rem; }

.pill {
  display: inline-flex; align-items: center; gap: 0.45em; padding: 0.45em 1em; border-radius: 999px;
  background: rgba(255, 255, 255, 0.08); border: 1px solid var(--line); font-weight: 700; white-space: nowrap;
}
.pill.red { background: var(--red); border-color: transparent; }
.pill.white { background: #fff; color: var(--ink); }

/* ---------- inputs ---------- */
.field { display: grid; gap: 0.4rem; text-align: left; }
.field > span { font-weight: 700; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.input {
  width: 100%; padding: 0.85rem 1rem; border-radius: 14px; border: 2px solid var(--line);
  background: rgba(0, 0, 0, 0.45); color: #fff; font-size: 1.15rem; outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus { border-color: var(--red); box-shadow: 0 0 0 4px rgba(227, 18, 27, 0.25); }
.input.code { text-transform: uppercase; letter-spacing: 0.35em; font-family: var(--display); font-size: 1.8rem; text-align: center; }

/* ---------- answer tiles (shared by host + phone) ---------- */
.tile {
  position: relative; overflow: hidden; display: flex; align-items: center; gap: 0.9em;
  border-radius: var(--radius); padding: 0.9em 1.1em; font-weight: 800; text-align: left;
  border: 3px solid transparent; transition: transform 0.25s, opacity 0.35s, filter 0.35s, box-shadow 0.35s;
}
.tile-letter {
  flex: none; display: grid; place-items: center; width: 2em; height: 2em; border-radius: 12px;
  font-family: var(--display); font-size: 1.15em; line-height: 1;
}
.tile-body { flex: 1; min-width: 0; display: grid; gap: 0.4em; }
.tile-text { overflow-wrap: anywhere; line-height: 1.15; }
.tile-img { max-height: 22vh; width: auto; border-radius: 10px; object-fit: contain; background: rgba(255, 255, 255, 0.9); }

.t0 { background: var(--red); color: #fff; }
.t0 .tile-letter { background: #fff; color: var(--red); }
.t1 { background: #fff; color: var(--ink); }
.t1 .tile-letter { background: var(--ink); color: #fff; }
.t2 { background: #18181d; color: #fff; border-color: var(--red); }
.t2 .tile-letter { background: var(--red); color: #fff; }
.t3 { background: repeating-linear-gradient(135deg, #b10d14 0 18px, #8f0910 18px 36px); color: #fff; border-color: rgba(255,255,255,.75); }
.t3 .tile-letter { background: #fff; color: #8f0910; }
.t4 { background: linear-gradient(180deg, #e9ecf1, #b9bec8); color: var(--ink); }
.t4 .tile-letter { background: var(--red); color: #fff; }

.tile.correct {
  box-shadow: 0 0 0 5px var(--good), 0 0 50px rgba(31, 203, 107, 0.55);
  animation: popIn 0.55s cubic-bezier(.2, 1.6, .4, 1) both;
  z-index: 1;
}
.tile.correct::after {
  content: '✓'; position: absolute; top: 50%; right: 0.6em; transform: translateY(-50%);
  display: grid; place-items: center; width: 1.7em; height: 1.7em; border-radius: 50%;
  background: var(--good); color: #fff; font-size: 1.2em; font-weight: 900; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}
.tile.dim { opacity: 0.25; filter: grayscale(0.7); transform: scale(0.97); }
.tile.mine { outline: 4px dashed rgba(255,255,255,.9); outline-offset: 3px; }

/* ---------- points meter ---------- */
.meter { display: flex; align-items: center; gap: 1rem; }
.meter-track {
  position: relative; flex: 1; height: 26px; border-radius: 99px; overflow: hidden;
  background: rgba(255, 255, 255, 0.08); border: 2px solid rgba(255, 255, 255, 0.14);
}
.meter-fill {
  position: absolute; inset: 0; transform-origin: left center;
  background: linear-gradient(90deg, var(--red-lo), var(--red) 60%, var(--red-hi));
  box-shadow: 0 0 22px rgba(227, 18, 27, 0.7);
}
.meter-fill::after {
  content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.18) 0 10px, transparent 10px 22px);
  animation: stripes 0.8s linear infinite;
}
@keyframes stripes { to { background-position: 44px 0; } }
.meter-pts { font-family: var(--display); line-height: 1; min-width: 3.3ch; text-align: right; }
.meter-pts small { font-size: 0.4em; color: var(--muted); margin-left: 0.15em; }
.meter-secs {
  display: grid; place-items: center; flex: none; border-radius: 50%; font-family: var(--display);
  background: #fff; color: var(--ink); box-shadow: 0 0 0 4px var(--red);
}
.meter.hurry .meter-secs { background: var(--red); color: #fff; box-shadow: 0 0 0 4px #fff; animation: throb 0.5s ease-in-out infinite alternate; }
.meter.done .meter-fill { opacity: 0.2; }
@keyframes throb { to { transform: scale(1.12); } }
.bump { animation: bump 0.25s ease-out; }
@keyframes bump { 40% { transform: scale(1.18); } }

/* get-ready bar */
.getready { display: grid; gap: 0.6rem; justify-items: center; }
.getready-label { font-family: var(--display); text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.getready-bar { width: min(520px, 80%); height: 10px; border-radius: 99px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.getready-fill { height: 100%; background: #fff; transform-origin: left; animation: fillUp linear forwards; }
@keyframes fillUp { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ---------- shared animations ---------- */
@keyframes popIn { 0% { transform: scale(0.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes slideDown { from { transform: translateY(-30px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes zoomIn { from { transform: scale(1.6); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-14px) rotate(4deg); } }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
.a-pop { animation: popIn 0.5s cubic-bezier(.2, 1.5, .4, 1) both; }
.a-up { animation: slideUp 0.5s cubic-bezier(.2, .9, .3, 1) both; }
.a-down { animation: slideDown 0.5s cubic-bezier(.2, .9, .3, 1) both; }
.a-zoom { animation: zoomIn 0.55s cubic-bezier(.2, .9, .3, 1) both; }
.d1 { animation-delay: 0.1s; } .d2 { animation-delay: 0.2s; } .d3 { animation-delay: 0.3s; } .d4 { animation-delay: 0.4s; } .d5 { animation-delay: 0.55s; }

/* ---------- toast + modal ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 100;
  background: #fff; color: var(--ink); font-weight: 700; padding: 0.8rem 1.3rem; border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5); animation: slideUp 0.3s both; max-width: calc(100vw - 32px); text-align: center;
}
.toast.err { background: var(--red); color: #fff; }
.modal-back {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 16px;
  background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(4px); animation: fade 0.2s both;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: min(440px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 22px;
  padding: 1.6rem; text-align: center; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6); animation: popIn 0.3s both;
}
.modal p { font-size: 1.15rem; margin: 0 0 1.4rem; }
.modal .row { display: flex; gap: 0.8rem; justify-content: center; flex-wrap: wrap; }

.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 80; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .bubble { display: none; }
}

/* ---------- swim race (shared) ---------- */
.race-keys { display: flex; gap: 0.45em; justify-content: center; }
.race-keys .key {
  display: grid; place-items: center; width: 1.7em; height: 1.7em; border-radius: 0.3em;
  background: #fff; color: var(--ink); font-weight: 900; line-height: 1; box-shadow: 0 0.14em 0 var(--red);
}
.swimmer {
  position: absolute; top: 50%; left: calc(var(--x, 0) * (100% - 1.9em)); width: 1.9em; height: 1.07em;
  transform: translateY(-50%); transition: left 0.25s linear; z-index: 1;
}
.swimmer svg { display: block; width: 100%; height: 100%; overflow: visible; }
.swimmer::before { /* wake trailing behind */
  content: ''; position: absolute; right: 85%; top: 62%; width: 2.4em; height: 0.3em; border-radius: 99px; transform: translateY(-50%);
  background: linear-gradient(to left, rgba(255, 255, 255, 0.5), transparent);
}

/* picture answers: the name appears under the picture at the reveal */
.tile-body:has(.tile-img) .tile-text { text-align: center; font-size: 0.85em; }
