:root{
  --bg1:#0f172a;
  --bg2:#11243f;
  --card:#10203dd9;
  --stroke:#ffffff1f;
  --text:#f8fbff;
  --muted:#d6e1f3;
  --accent:#ffb703;
  --accent-2:#8ecae6;
  --success:#80ed99;
  --danger:#ff6b6b;
  --shadow:0 18px 60px rgba(0,0,0,.28);
  --radius:24px;
  --tap:54px;
  --maxw:980px;
  --font:ui-rounded, "Avenir Next Rounded", "Trebuchet MS", "Segoe UI", sans-serif;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:var(--font);
  color:var(--text);
  background:
    radial-gradient(1200px 800px at 12% 10%, #f4a26155 0%, transparent 55%),
    radial-gradient(900px 700px at 84% 18%, #219ebc55 0%, transparent 60%),
    linear-gradient(180deg, var(--bg1), var(--bg2));
  overflow-x:hidden;
}

.bg{position:fixed; inset:0; z-index:-2; overflow:hidden}
.blob{
  position:absolute;
  width:520px;
  height:520px;
  border-radius:50%;
  filter:blur(52px);
  opacity:.42;
  animation:floaty 12s ease-in-out infinite;
}
.b1{left:-120px; top:-140px; background:#ffb703;}
.b2{right:-160px; top:70px; background:#8ecae6; animation-duration:14s;}
.b3{left:36%; bottom:-210px; background:#fb8500; animation-duration:16s;}

@keyframes floaty{
  0%,100%{transform:translate(0,0) scale(1)}
  50%{transform:translate(26px, 20px) scale(1.05)}
}

.app{
  width:min(var(--maxw), calc(100% - 28px));
  margin:18px auto 24px;
  display:flex;
  flex-direction:column;
  gap:14px;
}

.topbar{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:14px;
  padding:8px 6px;
}

.brand{
  display:flex;
  align-items:center;
  gap:12px;
  min-width:220px;
}

.logo{
  width:48px;
  height:48px;
  border-radius:16px;
  display:grid;
  place-items:center;
  background:linear-gradient(135deg, var(--accent), #ffd166);
  color:#2d1600;
  font-size:26px;
  font-weight:900;
  box-shadow:var(--shadow);
}

.title{font-weight:900; letter-spacing:.2px}
.subtitle{color:var(--muted); font-size:13px}

.hud{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  justify-content:flex-end;
}

.pill{
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 12px;
  border-radius:999px;
  border:1px solid var(--stroke);
  background:#0b1931b8;
  box-shadow:0 10px 30px rgba(0,0,0,.18);
}

.pill-label{color:var(--muted); font-size:12px}
.pill-value{font-weight:800; font-variant-numeric:tabular-nums}

.card{
  border:1px solid var(--stroke);
  border-radius:var(--radius);
  background:var(--card);
  backdrop-filter:blur(10px);
  box-shadow:var(--shadow);
  padding:18px;
}

.screen.hidden{display:none}

h1{
  margin:4px 0 8px;
  font-size:clamp(28px, 4vw, 42px);
  letter-spacing:-0.5px;
}

h2{
  margin:18px 0 10px;
  font-size:18px;
}

.lead{
  margin:0 0 14px;
  color:var(--muted);
  font-size:16px;
  line-height:1.45;
}

.table-picker{
  margin-bottom:14px;
}

.table-options{
  display:grid;
  grid-template-columns:repeat(2, minmax(0, 1fr));
  gap:10px;
}

.table-option{
  display:flex;
  align-items:center;
  gap:10px;
  padding:12px 14px;
  border-radius:18px;
  border:1px solid var(--stroke);
  background:#ffffff10;
  font-weight:800;
  cursor:pointer;
}

.table-option input{
  width:20px;
  height:20px;
  accent-color:#ffd166;
  cursor:pointer;
}

.selection-help{
  margin:10px 0 0;
  color:var(--muted);
  font-size:14px;
}

.best-to-beat{
  margin:0 0 12px;
  color:#ffe7a8;
  font-weight:700;
}

.cta-row{
  display:flex;
  flex-wrap:wrap;
  gap:12px;
  align-items:center;
  margin:12px 0 6px;
}

.btn{
  min-height:var(--tap);
  padding:12px 16px;
  border-radius:16px;
  border:1px solid var(--stroke);
  background:#0d1b33;
  color:var(--text);
  font-weight:800;
  letter-spacing:.2px;
  cursor:pointer;
  transition:transform .06s ease, filter .2s ease, background .2s ease, border-color .2s ease;
  touch-action:manipulation;
  -webkit-tap-highlight-color:transparent;
}

.btn:active{transform:translateY(1px) scale(.99)}
.btn:focus{outline:3px solid #ffffff33; outline-offset:2px}

.btn-primary{
  background:linear-gradient(135deg, var(--accent), #ffd166);
  color:#2d1600;
  border-color:#ffffff26;
}

.btn-ghost{background:#0d1b3385}

.podium{margin-top:12px}

.leaderboard{
  margin:0;
  padding-left:0;
  list-style:none;
  display:grid;
  gap:8px;
}

.leaderboard li{
  display:flex;
  justify-content:space-between;
  gap:12px;
  padding:10px 12px;
  border-radius:16px;
  border:1px solid #ffffff14;
  background:#0a1730a6;
}

.rank-name{
  display:flex;
  align-items:center;
  gap:10px;
  min-width:0;
}

.rank{
  width:32px;
  height:32px;
  border-radius:999px;
  display:grid;
  place-items:center;
  background:#ffffff14;
  font-weight:900;
  flex:0 0 auto;
}

.player{
  font-weight:800;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.time{
  font-weight:900;
  font-variant-numeric:tabular-nums;
  color:#ffe7a8;
}

.question-wrap{
  display:flex;
  flex-direction:column;
  align-items:center;
  text-align:center;
  gap:8px;
  padding:10px 0 12px;
}

.question-label{
  color:var(--muted);
  font-weight:700;
}

.question-expression{
  min-width:min(420px, 100%);
  padding:18px 20px;
  border-radius:24px;
  border:1px solid var(--stroke);
  background:#0b163080;
  box-shadow:0 18px 50px rgba(0,0,0,.22);
  font-size:clamp(54px, 10vw, 92px);
  font-weight:1000;
  letter-spacing:-2px;
  line-height:1;
  color:var(--text);
  font-family:inherit;
  text-align:center;
  cursor:pointer;
}

.answers{
  display:grid;
  grid-template-columns:repeat(3, 1fr);
  gap:12px;
  margin-top:14px;
}

.answer{
  min-height:76px;
  border-radius:18px;
  font-size:clamp(22px, 4vw, 30px);
  font-weight:900;
  background:#0c1b34;
  box-shadow:0 10px 28px rgba(0,0,0,.2);
}

.answer.correct{
  background:linear-gradient(135deg, var(--success), #d8ffd7);
  color:#08381a;
  border-color:#ffffff55;
}

.answer.wrong{
  background:linear-gradient(135deg, var(--danger), #ffc1c1);
  color:#430909;
  border-color:#ffffff55;
}

.answer.disabled{
  opacity:.85;
  filter:grayscale(.1);
  pointer-events:none;
}

.feedback{
  min-height:28px;
  margin-top:12px;
  text-align:center;
  font-weight:900;
  letter-spacing:.2px;
}

.feedback.ok{color:#d8ffd7}
.feedback.no{color:#ffc1c1}
.feedback.penalty{color:#ffd89a}

.bottom-row{
  display:flex;
  justify-content:center;
  align-items:center;
  margin-top:10px;
}

.hint{
  color:var(--muted);
  text-align:center;
  font-size:14px;
}

.score-entry{
  margin:8px 0 18px;
  padding:14px;
  border-radius:20px;
  border:1px solid #ffffff1d;
  background:#ffffff0e;
}

.score-entry.hidden{display:none}
.score-entry-text{margin:0 0 12px; color:var(--muted)}

.field{
  display:flex;
  flex-direction:column;
  gap:8px;
}

.field span{font-weight:700}

.field input{
  min-height:50px;
  padding:12px 14px;
  border-radius:14px;
  border:1px solid var(--stroke);
  background:#08152b;
  color:var(--text);
  font:inherit;
}

.field input::placeholder{color:#b8c5dd}

.footer{
  text-align:center;
  color:var(--muted);
  font-size:13px;
  padding:6px 0 2px;
}

.confetti{
  position:fixed;
  inset:0;
  width:100%;
  height:100%;
  pointer-events:none;
}

@media (max-width: 760px){
  .topbar{
    flex-direction:column;
    align-items:stretch;
  }

  .brand{min-width:0}

  .hud{
    justify-content:flex-start;
  }

  .answers{
    grid-template-columns:1fr;
  }

  .table-options{
    grid-template-columns:1fr;
  }

  .question-expression{
    min-width:100%;
    font-size:clamp(48px, 16vw, 76px);
  }

  .leaderboard li{
    align-items:center;
  }
}
