:root {
  --navy: #070b14;
  --navy-2: #0d1524;
  --ink: #e8f4ff;
  --muted: #8aa0b8;
  --teal: #3ee0c8;
  --teal-dim: #1a8f82;
  --gold: #f0c75e;
  --gold-2: #c9922a;
  --plasma: #e85cff;
  --danger: #ff5a6a;
  --glass: rgba(10, 16, 28, 0.62);
  --stroke: rgba(62, 224, 200, 0.22);
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  --font: "Trebuchet MS", "Segoe UI", "Avenir Next", ui-rounded, sans-serif;
  --display: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--navy); color: var(--ink); font-family: var(--font); overflow: hidden; }
button, select, input { font-family: inherit; }
button { cursor: pointer; }
kbd {
  display: inline-block;
  border: 1px solid rgba(232, 244, 255, 0.25);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0 6px;
  font-size: 11px;
  background: rgba(255,255,255,0.06);
}

#app { position: relative; width: 100%; height: 100%; }
#bgfx, #game {
  position: absolute; inset: 0; width: 100%; height: 100%;
  display: block;
}
#bgfx { z-index: 0; }
#game { z-index: 1; }

.hud {
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  display: grid;
  grid-template-columns: 132px 1fr 132px;
  grid-template-rows: auto 1fr;
  align-items: start;
}
.rail-left { grid-column: 1; grid-row: 2; }
.rail-right { grid-column: 3; grid-row: 2; }
.hud.hidden { display: none; }
.hud-top {
  grid-column: 1 / -1;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap;
  padding: 14px 18px 8px;
  pointer-events: auto;
  background: linear-gradient(to bottom, rgba(7,11,20,0.82), rgba(7,11,20,0));
  gap: 8px;
}
.quota-track {
  width: 100%;
  height: 5px;
  border-radius: 99px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
  order: 5;
}
#quotaFill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--teal), var(--gold));
  box-shadow: 0 0 12px rgba(62,224,200,0.65);
  transition: width 0.2s ease;
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background:
    radial-gradient(circle at 30% 30%, #fff, transparent 25%),
    conic-gradient(from 210deg, var(--teal), var(--gold), var(--teal));
  box-shadow: 0 0 24px rgba(62,224,200,0.45);
}
.brand-name { font-family: var(--display); letter-spacing: 0.28em; font-size: 13px; }
.brand-sub { color: var(--muted); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; }
.meters { display: flex; gap: 22px; }
.meter { text-align: center; }
.meter .k { display: block; color: var(--muted); font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; }
.meter .v { font-family: var(--display); font-size: 26px; line-height: 1.1; }
.v.gold { color: var(--gold); }
.v.teal { color: var(--teal); }
.icon-btn {
  pointer-events: auto;
  width: 42px; height: 42px; border-radius: 12px;
  border: 1px solid var(--stroke);
  background: var(--glass); color: var(--ink);
  backdrop-filter: blur(10px);
}
.rail {
  pointer-events: auto;
  margin: 8px 12px;
  padding: 12px 10px;
  border: 1px solid var(--stroke);
  background: var(--glass);
  backdrop-filter: blur(14px);
  border-radius: 18px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 10px; align-items: center;
  align-self: start;
}
.slot-label { font-size: 10px; letter-spacing: 0.22em; color: var(--muted); }
.hold-slot, .q-item {
  width: 88px; height: 88px; border-radius: 16px;
  border: 1px dashed rgba(62,224,200,0.35);
  background: rgba(0,0,0,0.28);
  position: relative;
}
.queue { display: flex; flex-direction: column; gap: 8px; }
.q-item { width: 76px; height: 76px; }
.q-item:first-child {
  width: 88px; height: 88px;
  border-style: solid;
  box-shadow: 0 0 20px rgba(62,224,200,0.2);
}
.legend { font-size: 11px; color: var(--muted); align-self: stretch; display: grid; gap: 6px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.dot.start { background: var(--gold); }
.dot.sink { background: var(--plasma); }
.dot.wall { background: #4a5568; }
.tips { font-size: 11px; color: var(--ink); opacity: 0.8; text-align: center; line-height: 1.4; }
.btn {
  pointer-events: auto;
  appearance: none; border: 1px solid var(--stroke);
  background: rgba(14, 22, 38, 0.85); color: var(--ink);
  padding: 12px 18px; border-radius: 999px;
  letter-spacing: 0.08em; text-transform: uppercase; font-size: 12px;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(62,224,200,0.16); }
.btn.primary {
  background: linear-gradient(180deg, #4af0d6, #1aa392);
  color: #04120f; border: none; font-weight: 700;
  box-shadow: 0 10px 30px rgba(62,224,200,0.28);
}
.btn.ghost { width: 100%; font-size: 10px; padding: 10px 8px; }
.btn:disabled { opacity: 0.35; cursor: default; transform: none; box-shadow: none; }

.overlay {
  position: absolute; inset: 0; z-index: 5;
  display: grid; place-items: center;
  background:
    linear-gradient(180deg, rgba(7,11,20,0.28), rgba(7,11,20,0.72)),
    url("../assets/bg-cathedral.jpg") center/cover no-repeat;
}
.overlay.hidden { display: none; }
#screen-pause, #screen-end, #screen-how, #screen-settings, #screen-scores {
  background: rgba(5, 8, 16, 0.72);
  backdrop-filter: blur(10px);
}
.title-wrap { text-align: center; max-width: 760px; padding: 24px; }
.eyebrow {
  letter-spacing: 0.28em; text-transform: uppercase; color: var(--gold);
  font-size: 11px;
}
h1 {
  font-family: var(--display);
  font-size: clamp(64px, 12vw, 128px);
  letter-spacing: 0.18em;
  margin: 8px 0 6px;
  font-weight: 500;
  text-shadow: 0 0 40px rgba(62,224,200,0.35), 0 20px 60px rgba(0,0,0,0.5);
}
h2 { font-family: var(--display); letter-spacing: 0.08em; margin: 0 0 12px; font-weight: 500; }
.lede { color: var(--muted); font-size: 18px; margin: 0 0 28px; }
.title-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.title-links { margin-top: 22px; display: flex; gap: 22px; justify-content: center; flex-wrap: wrap; }
.linkish {
  background: none; border: none; color: var(--teal); letter-spacing: 0.14em;
  text-transform: uppercase; font-size: 11px; padding: 6px;
}
.credit { margin-top: 36px; color: var(--muted); font-size: 12px; letter-spacing: 0.04em; }
.panel {
  width: min(560px, calc(100% - 32px));
  background: linear-gradient(180deg, rgba(16,24,40,0.92), rgba(8,12,22,0.92));
  border: 1px solid var(--stroke);
  border-radius: 24px;
  padding: 28px 28px 22px;
  box-shadow: var(--shadow);
}
.panel.slim { width: min(380px, calc(100% - 32px)); display: flex; flex-direction: column; gap: 10px; }
.howto { padding-left: 18px; color: var(--muted); line-height: 1.55; }
.howto strong { color: var(--ink); }
.fine { color: var(--muted); font-size: 12px; }
.row {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  margin: 12px 0; color: var(--muted);
}
.row input, .row select {
  width: 180px; accent-color: var(--teal);
  background: #0b1220; color: var(--ink); border: 1px solid var(--stroke); border-radius: 8px; padding: 6px;
}
.check { display: flex; gap: 10px; align-items: center; margin: 10px 0; color: var(--muted); }
.tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.tab {
  background: transparent; border: 1px solid var(--stroke); color: var(--muted);
  border-radius: 999px; padding: 6px 12px; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
}
.tab.on { color: #04120f; background: var(--teal); border-color: transparent; }
.scores { min-height: 160px; color: var(--muted); }
.scores li { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.06); }
.breakdown { list-style: none; padding: 0; margin: 0 0 18px; color: var(--muted); }
.breakdown li { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.06); }
.toast {
  position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 8; background: rgba(7,11,20,0.9); border: 1px solid var(--stroke);
  padding: 10px 16px; border-radius: 999px; pointer-events: none;
}
@media (max-width: 820px) {
  .toast { bottom: auto; top: 72px; max-width: 80%; text-align: center; }
}
.toast.hidden { display: none; }

.crt::after {
  content: "";
  pointer-events: none;
  position: absolute; inset: 0; z-index: 7;
  background:
    repeating-linear-gradient(to bottom, rgba(0,0,0,0.12) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,0.35) 100%);
  mix-blend-mode: multiply;
}

@media (max-width: 820px) {
  .hud {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr auto;
  }
  .hud-top { grid-column: 1; grid-row: 1; }
  .rail-right { grid-column: 1; grid-row: 2; }
  .rail-left { grid-column: 1; grid-row: 4; }
  .rail { flex-direction: row; flex-wrap: wrap; width: auto; margin: 4px; }
  .queue { flex-direction: row; }
  .meters { gap: 10px; }
  .meter .v { font-size: 18px; }
  h1 { letter-spacing: 0.1em; }
}
