/* Shared styles — quiz night. Dark game surface, four validated identity colors. */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg1: #1b1035; --bg2: #2b1a5e; --bg3: #0e0a20;
  --surface: rgba(255, 255, 255, 0.07);
  --surface-solid: #241744;
  --ink: #ffffff; --ink-2: #c9c4e4; --ink-3: #8f88b8;
  --accent: #ffd166; --good: #35c04f; --bad: #e66767;
  --opt0: #e66767; --opt1: #3987e5; --opt2: #c98500; --opt3: #008300;
  --radius: 16px;
}

html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  color: var(--ink);
  background: radial-gradient(1200px 800px at 80% -10%, var(--bg2), transparent 60%),
              radial-gradient(1000px 700px at -10% 110%, #3d1a5e, transparent 55%),
              linear-gradient(160deg, var(--bg1), var(--bg3));
  background-attachment: fixed;
  min-height: 100dvh;
  overflow-x: hidden;
}

.wrap { max-width: 640px; margin: 0 auto; padding: 20px 16px 40px; min-height: 100dvh;
        display: flex; flex-direction: column; }
.wrap.wide { max-width: 1100px; }

h1 { font-size: 1.9rem; font-weight: 800; letter-spacing: -0.5px; }
h2 { font-size: 1.35rem; font-weight: 700; }
.muted { color: var(--ink-2); }
.tiny { font-size: 0.8rem; color: var(--ink-3); }
.center { text-align: center; }
.grow { flex: 1; }
.hidden { display: none !important; }

.card {
  background: var(--surface); border: 1px solid rgba(255,255,255,0.09);
  border-radius: var(--radius); padding: 20px;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}

