:root {
  --bg: #0d130e;
  --grid: rgba(255, 255, 255, 0.045);
  --card: #0a0d0a;
  --card-line: rgba(255, 255, 255, 0.28);
  --ink: #f4f7f2;
  --muted: #a9b8aa;
  --pink: #f7c6e0;
  --green: #7fd69b;
  --gold: #ffe27a;
  --mono: "Space Mono", ui-monospace, Menlo, Consolas, monospace;
  --round: "Fredoka", "Arial Rounded MT Bold", system-ui, sans-serif;
}

body.day {
  --bg: #eaf4e4;
  --grid: rgba(20, 60, 30, 0.07);
  --card: #fffdf7;
  --card-line: rgba(20, 50, 30, 0.3);
  --ink: #16241a;
  --muted: #4f6554;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 48px 48px;
  color: var(--ink);
  font-family: var(--mono);
  overflow: hidden;
  transition: background-color 0.6s ease;
}

button { font: inherit; color: inherit; }

#dust {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 60;
}

/* ---------- stage ---------- */
.stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

body.slip .stage { animation: slip 1.3s cubic-bezier(.3,.1,.3,1); }
@keyframes slip {
  0% { transform: none; }
  20% { transform: translateX(-30px) rotate(-6deg); }
  45% { transform: translateX(40px) rotate(9deg); }
  70% { transform: translateX(-12px) rotate(-3deg); }
  100% { transform: none; }
}

/* ---------- hero (Raena) ---------- */
.hero {
  position: absolute;
  left: 50%;
  top: 1.5vh;
  width: 30vh;
  height: 46vh;
  transform: translateX(-50%);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  perspective: 1200px;
  z-index: 5;
}
.hero.flipped { z-index: 30; }
.hero:focus-visible { outline: 2px dashed var(--pink); outline-offset: 6px; border-radius: 16px; }

.hero-inner {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transition: transform 0.8s cubic-bezier(.2,.8,.2,1);
  transform-style: preserve-3d;
}
.hero.flipped .hero-inner { transform: rotateY(180deg); }
.hero:hover:not(.flipped) .hero-inner { transform: rotate(-2deg) scale(1.03); }

.hero-front, .hero-back {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.hero-front img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center top;
  filter: drop-shadow(0 10px 18px rgba(0,0,0,.45));
}
.hero-back {
  inset: 10% -40% auto -40%;
  transform: rotateY(180deg);
  background: #fff;
  color: #1c2a20;
  border-radius: 18px;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  text-align: left;
  box-shadow: 0 0 0 5px var(--pink), 0 18px 40px rgba(0,0,0,.5);
}
.quote { font-family: var(--round); font-weight: 500; font-size: clamp(12px, 1.75vh, 16px); line-height: 1.45; }
.quote-sig { font-family: var(--round); font-weight: 700; color: #c2508a; font-size: 1.05em; }

/* ---------- deck ---------- */
.deck {
  position: absolute;
  left: 50%;
  top: 40vh;
  width: min(440px, 88vw);
  transform: translateX(-50%);
  z-index: 20;
}
.deck-shadows {
  position: absolute;
  left: 0; right: 0; top: 100%;
  height: 120px;
  pointer-events: none;
}
.deck-shadows i {
  position: absolute;
  left: 50%;
  height: 26px;
  border: 1px solid var(--card-line);
  border-top: 0;
  border-radius: 0 0 16px 16px;
  transform: translateX(-50%);
}
.deck-shadows i:nth-child(1) { top: -14px; width: 96%; opacity: .8; }
.deck-shadows i:nth-child(2) { top: 0; width: 90%; opacity: .6; }
.deck-shadows i:nth-child(3) { top: 14px; width: 84%; opacity: .45; }
.deck-shadows i:nth-child(4) { top: 28px; width: 78%; opacity: .3; }
.deck-shadows i:nth-child(5) { top: 42px; width: 72%; opacity: .18; }

.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: 18px;
  padding: 16px 22px 22px;
  min-height: 250px;
  box-shadow: 0 24px 60px rgba(0,0,0,.45);
  transition: background .6s ease;
}
.card.swap-next .card-body { animation: inRight .35s ease; }
.card.swap-prev .card-body { animation: inLeft .35s ease; }
@keyframes inRight { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
@keyframes inLeft { from { opacity: 0; transform: translateX(-18px); } to { opacity: 1; transform: none; } }

.card-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}
.nav-btn {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 1px solid var(--card-line);
  background: transparent;
  cursor: pointer;
  line-height: 1;
  font-size: 15px;
  display: grid; place-items: center;
  padding: 0 0 2px;
}
.nav-btn:hover { background: var(--ink); color: var(--bg); }
.pager { font-weight: 700; color: var(--ink); min-width: 42px; text-align: center; }

.card-body { font-size: 14.5px; line-height: 1.6; }
.card-body h2 {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 10px;
  color: var(--pink);
}
body.day .card-body h2 { color: #b03f7a; }
.card-body p { margin: 0 0 12px; }
.card-body ul { list-style: none; margin: 0 0 12px; padding: 0; }
.card-body li { padding-left: 1.6em; text-indent: -1.6em; margin-bottom: 4px; }
.card-body .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.card-body .no { color: var(--muted); }
.big-price { font-family: var(--round); font-size: 44px; font-weight: 700; line-height: 1; margin: 4px 0 6px; }
.big-price small { font-size: 16px; font-weight: 500; color: var(--muted); }
.fine { font-size: 12px; color: var(--muted); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  border: 0;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform .15s ease;
}
.pill:hover { transform: translateY(-2px) rotate(-1deg); }
.pill.big {
  font-family: var(--round);
  font-size: 18px;
  padding: 12px 22px;
  background: linear-gradient(135deg, #ffb3d9, #ffe27a);
  color: #1b1b1b;
  box-shadow: 0 6px 24px rgba(255, 179, 217, .35);
}
.pill.ghost { background: transparent; color: var(--ink); border: 1px solid var(--card-line); }

/* ---------- stickers ---------- */
.stickers { position: absolute; inset: 0; z-index: 10; pointer-events: none; }

.sticker {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: calc(var(--w) * var(--scale, 1));
  transform: translate(-50%, -50%) rotate(var(--r));
  pointer-events: auto;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.sticker img {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,.4));
  animation: bob var(--bob, 6s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
  transition: transform .2s cubic-bezier(.3,1.6,.5,1);
}
.sticker:hover img, .sticker:focus-visible img { transform: scale(1.14) rotate(6deg); }
.sticker:active img { transform: scale(.94); }
.sticker:focus-visible { outline: 2px dashed var(--pink); outline-offset: 6px; border-radius: 10px; }

@keyframes bob {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -7px; }
}

.sticker .tag {
  position: absolute;
  left: 50%; bottom: -8px;
  transform: translateX(-50%) rotate(-4deg);
  white-space: nowrap;
  font-family: var(--round);
  font-size: 11px;
  font-weight: 600;
  background: #fff;
  color: #1a1a1a;
  padding: 2px 8px;
  border-radius: 6px;
  opacity: 0;
  transition: opacity .15s ease;
  pointer-events: none;
}
.sticker:hover .tag, .sticker:focus-visible .tag { opacity: 1; }
.sticker .tag:empty { display: none; }

/* sticker-specific effects */
.sticker.wiggle img { animation: wiggle .5s ease-in-out 3; }
@keyframes wiggle { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-18deg) scaleX(1.1); } 75% { transform: rotate(18deg) scaleX(.9); } }
.sticker.shake img { animation: shake .4s linear 3; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px) rotate(-8deg); } 75% { transform: translateX(6px) rotate(8deg); } }
.sticker.spin img { animation: spin 1s cubic-bezier(.4,1.6,.5,1); }
@keyframes spin { to { transform: rotate(360deg); } }
.sticker.flyaway { transition: left 2.2s ease-in-out, top 2.2s ease-in-out; }
.sticker.crawl { transition: left 6s linear; }
.sticker.follow { transition: none; z-index: 70; pointer-events: none; }
.sticker.popped { visibility: hidden; }

