:root {
  --ink: #070708;
  --panel: #121218;
  --paper: #f6f3ea;
  --muted: #b7b1a4;
  --gold: #ffcc00;
  --gold-deep: #e0b000;
  --line: rgba(255, 204, 0, 0.42);
  --danger: #ff5d3a;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #000;
  color: var(--paper);
  font-family: Manrope, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}

body {
  display: flex;
  justify-content: center;
  overflow: hidden;
}

button, input { font: inherit; color: inherit; }

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible, input:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

img { max-width: 100%; }

#app {
  width: 100%;
  max-width: 540px;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background:
    repeating-linear-gradient(-18deg, #070708, #070708 12px, #101014 12px, #101014 13px);
}

.mast {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: calc(8px + env(safe-area-inset-top)) 10px 8px;
  background:
    linear-gradient(100deg, rgba(7, 7, 8, 0.94) 0%, rgba(7, 7, 8, 0.72) 58%, rgba(7, 7, 8, 0.5) 100%),
    url("hero-night.jpg") center 42% / cover no-repeat;
  border-bottom: 1px solid var(--line);
}

.crest {
  width: 42px;
  height: 42px;
  object-fit: contain;
  display: block;
}

.brand { min-width: 0; }

.brand-title {
  font-family: Oswald, "Arial Narrow", sans-serif;
  font-size: clamp(22px, 6.4vw, 34px);
  line-height: 0.85;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold);
  transform: skewX(-8deg);
  transform-origin: left center;
}

.brand-sub {
  margin-top: 3px;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--paper);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.readout {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: 0;
}

.readout b, .readout span {
  font-family: Oswald, "Arial Narrow", sans-serif;
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--gold);
  white-space: nowrap;
}

.mute {
  margin-top: 2px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
  color: var(--gold);
  font-family: Oswald, "Arial Narrow", sans-serif;
  font-size: 11px;
  letter-spacing: 0.1em;
  padding: 3px 6px;
  min-height: 28px;
}

.mute.off {
  color: #8d887c;
  border-color: #3c3a32;
}

.rail {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 7px 12px;
  background: #0c0c10;
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 14px), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 14px), transparent);
}

.rail::-webkit-scrollbar { display: none; }

.rail button {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: var(--paper);
  font-family: Oswald, "Arial Narrow", sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 13px;
  padding: 7px 12px 7px 8px;
  min-height: 36px;
  clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
}

.rail button .num {
  color: var(--gold);
  font-size: 10px;
}

.rail button.active {
  background: var(--gold);
  color: #16140c;
}

.rail button.active .num { color: #16140c; }

main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.strike-page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
}

.levels {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  flex: 0 0 auto;
  padding: 6px 10px;
  scrollbar-width: none;
}

.levels::-webkit-scrollbar { display: none; }

.levels button {
  flex: 0 0 auto;
  min-width: 62px;
  min-height: 36px;
  border: 1px solid rgba(255, 204, 0, 0.28);
  background: #14141a;
  color: var(--paper);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 3px 8px;
  line-height: 1.05;
}

.levels button b {
  font-family: Oswald, "Arial Narrow", sans-serif;
  font-size: 13px;
  letter-spacing: 0.06em;
}

.levels button small {
  font-size: 10px;
  color: var(--muted);
}

.levels button.is-on {
  border-color: var(--gold);
  background: #2a240c;
}

.levels button:disabled {
  opacity: 0.38;
}

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  margin: 0 8px;
  border: 1px solid var(--line);
  background: #050506;
  overflow: hidden;
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hud {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  top: 0;
  padding: 6px 8px 12px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.72), rgba(0, 0, 0, 0));
}

.hud-top, .hud-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.hud strong, .hud span {
  font-family: Oswald, "Arial Narrow", sans-serif;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 12px;
  color: #fff6d0;
}

#level-name {
  font-size: 14px;
  color: var(--gold);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#keeper-name {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#timer, #wind-read { flex: 0 0 auto; white-space: nowrap; }

#level-blurb {
  margin: 2px 0 0;
  font-size: 11px;
  line-height: 1.3;
  color: #efe6cc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pips { display: flex; gap: 4px; flex: 0 0 auto; }

.pips i {
  width: 10px;
  height: 10px;
  display: block;
  background: var(--gold);
  transform: skewX(-14deg);
}

