:root {
  --night: #070b1f;
  --night-2: #101a45;
  --gold: #f5c542;
  --gold-deep: #d99a1e;
  --gold-soft: #ffe7a1;
  --red: #d7263d;
  --ink: #f7f4ea;
  --muted: #b9c0dc;
  --grass-1: #1f7a3a;
  --grass-2: #186b31;
  --panel: rgba(8, 12, 32, 0.72);
  --size: 300px;          /* rendered sprite size, set by app.js */
  --ground: 40px;         /* distance from stage bottom to the feet line */
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--night);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

body { overflow-x: hidden; }

/* ---------- Layout ---------- */

.hero {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto minmax(300px, 1fr);
  overflow: hidden;
}

/* Hidden completely (no stadium, Ronaldo or controls) until the forgiveness question is answered. */
.hero[hidden] { display: none; }

/* ---------- Scenery (pure CSS) ---------- */

.scenery { position: absolute; inset: 0; z-index: -1; pointer-events: none; }

.sky {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 60% 40% at 50% 0%, rgba(80, 110, 220, 0.35), transparent 70%),
    radial-gradient(1px 1px at 12% 18%, rgba(255,255,255,.8), transparent 60%),
    radial-gradient(1px 1px at 28% 8%, rgba(255,255,255,.6), transparent 60%),
    radial-gradient(1.5px 1.5px at 44% 22%, rgba(255,255,255,.7), transparent 60%),
    radial-gradient(1px 1px at 63% 12%, rgba(255,255,255,.7), transparent 60%),
    radial-gradient(1.5px 1.5px at 81% 20%, rgba(255,255,255,.6), transparent 60%),
    radial-gradient(1px 1px at 92% 6%, rgba(255,255,255,.8), transparent 60%),
    linear-gradient(180deg, #050817 0%, var(--night-2) 55%, #17245a 100%);
}

