:root {
  --bg: #0e1014;
  --surface: #171a21;
  --surface2: #1f232c;
  --line: #2b303b;
  --text: #eceef3;
  --muted: #9aa2b1;
  --accent: #f5b400;
  --seek: #3d9bff;
  --good: #3fbf6f;
  --bad: #ff5d5d;
  --warn: #ffb224;
  --radius: 14px;
  --tabs-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { overscroll-behavior: none; }
a { color: var(--seek); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.4rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: .4rem 0; }
small, .muted { color: var(--muted); }
.hidden { display: none !important; }
code { background: var(--surface2); padding: 0 .3em; border-radius: 4px; font-size: .85em; word-break: break-all; }

/* ---------- controls */
button, .btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface2); color: var(--text);
  font: inherit; font-weight: 600; padding: .7rem 1rem; border-radius: 12px; min-height: 46px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; text-decoration: none;
}
button:active { transform: scale(.98); }
button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); color: #1a1400; border-color: transparent; }
.btn-seek { background: var(--seek); color: #fff; border-color: transparent; }
.btn-good { background: var(--good); color: #04160b; border-color: transparent; }
.btn-bad { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn-ghost { background: transparent; }
.btn-sm { min-height: 36px; padding: .35rem .7rem; font-size: .9rem; border-radius: 10px; }
.btn-block { width: 100%; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; }
.stack > * + * { margin-top: .6rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }

input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: .65rem .75rem; min-height: 46px;
}
textarea { min-height: 80px; resize: vertical; }
input[type=checkbox], input[type=radio] { width: 22px; height: 22px; min-height: 0; accent-color: var(--accent); flex: none; }
label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: .25rem; }
label.check { display: flex; gap: .6rem; align-items: center; color: var(--text); font-size: 1rem; padding: .35rem 0; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.card + .card { margin-top: .75rem; }
.card.tight { padding: .75rem; }
.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .55rem; border-radius: 999px; font-size: .78rem;
  font-weight: 700; background: var(--surface2); border: 1px solid var(--line); white-space: nowrap; }
.chip.hider { background: var(--accent); color: #1a1400; border-color: transparent; }
.chip.seeker { background: var(--seek); color: #fff; border-color: transparent; }
.chip.good { color: var(--good); border-color: var(--good); }
.chip.bad { color: var(--bad); border-color: var(--bad); }
.chip.warn { color: var(--warn); border-color: var(--warn); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.section-title { display: flex; justify-content: space-between; align-items: center; margin: 1.1rem 0 .5rem; }
.section-title h2 { margin: 0; }
.empty { color: var(--muted); text-align: center; padding: 1.5rem .5rem; }
.list > * { border-top: 1px solid var(--line); padding: .7rem 0; }
.list > *:first-child { border-top: 0; }

/* ---------- player layout */
.app { display: flex; flex-direction: column; height: 100dvh; }
.topbar { padding: .6rem .9rem .5rem; padding-top: calc(.6rem + env(safe-area-inset-top, 0px)); background: var(--surface);
  border-bottom: 1px solid var(--line); flex: none; }
.topbar .line1 { display: flex; align-items: center; gap: .5rem; font-size: .85rem; color: var(--muted); }
.topbar .line1 .grow { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .timer { font-variant-numeric: tabular-nums; font-size: 2rem; font-weight: 800; letter-spacing: .5px; line-height: 1.1; }
.topbar .phase { font-size: .85rem; color: var(--muted); }
.banners:empty { display: none; }
.banners { flex: none; }
.banner { padding: .55rem .9rem; font-size: .9rem; font-weight: 600; border-bottom: 1px solid rgba(0,0,0,.25); display: flex; gap: .5rem; align-items: center; }
.banner .grow { flex: 1; }
.banner.warn { background: #3a2a00; color: #ffd27a; }
.banner.bad { background: #3b1010; color: #ffb3b3; }
.banner.info { background: #0f2747; color: #b7d7ff; }
.banner.good { background: #0d3320; color: #a5f0c2; }
main.view { flex: 1; overflow-y: auto; padding: .9rem .9rem calc(1.5rem); -webkit-overflow-scrolling: touch; }
main.view.map-mode { padding: 0; overflow: hidden; position: relative; }
nav.tabs { flex: none; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b); }
nav.tabs button { border: 0; border-radius: 0; background: transparent; min-height: var(--tabs-h); flex-direction: column; gap: 2px;
  font-size: .72rem; font-weight: 600; color: var(--muted); padding: .3rem 0; position: relative; }
nav.tabs button .ico { font-size: 1.35rem; line-height: 1; }
nav.tabs button.active { color: var(--text); }
nav.tabs button.active::before { content: ""; position: absolute; top: 0; left: 25%; right: 25%; height: 3px; background: var(--accent); border-radius: 0 0 3px 3px; }
nav.tabs .badge { position: absolute; top: 6px; right: calc(50% - 22px); background: var(--bad); color: #fff; font-size: .68rem;
  min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px; display: grid; place-items: center; }

/* ---------- map */
#map { position: absolute; inset: 0; background: #1b1f27; }
.map-ctrls { position: absolute; right: .7rem; bottom: .9rem; z-index: 500; display: flex; flex-direction: column; gap: .5rem; align-items: flex-end; }
.map-ctrls button { box-shadow: 0 4px 14px rgba(0,0,0,.45); }
.map-info { position: absolute; left: .7rem; top: .7rem; right: .7rem; z-index: 500; display: flex; gap: .4rem; flex-wrap: wrap; pointer-events: none; }
.map-info .chip { pointer-events: auto; background: rgba(23,26,33,.92); }
.map-info .chip.hider { background: var(--accent); }
.leaflet-container { font: inherit; }
.marker-label { background: rgba(14,16,20,.9); color: #fff; border: 0; border-radius: 6px; padding: 1px 6px; font-size: 12px; font-weight: 700; box-shadow: none; }
.marker-label::before { display: none; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--text); }
.leaflet-popup-content { margin: .7rem .9rem; font-size: .9rem; line-height: 1.4; }
.leaflet-popup-content button { margin-top: .5rem; width: 100%; }
.st-modes { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: .2rem; }
.st-mode { font-size: .7rem; font-weight: 700; padding: 0 .4rem; border-radius: 999px; color: #fff; }
.zpick { width: 100%; justify-content: flex-start; text-align: left; gap: .6rem; }
.zpick.btn-primary .qmeta { color: inherit; opacity: .8; }

/* ---------- questions */
.qcat { margin-bottom: .6rem; }
.qcat summary { list-style: none; cursor: pointer; padding: .8rem 1rem; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); display: flex; align-items: center; gap: .6rem; font-weight: 700; }
.qcat summary::-webkit-details-marker { display: none; }
.qcat[open] summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.qcat .qitems { border: 1px solid var(--line); border-top: 0; border-radius: 0 0 var(--radius) var(--radius); overflow: hidden; }
.qitem { display: flex; align-items: center; gap: .6rem; padding: .7rem 1rem; border-top: 1px solid var(--line); background: var(--bg); width: 100%;
  border-radius: 0; border-left: 0; border-right: 0; border-bottom: 0; font-weight: 500; text-align: left; justify-content: flex-start; min-height: 50px; }
.qitem:first-child { border-top: 0; }
.qitem .grow { flex: 1; }
.qitem.disabled { opacity: .4; }
.qabout { padding: .75rem 1rem; background: var(--surface2); font-size: .88rem; line-height: 1.45; }
.qabout p { margin: 0 0 .4rem; }
.qabout p:last-child { margin-bottom: 0; }
.qguide { padding: .7rem 0; border-top: 1px solid var(--line); font-size: .9rem; line-height: 1.45; }
.qguide:first-of-type { border-top: 0; }
.qguide p { margin: .25rem 0; }
.qmeta { font-size: .8rem; color: var(--muted); font-weight: 400; }
.cat-badge { font-size: .72rem; font-weight: 800; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); }
.qcard { border-left: 4px solid var(--seek); }
.qcard.pending { border-left-color: var(--warn); }
.qcard.late { border-left-color: var(--bad); }
.answer-big { font-size: 1.3rem; font-weight: 800; }
.countdown { font-variant-numeric: tabular-nums; font-weight: 800; }

/* ---------- cards */
.hand { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
.gcard { border-radius: 12px; padding: .7rem; min-height: 120px; display: flex; flex-direction: column; gap: .3rem; cursor: pointer; border: 2px solid transparent;
  background: var(--surface2); text-align: left; align-items: stretch; justify-content: flex-start; font-weight: 400; }
.gcard .kind { font-size: .68rem; text-transform: uppercase; letter-spacing: .6px; font-weight: 800; opacity: .8; }
.gcard .name { font-weight: 800; font-size: .95rem; line-height: 1.2; }
.gcard .val { font-size: 1.6rem; font-weight: 900; margin-top: auto; }
.gcard.time { color: #111; }
.gcard.powerup { background: #1d2b45; border-color: #2c4a7c; }
.gcard.curse { background: #2d1630; border-color: #5c2a63; }
.gcard.selected { outline: 3px solid var(--accent); outline-offset: 2px; }
.gcard .txt { font-size: .78rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.gcard.time .txt { color: #222; }

/* ---------- evidence */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .4rem; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--surface2); border: 1px solid var(--line); }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .st { position: absolute; left: 4px; bottom: 4px; }
.evrow { display: grid; grid-template-columns: 88px 1fr; gap: .7rem; align-items: start; }
.evrow .thumb { width: 88px; }
.upl { display: flex; gap: .4rem; flex-wrap: wrap; }
.upl .thumb { width: 72px; }
.upl .thumb button { position: absolute; top: 2px; right: 2px; min-height: 0; padding: 0 6px; border-radius: 8px; font-size: .8rem; }
.progress { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .2s; }

/* ---------- log */
.log-item { font-size: .9rem; }
.log-item time { color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; margin-right: .4rem; }

/* ---------- modal */
.modal-wrap { position: fixed; inset: 0; z-index: 2000; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--surface); width: 100%; max-width: 640px; max-height: 92dvh; overflow-y: auto; border-radius: 20px 20px 0 0;
  padding: 1.1rem 1rem calc(1rem + var(--safe-b)); border: 1px solid var(--line); animation: up .18s ease-out; }
@media (min-width: 700px) { .modal-wrap { align-items: center; } .modal { border-radius: 20px; } }
@keyframes up { from { transform: translateY(30px); opacity: .5; } to { transform: none; opacity: 1; } }
.modal .mhead { display: flex; align-items: flex-start; gap: .5rem; margin-bottom: .6rem; }
.modal .mhead h2 { flex: 1; margin: 0; }
.modal .close { min-height: 36px; padding: 0 .7rem; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabs-h) + 16px + var(--safe-b)); z-index: 3000;
  background: #000; color: #fff; padding: .7rem 1rem; border-radius: 12px; max-width: 90vw; box-shadow: 0 6px 24px rgba(0,0,0,.5);
  font-weight: 600; font-size: .95rem; }
.toast.err { background: #5a1212; }

/* ---------- center pages (join / login) */
.center { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 1.2rem; }
.center .card { width: 100%; max-width: 420px; }
.brand { font-weight: 900; font-size: 1.6rem; letter-spacing: -.5px; }
.brand span { color: var(--accent); }

/* ---------- admin */
.admin { max-width: 960px; margin: 0 auto; padding: 1rem 1rem 4rem; }
.admin header { display: flex; align-items: center; gap: .6rem; margin-bottom: 1rem; }
.admin header .grow { flex: 1; }
.size-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.size-pick label { margin: 0; }
.size-pick input { display: none; }
.size-pick .opt { border: 2px solid var(--line); border-radius: 12px; padding: .7rem; cursor: pointer; color: var(--text); height: 100%; }
.size-pick input:checked + .opt { border-color: var(--accent); background: #2a2205; }
.curse-list { max-height: 420px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: .2rem .7rem; }
.curse-list label.check { align-items: flex-start; border-top: 1px solid var(--line); padding: .55rem 0; }
.curse-list label.check:first-child { border-top: 0; }
.qr { background: #fff; border-radius: 10px; padding: 6px; width: 132px; height: 132px; flex: none; }
.qr svg { width: 100%; height: 100%; display: block; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .45rem .4rem; border-top: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
.timeline { max-height: 520px; overflow-y: auto; }
details.adv > summary { cursor: pointer; color: var(--muted); margin: .4rem 0; }
