:root {
  --ink: #e8f1ff;
  --dim: #9fb4d6;
  --faint: #6f86ab;
  --night: #071425;
  --navy: #0a1f3a;
  --panel: #0f2a4d;
  --panel-2: #133461;
  --line: rgba(160, 200, 255, 0.14);
  --gold: #ffcc33;
  --gold-2: #ffb300;
  --red: #ff5d5d;
  --green: #3ddc84;
  --radius: 16px;
  --display: "Lilita One", system-ui, sans-serif;
  --body: "Alata", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0;
  background: var(--night);
  color: var(--ink);
  font: 16px/1.6 var(--body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; }
h1, h2, h3 { font-family: var(--display); font-weight: 400; letter-spacing: 0.01em; margin: 0; line-height: 1.05; }
.kicker {
  margin: 0 0 6px; color: var(--gold); text-transform: uppercase; letter-spacing: 0.16em;
  font-size: 12.5px;
}

/* ---------- nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 28px;
  padding: 14px clamp(16px, 4vw, 48px);
  background: rgba(7, 20, 37, 0.78);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font: 26px var(--display); text-decoration: none; letter-spacing: 0.02em; }
.brand b { color: var(--gold); font-weight: 400; }
.brand-bag {
  width: 28px; height: 28px; border-radius: 8px; background: var(--gold);
  clip-path: polygon(10% 38%, 90% 38%, 82% 100%, 18% 100%);
  position: relative;
}
.nav nav { display: flex; gap: 22px; margin-left: auto; }
.nav nav a { text-decoration: none; color: var(--dim); font-size: 15px; transition: color .15s; }
.nav nav a:hover { color: var(--ink); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 22px; border-radius: 12px; border: 0; cursor: pointer;
  font: 18px var(--display); letter-spacing: 0.03em; text-decoration: none;
  transition: transform .12s ease, box-shadow .12s ease, background .15s;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn-gold { background: var(--gold); color: #1a1200; box-shadow: 0 4px 0 #b88a00, 0 10px 30px rgba(255, 204, 51, 0.18); }
.btn-gold:hover { background: #ffd65c; transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px rgba(232, 241, 255, 0.28); }
.btn-ghost:hover { box-shadow: inset 0 0 0 2px var(--ink); }
.nav-cta { padding: 9px 16px; font-size: 16px; }

/* ---------- hero: a live blueprint of the newest stage ---------- */
.hero {
  position: relative; min-height: min(88vh, 860px);
  display: flex; align-items: center;
  padding: 80px clamp(16px, 6vw, 96px);
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}
#hero-canvas { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.85; }
#hero-canvas.idle {
  background:
    linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 40px 40px,
    linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / 40px 40px,
    #0b2442;
}
.hero-shade {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(90deg, rgba(7, 20, 37, 0.96) 0%, rgba(7, 20, 37, 0.82) 38%, rgba(7, 20, 37, 0.15) 75%, rgba(7, 20, 37, 0.35) 100%),
    linear-gradient(0deg, var(--night) 0%, transparent 22%);
}
.hero-copy { position: relative; max-width: 620px; }
.hero h1 { font-size: clamp(54px, 9vw, 108px); text-shadow: 0 6px 0 rgba(0, 0, 0, 0.35); }
.hero h1 span { color: var(--gold); }
.lede { color: var(--dim); font-size: clamp(17px, 1.6vw, 19px); margin: 22px 0 30px; max-width: 540px; }
.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; }
.hero-caption { margin-top: 26px; color: var(--faint); font-size: 14px; min-height: 1.6em; }

/* ---------- stats ---------- */
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  max-width: 1180px; margin: -46px auto 0; position: relative; z-index: 2;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}
.stats > div { padding: 22px 16px; text-align: center; }
.stats > div + div { border-left: 1px solid var(--line); }
.stats b { display: block; font: 40px var(--display); color: var(--gold); line-height: 1.1; }
.stats span { color: var(--dim); font-size: 14px; text-transform: uppercase; letter-spacing: 0.1em; }