/* ------------------------------------------------ buttons & inputs */
button, a {
  touch-action: manipulation; /* no double-tap-zoom stealing fast taps on mobile */
}
button {
  font: inherit; color: var(--ink); border: 0; cursor: pointer;
  border-radius: 12px; padding: 13px 20px; font-weight: 700;
  background: rgba(255,255,255,0.12); transition: transform .12s, filter .15s, background .15s;
}
button:hover { filter: brightness(1.15); }
button:active { transform: scale(0.96); }
button:disabled { opacity: 0.4; cursor: default; transform: none; }
button.primary { background: linear-gradient(135deg, #7048e8, #4a3aa7); box-shadow: 0 4px 18px rgba(112,72,232,.4); }
button.accent { background: linear-gradient(135deg, #ffd166, #f4a814); color: #241744; }
button.danger { background: rgba(230,103,103,0.25); color: #ffb3b3; }
button.big { font-size: 1.15rem; padding: 16px 28px; border-radius: 14px; width: 100%; }

input {
  font: inherit; width: 100%; padding: 13px 16px; border-radius: 12px;
  border: 1.5px solid rgba(255,255,255,0.18); background: rgba(0,0,0,0.25);
  color: var(--ink); outline: none; transition: border-color .15s;
}
input:focus { border-color: #7f6ef2; }
input::placeholder { color: var(--ink-3); }
label { display: block; font-size: .85rem; color: var(--ink-2); margin: 14px 0 6px; font-weight: 600; }

/* ------------------------------------------------ answer buttons (player) */
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.answers.two { grid-template-columns: 1fr; }
.ans {
  min-height: 96px; border-radius: 14px; color: #fff; font-weight: 800; font-size: 1.05rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 12px; text-align: center; line-height: 1.25;
  box-shadow: 0 6px 0 rgba(0,0,0,0.35), 0 8px 24px rgba(0,0,0,0.3);
  animation: rise .35s cubic-bezier(.2,.9,.3,1.3) backwards;
  text-shadow: 0 1px 3px rgba(0,0,0,.45);
}
.ans .shape { font-size: 1.5rem; line-height: 1; }
.ans:nth-child(1) { background: var(--opt0); animation-delay: .00s; }
.ans:nth-child(2) { background: var(--opt1); animation-delay: .06s; }
.ans:nth-child(3) { background: var(--opt2); animation-delay: .12s; }
.ans:nth-child(4) { background: var(--opt3); animation-delay: .18s; }
.ans:active { transform: translateY(4px) scale(.98); box-shadow: 0 2px 0 rgba(0,0,0,.35); }
.ans.picked { outline: 4px solid #fff; }
.ans.dim { opacity: .3; filter: saturate(.4); }
@keyframes rise { from { opacity: 0; transform: translateY(26px) scale(.92); } }

/* ------------------------------------------------ timer */
.timerbar { height: 10px; border-radius: 6px; background: rgba(255,255,255,0.12); overflow: hidden; margin: 14px 0 4px; }
.timerbar > div { height: 100%; width: 100%; border-radius: 6px;
  background: linear-gradient(90deg, #ffd166, #f4a814); transition: none; }
.timerbar.hot > div { background: linear-gradient(90deg, #ff8f6b, #e66767); }
.bigclock { font-size: 2.6rem; font-weight: 900; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------ leaderboard */
.lb { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.lb-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  background: var(--surface); border-radius: 12px; border: 1px solid rgba(255,255,255,0.08);
  animation: slidein .4s cubic-bezier(.2,.9,.3,1.2) backwards;
}
.lb-row.me { border-color: var(--accent); background: rgba(255, 209, 102, 0.12); }
.lb-row .rank { width: 2em; font-weight: 900; font-size: 1.1rem; color: var(--ink-2); text-align: center; }
.lb-row .rank.r1 { color: #ffd166; } .lb-row .rank.r2 { color: #cfd6e4; } .lb-row .rank.r3 { color: #e5a06c; }
.lb-row .name { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-row .pts { font-weight: 800; font-variant-numeric: tabular-nums; }
.lb-row .delta { font-size: .78rem; color: var(--good); font-weight: 700; }
@keyframes slidein { from { opacity: 0; transform: translateX(-30px); } }

/* ------------------------------------------------ reveal bar chart */
.chart { display: flex; align-items: flex-end; justify-content: center; gap: 4%;
         height: 240px; margin: 22px 0 8px; }
.chart .col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
              height: 100%; width: 18%; min-width: 64px; }
.chart .cnt { font-weight: 800; font-size: 1.2rem; margin-bottom: 6px; }
.chart .bar { width: 100%; border-radius: 4px 4px 0 0; min-height: 4px;
              transition: height .9s cubic-bezier(.2,.8,.2,1); position: relative; }
.chart .col.wrong .bar { opacity: .32; }
.chart .col.right .bar { box-shadow: 0 0 0 3px #fff, 0 0 24px rgba(255,255,255,.5); }
.chart .lbl { margin-top: 10px; font-weight: 700; font-size: .95rem; display: flex; align-items: center; gap: 6px;
              max-width: 100%; }
.chart .lbl .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart .col.wrong .lbl { color: var(--ink-3); }
.checkmark { color: var(--good); font-size: 1.2rem; }

/* ------------------------------------------------ podium */
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 14px; margin: 30px 0 10px; height: 300px; }
.pod { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; width: 30%; max-width: 180px; }
.pod .who { font-weight: 800; font-size: 1.05rem; margin-bottom: 4px; text-align: center; word-break: break-word; }
.pod .sc { color: var(--ink-2); font-weight: 700; margin-bottom: 10px; font-variant-numeric: tabular-nums; }
.pod .block { width: 100%; border-radius: 12px 12px 0 0; display: flex; align-items: flex-start;
              justify-content: center; padding-top: 12px; font-size: 2rem; font-weight: 900;
              animation: grow 1s cubic-bezier(.2,.8,.2,1.2) backwards; }
.pod.p1 .block { height: 190px; background: linear-gradient(180deg, #ffd166, #b8860b); animation-delay: .8s; }
.pod.p2 .block { height: 140px; background: linear-gradient(180deg, #cfd6e4, #7d8797); animation-delay: .4s; }
.pod.p3 .block { height: 100px; background: linear-gradient(180deg, #e5a06c, #9c5f2e); animation-delay: .1s; }
.pod .medal { font-size: 2.4rem; margin-bottom: 6px; animation: bounce 1.4s ease infinite; }
@keyframes grow { from { height: 0; opacity: 0; } }
@keyframes bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* ------------------------------------------------ bits */
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 999px;
        background: var(--surface); border: 1px solid rgba(255,255,255,.1); font-weight: 700; font-size: .9rem; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); }

#connbar { position: fixed; top: 0; left: 0; right: 0; background: #b3541e; color: #fff; text-align: center;
           padding: 6px; font-weight: 700; font-size: .85rem; transform: translateY(-100%); transition: transform .3s; z-index: 1000; }
#connbar.show { transform: none; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px); opacity: 0;
         background: #241744; border: 1px solid rgba(255,255,255,.2); padding: 12px 22px; border-radius: 12px;
         font-weight: 700; transition: all .3s; z-index: 1001; max-width: 90vw; }
.toast.show { transform: translateX(-50%); opacity: 1; }

.bigpts { font-size: 3.2rem; font-weight: 900; animation: pts .6s cubic-bezier(.2,.9,.3,1.4) backwards; }
@keyframes pts { from { opacity: 0; transform: scale(.3); } }
.shake { animation: shake .5s; }
@keyframes shake { 20%,60% { transform: translateX(-8px); } 40%,80% { transform: translateX(8px); } }
.pulse { animation: pulse 1.2s ease infinite; }
@keyframes pulse { 50% { transform: scale(1.05); } }

.streak { color: #ff9f43; font-weight: 800; }

.namecloud { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; }
.namecloud span { background: var(--surface); padding: 7px 14px; border-radius: 999px; font-weight: 700;
                  animation: rise .4s backwards; border: 1px solid rgba(255,255,255,.1); }

@media (max-width: 480px) {
  h1 { font-size: 1.5rem; }
  .ans { min-height: 84px; font-size: .95rem; }
  .chart { height: 190px; }
}
