/* Pumpkin Slicer — dusk over the pumpkin field.
   The same sky as Pumpkin Smash behind everything (a fixed SVG), the field is
   a CSS band at the foot of the play screen, and play is one full-screen
   transparent canvas with a light DOM HUD on top. Same type, navy ink and
   chroma palette as the rest of the arcade. Safe areas follow the house
   convention (scripts/safe-area-sweep/README.md). */

:root {
  --pz-ink: #1b233e;
  --pz-navy: #1b233e;
  --pz-cream: #fff6e5;
  --pz-cream-soft: #ffe6c2;
  --pz-orange: #f39422;
  --pz-teal: #176877;
  --pz-teal-edge: #124b56;
  --pz-sky1: #2b2456;
  --pz-sky2: #6a3f8f;
  --pz-sky3: #e9874f;
  --pz-grass: #5fa64b;
  --pz-grass-dark: #4b8a3b;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0; min-height: 100%;
  font-family: Nunito, system-ui, -apple-system, sans-serif;
  color: var(--pz-ink);
  background: linear-gradient(180deg, var(--pz-sky1) 0%, var(--pz-sky2) 48%, var(--pz-sky3) 100%);
  -webkit-text-size-adjust: 100%;
}
body { overscroll-behavior: none; min-height: 100svh; -webkit-tap-highlight-color: transparent; }

/* Rob's Hall of the Mountain King castle (HOTMK-BG-2): open sky on the left
   for the flying pumpkins, the castle kept in view at the right. */
.pz-scenery {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: #0d062a url("../../../assets/pumpkins/bg/castle-2.jpg") 82% 100% / cover no-repeat;
}
/* Upright: "cover" filled the phone with castle, right behind the pumpkins.
   Stand it ON the grass (the field's top is 78% down), 55% tall; its sky's
   top colour fills above, its ground colour below (the menu shows that). */
@media (orientation: portrait) {
  .pz-scenery {
    background:
      url("../../../assets/pumpkins/bg/castle-2.jpg") left 82% bottom 21svh / auto 55svh no-repeat,
      linear-gradient(0deg, #5635a4 0 21.5svh, #0d062a 21.5svh);
  }
}
.pz-scenery svg { width: 100%; height: 100%; display: block; }
.pz-bat { animation: pz-fly 46s ease-in-out infinite alternate; }
@keyframes pz-fly { from { transform: translate(-40px, 10px); } to { transform: translate(80px, -24px); } }
.pz-stars circle { animation: pz-twinkle 3.2s ease-in-out infinite alternate; }
.pz-stars circle:nth-child(2n) { animation-delay: -1.1s; }
.pz-stars circle:nth-child(3n) { animation-delay: -2.3s; }
@keyframes pz-twinkle { from { opacity: 0.35; } to { opacity: 1; } }

.pz-app { position: relative; min-height: 100svh; z-index: 1; }

/* ── Menu ─────────────────────────────────────────────────────────────── */
.pz-menu {
  min-height: 100svh;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: calc(72px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) calc(28px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.pz-title {
  margin: 0;
  font-size: clamp(40px, 8.5vw, 68px); font-weight: 900; line-height: 1; letter-spacing: -0.5px;
  color: var(--pz-cream); text-align: center;
  text-shadow: 0 3px 0 rgba(43, 20, 60, 0.45);
}
.pz-title span { color: var(--pz-orange); }
.pz-sub { margin: 2px 0 0; font-size: clamp(15px, 2.8vw, 20px); font-weight: 800; color: var(--pz-cream-soft); text-align: center; }
.pz-hero {
  display: flex; align-items: flex-end; justify-content: center; gap: 2%;
  width: min(560px, 100%); height: clamp(64px, 11vw, 96px); margin-top: 4px;
}
.pz-hero .pa-pumpkin { height: calc(var(--pa-h) * 100%); width: auto; animation: pz-bob 2.6s ease-in-out infinite; }
.pz-hero .pa-pumpkin:nth-child(2n) { animation-delay: -0.8s; }
.pz-hero .pa-pumpkin:nth-child(3n) { animation-delay: -1.7s; }
@keyframes pz-bob { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-6px) rotate(3deg); } }
.pz-page .kid-quick-start { margin: 8px auto 2px; background: var(--pz-teal); }
.pz-page .kid-quick-start:hover { background: var(--pz-teal-edge); }
.pz-quick-blurb { color: #fff; font-size: 16px; font-weight: 800; }

.pz-labels { display: flex; gap: 8px; margin: 4px 0 2px; }
.pz-pill {
  min-height: 48px; padding: 0 18px;
  border: 2px solid rgba(255, 246, 229, 0.35); border-radius: 999px;
  background: rgba(253, 251, 246, 0.88); color: var(--pz-navy);
  font: 800 16px/1 Nunito, system-ui, sans-serif; cursor: pointer;
}
.pz-pill[aria-pressed="true"] { background: var(--pz-navy); border-color: var(--pz-navy); color: #fff; }
.pz-pill:focus-visible { outline: 4px solid #fff; outline-offset: 3px; }

.pz-levels-title { margin: 12px 0 2px; font-size: 22px; font-weight: 900; color: var(--pz-cream); text-shadow: 0 2px 0 rgba(43, 20, 60, 0.4); }
.pz-levels {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 176px), 1fr));
  gap: 12px; width: min(960px, 100%);
}
.pz-level {
  position: relative;
  display: grid; grid-template-columns: 44px minmax(0, 1fr); grid-template-rows: auto auto auto;
  column-gap: 10px; align-items: center;
  min-height: 92px; padding: 12px 12px 10px;
  border: 0; border-radius: 16px;
  background: rgba(255, 255, 255, 0.94); color: var(--pz-ink);
  text-align: left; font: inherit; cursor: pointer;
  box-shadow: 0 4px 0 rgba(43, 20, 60, 0.28);
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.pz-level:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 0 rgba(43, 20, 60, 0.28); }
.pz-level:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 rgba(43, 20, 60, 0.28); }
.pz-level:focus-visible { outline: 4px solid #fff; outline-offset: 3px; }
.pz-level-emoji { grid-row: 1 / span 3; font-size: 32px; text-align: center; }
.pz-level-name { font-size: 17px; font-weight: 900; line-height: 1.15; color: var(--pz-navy); }
.pz-level-num { color: #6a5a86; font-weight: 800; margin-right: 4px; }
.pz-level-dots { display: flex; flex-wrap: wrap; gap: 3px; margin: 3px 0 1px; }
.pz-level-dots i { width: 12px; height: 12px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1.5px rgba(0, 0, 0, 0.08); }
.pz-level-blurb { font-size: 13px; font-weight: 700; color: #5a4a6e; line-height: 1.25; }
.pz-level-stars { font-size: 15px; letter-spacing: 1px; color: #f2b72b; }
.pz-level-stars .off { color: #d9d2e3; }
.pz-level.is-locked { background: rgba(255, 255, 255, 0.55); cursor: not-allowed; }
.pz-level.is-locked :is(.pz-level-emoji, .pz-level-name, .pz-level-dots) { opacity: 0.5; }
.pz-level.is-paywalled { cursor: pointer; }

/* ── Play ─────────────────────────────────────────────────────────────── */
.pz-play {
  position: fixed; inset: 0; overflow: hidden;
  /* the field: a grass band the pumpkins fly up from */
  background: linear-gradient(180deg, transparent 0 78%, var(--pz-grass) 78%, var(--pz-grass-dark) 100%);
  /* the canvas IS the controller: no scrolling, zooming or text selection */
  touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.pz-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }

/* Hearts + count sit under the chrome's Menu pill. */
.pz-hud {
  position: absolute;
  top: calc(70px + env(safe-area-inset-top));
  left: max(12px, calc(12px + env(safe-area-inset-left)));
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  pointer-events: none;
}
.pz-hearts {
  display: flex; gap: 4px; padding: 6px 10px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.9); box-shadow: 0 3px 0 rgba(43, 20, 60, 0.3);
  font-size: 22px; line-height: 1;
}
.pz-hearts .off { filter: grayscale(1); opacity: 0.35; }
.pz-hearts.is-hit { animation: pz-shake 360ms ease-out; }
@keyframes pz-shake { 20% { transform: translateX(-5px); } 45% { transform: translateX(5px); } 70% { transform: translateX(-3px); } }
.pz-count {
  display: flex; flex-direction: column; align-items: center;
  min-width: 84px; padding: 6px 12px 8px; border-radius: 16px;
  background: rgba(255, 255, 255, 0.9); box-shadow: 0 3px 0 rgba(43, 20, 60, 0.3);
}
.pz-count b { font-size: 26px; font-weight: 900; line-height: 1.1; font-variant-numeric: tabular-nums; }
.pz-count small { font-size: 12px; font-weight: 900; letter-spacing: 0.6px; text-transform: uppercase; color: #5a4a6e; }
.pz-count.is-bump b { animation: pz-bump 260ms ease-out; }
@keyframes pz-bump { 40% { transform: scale(1.3); } }

/* The pattern ticket: top centre, between the chrome's Menu and Pause pills. */
.pz-ticket {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  /* max-content: an absolute box at left:50% otherwise shrinks to HALF the
     screen and wraps a 3-note song onto two rows */
  width: max-content; max-width: calc(100% - 200px);
  padding: 6px 14px 6px 10px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.94); box-shadow: 0 3px 0 rgba(43, 20, 60, 0.3);
  pointer-events: none;
}
.pz-ticket-icon { font-size: 22px; }
.pz-ticket-notes { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; }
/* --pz-chip is set by fitTicket() so a long pattern fits one row */
.pz-note {
  --c: #9aa3b8;
  display: inline-grid; place-items: center;
  min-width: var(--pz-chip, 34px); height: var(--pz-chip, 34px); padding: 0 calc(var(--pz-chip, 34px) * 0.12); border-radius: 999px;
  background: var(--c); color: #fff;
  font-size: calc(var(--pz-chip, 34px) * 0.41); font-weight: 900; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}
.pz-note.is-dark { color: #512d1b; text-shadow: none; }   /* yellow Mi, orange Re, green Fa */
.pz-note.is-done { opacity: 0.35; }
.pz-note.is-next { animation: pz-next 900ms ease-in-out infinite; outline: 3px solid var(--pz-ink); outline-offset: 2px; }
.pz-note.is-sing { animation: pz-sing 340ms ease-out; }
@keyframes pz-next { 50% { transform: scale(1.14); } }
@keyframes pz-sing { 40% { transform: scale(1.35); } }

.pz-toast {
  position: absolute;
  top: calc(150px + env(safe-area-inset-top));
  left: 50%; transform: translate(-50%, -8px);
  padding: 8px 18px; border-radius: 999px;
  background: rgba(27, 35, 62, 0.88); color: #fff;
  font-size: 20px; font-weight: 900; white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}
.pz-toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.pz-banner {
  position: absolute; top: 34%; left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  padding: 0 16px; color: #fff;
  font-size: clamp(34px, 7vw, 64px); font-weight: 900; text-align: center; line-height: 1.05;
  text-shadow: 0 4px 0 rgba(43, 20, 60, 0.55);
  opacity: 0; pointer-events: none;
  transition: opacity 220ms ease, transform 220ms ease;
}
.pz-banner.is-on { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* ── Results ──────────────────────────────────────────────────────────── */
.pz-veil {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: rgba(30, 16, 50, 0.5); overflow-y: auto;
}
.pz-card {
  width: min(440px, 100%); padding: 22px 22px 18px; border-radius: 24px;
  background: #fff; text-align: center;
  box-shadow: 0 10px 0 rgba(43, 20, 60, 0.3);
  animation: pz-pop 280ms ease-out;
}
@keyframes pz-pop { from { transform: scale(0.9); opacity: 0; } }
.pz-card h2 { margin: 0; font-size: 30px; font-weight: 900; color: var(--pz-navy); }
.pz-stars { margin: 6px 0 2px; font-size: 40px; letter-spacing: 4px; color: #f2b72b; }
.pz-stars .off { color: #dde5ec; }
.pz-big { display: flex; flex-direction: column; align-items: center; margin: 4px 0; }
.pz-big span { font-size: 56px; font-weight: 900; line-height: 1; color: var(--pz-orange); }
.pz-big small { font-size: 15px; font-weight: 800; color: #5a4a6e; }
.pz-stats { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; margin: 10px 0; font-size: 15px; font-weight: 700; color: #5a4a6e; }
.pz-stats b { color: var(--pz-ink); }
.pz-noterow { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 6px 0 10px; }
.pz-card button {
  display: block; width: 100%; min-height: 56px; margin-top: 10px;
  border: 0; border-radius: 16px;
  font: 900 20px/1 Nunito, system-ui, sans-serif; cursor: pointer;
}
.pz-card button:focus-visible { outline: 4px solid #183e74; outline-offset: 3px; }
.pz-next { background: var(--pz-teal); color: #fff; }
.pz-next:hover { background: var(--pz-teal-edge); }
.pz-again { background: #fff1e3; color: #8a4a05; }
.pz-menu-btn { background: transparent; color: #5a4a6e; min-height: 48px !important; font-size: 17px !important; }

/* Upright phones: the ticket drops to its own row under the chrome, and the
   hearts/count move under it. */
@media (max-width: 560px) {
  .pz-ticket { max-width: calc(100% - 24px); top: calc(66px + env(safe-area-inset-top)); }
  /* --pz-ticket-b is the ticket's real bottom edge (placeHud), so a two-row
     ticket for the long songs never sits on the hearts */
  .pz-hud { top: calc(var(--pz-ticket-b, calc(114px + env(safe-area-inset-top))) + 10px); flex-direction: row; align-items: center; }
  .pz-hud.no-ticket { top: calc(70px + env(safe-area-inset-top)); }
  .pz-count { flex-direction: row; gap: 6px; min-width: 0; padding: 6px 12px; }
  .pz-count b { font-size: 22px; }
  .pz-note { --pz-chip-max: 30px; }
  .pz-toast { top: calc(var(--pz-ticket-b, calc(114px + env(safe-area-inset-top))) + 72px); }
}

/* Short screens (a phone on its side): the results card fits without
   scrolling, so Play again is never below the fold. */
@media (max-height: 500px) {
  .pz-veil { padding-top: max(10px, env(safe-area-inset-top)); padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .pz-card { padding: 12px 18px 10px; }
  .pz-card h2 { font-size: 24px; }
  .pz-stars { margin: 2px 0 0; font-size: 28px; }
  .pz-big span { font-size: 38px; }
  .pz-stats { margin: 4px 0; }
  .pz-noterow { margin: 4px 0 6px; }
  .pz-card button { min-height: 46px; margin-top: 6px; font-size: 18px; }
  .pz-menu-btn { min-height: 40px !important; }
}
/* ...and when it is also wide, the buttons stand beside the score. */
@media (max-height: 500px) and (min-width: 600px) {
  .pz-card {
    width: min(700px, 100%);
    display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); column-gap: 20px;
    align-content: center; align-items: center;
  }
  .pz-res-info { grid-column: 1; grid-row: 1 / span 4; }
  .pz-card > button, .pz-card > .pgc-exit { grid-column: 2; }
  .pz-card > button:first-of-type { margin-top: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .pz-bat, .pz-stars circle, .pz-hero .pa-pumpkin, .pz-note.is-next, .pz-note.is-sing, .pz-count.is-bump b, .pz-card, .pz-hearts.is-hit { animation: none; }
}
