:root {
  --ink: #09070b;
  --night: #14080b;
  --panel: #1b1016;
  --panel-2: #2a1720;
  --gold: #e4c16a;
  --gold-deep: #8d6a2f;
  --crimson: #d21b32;
  --ivory: #f6efe2;
  --muted: #b7a89a;
  --fire: #ff5a2a;
  --water: #3ec2ff;
  --air: #e7f3c8;
  --earth: #d0893a;
  --gutter: 16px;
  --display: "Cinzel", "Palatino Linotype", Palatino, serif;
  --body: "Outfit", "Avenir Next", "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  max-width: 100%;
  overflow-x: clip;
  background: var(--ink);
  color: var(--ivory);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(210, 27, 50, 0.22), transparent 55%),
    repeating-linear-gradient(135deg, rgba(228, 193, 106, 0.035) 0 2px, transparent 2px 14px),
    var(--ink);
}

body.in-clash {
  overflow: hidden;
  height: 100dvh;
}

img { max-width: 100%; height: auto; display: block; }

a { color: inherit; }

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

button { cursor: pointer; }

h1, h2, h3, p { overflow-wrap: anywhere; }

h1, h2, h3 {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.15;
  margin: 0;
}

p { margin: 0; }

.mast {
  position: fixed;
  z-index: 40;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  background: linear-gradient(180deg, rgba(12, 8, 12, 0.97), rgba(12, 8, 12, 0.88));
  border-bottom: 1px solid rgba(228, 193, 106, 0.4);
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid var(--gold);
  flex: 0 0 auto;
}

.brand-mark i:nth-child(1) { background: var(--fire); }
.brand-mark i:nth-child(2) { background: var(--water); }
.brand-mark i:nth-child(3) { background: var(--earth); }
.brand-mark i:nth-child(4) { background: var(--air); }

.wordmark {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  text-decoration: none;
}

