:root{
  --bg:#15bdb5; --panel:#15bdb5; --text:#0b1020; --muted:#0b3b3a; --accent:#0d9488; --chip:#0ea5e9; --success:#22c55e; --border:#0b827c;
}
*{box-sizing:border-box}
/* Intro/primary font: Raleway (self-hosted) */
@font-face{
  font-family:'Raleway';
  src: url('assets/fonts/Raleway-Medium.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
body{margin:0;font-family:'Raleway', Helvetica, Arial, system-ui,-apple-system,Segoe UI,Roboto,Inter,sans-serif;background:var(--bg);color:var(--text)}
#stage{min-height:100svh;display:flex;align-items:flex-start;justify-content:center}
.site-header{display:flex;flex-direction:column;align-items:center;gap:6px;padding:12px 0}
.site-header .logo{height:72px;width:auto;display:block}
.site-header .title{font-weight:800;letter-spacing:.5px;margin:0}
/* Make the logo larger specifically during gameplay */
.game-active .site-header .logo{height:96px}
/* Landing welcome title */
.welcome-title{font-size:24px; margin:6px 0}
/* Use Raleway on landing text only (not buttons) */
#stage h1, #stage h2, #stage h3, #stage p, #stage ul, #stage li, #stage .welcome-title{
  font-family:'Raleway', Helvetica, Arial, sans-serif
}
/* Centered intro lines */
.intro-lines{max-width:720px;margin:8px auto;text-align:center}
/* Standard line height for intro lines */
.intro-line{margin:6px 0; line-height:1.5}
/* Match bullet list spacing under intro */
#stage ul li{line-height:1.5}
/* Large hero logo on landing */
.hero-image{width:50%;max-width:420px;height:auto;display:block;margin:4px auto 12px;object-fit:contain}
@media (max-width: 480px){ .hero-image{width:45%;max-width:240px} }
/* In gameplay, constrain hero height so the view fits 9:16 */
.game-active .hero-image{max-height:8vh;width:auto;margin:2px auto 6px}
@media (max-width: 480px){ .game-active .hero-image{max-height:5.5vh} }
/* Trivbot mascot at bottom of landing */
.trivbot{width:140px;max-width:40vw;height:auto;display:block;margin:18px auto 0}
.game-active .trivbot{display:none}
/* Host code under hero */
.host-code{display:flex;gap:8px;justify-content:center;align-items:center;margin:8px 0 12px}
.host-code-label{font-weight:700}
.host-code .badge{font-size:1.2rem;padding:6px 10px}
.flash-correct{animation: flashGreen 400ms ease-in-out}
.flash-wrong{animation: flashRed 400ms ease-in-out}
@keyframes flashGreen{0%{background:#0b1020}20%{background:#064e3b}100%{background:#0b1020}}
@keyframes flashRed{0%{background:#0b1020}20%{background:#7f1d1d}100%{background:#0b1020}}
.container{max-width:960px;margin:0 auto;padding:16px}
header h1{margin:0}
.subtitle{margin:4px 0 0;color:var(--muted)}
.card{background:var(--panel);padding:16px;border-radius:12px;box-shadow:0 2px 8px rgba(0,0,0,.3);margin:12px 0}
/* Landing/setup cards should blend into background (no boxes) */
#stage.card, #hostSetup.card, #joinSetup.card{ background: transparent; box-shadow: none; padding: 0; margin: 12px 0 }
.row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
/* Utilities */
.w-full{width:100%}
.btn-block{width:100%}
.stack{display:flex;flex-direction:column;gap:10px}
/* Form shell to align host inputs */
.form-shell{width:min(92vw, 420px);margin:0 auto}
.form-grid-2{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.form-shell label{display:block;width:100%}
/* Consistent control heights so the visual block feels aligned */
.form-shell input,.form-shell select{height:44px}
.form-shell button{height:48px}
/* Square buttons grid for Start/Join */
.square-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-top:10px;width:min(92vw, 360px);margin-left:auto;margin-right:auto;justify-items:stretch;justify-content:center}
.square-btn{aspect-ratio:1/1;width:100%;border-radius:16px;font-size:1.05rem;display:flex;align-items:center;justify-content:center;flex-direction:column;gap:8px;text-align:center}
.square-btn svg{width:40px;height:40px;fill:currentColor;stroke:currentColor}
@media (max-width:480px){
  .square-grid{grid-template-columns:1fr 1fr}
}
@media (max-width: 480px){
  body{padding:10px 12px 12px}
  #stage{padding:4px 0}
  #stage > div{width:100%}
  .welcome-title{font-size:19px;margin:2px 0}
  .hero-image{width:34%;max-width:170px;margin:2px auto 8px}
  .square-grid{gap:8px;margin-top:6px;width:min(100%, 320px);margin-left:auto;margin-right:auto}
  .square-btn{border-radius:14px;font-size:0.92rem;gap:5px}
  .square-btn svg{width:30px;height:30px}
  .intro-lines{margin:4px auto}
  .intro-line{margin:3px 0;line-height:1.2;font-size:0.88rem}
  #stage h3{font-size:0.98rem;margin:4px 0}
  .trivbot{width:84px;margin:8px auto 0}
}
@media (max-width: 480px) and (max-height: 780px){
  body{padding:8px 10px 10px}
  .hero-image{width:28%;max-width:128px;margin:0 auto 6px}
  .square-grid{gap:6px;width:min(100%, 288px);margin-left:auto;margin-right:auto}
  .square-btn{font-size:0.82rem;gap:4px}
  .square-btn svg{width:24px;height:24px}
  .intro-line{margin:2px 0;line-height:1.12;font-size:0.79rem}
  #stage h3{font-size:0.9rem;margin:3px 0}
  .trivbot{display:none}
  #stage br{display:none}
}
input,select{background:#0f172a;border:1px solid var(--border);color:var(--text);padding:10px;border-radius:8px}
button{background:var(--accent);color:#fff;border:0;padding:10px 12px;border-radius:8px;cursor:pointer}
button.secondary{background:#334155}
.muted{color:var(--muted)}
.question{font-size:1.2rem;margin:8px 0}
.choices{display:grid;grid-template-columns:1fr;gap:10px}
@media (min-width: 640px){
  .choices{grid-template-columns:1fr 1fr}
}
/* Bigger tap targets for mobile */
button{background:var(--accent);color:#fff;border:0;padding:14px 16px;border-radius:10px;cursor:pointer;font-size:1rem}
button.secondary{background:#334155}
/* High-contrast form controls for cyan background */
input,select{background:#ffffff;border:2px solid var(--border);color:#0b1020;padding:12px;border-radius:8px;font-size:1rem}
input::placeholder{color:#4b5563;opacity:0.9}
select:focus,input:focus{outline:3px solid rgba(13,148,136,0.35)}
.question{font-size:1.25rem;margin:10px 0}
.players{list-style:none;padding:0;margin:0}
.players li{display:flex;justify-content:space-between;border-bottom:1px solid var(--border);padding:6px 0}
.badge{background:var(--chip);color:#00121f;border-radius:999px;padding:2px 8px;font-weight:700}
.winner{color:var(--success);font-weight:700}
.info{justify-content:space-between}
.feedback{margin-top:8px}
label{margin-right:8px}

/* Live progress */
.progress-list{list-style:none;margin:8px 0 0;padding:0}
.progress-item{display:flex;align-items:center;gap:8px;margin:6px 0}
.progress-name{min-width:140px;flex:0 0 140px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.progress-bar{flex:1;height:12px;background:var(--border);border-radius:999px;position:relative}
.progress-fill{position:absolute;left:0;top:0;bottom:0;background:var(--chip);border-radius:999px}
.progress-score{min-width:48px;text-align:right}
.me .progress-name{font-weight:700}
.winner-row .progress-fill{background:var(--success)}

/* Intro overlay */
.intro{position:fixed;inset:0;background:#15bdb5;display:grid;place-items:center;z-index:9999;animation:introFade 2.5s ease-in-out forwards}
.intro img{max-width:80vw;max-height:60vh;height:auto;width:auto;filter:none}
@keyframes introFade{0%{opacity:0}10%{opacity:1}80%{opacity:1}100%{opacity:0;visibility:hidden}}

/* Health indicator */
.health{font-size:.9rem;margin:6px 0;color:var(--muted)}
.health.ok{color: var(--success)}
.health.err{color: #f87171}

/* Gameplay layout and boxes */
.game-layout{display:flex;flex-direction:column;gap:12px}
.box{border:none; border-radius:14px; padding:12px; background:rgba(255,255,255,0.08)}
.qbox{font-size:1.05rem; max-height:20vh; overflow:auto; -webkit-overflow-scrolling: touch}
.answer-grid{display:grid;grid-template-columns:repeat(2, minmax(104px, 1fr));gap:6px;align-items:center;justify-items:center}
.answer-grid button{aspect-ratio:1/1;width:100%;max-width:150px;margin:0 auto;border-radius:12px;display:flex;align-items:center;justify-content:center;text-align:center;line-height:1.25;word-wrap:break-word;white-space:normal;padding:8px;font-size:clamp(0.8rem, 2.2vw, 0.95rem)}
.answer-grid button.answer-selected{outline:3px solid rgba(255,255,255,0.9);outline-offset:2px}
.answer-grid button.answer-correct{background:#15803d;color:#fff}
.answer-grid button.answer-wrong{background:#b91c1c;color:#fff}
.answer-grid button:disabled{opacity:1;cursor:default}
@media (max-width: 360px){
  .answer-grid{grid-template-columns:repeat(2, minmax(90px, 1fr));gap:6px}
  .answer-grid button{max-width:130px}
}
.answer-grid button:active{transform:scale(0.98)}
.streak{font-weight:700}

/* Centered streak bar with numbered icons 1..10 */
.streak-wrap{display:grid;gap:10px;justify-items:center;text-align:center}
.streak-title{font-weight:700}
.streak-bar{display:grid;grid-template-columns:repeat(10, minmax(18px, 1fr));gap:4px;justify-items:center;width:100%;max-width:340px;margin:0 auto}
.streak-item{width:clamp(20px, 5.2vw, 26px);height:clamp(20px, 5.2vw, 26px);border-radius:50%;display:flex;align-items:center;justify-content:center;background:rgba(255,255,255,0.25);color:#0b3b3a;font-weight:800}
.streak-item.done{background:var(--accent);color:#fff}

/* 9:16 viewport fit for gameplay: hide extra chrome and size rows */
.game-active .site-header, .game-active #healthStatus{display:none}
.game-active .container{height:100vh;display:grid;grid-template-rows:auto 1fr auto auto;gap:6px;overflow:hidden}
/* Order on page: #game, #streakBox, #progressBox already follow each other */
.game-active #game{display:grid;grid-template-rows:auto auto 1fr;gap:6px;overflow:hidden}
.game-active #streakBox{max-height:none;margin:10px 0}
.game-active #progressBox{max-height:20vh;overflow:auto;margin:10px 0 0}

/* Countdown overlay for prefetch warmup */
#countdownOverlay{
  position:fixed; inset:0;
  background: radial-gradient(1200px 1200px at 50% 40%, #15bdb5, rgba(0,0,0,0.0)) , rgba(0,0,0,0.86);
  display:none; align-items:center; justify-content:center; z-index:9999;
  backdrop-filter: blur(1.5px);
}
#countdownOverlay.show{display:flex}
#countdownOverlay > div{ display:grid; place-items:center; padding:12px; position:relative; height:100vh; width:100%; }
/* Reserve hero area to avoid layout shifts while it loads */
#countdownOverlay img{ display:block; width:min(75vw, 680px); height:auto; margin:0 auto 8px; aspect-ratio: 16 / 9; object-fit:contain }
/* Progress bar for loading */
.loadbar{ width:min(80vw, 560px); height:12px; border-radius:999px; background:rgba(255,255,255,0.25); overflow:hidden; border:1px solid rgba(255,255,255,0.35); }
.loadbar-fill{ height:100%; width:0%; background:var(--chip); transition:width 160ms ease-out }
#countdownLabel{ color:#d8f4f3; text-align:center; margin-top:8px; font-size:clamp(14px, 4vw, 22px); letter-spacing:0.04em; opacity:0.95 }
