:root {
  --berry: #2a0838;
  --berry-2: #4a0a4a;
  --pink: #ff2e8a;
  --pink-hot: #ff4fa3;
  --gold: #ffd54f;
  --gold-deep: #f4a300;
  --cyan: #22d3ee;
  --cream: #fff3fa;
  --dim: #f3b6d4;
  --ink: #fff7fb;
  --line: rgba(255, 213, 79, 0.45);
  --shadow: 0 16px 36px rgba(42, 8, 56, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  max-width: 100%;
  background:
    radial-gradient(900px 420px at 50% -8%, rgba(255, 46, 138, 0.55), transparent 58%),
    radial-gradient(640px 280px at 100% 0%, rgba(34, 211, 238, 0.28), transparent 46%),
    radial-gradient(520px 240px at 0% 12%, rgba(255, 213, 79, 0.18), transparent 42%),
    var(--berry);
  color: var(--ink);
  font-family: "Trebuchet MS", "Avenir Next", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

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

button, input { font-family: inherit; }

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

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

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

.crest {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 12px 0;
  padding: 14px 10px 12px;
  min-width: 0;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(90, 18, 86, 0.95), rgba(42, 8, 56, 0.92));
  box-shadow:
    0 0 0 2px rgba(255, 213, 79, 0.55),
    inset 0 0 0 1px rgba(255, 79, 163, 0.45),
    var(--shadow);
  overflow: hidden;
}

.bulbs {
  position: absolute;
  inset: 5px 8px auto 8px;
  height: 8px;
  background-image: radial-gradient(circle at 50% 50%, var(--gold) 0 2.2px, transparent 2.4px);
  background-size: 16px 8px;
  background-repeat: repeat-x;
  animation: blink 1.1s steps(2, end) infinite;
  pointer-events: none;
  opacity: 0.95;
}

@keyframes blink {
  50% { filter: hue-rotate(80deg) brightness(1.25); }
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
  margin-top: 6px;
}

.seal {
  width: 54px;
  height: 54px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 35%, #ff6ea8, #c2185b 72%);
  box-shadow:
    0 0 0 3px var(--gold),
    0 0 16px rgba(34, 211, 238, 0.55);
}

.seal-melon {
  width: 30px;
  height: 30px;
  border-radius: 50% 50% 46% 46%;
  background:
    radial-gradient(circle at 40% 35%, #fff 0 3px, transparent 4px),
    conic-gradient(from 20deg, #e53935, #c62828, #e53935, #2e7d32, #e53935);
  box-shadow: inset 0 0 0 3px #43a047;
}

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

.brand-copy h1 {
  margin: 0;
  font-size: clamp(16px, 5.2vw, 32px);
  line-height: 1.12;
  font-weight: 800;
  letter-spacing: 0.01em;
  overflow-wrap: anywhere;
  background: linear-gradient(180deg, #fff8e1, var(--gold) 48%, var(--gold-deep));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 0 rgba(74, 10, 42, 0.45));
}

.eyebrow, .kicker {
  margin: 0;
  color: var(--cyan);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 10px;
  line-height: 1.4;
  font-weight: 700;
}

.mute {
  margin-left: auto;
  margin-top: 6px;
  flex: none;
  border: 1px solid var(--line);
  background: rgba(42, 8, 56, 0.7);
  color: var(--cream);
  border-radius: 999px;
  min-height: 40px;
  padding: 0 10px;
  font-weight: 700;
  font-size: 12px;
  max-width: 42%;
}

.mute[aria-pressed="true"] {
  color: var(--gold);
  box-shadow: 0 0 14px rgba(34, 211, 238, 0.45);
}

.rail-wrap {
  position: relative;
  min-width: 0;
}

.rail {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 14px 12px 18px;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

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

.rail-wrap::before,
.rail-wrap::after {
  content: "";
  position: absolute;
  top: 18px;
  bottom: 28px;
  width: 18px;
  pointer-events: none;
  z-index: 1;
}

.rail-wrap::before {
  left: 0;
  background: linear-gradient(90deg, var(--berry), transparent);
}

.rail-wrap::after {
  right: 0;
  background: linear-gradient(270deg, var(--berry), transparent);
}

.hex {
  flex: 0 0 auto;
  width: 76px;
  scroll-snap-align: center;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--dim);
  min-width: 0;
}

.gem {
  width: 62px;
  height: 68px;
  margin: 0 auto 6px;
  display: grid;
  place-items: center;
  clip-path: polygon(50% 0%, 96% 25%, 96% 75%, 50% 100%, 4% 75%, 4% 25%);
  background: linear-gradient(180deg, #7a1f6a, #3a0a48);
  box-shadow: 0 8px 0 rgba(20, 4, 28, 0.35);
  position: relative;
}

.gem::after {
  content: "";
  position: absolute;
  inset: 4px;
  clip-path: polygon(50% 0%, 96% 25%, 96% 75%, 50% 100%, 4% 75%, 4% 25%);
  background: linear-gradient(160deg, rgba(255, 213, 79, 0.35), transparent 42%, rgba(34, 211, 238, 0.2));
  pointer-events: none;
}

.hex-lab {
  display: block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hex.on { color: var(--cream); transform: translateY(-4px); }

.hex.on .gem {
  background: linear-gradient(180deg, #ff6eb4, #c2185b 70%);
  filter: drop-shadow(0 0 10px rgba(34, 211, 238, 0.75));
}

.g-line, .g-hall, .g-fruit, .g-gear, .g-book, .g-map {
  display: block;
  width: 22px;
  height: 22px;
  position: relative;
  z-index: 1;
}

.g-line {
  background: linear-gradient(90deg, transparent 40%, #fff 40% 60%, transparent 60%),
    linear-gradient(#ffd54f, #ffd54f);
  background-size: 100% 3px, 3px 100%;
  background-position: center, center;
  background-repeat: no-repeat;
  border-radius: 2px;
}

.g-hall {
  border: 3px solid #fff;
  border-bottom-width: 5px;
  clip-path: polygon(50% 0, 100% 28%, 100% 100%, 0 100%, 0 28%);
}

.g-fruit {
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff 0 3px, #ff5252 4px 70%, #2e7d32 71%);
}

.g-gear {
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 3px #fff, inset 0 0 0 3px #fff;
  background: transparent;
}

.g-book {
  border: 3px solid #fff;
  border-radius: 2px 6px 6px 2px;
  box-shadow: inset 6px 0 0 #fff;
}

.g-map {
  border: 3px solid #fff;
  border-radius: 4px;
  background: linear-gradient(135deg, transparent 40%, #fff 40% 45%, transparent 45%);
}

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

.sheet {
  margin: 0 12px 12px;
  padding: 14px;
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(74, 16, 78, 0.96), rgba(36, 8, 48, 0.96)) padding-box,
    linear-gradient(145deg, #ffe082, #ff2e8a 46%, #22d3ee 78%, #ffe082) border-box;
  border: 1.6px solid transparent;
  box-shadow: var(--shadow);
  min-width: 0;
  overflow: hidden;
}

.sheet h2, .sheet h3 {
  margin: 0 0 6px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.sheet h2 { font-size: clamp(20px, 5.4vw, 28px); }
.sheet h3 { font-size: clamp(17px, 4.4vw, 22px); }

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

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

.play { position: relative; }

.hud-top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 8px;
  min-width: 0;
}

.hud-top h2 {
  margin: 0;
  min-width: 0;
  flex: 1 1 8rem;
}

.meters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 8px;
}

.meter {
  min-width: 0;
  padding: 8px 6px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 46, 138, 0.22), rgba(42, 8, 56, 0.5));
  box-shadow: inset 0 0 0 1px rgba(255, 213, 79, 0.28);
  text-align: center;
}

.meter span {
  display: block;
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cyan);
}

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

.pips {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.pip {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #5a2048;
  box-shadow: inset 0 0 0 1px rgba(255, 213, 79, 0.35);
}

.pip.on {
  background: radial-gradient(circle at 35% 30%, #fff, #ff2e8a 55%, #c2185b);
}

.quota {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.quota b {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(42, 8, 56, 0.55);
  border: 1px solid var(--line);
  color: var(--cream);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}

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

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

.seal-btn {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  background: #3a0a48;
  color: var(--cream);
  font-weight: 800;
}

.seal-btn.on {
  background: linear-gradient(180deg, #ff6eb4, #c2185b);
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.7);
}

.seal-btn:disabled { opacity: 0.35; }

.stage {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  background: radial-gradient(circle at 50% 0%, #6a1b6a, #2a0838 70%);
  box-shadow:
    inset 0 0 0 3px var(--gold),
    inset 0 0 0 6px rgba(255, 46, 138, 0.65);
  min-width: 0;
}

.stage canvas {
  width: 100%;
  height: auto;
  aspect-ratio: 720 / 900;
  display: block;
}

.pulse-tag {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(34, 211, 238, 0.92);
  color: #08303a;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  pointer-events: none;
}

.note, .hint {
  margin: 8px 0 0;
  min-height: 1.2em;
  overflow-wrap: anywhere;
}

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

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

.controls button,
.veil-actions button,
.solid {
  min-width: 0;
  min-height: 44px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(42, 8, 56, 0.7);
  color: var(--cream);
  font-weight: 700;
}

.controls button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 4px;
}

.controls b { color: var(--gold); font-size: 16px; }
.controls span { font-size: 11px; letter-spacing: 0.04em; }

.solid {
  width: 100%;
  margin-top: 10px;
  background: linear-gradient(180deg, #ffe082, #f4a300);
  color: #4a0a2a;
  border: 0;
  box-shadow: 0 6px 0 #b37600, 0 0 16px rgba(255, 213, 79, 0.35);
  font-weight: 800;
}

.solid:disabled {
  opacity: 0.4;
  box-shadow: none;
}

.veil {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 6px;
  padding: 18px;
  text-align: center;
  background: rgba(24, 4, 36, 0.88);
  backdrop-filter: blur(6px);
  border-radius: 18px;
  z-index: 3;
}

.veil[hidden] { display: none; }

.veil h2 { margin: 0; color: var(--gold); }
.veil p { margin: 0; }
.stars { letter-spacing: 0.2em; color: var(--gold); font-size: 22px; }

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

.veil-actions .solid { margin-top: 0; }

.card-top {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.card-top img,
.split img,
.sheet img {
  width: 100%;
  border-radius: 14px;
  object-fit: cover;
  aspect-ratio: 16 / 11;
}

.card-top img { aspect-ratio: 1 / 1; }

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

.hall-card.is-open .status { color: var(--cyan); }

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.fruit-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.swatch {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  flex: none;
  box-shadow: 0 0 0 3px var(--gold);
}

.swatch.apple { background: radial-gradient(circle at 35% 30%, #fff, #e53935 55%); }
.swatch.grape { background: radial-gradient(circle at 35% 30%, #e1bee7, #7b1fa2 58%); }
.swatch.banana { background: radial-gradient(circle at 35% 30%, #fffde7, #fdd835 58%); }
.swatch.melon { background: radial-gradient(circle at 35% 30%, #c8e6c9, #43a047 40%, #e53935 41% 70%, #2e7d32 71%); }
.swatch.candy { background: radial-gradient(circle at 35% 30%, #fff, #ff2e8a 50%, #22d3ee 80%); }

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

.stat {
  min-width: 0;
  text-align: center;
  padding: 8px 4px;
}

.stat span {
  display: block;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cyan);
}

.stat strong {
  display: block;
  font-size: clamp(18px, 5vw, 26px);
  color: var(--gold);
}

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

.score-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px dashed rgba(255, 213, 79, 0.25);
  min-width: 0;
}

.score-list span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.score-list b { color: var(--gold); flex: none; }

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

.cap {
  margin-top: 8px;
  font-size: 13px;
}

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

.steps b {
  display: block;
  color: var(--gold);
  margin-bottom: 4px;
}

@media (min-width: 640px) {
  .meters { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
}

@media (min-width: 720px) {
  .split {
    grid-template-columns: 220px minmax(0, 1fr);
    align-items: center;
  }
  .card-top { grid-template-columns: 140px minmax(0, 1fr); }
}

@media (max-width: 380px) {
  .meters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats { grid-template-columns: 1fr; }
  .hex { width: 68px; }
  .gem { width: 54px; height: 60px; }
  .crest { padding: 12px 8px 10px; }
  .brand-copy h1 { font-size: 16px; }
  .mute { max-width: 38%; }
  .veil-actions { grid-template-columns: 1fr; }
}

@media (max-height: 560px) and (orientation: landscape) {
  .stage canvas { aspect-ratio: 720 / 700; max-height: 70vh; }
}