.wordmark strong {
  font-family: var(--display);
  font-size: clamp(12px, 3.4vw, 15px);
  letter-spacing: 0.14em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: linear-gradient(90deg, #f8e7b0, #e4c16a 42%, #fff6d8 50%, #e4c16a 58%, #a6843a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.wordmark span {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.crest-btn {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border: 1px solid var(--gold);
  background: linear-gradient(160deg, #a3182c, #4c0d16);
  transform: rotate(45deg);
  border-radius: 8px;
  padding: 0;
}

.crest-btn span {
  display: block;
  width: 16px;
  height: 16px;
  margin: auto;
  background:
    linear-gradient(var(--fire), var(--fire)) 0 0 / 7px 7px no-repeat,
    linear-gradient(var(--water), var(--water)) 9px 0 / 7px 7px no-repeat,
    linear-gradient(var(--earth), var(--earth)) 0 9px / 7px 7px no-repeat,
    linear-gradient(var(--air), var(--air)) 9px 9px / 7px 7px no-repeat;
}

.ledger {
  position: fixed;
  z-index: 45;
  top: calc(66px + env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  max-height: calc(100dvh - 168px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow: auto;
}

.ledger[hidden] { display: none !important; }

.ledger-card { padding: 18px 16px 16px; }

.ledger-stat { margin-top: 8px; color: var(--muted); }

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

.ledger-links {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}

.ledger-links a {
  display: block;
  text-decoration: none;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(228, 193, 106, 0.35);
  background: rgba(0, 0, 0, 0.25);
}

.dock {
  position: fixed;
  z-index: 40;
  left: 8px;
  right: 8px;
  bottom: calc(8px + env(safe-area-inset-bottom));
  height: 74px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: end;
  padding: 8px 4px 6px;
  border: 1px solid rgba(228, 193, 106, 0.5);
  border-radius: 28px 28px 18px 18px;
  background: linear-gradient(180deg, #3a1620, #10080c);
  box-shadow: 0 -12px 30px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 226, 170, 0.28);
}

.dock::before {
  content: "";
  position: absolute;
  z-index: -1;
  left: -10px;
  right: -10px;
  top: 18px;
  bottom: calc(-12px - env(safe-area-inset-bottom));
  background: #10080c;
}

.dock a {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  color: var(--muted);
  text-decoration: none;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.dock a svg { width: 18px; height: 18px; display: block; }

.dock a span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dock a.is-active { color: var(--gold); }

.dock .play-link {
  width: 58px;
  height: 58px;
  margin: -28px auto 0;
  border-radius: 50%;
  justify-content: center;
  color: #fff8ea;
  background: radial-gradient(circle at 35% 30%, #ff8b96, #c11228 58%, #6c0d18);
  border: 2px solid var(--gold);
  box-shadow: 0 10px 20px rgba(210, 27, 50, 0.4);
}

.dock .play-link svg { width: 18px; height: 18px; }

main {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: calc(74px + env(safe-area-inset-top)) var(--gutter) calc(118px + env(safe-area-inset-bottom));
}

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

.lead { color: var(--muted); margin-top: 10px; }

h1 { font-size: clamp(1.7rem, 8vw, 3.1rem); }

h2 { font-size: clamp(1.25rem, 5vw, 1.8rem); margin: 22px 0 10px; }

h3 { font-size: 1.15rem; }

.bleed {
  margin-left: calc(var(--gutter) * -1);
  margin-right: calc(var(--gutter) * -1);
}

.hero-band { position: relative; }

.hero-band img {
  width: 100%;
  height: min(58vw, 360px);
  object-fit: cover;
}

.hero-copy {
  position: relative;
  margin: -48px 12px 0;
  padding: 16px 16px 18px;
}

.hero-copy .cta { margin-top: 14px; }

.ticker {
  margin-top: 18px;
  overflow: hidden;
  max-width: 100%;
  border-block: 1px solid rgba(228, 193, 106, 0.28);
  background: rgba(18, 9, 13, 0.85);
}

.ticker-track {
  display: flex;
  gap: 28px;
  width: max-content;
  padding: 8px 0;
  animation: marquee 26s linear infinite;
  color: var(--gold);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 12px;
}

@keyframes marquee {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

.foil {
  position: relative;
  background: linear-gradient(180deg, rgba(46, 24, 32, 0.94), rgba(14, 9, 12, 0.96));
  border: 1px solid rgba(228, 193, 106, 0.55);
  border-radius: 18px;
  box-shadow: inset 0 1px 0 rgba(255, 236, 196, 0.25), 0 16px 34px rgba(0, 0, 0, 0.28);
}

.foil::before,
.foil::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 7px;
  border: 1px solid var(--gold);
  transform: rotate(45deg);
  pointer-events: none;
}

.foil::before { top: 8px; left: 8px; }
.foil::after { right: 8px; bottom: 8px; }

.status-line {
  margin-top: 14px;
  color: var(--gold);
  font-size: 13px;
  letter-spacing: 0.04em;
}

.steps, .stack, .split, .roster, .matchups { margin-top: 8px; }

.step, .ticket, .element-card, .hero-card, .guide-block {
  padding: 16px;
  margin-top: 12px;
}

.step-index {
  font-family: var(--display);
  color: var(--crimson);
  font-size: 1.4rem;
}

.ticket {
  display: grid;
  gap: 12px;
}

.ticket img, .hero-card img, .element-card img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  border-radius: 12px;
}

.hero-card img { height: 280px; object-position: center top; }

.lock-note, .ready-note, .meta { color: var(--muted); margin-top: 8px; font-size: 14px; }

.ready-note { display: none; color: var(--gold); }

.is-open .ready-note { display: block; }
.is-open .lock-note { display: none; }

.cta, .ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border-radius: 999px;
  text-decoration: none;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  font-size: 13px;
}

.cta {
  border: 1px solid var(--gold);
  color: #fff8ea;
  background: linear-gradient(180deg, #f04b5a, #9d1224);
  box-shadow: 0 10px 22px rgba(210, 27, 50, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.ghost {
  border: 1px solid rgba(228, 193, 106, 0.7);
  background: transparent;
  color: var(--gold);
}

.cycle {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 12px;
}

.cycle span {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(228, 193, 106, 0.25);
}

.tag {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tag.fire { color: var(--fire); }
.tag.water { color: var(--water); }
.tag.air { color: var(--air); }
.tag.earth { color: var(--earth); }

.chapter + .chapter { margin-top: 18px; }

.drop {
  font-family: var(--display);
  float: left;
  font-size: 2.4rem;
  line-height: 0.8;
  padding-right: 8px;
  color: var(--gold);
}

.chip-row {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding-bottom: 6px;
}

.pick {
  flex: 0 0 112px;
  width: 112px;
  padding: 8px;
  border-radius: 14px;
  border: 1px solid rgba(228, 193, 106, 0.35);
  background: rgba(20, 8, 11, 0.8);
  text-align: left;
}

.pick img {
  width: 100%;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
}

.pick span, .pick small { display: block; }
.pick span { margin-top: 6px; font-size: 13px; }
.pick small { color: var(--muted); font-size: 11px; }
.pick.is-selected { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.pick:disabled { opacity: 0.5; }

.passive, .best-line { margin-top: 8px; color: var(--muted); }

.hint-list {
  margin: 14px 0 0;
  padding-left: 18px;
  color: var(--muted);
}

.hint-list li + li { margin-top: 6px; }

.lobby .cta { margin-top: 16px; }

.stage {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  background: #07060a;
  touch-action: none;
  user-select: none;
}

.stage[hidden] { display: none !important; }

.match-top {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 10px 0;
}

.match-top span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

#arena-label { flex: 1.2; color: var(--gold); }
#wave-label { flex: 1; text-align: center; color: var(--ivory); }
#score-chip { flex: 0.8; text-align: right; }

.pause-btn {
  flex: 0 0 auto;
  min-width: 44px;
  min-height: 36px;
  border-radius: 999px;
  border: 1px solid var(--gold);
  background: transparent;
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.resonance {
  flex: 0 0 auto;
  height: 8px;
  margin: 6px 10px 4px;
  border-radius: 99px;
  background: #2a171c;
  overflow: hidden;
  border: 1px solid rgba(228, 193, 106, 0.35);
}

#resonance-fill {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--crimson), var(--gold));
}

.field-wrap { flex: 1; min-height: 0; position: relative; }

#field { width: 100%; height: 100%; display: block; }

.controls {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) 112px;
  gap: 8px;
  align-items: center;
  padding: 6px 10px calc(8px + env(safe-area-inset-bottom));
}

.stick {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 1px solid rgba(228, 193, 106, 0.55);
  background: radial-gradient(circle at 50% 50%, rgba(228, 193, 106, 0.08), rgba(0, 0, 0, 0.35));
  position: relative;
  touch-action: none;
}

.knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 35% 30%, #fff1c9, var(--gold) 45%, #8a6230);
  border: 1px solid #fff6d8;
}

.clash {
  justify-self: center;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  border: 1px solid rgba(228, 193, 106, 0.4);
  background: #1a1014;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.15;
}

.clash.is-ready {
  color: #1a0c0e;
  border-color: var(--gold);
  background: radial-gradient(circle at 40% 30%, #fff1c4, #e4c16a 42%, #d21b32 78%);
  box-shadow: 0 0 18px rgba(228, 193, 106, 0.45);
}

.glyphs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.glyph {
  min-height: 46px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #140c10;
  padding: 4px 2px 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.glyph b { font-size: 11px; font-weight: 700; letter-spacing: 0.04em; }
.glyph.fire { color: var(--fire); box-shadow: inset 0 0 0 1px rgba(255, 90, 42, 0.45); }
.glyph.water { color: var(--water); box-shadow: inset 0 0 0 1px rgba(62, 194, 255, 0.45); }
.glyph.air { color: var(--air); box-shadow: inset 0 0 0 1px rgba(231, 243, 200, 0.45); }
.glyph.earth { color: var(--earth); box-shadow: inset 0 0 0 1px rgba(208, 137, 58, 0.5); }
.glyph[data-count="0"], .glyph.cooling { opacity: 0.45; }

.pips { display: flex; gap: 3px; }
.pips i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.25;
}
.pips i.on { opacity: 1; }

.veil {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(7, 6, 10, 0.72);
}

.veil[hidden] { display: none !important; }

.veil-card { width: min(420px, 100%); padding: 18px 16px; }

.veil-card h2 { font-size: clamp(1.4rem, 6vw, 2rem); }

.veil-card p { margin-top: 8px; color: var(--muted); }

.veil-card .cta, .veil-card .ghost { margin-top: 10px; }

.stage.compact .controls { grid-template-columns: 78px minmax(0, 1fr) 100px; padding-top: 4px; }
.stage.compact .stick, .stage.compact .stick { width: 78px; height: 78px; }
.stage.compact .clash { width: 64px; height: 64px; }
.stage.compact .glyph { min-height: 44px; }
.stage.compact .knob { width: 34px; height: 34px; }

.stage.tiny .match-top { min-height: 36px; }
.stage.tiny .controls { grid-template-columns: 70px minmax(0, 1fr) 96px; gap: 6px; }
.stage.tiny .stick { width: 70px; height: 70px; }
.stage.tiny .clash { width: 58px; height: 58px; font-size: 10px; }
.stage.tiny .glyph { min-height: 44px; }
.stage.tiny .glyph b { font-size: 10px; }

body.in-clash .mast,
body.in-clash .dock,
body.in-clash .ledger,
body.in-clash main { display: none !important; }

@media (min-width: 520px) {
  .ticket { grid-template-columns: 180px minmax(0, 1fr); align-items: center; }
  .ticket img { height: 140px; }
  .cycle { grid-template-columns: 1fr 1fr; }
  .roster { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .roster .hero-card { margin-top: 0; }
}

@media (min-width: 700px) {
  .ledger { left: auto; width: min(420px, calc(100% - 24px)); }
  .steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
  .step { margin-top: 0; }
  .hero-band img { height: 380px; }
}

@media (max-height: 740px) {
  .hero-band img { height: 148px; }
  .hero-copy { margin-top: -28px; }
}

@media (max-width: 360px) {
  .dock { height: 68px; left: 6px; right: 6px; }
  .dock .play-link { width: 52px; height: 52px; margin-top: -22px; }
  .dock a { font-size: 9px; }
  :root { --gutter: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .ticker-track { animation: none; }
}

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