/* ===========================================================
   TACO STACK — The Papillion Taco Guy
   Warm taco-shop palette, hand-drawn edges, mobile first.
   =========================================================== */

:root {
  --cream:       #FFF8EC;
  --cream-deep:  #FBEBCE;
  --charcoal:    #2E2A27;
  --charcoal-soft:#5A524B;
  --shell:       #F2C14E;
  --shell-dark:  #D29A24;
  --shell-light: #FFDE8C;
  --tomato:      #E24B33;
  --tomato-dark: #B9351F;
  --cilantro:    #4C9A52;
  --cilantro-dark:#357A3B;

  --radius:      26px;
  --ink:         3px;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  font-family: var(--font);
  color: var(--charcoal);
  background: var(--cream);
  background-image:
    radial-gradient(circle at 12% 8%,  rgba(242,193,78,.22), transparent 42%),
    radial-gradient(circle at 88% 92%, rgba(226,75,51,.14), transparent 46%);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

/* ── Shell ────────────────────────────────────────────────── */

.app { width: 100%; display: flex; justify-content: center; }

.card {
  position: relative;
  width: 100%;
  max-width: 430px;
  background: var(--cream);
  border: var(--ink) solid var(--charcoal);
  border-radius: var(--radius);
  box-shadow: 0 6px 0 var(--charcoal), 0 16px 32px rgba(46,42,39,.14);
  overflow: hidden;
}

/* ── HUD ──────────────────────────────────────────────────── */

.hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  background: var(--shell);
  border-bottom: var(--ink) solid var(--charcoal);
}

.hud__item { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.hud__item--lives { align-items: flex-end; }
.hud__item--stack { align-items: center; }

.hud__label strong { font-size: 12px; color: var(--charcoal); }

.hud__label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(46,42,39,.62);
  white-space: nowrap;
}

