:root {
  color-scheme: dark;
  --bg: #121212;
  --bg-2: #1a1a19;
  --panel: #20201e;
  --panel-2: #2a2a27;
  --line: #3a3934;
  --text: #ece8de;
  --muted: #a8a397;
  --faint: #6f6b62;
  --accent: #c62828;      /* State 430 flag red */
  --accent-ink: #ffffff;
  --accent-text: #f0625a;
  --danger: #e2574c;
  --ok: #5fb878;
  --warn: #e5b94e;
  --elite: #f2b632;
  --advanced: #9b5cf6;
  --intermediate: #4ea4f5;
  --regular: #c9ced6;
  --radius: 10px;
  --font-display: 'Big Shoulders Display', 'Arial Narrow', sans-serif;
  --font-body: 'Barlow', 'Segoe UI', sans-serif;
  --text-xs: 0.75rem; --text-sm: 0.875rem; --text-base: 1rem; --text-lg: 1.125rem;
  --text-xl: 1.5rem; --text-2xl: 2rem; --text-3xl: clamp(2.25rem, 5vw, 3.5rem);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font-body); font-size: var(--text-base); line-height: 1.5;
  background-image: radial-gradient(ellipse at top, #2a1515 0%, var(--bg) 60%);
  background-attachment: fixed; min-height: 100vh;
}
a { color: var(--accent-text); }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: 0.02em; line-height: 1.1; margin: 0; text-transform: uppercase; }
h1 { font-size: var(--text-3xl); font-weight: 800; }
h2 { font-size: var(--text-2xl); font-weight: 700; }
h3 { font-size: var(--text-xl); font-weight: 700; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.small { font-size: var(--text-sm); }
.xs { font-size: var(--text-xs); }
.hidden { display: none !important; }

/* Header */
.site-head { border-bottom: 1px solid var(--line); background: rgba(18,18,18,.85); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 20; }
.site-head .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand svg { width: 34px; height: 34px; color: var(--accent-text); }
.brand b { white-space: nowrap; font-family: var(--font-display); font-size: 1.4rem; letter-spacing: .04em; text-transform: uppercase; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 6px; font-weight: 600; font-size: var(--text-sm); }
.nav a:hover, .nav a.on { color: var(--text); background: var(--panel-2); }

/* Hero */
.hero { padding-top: 40px; padding-bottom: 28px; }
.hero-grid { display: grid; grid-template-columns: 1fr minmax(280px, 460px); gap: 32px; align-items: center; }
.hero-flag { margin: 0; }
.hero-flag img { width: 100%; height: auto; display: block; border-radius: var(--radius); border: 1px solid #3a1c1c; box-shadow: 0 20px 60px rgba(198,40,40,.18); }
@media (max-width: 860px) { .hero-grid { grid-template-columns: 1fr; gap: 20px; } .hero-flag { order: -1; max-width: 520px; } }
.hero p { max-width: 640px; color: var(--muted); font-size: var(--text-lg); margin: 12px 0 0; }
.banner { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; margin-top: 22px; padding: 14px 18px; border: 1px solid var(--line); border-left: 4px solid var(--ok); background: var(--panel); border-radius: var(--radius); }
.banner.closed { border-left-color: var(--warn); }
.banner .state { font-family: var(--font-display); font-size: 1.35rem; font-weight: 700; text-transform: uppercase; }
.countdown { font-variant-numeric: tabular-nums; font-weight: 600; }

section { padding: 28px 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }

/* Board */
.board { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.tier { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; border-top: 4px solid var(--tc); display: flex; flex-direction: column; gap: 10px; }
.tier-head { display: flex; align-items: center; gap: 10px; }
.tier-head svg { width: 30px; height: 30px; color: var(--tc); flex: none; }
.tier-head h3 { font-size: 1.6rem; }
.range { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 600; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 2px 8px; border-radius: 999px; border: 1px solid currentColor; }
.badge.unconf { color: var(--warn); }
.badge.conf { color: var(--ok); }
.pips { display: flex; flex-wrap: wrap; gap: 5px; }
.pip { width: 18px; height: 18px; border-radius: 4px; border: 2px solid var(--tc); }
.pip.filled { background: var(--tc); }
.pip.possible { background: repeating-linear-gradient(45deg, var(--tc) 0 3px, transparent 3px 6px); }
.pip.reserved { border-style: dashed; border-color: var(--muted); background: rgba(255,255,255,.06); }
.pip.open { opacity: .55; }
.counts { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; font-size: var(--text-sm); }
.counts b { font-variant-numeric: tabular-nums; }
.over { color: var(--warn); font-size: var(--text-sm); font-weight: 600; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: var(--text-sm); color: var(--muted); margin-top: 14px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .pip { --tc: var(--muted); width: 14px; height: 14px; }
.unassigned { margin-top: 14px; padding: 12px 16px; border: 1px dashed var(--line); border-radius: var(--radius); display: flex; justify-content: space-between; align-items: center; }

/* Cards and forms */
.grid-2 { display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
label { display: block; font-weight: 600; font-size: var(--text-sm); margin: 14px 0 6px; }
label .opt { color: var(--faint); font-weight: 500; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; min-height: 44px;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.hint { font-size: var(--text-xs); color: var(--muted); margin-top: 4px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 700; cursor: pointer; border-radius: 8px; padding: 10px 18px; min-height: 44px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); text-transform: uppercase; letter-spacing: .04em; font-size: var(--text-sm); }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.sm { min-height: 34px; padding: 6px 12px; font-size: var(--text-xs); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 18px; text-align: center; cursor: pointer; background: var(--bg-2); }
.drop.has { border-style: solid; border-color: var(--accent); }
.drop img { max-height: 220px; max-width: 100%; border-radius: 6px; display: block; margin: 10px auto 0; }
.msg { margin-top: 12px; padding: 10px 14px; border-radius: 8px; font-size: var(--text-sm); }
.msg.err { background: rgba(226,87,76,.12); color: #ffb3ab; border: 1px solid rgba(226,87,76,.4); }
.msg.ok { background: rgba(95,184,120,.12); color: #b6f0c6; border: 1px solid rgba(95,184,120,.4); }
.code-box { font-family: var(--font-display); font-size: 2rem; letter-spacing: .06em; color: var(--accent-text); text-align: center; padding: 16px; border: 2px solid var(--accent); border-radius: var(--radius); margin: 12px 0; word-break: break-word; }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 560px) { .steps { grid-template-columns: 1fr 1fr; } }
.steps figure { margin: 0; }
.steps img { width: 100%; border-radius: 8px; border: 1px solid var(--line); display: block; cursor: zoom-in; }
.steps figcaption { font-size: var(--text-xs); color: var(--muted); margin-top: 6px; }
.rules { white-space: pre-wrap; color: var(--muted); }

.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }

footer { border-top: 1px solid var(--line); padding: 24px 0 40px; color: var(--faint); font-size: var(--text-sm); margin-top: 20px; }

/* Admin */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { background: none; border: 0; color: var(--muted); font: inherit; font-weight: 700; padding: 10px 14px; cursor: pointer; border-bottom: 3px solid transparent; text-transform: uppercase; font-size: var(--text-sm); letter-spacing: .04em; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.filters label { margin: 0 0 4px; font-size: var(--text-xs); color: var(--muted); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { background: var(--panel-2); font-weight: 700; color: var(--muted); text-transform: uppercase; font-size: var(--text-xs); letter-spacing: .05em; position: sticky; top: 0; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: rgba(255,255,255,.03); }
td.num { font-variant-numeric: tabular-nums; text-align: right; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: var(--text-xs); font-weight: 700; background: var(--panel-2); border: 1px solid var(--line); }
.chip.red { color: #ffb3ab; border-color: rgba(226,87,76,.5); }
.chip.amber { color: var(--warn); border-color: rgba(229,185,78,.5); }
.chip.green { color: #b6f0c6; border-color: rgba(95,184,120,.5); }
.chip.blue { color: #a9d3ff; border-color: rgba(78,164,245,.5); }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--bg-2); border-left: 1px solid var(--line); z-index: 50; overflow-y: auto; padding: 20px; box-shadow: -10px 0 30px rgba(0,0,0,.4); }
.drawer .shot { position: relative; margin: 12px 0; }
.drawer .shot img { width: 100%; max-height: 70vh; object-fit: contain; background: #000; border-radius: 8px; border: 1px solid var(--line); display: block; }
.drawer .shot.blur img { filter: blur(24px); }
.drawer .shot .reveal { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 8px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: var(--text-sm); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
.auth-box { max-width: 420px; margin: 60px auto; }
.qr { background: #fff; padding: 12px; border-radius: 8px; width: 220px; margin: 12px auto; }
.qr img, .qr svg { width: 100%; display: block; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 8px; z-index: 200; font-size: var(--text-sm); }
.skeleton { background: linear-gradient(90deg, var(--panel) 0%, var(--panel-2) 50%, var(--panel) 100%); background-size: 200% 100%; animation: sh 1.2s infinite; border-radius: var(--radius); min-height: 180px; }
@keyframes sh { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

.admin-wrap { max-width: 1400px; }
@media (max-width: 600px) {
  .nav a[href="#board"], .nav a[href="#rules"] { display: none; }
  .nav a { padding: 6px 8px; }
  .brand b { font-size: 1.2rem; }
}
@media (max-width: 600px) {
  .site-head .wrap { height: auto; min-height: 60px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
}
section { scroll-margin-top: 64px; }
@media (max-width: 860px) { #apply .grid-2 > .card:last-child { order: -1; } }
