@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@500;700;800;900&display=swap');

:root {
  --bg: #f2f2f2;
  --surface: #ffffff;
  --text: #1d1d1f;
  --muted: #6b6b76;
  --border: #e2e2e8;
  --brand: #46178f;
  --brand-2: #864cbf;
  --red: #e21b3c;
  --blue: #1368ce;
  --yellow: #d89e00;
  --green: #26890c;
  --ok: #26890c;
  --bad: #e21b3c;
  --radius: 10px;
  --shadow: 0 2px 0 rgba(0, 0, 0, .12), 0 6px 20px rgba(0, 0, 0, .06);
  font-family: Montserrat, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); }
a { color: var(--brand-2); }
button, input, select, textarea { font: inherit; }
h1, h2, h3 { margin: 0 0 .5em; font-weight: 800; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  padding: .7em 1.2em; border: 0; border-radius: 6px; cursor: pointer; font-weight: 800;
  background: #333; color: #fff; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .25); text-decoration: none;
  transition: transform .05s, filter .15s; white-space: nowrap;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: translateY(2px); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .25); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); }
.btn.green { background: var(--green); }
.btn.red { background: var(--red); }
.btn.blue { background: var(--blue); }
.btn.light { background: #fff; color: var(--text); box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .12); }
.btn.ghost { background: transparent; color: inherit; box-shadow: none; border: 2px solid currentColor; }
.btn.sm { padding: .4em .8em; font-size: .85em; }
.btn.lg { padding: .9em 1.6em; font-size: 1.15em; }
.input, select.input, textarea.input {
  width: 100%; padding: .7em .9em; border: 2px solid var(--border); border-radius: 6px; background: #fff; color: var(--text);
}
.input:focus { outline: none; border-color: var(--brand-2); }
label.field { display: block; margin-bottom: .9em; }
label.field > span { display: block; font-weight: 700; font-size: .85em; margin-bottom: .3em; color: var(--muted); }
.row { display: flex; gap: .8em; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 1em; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.hidden, [hidden] { display: none !important; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.2em; }
.badge { display: inline-block; padding: .15em .6em; border-radius: 99px; font-size: .75em; font-weight: 800; background: #eee; color: #444; }
.badge.ok { background: #e3f4dc; color: var(--green); }
.badge.warn { background: #fff3d1; color: #946c00; }
.badge.bad { background: #fde3e7; color: var(--red); }
.error { color: var(--bad); font-weight: 700; }

/* ---------- purple game backdrop ---------- */
.stage {
  min-height: 100vh; min-height: 100dvh; color: #fff; background: var(--brand);
  background-image: radial-gradient(circle at 15% 20%, rgba(255,255,255,.08) 0 120px, transparent 121px),
    radial-gradient(circle at 85% 80%, rgba(255,255,255,.06) 0 200px, transparent 201px);
  display: flex; flex-direction: column;
}
.stage .card { color: var(--text); }
.logo { font-weight: 900; font-size: 1.6rem; letter-spacing: -.02em; color: #fff; text-decoration: none; }
.logo b { color: #ffd34d; }

/* ---------- answer tiles ---------- */
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.answer {
  position: relative; display: flex; align-items: center; gap: .8em; padding: 1em; min-height: 80px;
  border: 0; border-radius: 6px; color: #fff; font-weight: 800; font-size: 1.15rem; text-align: left;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .2); cursor: pointer; transition: opacity .2s, transform .08s;
  overflow-wrap: anywhere;
}
.answer:active { transform: scale(.98); }
.answer svg { flex: 0 0 auto; width: 40px; height: 40px; }
.answer.c0 { background: var(--red); } .answer.c1 { background: var(--blue); }
.answer.c2 { background: var(--yellow); } .answer.c3 { background: var(--green); }
.answer.dim { opacity: .25; }
.answer .count { margin-left: auto; font-size: 1.3em; }
.answer .tick { margin-left: auto; font-size: 1.6em; }

/* ---------- timer & misc game widgets ---------- */
.timer {
  width: 90px; height: 90px; border-radius: 50%; background: var(--brand-2); color: #fff;
  display: grid; place-items: center; font-weight: 900; font-size: 2.2rem; flex: 0 0 auto;
}
.timer.small { width: 56px; height: 56px; font-size: 1.4rem; }
.progress { height: 8px; background: rgba(255, 255, 255, .25); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: #fff; width: 100%; transition: width .25s linear; }
.qtext {
  background: #fff; color: var(--text); padding: .7em 1em; border-radius: 6px; font-weight: 800; text-align: center;
  box-shadow: var(--shadow); overflow-wrap: anywhere;
}
.bar-chart { display: flex; gap: 16px; align-items: flex-end; justify-content: center; height: 180px; }
.bar-chart .bar { width: 80px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar-chart .bar i { display: block; width: 100%; border-radius: 4px 4px 0 0; min-height: 6px; transition: height .6s ease; }
.bar-chart .bar b { margin-bottom: 4px; font-size: 1.3rem; display: flex; gap: 6px; align-items: center; }
.bar-chart .bar svg { width: 22px; height: 22px; }
.bar-chart .bar.c0 i { background: var(--red); } .bar-chart .bar.c1 i { background: var(--blue); }
.bar-chart .bar.c2 i { background: var(--yellow); } .bar-chart .bar.c3 i { background: var(--green); }
.bar-chart .bar.dim { opacity: .35; }

.lb { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.lb li {
  display: flex; align-items: center; gap: 1em; background: #fff; color: var(--text); padding: .7em 1em;
  border-radius: 6px; font-weight: 800; font-size: 1.2rem; box-shadow: var(--shadow);
  animation: slideIn .4s both;
}
.lb li .rank { width: 2em; text-align: center; color: var(--muted); }
.lb li .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb li .streak { font-size: .8em; color: #e85d04; }
.lb li .move { font-size: .75em; width: 2.5em; }
.lb li .move.up { color: var(--green); } .lb li .move.down { color: var(--red); }
@keyframes slideIn { from { opacity: 0; transform: translateY(14px); } }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.08); } 100% { transform: scale(1); opacity: 1; } }
.pop { animation: pop .45s both; }

.spinner { width: 46px; height: 46px; border: 5px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto; }
.spinner.dark { border-color: rgba(0,0,0,.1); border-top-color: var(--brand); }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #222; color: #fff; padding: .7em 1.2em;
  border-radius: 8px; font-weight: 700; z-index: 1000; box-shadow: 0 8px 30px rgba(0,0,0,.3); max-width: calc(100% - 32px);
}

@media (max-width: 640px) {
  .answers { grid-template-columns: 1fr; }
  .answer { min-height: 64px; font-size: 1rem; }
}