.hud__value {
  font-size: 24px;
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.hud__value.is-pop { animation: pop .34s cubic-bezier(.3,1.6,.5,1); }



/* drops left */
.lives { display: flex; gap: 5px; margin: 4px 0 0; padding: 0; list-style: none; }
.lives li {
  width: 12px; height: 12px;
  border: 2px solid var(--charcoal);
  border-radius: 50%;
  background: var(--tomato);
  transition: background-color .18s ease, transform .18s ease, opacity .18s ease;
}
.lives li.is-lost { background: transparent; opacity: .4; transform: scale(.8); }
.lives.is-hit { animation: shake .34s ease; }

/* stack pips */
.pips { display: flex; gap: 5px; margin: 3px 0 0; padding: 0; list-style: none; }
.pips li {
  width: 11px; height: 11px;
  border: 2px solid var(--charcoal);
  border-radius: 50%;
  background: transparent;
  transition: background-color .14s ease, transform .14s ease;
}
.pips li.is-on { background: var(--tomato); transform: scale(1.12); }

/* ── Board + stage ────────────────────────────────────────── */

.board {
  position: relative;
  height: clamp(300px, 56vh, 540px);
  -webkit-user-select: none;
  user-select: none;
  background:
    linear-gradient(180deg, var(--cream-deep) 0%, var(--cream) 58%),
    var(--cream);
  overflow: hidden;
}

.stage {
  position: absolute;
  inset: 0;
  touch-action: none;
}

/* hand-drawn counter line the taco slides along */
.stage::after {
  content: "";
  position: absolute;
  left: 10px; right: 10px;
  bottom: 12px;
  height: 0;
  border-bottom: 3px dashed rgba(46,42,39,.16);
}

.layer { position: absolute; inset: 0; pointer-events: none; }

.board.is-bonus {
  box-shadow: inset 0 0 0 4px var(--tomato);
  background:
    linear-gradient(180deg, #FFE7B4 0%, var(--cream) 62%),
    var(--cream);
}

/* ── Falling ingredients ──────────────────────────────────── */

.ing {
  position: absolute;
  top: 0; left: 0;
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  font-size: 30px;
  line-height: 1;
  will-change: transform;
  user-select: none;
}

.ing--big {
  width: 62px; height: 62px;
  font-size: 50px;
  filter: drop-shadow(0 0 10px rgba(226,75,51,.65));
}

.ing--big::before {
  content: "";
  position: absolute;
  inset: -4px;
  border: 3px solid var(--tomato);
  border-radius: 50%;
  animation: halo 1.1s ease-in-out infinite;
}

/* ── The tortilla ─────────────────────────────────────────── */

.taco {
  position: absolute;
  pointer-events: none;
  bottom: 14px;
  left: 0;
  /* scales with the playfield so the catch feels the same on every screen;
     --taco-scale is the clean-streak reward, set from game.js */
  --taco-scale: 1;
  width: calc(22% * var(--taco-scale));
  min-width: calc(74px * var(--taco-scale));
  max-width: calc(104px * var(--taco-scale));
  will-change: transform;
}

/* The bounce lives on an inner element: .taco itself owns the transform that
   positions it horizontally, and an animation on the same element would wipe
   that out mid-bounce. */
.taco__body { position: relative; }
.taco__body.is-bounce { animation: bounce .42s cubic-bezier(.3,1.5,.5,1); }

.shell { display: block; width: 100%; height: auto; overflow: visible; }
.shell.is-grow   { animation: grow .42s cubic-bezier(.3,1.6,.5,1); }
.shell.is-shrink { animation: shrink .3s ease; }
.shell__body {
  fill: var(--shell);
  stroke: var(--charcoal);
  stroke-width: 4;
  stroke-linecap: round;
}
.shell__rim {
  fill: var(--shell-light);
  stroke: var(--charcoal);
  stroke-width: 4;
  stroke-linejoin: round;
}
.shell__toast {
  fill: none;
  stroke: var(--shell-dark);
  stroke-width: 4;
  stroke-linecap: round;
  opacity: .75;
}

/* stacked ingredients sit just above the rim */
.stack {
  position: absolute;
  bottom: 74%;
  left: 0;
  width: 100%;
  margin: 0; padding: 0;
  list-style: none;
  pointer-events: none;
}

.stack li {
  position: absolute;
  left: 50%;
  bottom: 0;
  font-size: 26px;
  line-height: 1;
  transform: translate(calc(-50% + var(--jitter, 0px)), var(--lift, 0px))
             rotate(var(--tilt, 0deg));
}

/* Only the ingredient that just landed carries this. An animation
   outranks an inline style, so the keyframes below have to restate
   the element's own position — otherwise every frame of the landing
   would snap it to the middle of the stack and back. */
.stack li.is-landing {
  animation: land .22s cubic-bezier(.3,1.5,.5,1);
}

/* ── Floating messages ────────────────────────────────────── */

.toasts {
  position: absolute;
  left: 0; right: 0;
  top: 16%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  pointer-events: none;
}

.toast {
  padding: 7px 15px;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: .01em;
  color: var(--cream);
  background: var(--charcoal);
  border-radius: 999px;
  white-space: nowrap;
  animation: float-up 1.1s ease-out forwards;
}

.toast--taco  { background: var(--cilantro); }
.toast--bonus { background: var(--tomato); font-size: 17px; }
.toast--miss  { background: var(--charcoal-soft); }
.toast--wide {
  background: var(--shell-light);
  color: var(--charcoal);
  border: 2px solid var(--charcoal);
}

.toast--level {
  background: var(--shell);
  color: var(--charcoal);
  border: 2px solid var(--charcoal);
  font-size: 16px;
  letter-spacing: .04em;
}

/* ── Particles ────────────────────────────────────────────── */

.bit {
  position: absolute;
  width: 9px; height: 9px;
  border-radius: 2px;
  will-change: transform, opacity;
  animation: bit .72s ease-out forwards;
}

.bonus-pill {
  position: absolute;
  pointer-events: none;
  top: 10px; left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  padding: 5px 13px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .06em;
  color: var(--cream);
  background: var(--tomato);
  border: 2px solid var(--charcoal);
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

/* ── Screens ──────────────────────────────────────────────── */

.screen {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 22px;
  text-align: center;
  overflow-y: auto;
  background: rgba(255,248,236,.96);
  backdrop-filter: blur(2px);
}

.screen[hidden] { display: none; }

.eyebrow {
  margin: 0;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--cilantro-dark);
}

.title {
  margin: 0;
  font-size: clamp(30px, 9vw, 40px);
  font-weight: 900;
  letter-spacing: -.02em;
  line-height: 1.04;
}
.title__emoji { display: inline-block; transform: rotate(-9deg); }
.title--result { font-size: clamp(24px, 7.2vw, 32px); }
.title--result:focus-visible { outline: 3px solid var(--cilantro); outline-offset: 6px; border-radius: 8px; }

.lede   { margin: 0; font-size: 17px; font-weight: 800; color: var(--tomato); }
.sub    { margin: 0 0 6px; font-size: 14px; font-weight: 600; color: var(--charcoal-soft); max-width: 25ch; }
.sub--result { margin: 4px 0 0; font-weight: 800; color: var(--cilantro-dark); }

.rank {
  margin: 2px 0 0;
  padding: 7px 18px;
  font-size: 19px;
  font-weight: 900;
  color: var(--charcoal);
  background: var(--shell);
  border: var(--ink) solid var(--charcoal);
  border-radius: 999px;
  transform: rotate(-1.6deg);
}

/* ── Buttons ──────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  padding: 13px 26px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: .05em;
  text-decoration: none;
  color: var(--charcoal);
  background: var(--cream);
  border: var(--ink) solid var(--charcoal);
  border-radius: 999px;
  box-shadow: 0 4px 0 var(--charcoal);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .09s ease, box-shadow .09s ease;
  -webkit-user-select: none; user-select: none;
}

.btn:hover { transform: translateY(-1px); box-shadow: 0 5px 0 var(--charcoal); }
.btn:active { transform: translateY(4px); box-shadow: 0 0 0 var(--charcoal); }

.btn:focus-visible {
  outline: 3px solid var(--cilantro-dark);
  outline-offset: 3px;
}

.btn--primary { background: var(--shell); }
.btn--tomato  { background: var(--tomato); color: var(--cream); }
.btn--ghost   { background: transparent; box-shadow: 0 3px 0 var(--charcoal); min-height: 44px; font-size: 14px; }
.btn--xl      { min-height: 60px; font-size: 19px; padding: 16px 34px; margin-top: 4px; }

.actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 280px;
  margin-top: 10px;
}

/* ── Logo slot (end screen) ───────────────────────────────── */

.brandmark {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Caps rather than a fixed size: whatever the shop's logo turns out
   to be, it has to sit above the result without pushing the buttons
   off a short screen. */
.brandmark__img {
  display: block;
  width: auto;
  height: auto;
  max-width: 170px;
  max-height: 62px;
}

/* ── "Presented by" credit (start screen) ─────────────────── */

.presented {
  margin: 6px 0 0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .04em;
  color: var(--charcoal-soft);
}

.presented a {
  color: var(--cilantro-dark);
  text-decoration: none;
  border-bottom: 2px solid rgba(53,122,59,.4);
}

.presented a:hover { border-bottom-color: var(--cilantro-dark); }

/* ── Newsletter signup (end screen) ───────────────────────── */

.signup {
  width: 100%;
  max-width: 280px;
  margin-top: 12px;
  padding: 14px 14px 12px;
  text-align: center;
  background: var(--cream);
  border: var(--ink) solid var(--charcoal);
  border-radius: 20px;
  box-shadow: 0 4px 0 var(--charcoal);
}

.signup__title {
  margin: 0;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: -.01em;
  color: var(--charcoal);
}

.signup__title a {
  color: var(--cilantro-dark);
  text-decoration: none;
  border-bottom: 2px solid rgba(53,122,59,.4);
}

.signup__title a:hover { border-bottom-color: var(--cilantro-dark); }

.signup__desc {
  margin: 5px 0 10px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--charcoal-soft);
}

.signup__row { display: flex; gap: 7px; }

/* 16px keeps iOS from zooming the whole board on focus — do not
   shrink this below 16px. */
.signup__input {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  padding: 9px 14px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  color: var(--charcoal);
  background: #fff;
  border: var(--ink) solid var(--charcoal);
  border-radius: 999px;
}

.signup__input::placeholder { color: rgba(90,82,75,.55); font-weight: 600; }
.signup__input:focus-visible { outline: 3px solid var(--cilantro-dark); outline-offset: 2px; }

.signup__go {
  flex: 0 0 auto;
  width: 46px;
  min-height: 42px;
  font-family: inherit;
  font-size: 19px;
  font-weight: 900;
  color: var(--charcoal);
  background: var(--shell);
  border: var(--ink) solid var(--charcoal);
  border-radius: 999px;
  box-shadow: 0 3px 0 var(--charcoal);
  cursor: pointer;
}

.signup__go:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--charcoal); }

