:root {
  --bg: #0b0d14;
  --surface: #151926;
  --surface-2: #1d2233;
  --line: #2a3048;
  --text: #eef1f8;
  --muted: #8f9ab8;
  --accent: #6ee7a8;
  --accent-2: #7aa2ff;
  --gold: #f5c451;
  --warn: #ff8a7a;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* The UA rule for [hidden] is display:none at the lowest specificity, so any
   component rule setting display (.tabbar is grid, .card.recruiter is flex)
   silently beats it and the element stays on screen. Everything here toggles
   visibility through the hidden attribute, so it has to actually win. */
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

#app { min-height: 100%; display: flex; flex-direction: column; }

.screen { display: none; flex: 1; flex-direction: column; padding-bottom: calc(76px + var(--safe-b)); }
.screen.active { display: flex; }

.pad { padding: 20px 16px; width: 100%; max-width: 560px; margin: 0 auto; }
.center-col { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; justify-content: center; flex: 1; }

/* Icons -------------------------------------------------------------
   One inline <symbol> sprite, stroked in currentColor, so every icon
   inherits the theme colour and costs no extra request. */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico { width: 20px; height: 20px; flex: none; }
.ico.lg { width: 28px; height: 28px; }
.mark { width: 64px; height: 64px; color: var(--accent); }

.logo { line-height: 0; }
.title { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; margin: 0; }
.title.sm { font-size: 22px; }
.lede { color: var(--muted); margin: 0; max-width: 34ch; }
.lede.sm { font-size: 14px; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; letter-spacing: 0.02em; }
.strong { font-weight: 700; }
.fineprint { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 14px 0 0; }

.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.name { font-size: 26px; font-weight: 800; margin: 2px 0 0; letter-spacing: -0.02em; }

.score-chip { text-align: right; }
.score { font-size: 34px; font-weight: 800; color: var(--accent); line-height: 1; font-variant-numeric: tabular-nums; }

/* Cards ------------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; text-align: left;
}
.card.warn { border-color: var(--warn); color: var(--warn); }
.card.hint { border-color: var(--accent-2); font-size: 13.5px; line-height: 1.5; }
.card.hint b { color: var(--accent-2); }
.card.recruiter { display: flex; align-items: center; gap: 12px; width: 100%; }
.card.result { animation: pop 0.25s ease-out; }

.avatar {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 800; font-size: 18px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent)); color: #0b0d14;
}

/* Inputs / buttons -------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; width: 100%; text-align: left; }
.field input {
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
  border-radius: 12px; padding: 14px; font-size: 17px; width: 100%;
}
.field input:focus { outline: 2px solid var(--accent-2); border-color: transparent; }

.btn {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  border-radius: 12px; padding: 13px 18px; font-size: 16px; font-weight: 600;
  width: 100%; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
}
.btn.primary { background: var(--accent); color: #07120c; border-color: transparent; }
.btn.big { padding: 16px; font-size: 17px; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.5; }
.btn + .fineprint { margin-top: 10px; }

/* QR ---------------------------------------------------------------- */
.qr-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 8px 0 22px; }
.qr-wrap canvas {
  width: min(300px, 74vw); height: auto; image-rendering: pixelated;
  background: #fff; padding: 10px; border-radius: 14px;
}
.qr-wrap.small canvas { width: min(240px, 60vw); }
.qr-caption { text-align: center; }

/* Stats ------------------------------------------------------------- */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 18px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 6px; text-align: center;
}
.stat b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11px; color: var(--muted); }

/* Camera ------------------------------------------------------------ */
.cam-wrap { position: relative; background: #000; aspect-ratio: 3 / 4; max-height: 56vh; overflow: hidden; }
.cam-wrap video { width: 100%; height: 100%; object-fit: cover; }
.reticle {
  position: absolute; inset: 50% auto auto 50%; transform: translate(-50%, -50%);
  width: 62%; aspect-ratio: 1; border: 3px solid rgba(255, 255, 255, 0.85);
  border-radius: 20px; box-shadow: 0 0 0 4000px rgba(0, 0, 0, 0.45);
}
.cam-status {
  position: absolute; left: 0; right: 0; bottom: 14px; text-align: center;
  font-size: 14px; text-shadow: 0 1px 6px #000;
}
.mini-cam { width: 120px; border-radius: 12px; background: #000; }

/* Leaderboard ------------------------------------------------------- */
.board { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.board li {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
}
.board li.me { border-color: var(--accent); background: var(--surface-2); }
.board .pos { font-weight: 800; width: 26px; color: var(--muted); font-variant-numeric: tabular-nums; }
.board li:nth-child(1) .pos { color: var(--gold); }
.board .who { flex: 1; min-width: 0; }
.board .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .pts { font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }

/* Tree -------------------------------------------------------------- */
.tree { display: flex; flex-direction: column; gap: 8px; }
.tree .node {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
}
.tree .node[data-depth="1"] { margin-left: 18px; background: var(--surface); opacity: 0.92; }
.tree .node[data-depth="2"] { margin-left: 36px; opacity: 0.84; }
.tree .node[data-depth="3"] { margin-left: 54px; opacity: 0.76; }
.tree .node[data-depth="4"] { margin-left: 72px; opacity: 0.68; }
.tree .cut { margin-left: auto; font-weight: 700; color: var(--gold); font-size: 13px; }
.card.upline { margin-bottom: 14px; }

/* Tabs -------------------------------------------------------------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(11, 13, 20, 0.94); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding-bottom: var(--safe-b);
}
.tab {
  background: none; border: 0; color: var(--muted); font-size: 11px;
  padding: 9px 0 10px; display: flex; flex-direction: column; align-items: center;
  gap: 3px; cursor: pointer; font-weight: 600;
}
.tab .ico { width: 22px; height: 22px; opacity: 0.65; }
.tab.active { color: var(--text); }
.tab.active .ico { opacity: 1; color: var(--accent); }

/* Toasts ------------------------------------------------------------ */
#toasts {
  position: fixed; left: 12px; right: 12px; bottom: calc(86px + var(--safe-b));
  z-index: 20; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--accent); color: #07120c; font-weight: 700;
  padding: 11px 18px; border-radius: 999px; animation: pop 0.25s ease-out;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45); max-width: 100%;
}
.toast.info { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.toast.bad { background: var(--warn); color: #2a0c07; }

@keyframes pop { from { transform: scale(0.9) translateY(6px); opacity: 0; } }

.gain { color: var(--accent); font-weight: 800; }
.big-gain {
  font-size: 28px; font-weight: 800; color: var(--accent);
  display: flex; align-items: center; gap: 10px;
}

@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }
