:root {
  --plum: #2a0848;
  --violet: #3b0a68;
  --orchid: #6b1b8a;
  --magenta: #ff3d8a;
  --pink: #ff7eb6;
  --blush: #ffd0e6;
  --aqua: #2de2e0;
  --mint: #7ff5f0;
  --gold: #ffd56a;
  --cream: #fff4f8;
  --cocoa: #6b3410;
  --ink: #fff7fb;
  --dim: #f0c3de;
  --line: rgba(255, 213, 106, 0.45);
  --shadow: 0 16px 36px rgba(18, 2, 36, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  overflow-x: hidden;
  background:
    radial-gradient(900px 420px at 50% -8%, rgba(255, 61, 138, 0.38), transparent 58%),
    radial-gradient(700px 380px at 100% 12%, rgba(45, 226, 224, 0.22), transparent 50%),
    linear-gradient(180deg, rgba(42, 8, 72, 0.55), rgba(42, 8, 72, 0.88)),
    url("hills.jpg") center top / cover no-repeat,
    var(--violet);
  color: var(--ink);
  font-family: "Nunito", "Avenir Next", sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

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

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

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

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

.glow {
  pointer-events: none;
  position: fixed;
  z-index: 0;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.55;
}

.glow-a {
  width: 180px;
  height: 180px;
  left: -50px;
  top: 120px;
  background: #ff3d8a;
}

.glow-b {
  width: 160px;
  height: 160px;
  right: -40px;
  bottom: 80px;
  background: #2de2e0;
}

.shell {
  position: relative;
  z-index: 1;
  width: min(920px, 100%);
  max-width: 100%;
  margin: 0 auto;
  min-height: 100dvh;
  height: 100dvh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 0 0 calc(10px + env(safe-area-inset-bottom));
  overflow: hidden;
}

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

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

.brand img {
  width: 52px;
  height: 52px;
  flex: none;
  object-fit: cover;
  border-radius: 16px;
  box-shadow:
    0 0 0 2px var(--gold),
    0 0 16px rgba(255, 61, 138, 0.7);
}

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

.brand-copy h1 {
  margin: 0;
  font-family: "Fredoka", "Nunito", sans-serif;
  font-size: clamp(22px, 6vw, 30px);
  line-height: 1.1;
  letter-spacing: 0.01em;
}

.eyebrow, .kicker {
  margin: 0;
  color: var(--gold);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.3;
}

.mute {
  margin-left: auto;
  flex: none;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 126, 182, 0.22), rgba(42, 8, 72, 0.7));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

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

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

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

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

.rail-wrap::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 0;
  bottom: 12px;
  width: 28px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(42, 8, 72, 0.88));
}

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

.slice .cake {
  display: grid;
  width: 100%;
  height: 58px;
  border-radius: 14px 14px 10px 10px;
  overflow: hidden;
  background: #f0b35a;
  box-shadow:
    inset 0 0 0 2px rgba(255, 213, 106, 0.25),
    0 8px 0 #4a1230,
    0 12px 16px rgba(0, 0, 0, 0.28);
  transform: translateY(2px);
}

.slice .cake i {
  display: block;
  width: 100%;
}