.pips i.used { background: #3a3424; }

.flash:not([hidden]) {
  position: absolute;
  z-index: 3;
  left: 8px;
  right: 8px;
  bottom: 10px;
  text-align: center;
  font-family: Oswald, "Arial Narrow", sans-serif;
  font-size: clamp(18px, 6vw, 34px);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  text-shadow: 0 2px 0 #000;
  pointer-events: none;
}

.banner:not([hidden]) {
  position: absolute;
  z-index: 4;
  left: 8px;
  right: 8px;
  bottom: 8px;
  max-height: calc(100% - 16px);
  overflow: auto;
  background: rgba(8, 8, 10, 0.94);
  border: 1px solid var(--gold);
  padding: 12px;
}

.banner h2 {
  font-family: Oswald, "Arial Narrow", sans-serif;
  font-size: clamp(22px, 6vw, 32px);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.05;
  margin: 0 0 6px;
}

.banner p {
  margin: 0 0 6px;
  color: #efe6cc;
  font-size: 14px;
  line-height: 1.4;
}

.star-row { display: flex; gap: 5px; margin: 6px 0 8px; }

.star-row span {
  width: 28px;
  height: 8px;
  background: #3a3424;
  transform: skewX(-16deg);
}

.star-row span.on { background: var(--gold); }

.banner-actions { display: flex; gap: 8px; margin-top: 8px; }

.banner-actions button, .intro-card .strike, .use, .strike {
  min-height: 44px;
  border: 0;
  font-family: Oswald, "Arial Narrow", sans-serif;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.banner-actions button {
  flex: 1;
  background: var(--gold);
  color: #16140c;
}

.banner-actions button.ghost {
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--line);
}

.intro:not([hidden]) {
  position: absolute;
  z-index: 5;
  inset: 0;
  display: flex;
  align-items: flex-end;
  padding: 8px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0.78));
}

.intro-card {
  width: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: rgba(10, 10, 12, 0.94);
  border: 1px solid var(--gold);
  padding: 12px;
}

.intro-copy {
  min-height: 0;
  overflow: auto;
}

.intro-card h2 {
  font-family: Oswald, "Arial Narrow", sans-serif;
  font-size: clamp(20px, 5.6vw, 30px);
  text-transform: uppercase;
  line-height: 1.05;
  margin: 0 0 8px;
}