.signup__go:disabled,
.signup__input:disabled { opacity: .55; cursor: default; }
.signup__go:disabled:active { transform: none; box-shadow: 0 3px 0 var(--charcoal); }
.signup__go:focus-visible { outline: 3px solid var(--cilantro-dark); outline-offset: 2px; }

.signup__note {
  margin: 9px 0 0;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
  color: var(--cilantro-dark);
}

.signup__note--error { color: var(--tomato-dark); }

.signup.is-done .signup__row { display: none; }

/* ── How to play ──────────────────────────────────────────── */

.how {
  margin: 4px 0 2px;
  padding: 12px 16px;
  max-width: 34ch;
  list-style: none;
  text-align: left;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--charcoal);
  background: var(--cream-deep);
  border: 2px dashed rgba(46,42,39,.3);
  border-radius: 18px;
}

.how li { position: relative; padding-left: 17px; }
.how li + li { margin-top: 6px; }
.how li::before {
  content: "";
  position: absolute;
  left: 0; top: .58em;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--cilantro);
}

/* show the control line that matches the device */
.how__touch { display: none; }
@media (pointer: coarse) {
  .how__keys  { display: none; }
  .how__touch { display: list-item; }
}

.keys { white-space: nowrap; }
.keys kbd + kbd { margin-left: 3px; }