.floodlight {
  position: absolute; top: 4%;
  width: 54px; height: 22px;
  border-radius: 6px;
  background: repeating-linear-gradient(90deg, #fffbe6 0 8px, #d9d3b0 8px 10px);
  box-shadow: 0 0 24px 10px rgba(255, 244, 200, .55), 0 0 90px 40px rgba(255, 230, 160, .18);
}
.floodlight--left  { left: 6%;  transform: rotate(-8deg); }
.floodlight--right { right: 6%; transform: rotate(8deg); }

.beam {
  position: absolute; top: 12px; left: 50%;
  width: 46vw; height: 80vh;
  transform-origin: top left;
  background: linear-gradient(180deg, rgba(255, 243, 200, .16), rgba(255, 243, 200, 0) 75%);
  clip-path: polygon(0 0, 8% 0, 100% 100%, 40% 100%);
  filter: blur(2px);
}
.floodlight--left .beam  { transform: rotate(-12deg); }
.floodlight--right .beam { left: auto; right: 50%; transform-origin: top right; transform: rotate(12deg); clip-path: polygon(92% 0, 100% 0, 60% 100%, 0 100%); }

.crowd {
  position: absolute; left: 0; right: 0;
  bottom: calc(var(--ground) + var(--size) * .28);
  height: min(30%, 140px);
  background:
    radial-gradient(circle at 50% 30%, rgba(245, 197, 66, .55) 0 1.4px, transparent 2px) 0 0 / 23px 17px,
    radial-gradient(circle at 50% 30%, rgba(215, 38, 61, .5) 0 1.4px, transparent 2px) 9px 6px / 29px 19px,
    radial-gradient(circle at 50% 60%, #0b1030 0 6px, transparent 6.5px) 0 0 / 14px 13px,
    radial-gradient(circle at 50% 60%, #121a44 0 6px, transparent 6.5px) 7px 6px / 14px 13px,
    linear-gradient(180deg, #0d1336, #0a0f2a);
  border-bottom: 6px solid #0a0e24;
  mask-image: linear-gradient(180deg, transparent, #000 35%);
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 35%);
}

/* ---------- Banner / message ---------- */

.banner {
  position: relative;
  padding: max(20px, env(safe-area-inset-top)) 16px 8px;
  text-align: center;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: .78rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--gold-soft);
  opacity: .85;
}

.message {
  margin: 0 auto;
  max-width: 22ch;
  display: grid;
  place-items: center;
  font-size: clamp(2.1rem, 7vw + .4rem, 4.8rem);
  line-height: 1.02;
  font-weight: 900;
  letter-spacing: .01em;
  overflow-wrap: anywhere;
}

/* The greeting always takes its space (so the stage never resizes); it is only made visible on landing. */
.message__reveal {
  display: grid;
  gap: .06em;
  opacity: 0;
  transition: opacity .45s ease;
}

.message__line {
  background: linear-gradient(180deg, #fff6d4 0%, var(--gold) 55%, var(--gold-deep) 100%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 0 rgba(0,0,0,.45)) drop-shadow(0 0 22px rgba(245,197,66,.35));
}

.message__suu {
  color: #fff;
  font-size: 1.08em;
  letter-spacing: .04em;
  text-shadow: 0 3px 0 var(--red), 0 0 24px rgba(215, 38, 61, .6);
}

.message.is-revealed .message__reveal { opacity: 1; transition: none; animation: pop-in .55s cubic-bezier(.2, 1.4, .4, 1) both; }
.message.is-revealed .message__suu   { animation: pop-in .55s .18s cubic-bezier(.2, 1.4, .4, 1) both; }
.message.is-revealed.is-fading .message__reveal { opacity: 0; transition: opacity .45s ease; }

.hero.is-paused .message * { animation-play-state: paused; }

@keyframes pop-in {
  from { opacity: 0; transform: scale(.6) translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Stage ---------- */

.stage {
  position: relative;
  min-height: 300px;
  overflow: hidden;   /* nothing leaks horizontally; JS sizes the sprite so the jump apex fits */
}

.pitch {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: calc(var(--ground) + var(--size) * .28);
  background:
    linear-gradient(180deg, rgba(0,0,0,.35), transparent 30%),
    repeating-linear-gradient(90deg, var(--grass-1) 0 9%, var(--grass-2) 9% 18%);
  border-top: 3px solid rgba(255,255,255,.85);
  box-shadow: 0 -18px 40px rgba(0,0,0,.35);
}

.pitch__line {
  position: absolute; left: 50%; top: 0; bottom: 0;
  width: 3px; transform: translateX(-50%);
  background: rgba(255,255,255,.6);
}

.pitch__circle {
  position: absolute; left: 50%; top: 50%;
  width: min(60vw, 420px); aspect-ratio: 4 / 1;
  transform: translate(-50%, -30%);
  border: 3px solid rgba(255,255,255,.55);
  border-radius: 50%;
}

.shadow {
  position: absolute; left: 0; bottom: calc(var(--ground) - var(--size) * .03);
  width: calc(var(--size) * .5); height: calc(var(--size) * .07);
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(0,0,0,.55), transparent);
  will-change: transform, opacity;
}

/* The single character wrapper: every frame uses the same square box and anchor. */
.player {
  position: absolute; left: 0;
  bottom: calc(var(--ground) - var(--size) * .043);   /* feet sit at ~400/418 of each canvas */
  width: var(--size); height: var(--size);
  will-change: transform;
}

.player__body {
  position: relative;
  width: 100%; height: 100%;
  transform-origin: 50% 95.7%;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,.45));
}

.frame {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  visibility: hidden;
  user-select: none; -webkit-user-select: none;
  pointer-events: none;
}
.frame.is-active { visibility: visible; }

/* ---------- Corner buttons ---------- */

.corner-btn {
  position: absolute;
  z-index: 2;
  bottom: max(14px, env(safe-area-inset-bottom));
  width: 44px; height: 44px;
  display: grid; place-items: center;
  padding: 0;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid rgba(245, 197, 66, .35);
  border-radius: 50%;
  box-shadow: 0 6px 18px rgba(0,0,0,.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  cursor: pointer;
  opacity: .82;
  transition: opacity .15s, background .15s, transform .1s;
}
.corner-btn--left  { left:  max(14px, env(safe-area-inset-left)); }
.corner-btn--right { right: max(14px, env(safe-area-inset-right)); }
.corner-btn:hover:not(:disabled) { opacity: 1; background: rgba(20, 28, 70, .9); }
.corner-btn:active:not(:disabled) { transform: scale(.94); }
.corner-btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; opacity: 1; }
.corner-btn:disabled { opacity: .35; cursor: not-allowed; }
.corner-btn[aria-pressed="true"] { border-color: var(--gold); color: var(--gold-soft); }

.icon {
  width: 20px; height: 20px;
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat;
}
.icon--pause {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='6' y='5' width='4' height='14' rx='1'/%3E%3Crect x='14' y='5' width='4' height='14' rx='1'/%3E%3C/svg%3E");
}
.corner-btn[data-state="paused"] .icon--pause {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M8 5.5v13a1 1 0 0 0 1.5.86l10-6.5a1 1 0 0 0 0-1.72l-10-6.5A1 1 0 0 0 8 5.5z'/%3E%3C/svg%3E");
}
/* Muted speaker by default; full speaker when sound is on. */
.icon--sound {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 9v6h4l5 4V5L7 9H3z'/%3E%3Cpath d='M16 9l6 6M22 9l-6 6' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
}
.corner-btn[aria-pressed="true"] .icon--sound {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 9v6h4l5 4V5L7 9H3z'/%3E%3Cpath d='M15.5 8.5a5 5 0 0 1 0 7' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'/%3E%3Cpath d='M18 6a8.5 8.5 0 0 1 0 12' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
}

/* ---------- Confetti ---------- */

.confetti {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 1;   /* above the scenery and player, below the corner buttons */
}

/* ---------- Narrow phones ---------- */

@media (max-width: 640px) {
  .floodlight { width: 38px; height: 16px; }
  .eyebrow { padding-inline: 40px; font-size: .68rem; letter-spacing: .1em; }
}

/* ---------- Forgiveness screen ---------- */
/* No ancestor of the No button uses transform / filter / backdrop-filter (the blur lives on
   pseudo-elements), so position: fixed on No is relative to the viewport while it runs. */

.forgive {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  overflow-x: hidden;
  overflow-y: auto;          /* short phones can scroll the card */
  overscroll-behavior: contain;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  opacity: 1;
  transition: opacity .4s ease;
}
.forgive::before {
  content: "";
  position: absolute; inset: 0;
  position: fixed;
  background: var(--night);   /* plain dark: the birthday page is hidden until Yes */
}
.forgive.is-leaving { opacity: 0; pointer-events: none; }
.forgive[hidden] { display: none; }

.forgive__card {
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
  margin: auto;              /* centred, but scrolls from the top when taller than the screen */
  padding: clamp(22px, 5vw, 36px) clamp(18px, 5vw, 36px) clamp(18px, 4vw, 28px);
  text-align: center;
  border: 1px solid rgba(245, 197, 66, .4);
  border-radius: 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5), 0 0 0 1px rgba(255, 255, 255, .04) inset;
  animation: forgive-in .5s ease both;
}
.forgive__card::before {
  content: "";
  position: absolute; inset: 0; z-index: -1;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(20, 30, 78, .92), rgba(8, 12, 32, .94));
}
@keyframes forgive-in { from { opacity: 0; } to { opacity: 1; } }

.forgive__dancer {
  display: block;
  width: 180px; height: 180px;
  margin: -8px auto 6px;
  pointer-events: none;      /* decoration, not a control */
  user-select: none; -webkit-user-select: none;
}
@media (min-width: 900px) and (min-height: 820px) { .forgive__dancer { width: 196px; height: 196px; } }
@media (max-height: 740px) { .forgive__dancer { width: 160px; height: 160px; } }

.forgive__text { display: grid; gap: .7em; }
.forgive__text p { margin: 0; }

.forgive__title {
  margin: 0;
  font-size: clamp(1.5rem, 4.6vw + .3rem, 2.3rem);
  line-height: 1.12;
  font-weight: 900;
  background: linear-gradient(180deg, #fff6d4 0%, var(--gold) 55%, var(--gold-deep) 100%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.forgive__emoji { color: initial; -webkit-text-fill-color: initial; }

.forgive__body {
  font-size: clamp(1rem, 1.6vw + .7rem, 1.18rem);
  line-height: 1.45;
  color: var(--ink);
  opacity: .92;
}

.forgive__bad {
  font-size: clamp(1.8rem, 6vw + .3rem, 2.8rem);
  font-weight: 900;
  letter-spacing: .06em;
  color: #fff;
  text-shadow: 0 3px 0 var(--red), 0 0 24px rgba(215, 38, 61, .55);
}

.forgive__ask {
  font-size: clamp(1.15rem, 2vw + .8rem, 1.45rem);
  font-weight: 800;
  color: var(--gold-soft);
}

.forgive__actions {
  margin-top: clamp(18px, 4vw, 26px);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 18px 22px;
}

.forgive__yes {
  min-width: 180px;
  min-height: 62px;
  padding: 14px 44px;
  font: inherit;
  font-size: 1.45rem;
  font-weight: 900;
  letter-spacing: .03em;
  color: #231600;
  background: linear-gradient(180deg, #ffe08a, var(--gold) 50%, var(--gold-deep));
  border: 1px solid #ffe9a8;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(245, 197, 66, .35), 0 0 0 6px rgba(245, 197, 66, .12);
  cursor: pointer;
  transition: transform .12s, box-shadow .15s;
}
.forgive__yes:hover { box-shadow: 0 10px 30px rgba(245, 197, 66, .5), 0 0 0 8px rgba(245, 197, 66, .16); }
.forgive__yes:active { transform: translateY(1px) scale(.98); }
.forgive__yes:focus-visible { outline: 3px solid #fff; outline-offset: 4px; }

/* The slot keeps No's original space, so Yes never shifts when No starts running. */
.forgive__no-slot { display: inline-block; position: relative; }

.forgive__no {
  position: relative;
  z-index: 3;
  min-height: 36px;
  padding: 6px 16px;
  font: inherit;
  font-size: .95rem;
  font-weight: 800;
  color: var(--ink);
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .3);
  border-radius: 999px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.forgive__no:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.forgive__no.is-loose {
  position: fixed;
  margin: 0;
  transition-property: left, top;
  transition-timing-function: cubic-bezier(.3, .7, .4, 1);
}
.forgive__no-label { display: inline-block; }
.forgive__no.is-running .forgive__no-label { animation: no-bob .18s ease-in-out infinite alternate; }
@keyframes no-bob { from { transform: translateY(0); } to { transform: translateY(-3px); } }

/* Little cartoon legs */
.legs {
  position: absolute;
  left: 50%; top: 100%;
  width: 30px; height: 18px;
  margin-left: -15px;
  pointer-events: none;
  transform-origin: 50% 0;
  transform: scaleY(0);
  opacity: 0;
  transition: transform .16s ease, opacity .16s ease;
}
.forgive__no.has-legs .legs { transform: scaleY(1); opacity: 1; }
.forgive__no.has-legs[data-dir="left"] .legs { transform: scaleY(1) scaleX(-1); }
.leg {
  position: absolute;
  top: -2px;
  width: 4px; height: 14px;
  border-radius: 2px;
  background: #f7f4ea;
  transform-origin: 50% 0;
}
.leg::after {           /* shoe */
  content: "";
  position: absolute;
  left: -1px; bottom: -3px;
  width: 10px; height: 5px;
  border-radius: 5px 6px 3px 3px;
  background: var(--red);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .4);
}
.leg--l { left: 8px; }
.leg--r { left: 18px; }
.forgive__no.is-running .leg--l { animation: leg-run .16s ease-in-out infinite alternate; }
.forgive__no.is-running .leg--r { animation: leg-run .16s ease-in-out infinite alternate-reverse; }
@keyframes leg-run { from { transform: rotate(-32deg); } to { transform: rotate(32deg); } }

.forgive__reply {
  margin: 14px 0 0;
  min-height: 1.4em;
  font-size: 1rem;
  font-weight: 700;
  color: var(--gold-soft);
}