.intro-card p { margin: 0 0 8px; color: #efe6cc; line-height: 1.4; }

.intro-card .strike { width: 100%; margin-top: 4px; }

.deck {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
}

.deck .strike { grid-column: 1 / -1; }

.meter {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.meter span {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.meter b { color: var(--gold); font-weight: 700; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 36px;
  background: transparent;
  margin: 0;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: #3a3420;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px;
  height: 26px;
  margin-top: -11px;
  background: var(--gold);
  border: 2px solid #14120a;
}

input[type="range"]::-moz-range-track {
  height: 4px;
  background: #3a3420;
  border: 0;
}

input[type="range"]::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border: 2px solid #14120a;
  border-radius: 0;
  background: var(--gold);
}

.strike {
  background: var(--gold);
  color: #16140c;
  font-size: 18px;
  clip-path: polygon(12px 0, 100% 0, calc(100% - 12px) 100%, 0 100%);
}

.strike:disabled { opacity: 0.45; }

.strike:active:not(:disabled) { transform: translateY(1px); }

.page-scroll {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 12px 12px calc(18px + env(safe-area-inset-bottom));
  -webkit-overflow-scrolling: touch;
  overflow-wrap: break-word;
}

.kicker {
  font-family: Oswald, "Arial Narrow", sans-serif;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  font-size: 12px;
  margin: 0 0 4px;
}

.lede {
  margin: 0 0 12px;
  color: var(--paper);
  line-height: 1.45;
}

.page-scroll h2 {
  font-family: Oswald, "Arial Narrow", sans-serif;
  font-size: clamp(22px, 6vw, 32px);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.05;
  margin: 0 0 8px;
}

.card {
  background: linear-gradient(180deg, #17171d, #0e0e12);
  border: 1px solid rgba(255, 204, 0, 0.28);
  padding: 12px;
  margin-bottom: 10px;
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 0 100%);
}

.card h3 {
  font-family: Oswald, "Arial Narrow", sans-serif;
  font-size: 18px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0 0 4px;
}

.card p, .steps li {
  color: #ddd6c6;
  font-size: 14px;
  line-height: 1.45;
  margin: 0 0 8px;
}

.card p:last-child { margin-bottom: 0; }

.steps { margin: 0; padding-left: 18px; }

.steps li { margin-bottom: 8px; }

.gear-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.pitch-card { grid-column: 1 / -1; }

.ball-shot, .swatch {
  width: 72px;
  height: 72px;
  object-fit: contain;
  display: block;
  margin-bottom: 6px;
}

.pitch-shot {
  width: 100%;
  height: 92px;
  object-fit: cover;
  display: block;
  margin-bottom: 8px;
  border: 1px solid rgba(255, 204, 0, 0.25);
}

.tint-gold { filter: sepia(0.85) saturate(3.4) brightness(1.08); }

.grade-flood { filter: brightness(1.28) saturate(1.15); }

.grade-haze { filter: sepia(0.45) saturate(1.45) brightness(1.05); }

.swatch {
  background: #0c0c0e;
  border: 1px solid rgba(255, 204, 0, 0.3);
  position: relative;
  overflow: hidden;
}

.swatch.spark::before, .swatch.dust::before, .swatch.pulse::before, .swatch.none::before {
  content: "";
  position: absolute;
  inset: 16px;
}

.swatch.none::before {
  border: 2px solid var(--gold);
  inset: 22px;
}

.swatch.spark::before {
  background:
    linear-gradient(90deg, transparent 40%, var(--gold) 40% 46%, transparent 46%),
    linear-gradient(var(--gold), var(--gold));
  background-size: 100% 100%, 8px 8px;
  background-repeat: no-repeat;
  background-position: center, 18px 18px;
}

.swatch.dust::before {
  background-image: radial-gradient(circle, var(--gold) 1.5px, transparent 1.6px);
  background-size: 10px 10px;
  inset: 12px;
}

.swatch.pulse::before {
  border: 2px solid var(--gold);
  border-radius: 50%;
  box-shadow: 0 0 0 6px rgba(255, 204, 0, 0.25);
}

.use {
  width: 100%;
  margin-top: 8px;
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--line);
  font-size: 13px;
}

.use.in-use {
  background: var(--gold);
  color: #16140c;
  border-color: var(--gold);
}

.use:disabled {
  color: #8d887c;
  border-color: #3a382f;
  background: transparent;
}

.is-locked { opacity: 0.62; }

.note-photo, .keeper-hero {
  width: 100%;
  display: block;
  margin-bottom: 8px;
  border: 1px solid rgba(255, 204, 0, 0.3);
  object-fit: cover;
}

.note-photo { height: 168px; object-position: center 20%; }

.keeper-hero {
  height: 210px;
  object-fit: contain;
  background: #070708;
}

.meter-line { margin-top: 8px; }

.meter-line span {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.track {
  height: 5px;
  background: #2c291f;
  margin-top: 3px;
}

.track i {
  display: block;
  height: 100%;
  background: var(--gold);
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.stat strong {
  display: block;
  font-family: Oswald, "Arial Narrow", sans-serif;
  font-size: clamp(28px, 8vw, 42px);
  line-height: 0.9;
  color: var(--gold);
}

.stat span {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.stage-line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid rgba(255, 204, 0, 0.16);
  font-size: 14px;
}

.stage-line b {
  font-family: Oswald, "Arial Narrow", sans-serif;
  letter-spacing: 0.04em;
  font-weight: 500;
}

@media (max-width: 340px) {
  .gear-grid { grid-template-columns: 1fr; }
  .brand-sub { letter-spacing: 0.08em; }
  .crest { width: 34px; height: 34px; }
}

@media (max-height: 680px) {
  #level-blurb { display: none; }
  .mast { padding-top: calc(4px + env(safe-area-inset-top)); padding-bottom: 4px; }
  .rail button { min-height: 32px; padding-top: 4px; padding-bottom: 4px; }
  .levels { padding-top: 4px; padding-bottom: 4px; }
  .deck { gap: 4px; padding-top: 6px; }
  .strike { min-height: 40px; font-size: 16px; }
  .keeper-hero { height: 160px; }
}

@media (min-width: 420px) and (min-height: 820px) {
  .stage { margin-top: 4px; }
  .deck { gap: 10px; }
}