.how kbd {
  display: inline-block;
  padding: 1px 5px;
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  background: var(--cream-deep);
  border: 2px solid var(--charcoal);
  border-radius: 5px;
}

/* ── Footer ───────────────────────────────────────────────── */

.brand {
  padding: 9px 14px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  text-align: center;
  color: rgba(46,42,39,.55);
  background: var(--cream-deep);
  border-top: var(--ink) solid var(--charcoal);
}

/* ── Animations ───────────────────────────────────────────── */

@keyframes grow    { 0% { transform: scaleX(.8) scaleY(.94); } 100% { transform: scaleX(1) scaleY(1); } }
@keyframes shrink  { 0% { transform: scaleX(1.2); } 100% { transform: scaleX(1); } }
@keyframes shake   { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 50% { transform: translateX(4px); } 75% { transform: translateX(-2px); } }
@keyframes pop     { 0% { transform: scale(1); } 45% { transform: scale(1.42); } 100% { transform: scale(1); } }
@keyframes bounce  { 0% { transform: translateY(0) scale(1); } 35% { transform: translateY(7px) scale(1.1,.9); } 70% { transform: translateY(-5px) scale(.96,1.05); } 100% { transform: translateY(0) scale(1); } }
@keyframes land {
  from {
    transform: translate(calc(-50% + var(--jitter, 0px)), calc(var(--lift, 0px) - 14px))
               rotate(var(--tilt, 0deg)) scale(.7);
    opacity: 0;
  }
  to {
    transform: translate(calc(-50% + var(--jitter, 0px)), var(--lift, 0px))
               rotate(var(--tilt, 0deg)) scale(1);
    opacity: 1;
  }
}
@keyframes halo    { 0%,100% { transform: scale(1); opacity: .9; } 50% { transform: scale(1.14); opacity: .35; } }
@keyframes float-up{ 0% { transform: translateY(10px) scale(.86); opacity: 0; } 18% { transform: translateY(0) scale(1); opacity: 1; } 72% { opacity: 1; } 100% { transform: translateY(-26px); opacity: 0; } }
@keyframes bit     { 0% { transform: translate(0,0) rotate(0); opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)) rotate(var(--dr)); opacity: 0; } }

/* ── Desktop polish ───────────────────────────────────────── */

@media (min-width: 560px) and (min-height: 700px) {
  .card { max-width: 460px; }
  .board { height: 560px; }
}

/* ── Short viewports (landscape phones, small windows) ────── */

@media (max-height: 700px) {
  .screen { gap: 6px; }
  .screen--end .title--result { font-size: clamp(20px, 6vw, 26px); }
  .actions { gap: 8px; margin-top: 6px; }
}

@media (max-height: 600px) {
  body { padding: 6px; }
  .board { height: clamp(210px, 54vh, 380px); }
  .hud { padding: 7px 12px; }
  .hud__value { font-size: 20px; }
  .brand { padding: 6px 12px; font-size: 10px; }
  .screen { gap: 6px; padding: 14px; }
  .btn--xl { min-height: 50px; font-size: 17px; }
  .how { font-size: 12px; padding: 9px 13px; margin: 0; }
  .how li + li { margin-top: 3px; }
  .how__extra { display: none; }   /* keep only move / make a taco / how you lose */
  .sub:not(.sub--result) { display: none; }
}

/* Very short viewports (landscape phones): lay the end-screen buttons out
   in a row so the result still fits without scrolling. */
@media (max-height: 430px) {
  .actions { flex-direction: row; max-width: none; gap: 8px; }
  .actions .btn { padding: 10px 12px; font-size: 13px; min-height: 42px; flex: 1; }
  .btn--ghost { min-height: 42px; }
  .rank { font-size: 15px; padding: 5px 14px; }
  .title--result { font-size: clamp(18px, 5vw, 22px); }
  .sub--result, #statsLine { font-size: 12px; }
}

/* ── Respect reduced motion ───────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .hud__value.is-pop,
  .lives.is-hit,
  .shell.is-grow,
  .shell.is-shrink,
  .taco__body.is-bounce,
  .stack li.is-landing,
  .ing--big::before { animation: none; }
  .toast { animation: float-up 1.1s linear forwards; }
  .btn { transition: none; }
}
