:root {
  --navy: #070b22;
  --navy-2: #10183a;
  --ink: #f3fbff;
  --muted: #b7d4e4;
  --cyan: #3ce7ff;
  --magenta: #ff2d8a;
  --gold: #e8c56b;
  --line: rgba(232, 197, 107, 0.42);
  --pad: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--navy);
  color: var(--ink);
  overflow-x: clip;
}

body {
  min-height: 100dvh;
  font-family: Outfit, "Avenir Next", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

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

button { cursor: pointer; }

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

h1, h2, h3, p, button, span, strong { overflow-wrap: break-word; }

h1, h2, h3 {
  font-family: Syne, Outfit, sans-serif;
  line-height: 1.05;
  margin: 0;
}

p { margin: 0; }

.shell {
  width: min(640px, 100%);
  margin: 0 auto;
  max-width: 100%;
  min-height: 100dvh;
  padding-bottom: calc(124px + env(safe-area-inset-bottom));
  background:
    radial-gradient(90% 40% at 100% -10%, rgba(255, 45, 138, 0.28), transparent 55%),
    radial-gradient(70% 36% at -10% 8%, rgba(60, 231, 255, 0.2), transparent 50%),
    var(--navy);
}

.mast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) var(--pad) 8px;
}

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

.mark {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 58%, #fff 0 7px, #9af4ff 8px 13px, transparent 14px),
    conic-gradient(from 210deg, var(--magenta), var(--cyan), #7a4dff, var(--magenta), var(--cyan));
  box-shadow: 0 0 18px rgba(60, 231, 255, 0.45);
}

.wordmark {
  margin: 0;
  font-family: Syne, sans-serif;
  font-weight: 800;
  letter-spacing: 0.01em;
  font-size: 15px;
  color: var(--cyan);
}

.wordmark i {
  font-style: normal;
  color: var(--magenta);
}

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

.sound {
  border: 1px solid var(--line);
  background: rgba(8, 16, 40, 0.7);
  border-radius: 999px;
  min-height: 40px;
  padding: 0 14px;
  color: var(--gold);
}

.sound.is-on { color: var(--cyan); border-color: rgba(60, 231, 255, 0.7); }

.filament {
  height: 3px;
  margin: 0 var(--pad) 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px;
  overflow: hidden;
}

.filament span {
  display: block;
  height: 100%;
  width: 100%;
  transform: scaleX(0);
  transform-origin: left center;
  background: linear-gradient(90deg, var(--cyan), var(--gold), var(--magenta));
}

.screen { display: none; padding: 0 var(--pad) 18px; }
.screen.on { display: block; }

.hero {
  margin: 0 0 14px;
  position: relative;
  border-radius: 28px 28px 48px 22px;
  overflow: hidden;
  border: 1px solid var(--line);
  min-height: 0;
}

.hero img {
  width: 100%;
  height: clamp(190px, 48vw, 340px);
  object-fit: cover;
}

.hero figcaption {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(7, 11, 34, 0.72);
  backdrop-filter: blur(8px);
}

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

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

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

.solid, .ghost, .rose button, .tools button, .picks button, .hull button {
  border: 0;
  min-height: 46px;
}

.solid, .ghost {
  border-radius: 999px;
  padding: 0 16px;
}

.solid {
  background: linear-gradient(90deg, var(--cyan), #8af7ff 40%, var(--magenta));
  color: #081018;
  font-weight: 700;
}

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

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

.triad article, .sheet, .hull, .place {
  background: linear-gradient(180deg, rgba(18, 28, 64, 0.92), rgba(8, 12, 32, 0.92));
  border: 1px solid rgba(60, 231, 255, 0.18);
  border-radius: 22px;
  padding: 12px;
  min-width: 0;
}

.triad strong, .sheet h2, .place h3, .hull h3 { display: block; }
.triad span, .place p, .hull p, .sheet p { color: var(--muted); }

.sheet { margin-top: 12px; }
.sheet h2 { font-size: clamp(28px, 8vw, 44px); }

.place { margin-top: 12px; padding: 0; overflow: hidden; }
.place img {
  width: 100%;
  height: clamp(150px, 42vw, 230px);
  object-fit: cover;
}
.place div, .place > p, .place > button { margin-left: 12px; margin-right: 12px; }
.place div { padding-top: 12px; }
.place > p { margin-top: 8px; }
.place > button { margin: 12px; }

.num {
  color: var(--gold);
  font-family: Syne, sans-serif;
  letter-spacing: 0.14em;
}

.hud-top { display: flex; justify-content: space-between; gap: 8px; align-items: end; min-width: 0; }
.hud-top > div { min-width: 0; }
.hud-top h2 { font-size: clamp(22px, 6vw, 36px); }

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

.meters div {
  background: rgba(6, 16, 36, 0.55);
  border-radius: 14px;
  padding: 8px 6px;
  min-width: 0;
}

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

.meters strong { font-size: 18px; }

.picks {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 0 4px;
  scrollbar-width: none;
}

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

.picks button {
  flex: 0 0 auto;
  width: 42px;
  border-radius: 50%;
  background: #10203f;
  border: 1px solid rgba(60, 231, 255, 0.35);
  color: var(--cyan);
}

.picks button.on {
  background: radial-gradient(circle at 50% 40%, #fff, var(--gold) 42%, #8a5a12);
  color: #1a1206;
  border-color: transparent;
}

.picks button.done { box-shadow: inset 0 0 0 2px var(--magenta); }
.picks button.locked { opacity: 0.35; }

.stage {
  width: min(100%, 72vw, 420px);
  margin: 8px auto 0;
  position: relative;
}

.stage canvas {
  width: 100%;
  height: auto;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: #07111f;
  touch-action: none;
}

.note {
  min-height: 1.4em;
  margin: 8px 0;
  color: var(--gold);
  text-align: center;
}

.rose {
  width: 100%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.rose button {
  border-radius: 18px;
  background: #102446;
  border: 1px solid rgba(60, 231, 255, 0.35);
  color: var(--ink);
  min-width: 0;
  padding: 0 4px;
}

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

.tools button {
  border-radius: 16px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--gold);
  padding: 0 6px;
  font-size: 14px;
}

.tools button.ready {
  background: linear-gradient(180deg, var(--magenta), #7a1d55);
  color: white;
  border-color: transparent;
}

.tools button:disabled { opacity: 0.4; }

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

.legend i {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: -1px;
}

.swatch.ribbon { background: var(--cyan); }
.swatch.drum { background: #e7dcc8; }
.swatch.pearl { background: #fff; }
.swatch.gate { background: var(--magenta); }
.swatch.wheel { background: var(--gold); }
.swatch.anemone { background: #ff5caa; }

.help { margin-top: 8px; color: var(--muted); }
.help summary { color: var(--ink); cursor: pointer; }
.help ol { padding-left: 18px; }

.veil {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 12px;
  background: rgba(4, 8, 20, 0.72);
  border-radius: 24px;
}

.veil[hidden] { display: none; }

.veil-card {
  width: min(100%, 320px);
  background: #10183a;
  border: 1px solid var(--gold);
  border-radius: 24px;
  padding: 16px;
  text-align: center;
}

.lights { display: flex; justify-content: center; gap: 8px; margin: 10px 0; }
.lights i {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #24304e;
  box-shadow: inset 0 0 0 1px var(--gold);
}
.lights i.on { background: radial-gradient(circle at 35% 35%, #fff, var(--gold)); }

.veil-card .solid, .veil-card .ghost { width: 100%; margin-top: 8px; }

.fleet-head, .relic-head { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 12px; align-items: center; }
.fleet-head img, .relic-head img {
  width: 92px;
  height: 92px;
  object-fit: cover;
  border-radius: 24px;
  border: 1px solid var(--line);
}

.hull { margin-top: 10px; }
.hull.locked { opacity: 0.55; }
.hull.on { border-color: var(--gold); }
.hull button { margin-top: 8px; }

.relics, .records { list-style: none; padding: 0; margin: 10px 0 0; }
.relics li, .records li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.relics li span, .records li span { color: var(--muted); text-align: right; }
.relics li.found strong { color: var(--gold); }

.fan {
  position: fixed;
  z-index: 5;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(640px, 100%);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 2px;
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  background:
    radial-gradient(70% 80% at 50% 120%, rgba(60, 231, 255, 0.16), transparent 58%),
    #070b22;
  border-top: 1px solid var(--line);
}

.fan button {
  appearance: none;
  border: 0;
  min-width: 0;
  min-height: 64px;
  padding: 0 1px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  color: #d8f7ff;
  background: transparent;
  font-family: Syne, sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.fan button::before {
  content: "";
  width: 74%;
  height: 22px;
  background: linear-gradient(180deg, rgba(60, 231, 255, 0.2), rgba(255, 45, 138, 0.55));
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.fan button.hub::before { height: 34px; width: 86%; }

.fan button.on { color: #fffaf0; }

.fan button.on::before {
  height: 30px;
  background: linear-gradient(180deg, var(--cyan), var(--magenta));
}

.fan button.hub.on::before { height: 40px; }

.note-photo {
  width: 100%;
  height: clamp(150px, 40vw, 220px);
  object-fit: cover;
  border-radius: 16px;
  margin-bottom: 10px;
}

@media (max-width: 359px) {
  :root { --pad: 10px; }
  .fan button { font-size: 8px; min-height: 58px; }
  .fan button::before { height: 16px; }
  .fan button.hub::before, .fan button.hub.on::before { height: 26px; }
  .meters strong { font-size: 16px; }
  .tools button { font-size: 12px; }
  .triad { gap: 6px; }
  .triad article { padding: 8px; }
}

@media (min-width: 720px) {
  :root { --pad: 22px; }
  .fan button { font-size: 12px; min-height: 76px; }
  .fan button::before { height: 28px; }
  .fan button.hub::before, .fan button.hub.on::before { height: 42px; }
}

@media (max-height: 760px) {
  .stage { width: min(100%, 58vw, 300px); }
  .hero img { height: 180px; }
}

@media (prefers-reduced-motion: reduce) {
  .filament span { transition: none; }
}
