:root {
  --bg: #46178f;
  --bg-dark: #33106a;
  --card: #ffffff;
  --ink: #1f1f2e;
  --muted: #6b6b80;
  --c0: #e21b3c; /* red    ▲ */
  --c1: #1368ce; /* blue   ◆ */
  --c2: #d89e00; /* yellow ● */
  --c3: #26890c; /* green  ■ */
  --good: #26890c;
  --bad: #e21b3c;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }
body { min-height: 100vh; display: flex; flex-direction: column; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: #fff;
  -webkit-tap-highlight-color: transparent;
}

#app { flex: 1; display: flex; flex-direction: column; }
.site-footer { text-align: center; padding: 14px 16px 18px; font-size: .8rem; color: rgba(255,255,255,.6); }

h1, h2, h3 { margin: 0 0 .5em; }
a { color: inherit; }

.page { flex: 1; width: 100%; max-width: 980px; margin: 0 auto; padding: 24px 16px 40px; }
.page.center { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.page.wide { max-width: 1200px; }

.logo { display: flex; align-items: center; justify-content: center; gap: .3em; font-size: 2.4rem; font-weight: 900; letter-spacing: -1px; margin-bottom: 24px; }
.logo-mark { width: 1.05em; height: 1.05em; flex-shrink: 0; }
.logo-text > span { color: #ffd23f; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.topbar h1 { margin: 0; }

/* cards & forms */
.card { background: var(--card); color: var(--ink); border-radius: var(--radius); padding: 20px; box-shadow: 0 4px 0 rgba(0,0,0,.2); }
.card + .card { margin-top: 14px; }
.join-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 12px; }

label.field { display: block; font-weight: 600; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }

input[type=text], input[type=email], input[type=password], input[type=number], textarea, select {
  width: 100%; font: inherit; color: var(--ink);
  padding: 12px 14px; border: 2px solid #d8d8e4; border-radius: 10px; background: #fff;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--c1); }
textarea { resize: vertical; min-height: 64px; }
.big-input { text-align: center; font-size: 1.3rem; font-weight: 700; }

.btn {
  font: inherit; font-weight: 700; cursor: pointer; border: 0; border-radius: 10px;
  padding: 12px 20px; background: #333; color: #fff; box-shadow: 0 4px 0 rgba(0,0,0,.25);
  text-decoration: none; display: inline-block; text-align: center;
}
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,.25); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--c1); }
.btn.good { background: var(--good); }
.btn.danger { background: var(--bad); }
.btn.ghost { background: rgba(255,255,255,.18); color: #fff; box-shadow: none; }
.btn.light { background: #eceaf4; color: var(--ink); box-shadow: none; }
.btn.small { padding: 7px 12px; font-size: .85rem; box-shadow: none; }
.btn.huge { font-size: 1.3rem; padding: 16px 32px; }

.error, .flash { background: #fff0f2; color: #b00020; padding: 10px 14px; border-radius: 10px; font-weight: 600; }
.flash { margin-bottom: 14px; max-width: 380px; width: 100%; }

.muted { color: var(--muted); }
.on-dark-muted { color: rgba(255,255,255,.75); }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* quiz list */
.quiz-item { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.quiz-item h3 { margin: 0 0 2px; }
.quiz-item .info { flex: 1; min-width: 200px; }
.empty { text-align: center; padding: 40px 10px; color: rgba(255,255,255,.8); }

/* editor */
.q-card { border-left: 8px solid var(--c1); }
.q-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.q-head .num { font-weight: 800; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.opt-edit { display: flex; align-items: center; gap: 8px; padding: 6px; border-radius: 10px; color: #fff; }
.opt-edit.c0 { background: var(--c0); } .opt-edit.c1 { background: var(--c1); }
.opt-edit.c2 { background: var(--c2); } .opt-edit.c3 { background: var(--c3); }
.opt-edit .shape { font-size: 1.3rem; width: 26px; text-align: center; }
.opt-edit input[type=text] { border: 0; padding: 9px 10px; }
.opt-edit input[type=radio] { width: 22px; height: 22px; accent-color: #fff; flex-shrink: 0; }
.q-settings { display: flex; gap: 12px; flex-wrap: wrap; }
.q-settings > div { flex: 1; min-width: 150px; }

/* host + play screens */
.pin-box { background: #fff; color: var(--ink); border-radius: var(--radius); padding: 12px 36px; display: inline-block; }
.pin-box .label { font-size: .9rem; font-weight: 700; color: var(--muted); }
.pin-box .pin { font-size: clamp(3rem, 12vw, 6rem); font-weight: 900; letter-spacing: 6px; line-height: 1.1; }
.join-help { display: flex; gap: 24px; align-items: center; justify-content: center; flex-wrap: wrap; margin: 20px 0; }
.join-help .qr { width: 160px; height: 160px; background: #fff; border-radius: 12px; padding: 6px; }
.join-help .qr img { width: 100%; height: 100%; display: block; }
.join-help .url { font-size: 1.15rem; font-weight: 700; word-break: break-all; }

.players { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 16px 0 24px; }
.chip { background: rgba(255,255,255,.18); padding: 8px 16px; border-radius: 999px; font-weight: 700; cursor: default; display: inline-flex; gap: 8px; align-items: center; }
.chip button { background: none; border: 0; color: inherit; cursor: pointer; font-size: 1rem; opacity: .7; padding: 0; }
.chip button:hover { opacity: 1; }

.q-banner { background: #fff; color: var(--ink); border-radius: var(--radius); padding: 22px 26px; font-size: clamp(1.3rem, 3.5vw, 2.2rem); font-weight: 800; text-align: center; margin: 12px 0 18px; }
.q-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-weight: 700; }
.timer { width: 76px; height: 76px; border-radius: 50%; background: #fff; color: var(--bg); display: grid; place-items: center; font-size: 2.2rem; font-weight: 900; }
.timer.low { background: var(--bad); color: #fff; }
.timebar { height: 10px; background: rgba(255,255,255,.2); border-radius: 99px; overflow: hidden; margin: 10px 0; }
.timebar > div { height: 100%; background: #ffd23f; width: 100%; transition: width .25s linear; }

.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ans { display: flex; align-items: center; gap: 14px; padding: 18px 16px; border-radius: 12px; font-weight: 800; font-size: clamp(1rem, 2.6vw, 1.6rem); color: #fff; border: 0; text-align: left; font-family: inherit; box-shadow: 0 5px 0 rgba(0,0,0,.25); min-height: 84px; }
.ans .shape { font-size: 1.8em; width: 1.2em; text-align: center; flex-shrink: 0; }
.ans.c0 { background: var(--c0); } .ans.c1 { background: var(--c1); }
.ans.c2 { background: var(--c2); } .ans.c3 { background: var(--c3); }
button.ans { cursor: pointer; }
button.ans:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.25); }
.ans.dim { opacity: .35; }
.ans.chosen { outline: 5px solid #fff; }
.ans .tick { margin-left: auto; font-size: 1.6em; }
.player-answers .ans { min-height: 120px; }

.bars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; align-items: end; height: 220px; margin: 16px 0; }
.bars.n2 { grid-template-columns: repeat(2, 1fr); } .bars.n3 { grid-template-columns: repeat(3, 1fr); }
.bar { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; }
.bar .fill { width: 100%; border-radius: 8px 8px 0 0; min-height: 6px; transition: height .6s ease; }
.bar .count { font-weight: 900; font-size: 1.6rem; margin-bottom: 4px; }
.bar.dim { opacity: .35; }
.bar .lbl { font-weight: 800; margin-top: 6px; font-size: 1.4rem; }
.fill.c0 { background: var(--c0); } .fill.c1 { background: var(--c1); } .fill.c2 { background: var(--c2); } .fill.c3 { background: var(--c3); }

.board { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.board li { display: flex; align-items: center; gap: 12px; background: #fff; color: var(--ink); border-radius: 10px; padding: 12px 16px; font-weight: 700; }
.board li .rank { width: 2em; color: var(--muted); }
.board li .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board li .score { font-variant-numeric: tabular-nums; }
.board li.me { outline: 4px solid #ffd23f; }

.podium { display: flex; justify-content: center; align-items: flex-end; gap: 12px; margin: 24px 0; min-height: 260px; }
.podium .place { display: flex; flex-direction: column; align-items: center; width: min(28vw, 220px); }
.podium .name { font-weight: 900; font-size: 1.2rem; margin-bottom: 6px; word-break: break-word; text-align: center; }
.podium .pts { font-weight: 700; margin-bottom: 6px; opacity: .85; }
.podium .block { width: 100%; border-radius: 10px 10px 0 0; display: grid; place-items: start center; padding-top: 10px; font-size: 2.2rem; font-weight: 900; color: #fff; }
.podium .p1 .block { height: 190px; background: #d89e00; } .podium .p2 .block { height: 140px; background: #8a8fa3; } .podium .p3 .block { height: 100px; background: #b0723a; }

/* player feedback screens */
.fullscreen { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; gap: 8px; }
.fullscreen.correct { background: var(--good); } .fullscreen.wrong { background: var(--bad); } .fullscreen.waiting { background: var(--bg-dark); }
.fullscreen .big { font-size: clamp(2.2rem, 9vw, 4rem); font-weight: 900; }
.fullscreen .pill { background: rgba(0,0,0,.25); border-radius: 999px; padding: 8px 20px; font-weight: 800; font-size: 1.2rem; }
.player-bar { display: flex; justify-content: space-between; padding: 10px 16px; background: rgba(0,0,0,.25); font-weight: 800; }

.spinner { width: 42px; height: 42px; border: 5px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin 1s linear infinite; margin: 12px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  .opts, .answers { grid-template-columns: 1fr; }
  .player-answers { grid-template-columns: 1fr 1fr; }
  .bars { height: 160px; gap: 6px; }
}

/* ---------- admin ---------- */
.admin-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.admin-brand { display: flex; align-items: center; gap: 10px; }
.admin-brand .logo { margin: 0; font-size: 1.7rem; }
.badge { background: #ffd23f; color: #33106a; font-weight: 800; font-size: .7rem; text-transform: uppercase; letter-spacing: .5px; padding: 3px 8px; border-radius: 99px; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 2px solid rgba(255,255,255,.18); margin-bottom: 22px; }
.tab { text-decoration: none; padding: 10px 16px; font-weight: 700; border-radius: 10px 10px 0 0; color: rgba(255,255,255,.75); }
.tab:hover { color: #fff; background: rgba(255,255,255,.08); }
.tab.active { color: var(--ink); background: #fff; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.stat { background: #fff; color: var(--ink); border-radius: var(--radius); padding: 16px; box-shadow: 0 4px 0 rgba(0,0,0,.2); }
.stat .value { font-size: 2rem; font-weight: 900; line-height: 1.1; }
.stat .label { color: var(--muted); font-weight: 600; font-size: .85rem; margin-top: 4px; }

.pin-tag { background: var(--bg); color: #fff; font-weight: 900; letter-spacing: 2px; padding: 10px 14px; border-radius: 10px; }
.players-admin { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px solid #e5e5ee; }
.chip-light { background: #eceaf4; color: var(--ink); padding: 5px 12px; border-radius: 99px; font-weight: 700; font-size: .85rem; display: inline-flex; gap: 8px; align-items: center; }
.chip-light.off { opacity: .5; }
.chip-light button { background: none; border: 0; cursor: pointer; color: var(--muted); padding: 0; }
.chip-light button:hover { color: var(--bad); }

.details { margin-top: 16px; padding-top: 16px; border-top: 1px solid #e5e5ee; }
.details h3 { color: var(--ink); }
.details .scroll { max-height: 260px; overflow: auto; padding: 4px; }
.details .board li { background: #f4f3f9; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #e5e5ee; vertical-align: top; }
.table th { color: var(--muted); font-size: .8rem; text-transform: uppercase; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.two-col .card + .card { margin-top: 0; }
.ok { background: #eaf7e6; color: #1b5e0a; padding: 10px 14px; border-radius: 10px; font-weight: 600; }
.card .error, .card .ok { margin-bottom: 12px; }

@media (max-width: 760px) { .two-col { grid-template-columns: 1fr; } }

/* ---------- Google sign-in button ---------- */
.btn.google { display: flex; align-items: center; justify-content: center; gap: 10px; background: #fff; color: #3c4043; border: 2px solid #dadce0; box-shadow: none; font-size: 1rem; }
.btn.google:hover:not(:disabled) { background: #f7f8f8; }
.g-icon { display: inline-flex; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .8rem; font-weight: 600; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: #d8d8e4; }
.auth-links { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: .9rem; color: var(--muted); text-align: center; }
.auth-link { color: var(--bg); font-weight: 700; text-decoration: none; }
.auth-link:hover { text-decoration: underline; }

/* ---------- home page guide ---------- */
.hero { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 28px 0 8px; }
.hero .logo { margin-bottom: 8px; font-size: 3rem; }
.tagline { font-size: 1.1rem; max-width: 520px; margin: 0 0 22px; color: rgba(255,255,255,.88); }

.guide { margin-top: 36px; scroll-margin-top: 16px; }
.section-title { text-align: center; font-size: 1.8rem; margin-bottom: 18px; }
.info-card { background: #fff; color: var(--ink); border-radius: var(--radius); padding: 22px; box-shadow: 0 4px 0 rgba(0,0,0,.2); }
.info-card > h2 { margin: 0 0 16px; font-size: 1.35rem; }

.guide-tabs { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 14px; }
.guide-tab { font: inherit; font-weight: 800; cursor: pointer; padding: 10px 18px; border-radius: 999px; border: 2px solid rgba(255,255,255,.4); background: transparent; color: #fff; }
.guide-tab:hover { background: rgba(255,255,255,.14); }
.guide-tab.active { background: #fff; color: var(--bg); border-color: #fff; }
.guide-tab:focus-visible, .guide-panel:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.guide-panel { max-width: 860px; margin: 0 auto; }

.steps { list-style: none; counter-reset: step; margin: 0 0 14px; padding: 0; }
.steps li { counter-increment: step; position: relative; padding-left: 40px; margin-bottom: 12px; line-height: 1.5; }
.steps li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%; background: var(--bg); color: #fff; font-weight: 800; font-size: .9rem; display: grid; place-items: center; }
.tip { background: #f4f3f9; border-radius: 10px; padding: 10px 14px; font-size: .92rem; color: var(--muted); line-height: 1.45; }

.rules-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px 28px; }
.rule-group h3 { margin: 0 0 8px; font-size: 1.05rem; color: var(--bg); }
.rule-group ul { margin: 0; padding-left: 20px; }
.rule-group li { margin-bottom: 8px; line-height: 1.5; }
