:root {
  --void: #0a0618;
  --velvet: #14082c;
  --plum: #2a1050;
  --brand: #8b3dff;
  --magenta: #c84bff;
  --gold: #f0c14a;
  --gold-deep: #9a6b16;
  --cyan: #2ee6d6;
  --water: #18c8ff;
  --ink: #f4f0ff;
  --dim: #b9a8d8;
  --line: rgba(240, 193, 74, 0.42);
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.42);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  background:
    radial-gradient(1100px 460px at 50% -8%, rgba(139, 61, 255, 0.38), transparent 58%),
    radial-gradient(700px 320px at 100% 12%, rgba(46, 230, 214, 0.14), transparent 46%),
    radial-gradient(640px 380px at 0% 80%, rgba(240, 193, 74, 0.1), transparent 42%),
    var(--void);
  color: var(--ink);
  font-family: Outfit, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.65;
}

img, canvas, svg { max-width: 100%; display: block; }

button, input { font-family: inherit; }

button {
  touch-action: manipulation;
  cursor: pointer;
}

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

.shell {
  width: min(920px, 100%);
  margin: 0 auto;
  padding-bottom: calc(28px + env(safe-area-inset-bottom));
  min-width: 0;
}

.crest {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 2px;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.stamp {
  width: 52px;
  height: 52px;
  flex: none;
  clip-path: polygon(50% 0%, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%);
  display: grid;
  place-items: center;
  color: var(--gold);
  font-family: Cinzel, serif;
  font-weight: 700;
  letter-spacing: 0.04em;
  background:
    radial-gradient(circle at 50% 30%, #6d3cff, #1a0828 72%);
  box-shadow:
    0 0 0 2px var(--gold),
    0 0 18px rgba(139, 61, 255, 0.55);
}

.stamp span {
  font-size: 14px;
}

.brand-copy {
  min-width: 0;
}

.eyebrow {
  margin: 0;
  color: var(--gold);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

h1, h2, h3 {
  font-family: Cinzel, serif;
  font-weight: 700;
  line-height: 1.2;
  margin: 0;
}

h1 {
  font-size: clamp(1.15rem, 4.6vw, 1.55rem);
  color: var(--ink);
}

h2 { font-size: clamp(1.2rem, 4.2vw, 1.7rem); }
h3 { font-size: 1.05rem; }

.mute {
  flex: none;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--gold);
  background: linear-gradient(180deg, rgba(42, 16, 80, 0.9), rgba(10, 6, 24, 0.9));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.mute[aria-pressed="true"] { opacity: 0.55; }

.manifold-wrap {
  position: relative;
  margin: 6px 0 8px;
  padding: 0 8px 6px;
  min-width: 0;
}

.rail {
  position: absolute;
  top: 6px;
  left: 18px;
  right: 18px;
  height: 9px;
  border-radius: 999px;
  background: linear-gradient(90deg, #3a2410, #f0c14a 18%, #8b3dff 50%, #2ee6d6 78%, #f0c14a, #3a2410);
  box-shadow:
    0 0 16px rgba(240, 193, 74, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
  pointer-events: none;
}

.manifold {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 18px 4px 6px;
  mask-image: linear-gradient(90deg, transparent 0, #000 12px, #000 calc(100% - 12px), transparent);
}

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

.port {
  flex: 0 0 auto;
  width: 88px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

.stem {
  width: 3px;
  height: 14px;
  margin-bottom: -1px;
  background: linear-gradient(#f0c14a, #6a4a12);
  box-shadow: 0 0 8px rgba(240, 193, 74, 0.6);
}

.hex {
  width: 76px;
  height: 64px;
  display: grid;
  place-items: center;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  background:
    radial-gradient(circle at 50% 30%, rgba(139, 61, 255, 0.35), #12081f 70%);
  box-shadow: inset 0 0 0 2px rgba(240, 193, 74, 0.35);
  transition: color 0.2s ease, filter 0.2s ease;
}

.hex span {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  padding: 0 6px;
  text-align: center;
  line-height: 1.2;
}

.port.on .hex {
  color: #14081c;
  background:
    radial-gradient(circle at 50% 25%, #fff3c4, var(--gold) 38%, #c4922a 78%);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.35),
    0 0 18px rgba(46, 230, 214, 0.45);
  animation: fillPort 2.8s ease-in-out infinite;
}

.port.on .stem {
  background: linear-gradient(var(--cyan), var(--gold));
}

@keyframes fillPort {
  0%, 100% { filter: saturate(1); }
  50% { filter: saturate(1.35) brightness(1.08); }
}

.panel { display: none; padding: 0 12px 12px; min-width: 0; }
.panel.on { display: block; }

.sheet {
  position: relative;
  margin-top: 12px;
  padding: 14px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(36, 16, 72, 0.88), rgba(12, 7, 28, 0.92));
  box-shadow:
    var(--shadow),
    inset 0 0 0 1px rgba(240, 193, 74, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  overflow: hidden;
  min-width: 0;
}

.sheet::before,
.sheet::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  pointer-events: none;
  border: 2px solid var(--gold);
}

.sheet::before { top: 8px; left: 8px; border-right: 0; border-bottom: 0; }
.sheet::after { top: 8px; right: 8px; border-left: 0; border-bottom: 0; }

.kicker {
  margin: 0 0 4px;
  color: var(--cyan);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.lead, .sheet p {
  margin: 8px 0 0;
  color: var(--dim);
}

.play { padding-bottom: 16px; }

.hud-top { min-width: 0; }

.meters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.meter {
  min-width: 0;
  padding: 8px 6px;
  border-radius: 12px;
  text-align: center;
  background: rgba(8, 4, 20, 0.55);
  box-shadow: inset 0 0 0 1px rgba(139, 61, 255, 0.35);
}

.meter span {
  display: block;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
}

.meter strong {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  color: var(--gold);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.picks {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin-top: 12px;
  padding-bottom: 4px;
  scrollbar-width: none;
}

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

.pick {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(240, 193, 74, 0.3);
  background: rgba(12, 6, 28, 0.8);
  color: var(--dim);
  font-size: 12px;
}

.pick.on {
  color: #14081c;
  background: linear-gradient(180deg, #ffe08a, #d4a12e);
  border-color: transparent;
}

.pick[disabled] { opacity: 0.35; }

.ribbon {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 4px;
  margin-top: 10px;
  height: 10px;
}

.ribbon i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: rgba(139, 61, 255, 0.28);
}

.ribbon i.live {
  background: linear-gradient(90deg, var(--cyan), var(--gold));
  box-shadow: 0 0 8px rgba(46, 230, 214, 0.65);
}

.stage {
  margin-top: 12px;
  width: min(100%, 72vw, 560px);
  margin-left: auto;
  margin-right: auto;
  aspect-ratio: 1 / 1;
}

#board {
  width: 100%;
  height: 100%;
  border-radius: 16px;
  background: #070414;
  box-shadow:
    inset 0 0 0 1px rgba(240, 193, 74, 0.28),
    0 0 28px rgba(139, 61, 255, 0.22);
}

.note, .hint {
  margin: 10px 0 0;
  min-height: 1.4em;
  color: var(--ink);
}

.hint { color: var(--dim); font-size: 14px; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  color: var(--dim);
  font-size: 12px;
}

.swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 6px;
  border-radius: 50%;
  vertical-align: -1px;
  box-shadow: 0 0 8px currentColor;
}

.swatch.aqua { background: var(--cyan); color: var(--cyan); }
.swatch.volt { background: var(--magenta); color: var(--magenta); }
.swatch.fuse { background: linear-gradient(90deg, var(--cyan), var(--magenta)); color: var(--gold); }
.swatch.gate { background: var(--gold); color: var(--gold); }
.swatch.yard { background: #7affc8; color: #7affc8; }
.swatch.plant { background: #ff8a4a; color: #ff8a4a; }

.controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.controls button,
.solid,
.veil-actions button {
  min-height: 48px;
  border-radius: 14px;
  border: 1px solid rgba(240, 193, 74, 0.35);
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(48, 22, 92, 0.95), rgba(16, 8, 36, 0.95));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.controls button b {
  display: block;
  color: var(--gold);
  font-size: 16px;
}

.controls button span {
  display: block;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
}

.solid,
.veil-actions .solid {
  padding: 0 16px;
  color: #14081c;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: linear-gradient(180deg, #ffe08a, #c4922a);
  box-shadow:
    0 0 18px rgba(240, 193, 74, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
  border: 0;
}

.help {
  margin-top: 12px;
  color: var(--dim);
}

.help summary {
  cursor: pointer;
  color: var(--gold);
  min-height: 44px;
  display: flex;
  align-items: center;
}

.help ol {
  margin: 8px 0 0;
  padding-left: 18px;
}

.help li { margin-top: 6px; }

.veil {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 20px;
  text-align: center;
  background: rgba(8, 4, 22, 0.88);
  backdrop-filter: blur(8px);
  z-index: 2;
}

.veil[hidden] { display: none; }

.stars {
  color: var(--gold);
  letter-spacing: 0.2em;
  min-height: 1.2em;
}

.veil-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  margin-top: 16px;
}

.brief .veil-actions {
  grid-template-columns: 1fr;
}

.hall-card .card-top,
.relic-card,
.split {
  display: flex;
  gap: 12px;
  align-items: stretch;
  min-width: 0;
}

.card-top img,
.relic-card img,
.frame,
.portrait {
  width: 42%;
  max-width: 180px;
  height: 110px;
  object-fit: cover;
  border-radius: 12px;
  flex: none;
  box-shadow: 0 0 0 1px rgba(240, 193, 74, 0.28);
}

.hero-card .frame {
  width: 100%;
  max-width: none;
  height: min(42vw, 220px);
  margin-bottom: 10px;
}

.split .frame,
.split .portrait {
  width: 44%;
  max-width: 200px;
  height: 140px;
}

.status {
  margin: 6px 0 0;
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.status.sealed { color: var(--dim); }

.hall-card .solid,
.split .solid {
  margin-top: 12px;
  width: 100%;
}

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
}

.steps li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.num {
  flex: none;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: #14081c;
  font-family: Cinzel, serif;
  font-weight: 700;
  background: linear-gradient(180deg, #ffe08a, #c4922a);
}

.facts {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}

.score-list,
.run-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.score-list li,
.run-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(139, 61, 255, 0.28);
  min-width: 0;
}

.score-list span,
.run-list span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty { color: var(--dim); }

@media (max-width: 520px) {
  .port { width: 74px; }
  .hex { width: 66px; height: 56px; }
  .meters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-top,
  .relic-card,
  .split {
    flex-direction: column;
  }
  .card-top img,
  .relic-card img,
  .frame,
  .portrait,
  .split .frame,
  .split .portrait {
    width: 100%;
    max-width: none;
    height: 140px;
  }
  .stamp { width: 46px; height: 46px; }
}

@media (min-width: 640px) {
  .facts {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
  }
  .facts .sheet { margin-top: 12px; }
  .manifold {
    mask-image: none;
    justify-content: space-between;
  }
  .port { width: 110px; }
  .hex { width: 96px; height: 76px; }
  .hex span { font-size: 11px; }
}

@media (min-width: 860px) {
  .crest { padding-left: 4px; padding-right: 4px; }
  .panel { padding-left: 4px; padding-right: 4px; }
}