/* ---------- footer ---------- */
.footer {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  margin: 0;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  z-index: 25;
}
.linkish { background: none; border: 0; padding: 0; color: var(--pink); cursor: pointer; text-decoration: underline dotted; font-size: inherit; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  top: 18px;
  transform: translate(-50%, calc(-100% - 40px));
  visibility: hidden;
  max-width: min(420px, 92vw);
  background: #fff;
  color: #17221a;
  font-family: var(--round);
  font-weight: 500;
  font-size: 15px;
  line-height: 1.4;
  padding: 12px 18px;
  border-radius: 14px;
  box-shadow: 0 0 0 3px var(--pink), 0 14px 40px rgba(0,0,0,.4);
  z-index: 80;
  transition: transform .35s cubic-bezier(.3,1.4,.5,1), visibility 0s .35s;
  text-align: center;
}
.toast.show { transform: translate(-50%, 0); visibility: visible; transition-delay: 0s; }

/* ---------- modal ---------- */
dialog {
  border: 0;
  border-radius: 20px;
  padding: 22px;
  width: min(560px, 94vw);
  max-height: 92vh;
  background: #0a0d0a;
  color: #f4f7f2;
  box-shadow: 0 0 0 1px rgba(255,255,255,.25), 0 30px 80px rgba(0,0,0,.6);
  font-family: var(--mono);
}
dialog::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(3px); }
.modal-x {
  position: absolute; right: 12px; top: 10px;
  background: none; border: 0; color: #fff; font-size: 18px; cursor: pointer;
}
dialog h3 { font-family: var(--round); font-size: 24px; margin: 0 0 6px; }
dialog p { font-size: 13.5px; line-height: 1.55; margin: 0 0 12px; }
.video {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
}
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* games */
.game-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 12px;
  background: linear-gradient(#10261a, #1d3a26);
  touch-action: none;
  cursor: none;
}
.hud { display: flex; justify-content: space-between; font-size: 13px; margin: 0 0 8px; }
.menu { display: grid; gap: 10px; margin-top: 12px; }
.menu button {
  text-align: left;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.25);
  background: #121812;
  cursor: pointer;
  font-family: var(--round);
  font-size: 17px;
}
.menu button:hover { background: #1c261c; }
.menu small { display: block; font-family: var(--mono); font-size: 12px; color: #a9b8aa; margin-top: 2px; }

.quiz-item { font-family: var(--round); font-size: 54px; text-align: center; margin: 10px 0 2px; }
.quiz-name { font-family: var(--round); font-size: 22px; text-align: center; margin: 0 0 16px; }
.quiz-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quiz-btns button {
  padding: 14px; border-radius: 14px; border: 0; cursor: pointer;
  font-family: var(--round); font-size: 18px; font-weight: 600;
}
.quiz-btns .c { background: #7fd69b; color: #0b2414; }
.quiz-btns .t { background: #d0d4d8; color: #1c1f22; }
.quiz-feedback { min-height: 48px; margin-top: 14px; text-align: center; font-size: 14px; }
.progress { height: 6px; background: rgba(255,255,255,.12); border-radius: 3px; overflow: hidden; margin-bottom: 8px; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, #ffb3d9, #ffe27a); transition: width .3s ease; }

/* ---------- small screens: stack it ---------- */
/* phone-only pieces are hidden on desktop */
.mstage { display: contents; }
.tray-title, .cta-bar { display: none; }

/* ---------- phones & small tablets ---------- */
@media (max-width: 900px), (max-height: 560px) {
  html, body { height: auto; }
  body { overflow: visible; overflow-x: clip; background-size: 36px 36px; }
  button, a { touch-action: manipulation; }
  .stage {
    height: auto;
    min-height: 100svh;
    overflow: visible;
    overflow-x: clip;
    padding: 0 0 calc(96px + env(safe-area-inset-bottom));
  }

  /* top stage: Raena with stickers floating around her */
  .mstage {
    display: block;
    position: relative;
    height: clamp(340px, 56svh, 500px);
    max-width: 560px;
    margin: 0 auto;
  }
  .hero {
    position: absolute;
    left: 50%;
    top: 10px;
    transform: translateX(-50%);
    height: calc(100% - 4px);
    width: 42%;
    max-width: 230px;
  }
  .hero-back { inset: 18% -62% auto -62%; }
  .quote { font-size: 14px; }
  .mstage .sticker {
    position: absolute;
    left: var(--x);
    top: var(--y);
    width: var(--w);
    transform: translate(-50%, -50%) rotate(var(--r));
    z-index: 6;
  }
  .mstage .sticker .tag { display: none; }
  .mstage .sticker.mtag .tag {
    display: block; opacity: 1;
    bottom: -12px; font-size: 10px;
  }

  /* card deck */
  .deck {
    position: relative;
    left: auto; top: auto;
    transform: none;
    width: auto;
    max-width: 520px;
    margin: -44px 14px 0;
  }
  @media (min-width: 548px) { .deck { margin-left: auto; margin-right: auto; } }
  .deck-shadows { display: none; }
  .card { padding: 14px 18px 18px; min-height: var(--card-h, 280px); border-radius: 20px; }
  .card-body { font-size: 15px; line-height: 1.55; }
  .card-body h2 { font-size: 16px; }
  .card-body .cols { gap: 0 10px; font-size: 14px; }
  .nav-btn { width: 40px; height: 40px; font-size: 20px; }
  .card-nav { justify-content: space-between; margin-bottom: 6px; }
  .pager { font-size: 13px; }
  .swipe-hint { display: inline; }
  .pill.big { width: 100%; justify-content: center; font-size: 19px; padding: 14px 20px; }

  /* the tray */
  .tray-title {
    display: block;
    text-align: center;
    font-family: var(--round);
    font-size: 22px;
    margin: 34px 16px 4px;
  }
  .tray-title small {
    display: block;
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 400;
    color: var(--muted);
    margin-top: 4px;
  }
  .stickers {
    position: relative;
    inset: auto;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 28px 6px;
    max-width: 520px;
    margin: 0 auto;
    padding: 22px 12px 8px;
    pointer-events: auto;
  }
  .stickers .sticker {
    position: relative;
    left: auto !important; top: auto !important;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    transform: rotate(var(--tr, 0deg));
  }
  .stickers .sticker img { width: min(64px, 100%); }
  .stickers .sticker .tag {
    position: static;
    transform: rotate(-3deg);
    opacity: 1;
    margin-top: 2px;
    font-size: 10px;
    white-space: normal;
    text-align: center;
    line-height: 1.15;
    max-width: 84px;
  }
  .stickers .sticker .tag:empty { display: none; }
  .sticker.flyaway, .sticker.crawl { transition: none; }
  .sticker:hover img { transform: none; }

  /* always-visible sign-up */
  .cta-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    left: 12px; right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    height: 56px;
    border-radius: 999px;
    background: linear-gradient(135deg, #ffb3d9, #ffe27a);
    color: #1b1b1b;
    font-family: var(--round);
    font-weight: 600;
    font-size: 18px;
    text-decoration: none;
    box-shadow: 0 10px 30px rgba(0,0,0,.45), 0 0 0 3px rgba(255,255,255,.9);
    z-index: 50;
    transition: transform .25s ease;
  }
  .cta-bar:active { transform: scale(.97); }
  body.on-last .cta-bar { transform: translateY(160%); }

  .footer { position: static; transform: none; text-align: center; white-space: normal; padding: 22px 16px 0; }
  .toast { top: calc(12px + env(safe-area-inset-top)); }
  dialog { padding: 18px 14px; }
}
.swipe-hint { display: none; }

@media (prefers-reduced-motion: reduce) {
  .sticker img { animation: none; }
  .hero-inner { transition: none; }
  body.slip .stage { animation: none; }
}