.slice .dom { height: 12px; background: linear-gradient(180deg, #fff, var(--pink)); }
.slice .jam { height: 9px; background: var(--magenta); }
.slice .crumb { height: 16px; background: linear-gradient(180deg, #f6c56a, #d4893a); }
.slice .cream { height: 21px; background: linear-gradient(180deg, #ffd0e6, #ff7eb6); }

.slice .cake.aqua .jam { background: var(--aqua); }
.slice .cake.aqua .cream { background: linear-gradient(180deg, #d9fffb, #2de2e0); }
.slice .cake.cocoa .jam { background: #3d1c0c; }
.slice .cake.cocoa .cream { background: linear-gradient(180deg, #c47a3a, #6b3410); }
.slice .cake.berry .jam { background: #8e1f7a; }
.slice .cake.berry .cream { background: linear-gradient(180deg, #e8a0ff, #9b2b9b); }
.slice .cake.vanilla .dom { background: linear-gradient(180deg, #fff, #fff4d6); }
.slice .cake.vanilla .jam { background: #ffe08a; }
.slice .cake.vanilla .cream { background: linear-gradient(180deg, #fffaf0, #ffe08a); }
.slice .cake.gold .jam { background: #ffd56a; }
.slice .cake.gold .cream { background: linear-gradient(180deg, #fff1b0, #e8b03a); }

.slice .tag {
  display: block;
  margin-top: 10px;
  font-family: "Fredoka", sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slice.on { color: var(--cream); }

.slice.on .cake {
  transform: translateY(-4px);
  box-shadow:
    inset 0 0 0 2px var(--gold),
    0 0 0 3px rgba(255, 61, 138, 0.55),
    0 10px 0 #4a1230,
    0 0 18px rgba(255, 213, 106, 0.55);
}

main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
  padding: 0 12px;
  overflow-x: hidden;
}

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

.panel.on {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  flex: 1;
}

.panel.flow {
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 18px;
}

.ticket {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(42, 8, 72, 0.4)),
    rgba(74, 14, 122, 0.72);
  box-shadow:
    inset 0 0 0 1px rgba(255, 213, 106, 0.35),
    var(--shadow);
  min-width: 0;
}

.ticket img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 16px;
}

.ticket h2, .head h2, .veil-card h2 {
  margin: 2px 0 0;
  font-family: "Fredoka", sans-serif;
  font-size: clamp(15px, 4.4vw, 22px);
  line-height: 1.2;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.ticket p, .lede, .callout, .veil-card p {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
}

.ticket p { color: var(--blush); font-size: 13px; }

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

.pins.wide { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.pin {
  min-width: 0;
  padding: 7px 6px;
  border-radius: 14px;
  text-align: center;
  background: radial-gradient(circle at 50% 0%, rgba(255, 126, 182, 0.35), rgba(42, 8, 72, 0.8));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16), 0 6px 0 rgba(18, 2, 36, 0.35);
}

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

.pin strong {
  display: block;
  font-family: "Fredoka", sans-serif;
  font-size: clamp(14px, 4vw, 18px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#screen-bake.on {
  overflow: hidden;
}

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 180px;
  height: auto;
  border-radius: 26px;
  overflow: hidden;
  border: 7px solid transparent;
  background-color: #24063c;
  background-image:
    linear-gradient(#24063c, #1a0530),
    repeating-linear-gradient(45deg, #ff4d6d 0 9px, #fff7fb 9px 18px);
  background-origin: border-box;
  background-clip: padding-box, border-box;
  box-shadow: var(--shadow), 0 0 24px rgba(255, 61, 138, 0.35);
}

.stage canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.veil {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 8px;
  overflow: auto;
  background: rgba(24, 4, 48, 0.62);
  backdrop-filter: blur(6px);
}

.veil[hidden] { display: none; }

.veil-card {
  width: min(100%, 360px);
  max-height: 100%;
  overflow: auto;
  padding: 12px 12px 14px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(107, 27, 138, 0.95), rgba(42, 8, 72, 0.96));
  box-shadow: inset 0 0 0 2px rgba(255, 213, 106, 0.4), var(--shadow);
  text-align: center;
}

.veil-card img {
  width: 64px;
  height: 64px;
  margin: 0 auto 6px;
  object-fit: cover;
  border-radius: 50%;
  box-shadow: 0 0 0 3px var(--gold);
}

.veil-card p:not(.kicker) {
  color: var(--blush);
  font-size: 14px;
}

.callout {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 10px;
  z-index: 2;
  margin: 0;
  min-height: 22px;
  text-align: center;
  color: var(--gold);
  font-weight: 800;
  font-size: 13px;
  text-shadow: 0 1px 8px #1a0530;
  pointer-events: none;
}

.candy {
  appearance: none;
  border: 0;
  width: 100%;
  min-height: 48px;
  border-radius: 999px;
  padding: 0 18px;
  font-family: "Fredoka", sans-serif;
  font-size: 17px;
  font-weight: 700;
  color: #3b0a68;
  background:
    linear-gradient(180deg, #fff4d6 0%, var(--gold) 42%, #e8b03a 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.75),
    0 6px 0 #9a4a16,
    0 0 18px rgba(255, 213, 106, 0.45);
}

.candy.fat { min-height: 54px; }

.candy.overlay {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 10px;
  width: auto;
  z-index: 2;
}

.candy:active { transform: translateY(2px); box-shadow: inset 0 2px 0 rgba(255,255,255,0.7), 0 3px 0 #9a4a16; }

.head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 10px;
  align-items: end;
}

.head-art {
  width: 92px;
  height: 72px;
  object-fit: cover;
  border-radius: 16px;
  box-shadow: 0 0 0 2px rgba(255, 213, 106, 0.45);
}

.lede {
  color: var(--blush);
  font-size: 14px;
}

#finder {
  width: 100%;
  min-height: 44px;
  border-radius: 16px;
  border: 1px solid rgba(255, 213, 106, 0.35);
  background: rgba(24, 4, 48, 0.55);
  padding: 0 12px;
}

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

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

.chip {
  flex: none;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(42, 8, 72, 0.55);
  color: var(--blush);
}

.chip.on {
  color: #3b0a68;
  background: linear-gradient(180deg, var(--mint), var(--aqua));
  border-color: transparent;
  font-weight: 800;
}

.stack {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.card, .note, .run {
  min-width: 0;
  padding: 12px;
  border-radius: 20px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.1), rgba(42, 8, 72, 0.72));
  box-shadow: inset 0 0 0 1px rgba(255, 213, 106, 0.22);
}

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

.card img, .note img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 16px;
}

.card h3, .note h3, .run h3, .essay h3 {
  margin: 0;
  font-family: "Fredoka", sans-serif;
  font-size: 17px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.card p, .note p, .run p, .essay p {
  margin: 6px 0 0;
  color: var(--blush);
  font-size: 13px;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.pill {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(255, 61, 138, 0.28);
  color: var(--cream);
}

.pill.aqua { background: rgba(45, 226, 224, 0.28); color: var(--mint); }
.pill.gold { background: rgba(255, 213, 106, 0.25); color: var(--gold); }
.pill.seal { background: rgba(0, 0, 0, 0.28); color: var(--dim); }

.card.sealed { opacity: 0.62; filter: saturate(0.7); }

.keep {
  margin-top: 8px;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  font-size: 12px;
  font-weight: 800;
}

.keep.on {
  background: linear-gradient(180deg, var(--pink), var(--magenta));
  border-color: transparent;
}

.mosaic {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

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

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

.essay article {
  padding: 12px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 126, 182, 0.16), rgba(42, 8, 72, 0.78));
  box-shadow: inset 0 0 0 1px rgba(45, 226, 224, 0.22);
}

.essay img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 16px;
  margin-bottom: 8px;
}

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

.steps li { margin: 4px 0; color: var(--blush); font-size: 13px; }

@media (min-width: 520px) {
  .mosaic { grid-template-columns: 1fr 1fr; }
  .pins.wide { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .slice { flex-basis: 88px; width: 88px; }
}

@media (max-width: 360px) {
  .brand img { width: 44px; height: 44px; }
  .slice { flex: 0 0 68px; width: 68px; }
  .pin { padding: 5px 4px; }
  .head { grid-template-columns: minmax(0, 1fr); }
  .head-art { display: none; }
  .ticket { grid-template-columns: 52px minmax(0, 1fr); }
  .ticket img { width: 52px; height: 52px; }
}

@media (max-height: 680px) {
  .stage { min-height: 160px; }
  .veil-card img { width: 44px; height: 44px; }
  .candy { min-height: 44px; }
  .candy.fat { min-height: 44px; }
  .rail { padding-top: 6px; padding-bottom: 8px; }
  .slice .cake { height: 48px; }
}

@media (max-height: 600px) {
  .mast { padding: 6px 12px 0; }
  .brand img { width: 40px; height: 40px; }
  .ticket { padding: 6px 8px; }
  .ticket img { width: 44px; height: 44px; }
  .pin { padding: 4px 3px; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.16); }
  .veil-card { padding: 8px; }
  .veil-card p:not(.kicker) { font-size: 12px; }
  .veil-card img { width: 36px; height: 36px; }
  .stage { min-height: 140px; }
}