/* ---------- sections ---------- */
.block { max-width: 1180px; margin: 0 auto; padding: 96px 16px 0; }
.block-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 28px; }
.block h2 { font-size: clamp(40px, 5vw, 56px); }
.controls { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.tabs { display: flex; background: var(--panel); border-radius: 12px; padding: 4px; border: 1px solid var(--line); }
.tab {
  background: none; border: 0; color: var(--dim); font: 16px var(--display); letter-spacing: 0.03em;
  padding: 8px 16px; border-radius: 9px; cursor: pointer;
}
.tab.on { background: var(--gold); color: #1a1200; }
#search {
  background: var(--panel); border: 1px solid var(--line); color: var(--ink);
  font: 15px var(--body); padding: 11px 14px; border-radius: 12px; width: 220px; outline: none;
}
#search:focus { border-color: var(--gold); }

/* ---------- gallery ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.card {
  display: flex; flex-direction: column; text-decoration: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; transition: transform .16s ease, box-shadow .16s ease, border-color .16s;
}
.card:hover { transform: translateY(-4px); border-color: rgba(255, 204, 51, 0.6); box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45); }
.card-map { aspect-ratio: 4 / 3; background: #0b2442; border-bottom: 1px solid var(--line); }
.card-map canvas, .card-map img { width: 100%; height: 100%; display: block; object-fit: cover; image-rendering: pixelated; }
.card-body { padding: 14px 16px 16px; }
.card-top { display: flex; align-items: start; justify-content: space-between; gap: 10px; }
.card h3 { font-size: 23px; overflow-wrap: anywhere; }
.by { margin: 2px 0 10px; color: var(--dim); font-size: 14px; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--faint); font-size: 13.5px; }
.empty { text-align: center; color: var(--dim); padding: 48px 16px; border: 1px dashed var(--line); border-radius: var(--radius); }
.more { text-align: center; margin-top: 26px; }

.grade {
  display: inline-block; padding: 3px 10px; border-radius: 999px; white-space: nowrap;
  font: 13px var(--display); letter-spacing: 0.05em; text-transform: uppercase;
}
.g-new { background: #2a3d5c; color: #c5d4ee; }
.g-easy { background: #1d5c3a; color: #8af0b5; }
.g-normal { background: #1d4a7a; color: #9fd0ff; }
.g-expert { background: #6b3d12; color: #ffc285; }
.g-super { background: #6e1a24; color: #ff9aa5; }

/* ---------- leaderboards ---------- */
.resets { color: var(--faint); font-size: 14px; }
.boards { display: grid; grid-template-columns: 1.15fr 1fr 1fr; gap: 20px; }
.board { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; min-width: 0; }
.board-legends { background: linear-gradient(160deg, #1b3a66 0%, var(--panel) 55%); border-color: rgba(255, 204, 51, 0.35); }
.board-legends h3 { color: var(--gold); }
.board h3 { font-size: 28px; }
.board-note { color: var(--faint); font-size: 14px; margin: 6px 0 14px; }
.board ol { list-style: none; margin: 0; padding: 0; }
.board li { display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 10px; padding: 9px 4px; border-top: 1px solid var(--line); }
.board li:first-child { border-top: 0; }
.rank { font: 20px var(--display); color: var(--faint); text-align: center; }
.who-col { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub { color: var(--faint); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score { font: 22px var(--display); color: var(--ink); }
.podium .rank { color: #1a1200; border-radius: 10px; height: 30px; display: grid; place-items: center; font-size: 18px; }
.p1 .rank { background: var(--gold); }
.p2 .rank { background: #cfd9e8; }
.p3 .rank { background: #d9925b; }
.p1 .who { font-family: var(--display); font-size: 20px; color: var(--gold); }
.p1 .score { color: var(--gold); }
.board-empty { display: block !important; color: var(--dim); text-align: center; padding: 22px 6px !important; font-size: 14.5px; }

.rules { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px; }
.rule { border: 1px dashed var(--line); border-radius: var(--radius); padding: 18px 22px; }
.rule h4 { font: 20px var(--display); margin: 0; }
.rule p { color: var(--faint); font-size: 14px; margin: 4px 0 12px; }
.rule-grid { display: grid; grid-template-columns: auto auto 1fr; gap: 8px 12px; align-items: center; font-size: 14px; }
.rule-grid > .grade, .rule-grid > .chip { justify-self: start; }
.rule-pts { font: 18px var(--display); color: var(--gold); text-align: right; }
.rule-note { color: var(--dim); }
.chip-maker { background: #24406b; color: #b9d2ff; font: 13px var(--display); letter-spacing: 0.05em; text-transform: uppercase; padding: 3px 10px; }

/* ---------- how it works ---------- */
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.steps article { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.steps h3 { font-size: 26px; margin: 16px 0 8px; }
.steps p { color: var(--dim); margin: 0; font-size: 15px; }
.step-ico { display: block; width: 52px; height: 52px; border-radius: 14px; position: relative; }
.ico-case { background: radial-gradient(circle at 30% 50%, var(--red) 0 5px, transparent 6px), conic-gradient(from 60deg at 30% 50%, rgba(255, 93, 93, 0.6) 0 60deg, transparent 60deg), #1a3a66; }
.ico-grab { background: linear-gradient(var(--gold), var(--gold)) 50% 70% / 26px 20px no-repeat, linear-gradient(#e8f1ff, #e8f1ff) 50% 34% / 14px 4px no-repeat, #1a3a66; }
.ico-van { background: linear-gradient(var(--gold), var(--gold)) 50% 50% / 30px 18px no-repeat, radial-gradient(circle, transparent 18px, rgba(255, 204, 51, 0.5) 19px 20px, transparent 21px), #1a3a66; }
.ico-make { background: linear-gradient(var(--line), var(--line)) 0 0 / 10px 10px, repeating-linear-gradient(0deg, transparent 0 9px, rgba(160, 200, 255, 0.35) 9px 10px), repeating-linear-gradient(90deg, transparent 0 9px, rgba(160, 200, 255, 0.35) 9px 10px), #1a3a66; }

.foot {
  max-width: 1180px; margin: 110px auto 0; padding: 28px 16px 40px;
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  color: var(--faint); font-size: 14px; border-top: 1px solid var(--line);
}
.foot span:first-child { font-family: var(--display); color: var(--dim); letter-spacing: 0.04em; }

/* ---------- stage dialog ---------- */
dialog {
  padding: 0; border: 0; background: transparent; color: var(--ink);
  max-width: min(1180px, 96vw); width: 100%; max-height: 94vh;
}
dialog::backdrop { background: rgba(3, 9, 18, 0.78); backdrop-filter: blur(4px); }
.dlg {
  position: relative; display: grid; grid-template-columns: 1fr 340px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px; overflow: hidden;
  height: min(760px, 94vh);
}
.dlg-map { background: #0b2442; min-height: 0; }
.dlg-map canvas { width: 100%; height: 100%; display: block; }
.dlg-side { padding: 26px 24px; overflow-y: auto; border-left: 1px solid var(--line); }
.dlg-side h2 { font-size: 38px; overflow-wrap: anywhere; }
.dlg-x {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  width: 38px; height: 38px; border-radius: 10px; border: 0; cursor: pointer;
  background: rgba(7, 20, 37, 0.7); color: var(--ink); font-size: 24px; line-height: 1;
}
.dlg-x:hover { background: var(--red); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 18px; }
.chip { background: var(--panel-2); color: var(--dim); padding: 3px 10px; border-radius: 999px; font-size: 13px; }
.chip-hot { background: #6e1a24; color: #ff9aa5; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 20px; font-size: 14.5px; }
.facts dt { color: var(--faint); }
.facts dd { margin: 0; }
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; font-size: 13px; color: var(--dim); margin-bottom: 22px; }
.lg { display: flex; align-items: center; gap: 8px; }
.lg i { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.share .btn { width: 100%; }
.share-note { color: var(--faint); font-size: 13.5px; margin: 10px 0 0; text-align: center; }
.share-note b { color: var(--dim); font-weight: 400; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 30px); opacity: 0; z-index: 50;
  background: var(--gold); color: #1a1200; padding: 12px 20px; border-radius: 12px;
  font: 17px var(--display); letter-spacing: 0.02em; box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  transition: opacity .2s, transform .2s; pointer-events: none;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- small screens ---------- */
@media (max-width: 960px) {
  .steps { grid-template-columns: 1fr 1fr; }
  .boards, .rules { grid-template-columns: 1fr; }
  .dlg { grid-template-columns: 1fr; grid-template-rows: 46vh auto; height: auto; max-height: 94vh; overflow-y: auto; }
  .dlg-side { border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
}
@media (max-width: 720px) {
  .nav { gap: 12px; }
  .nav nav { display: none; }
  .nav-cta { margin-left: auto; }
  .stats { grid-template-columns: 1fr 1fr; margin: -36px 16px 0; }
  .stats > div:nth-child(3) { border-left: 0; }
  .stats > div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .steps { grid-template-columns: 1fr; }
  #search { width: 100%; }
  .controls { width: 100%; }
  .hero-shade { background: linear-gradient(0deg, var(--night) 0%, rgba(7, 20, 37, 0.85) 45%, rgba(7, 20, 37, 0.55) 100%); }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
