:root {
  --eazo-safe-area-top: max(56px, env(safe-area-inset-top, 0px));
  --eazo-safe-area-bottom: max(34px, env(safe-area-inset-bottom, 0px));
  --ink: #1b1a20;
  --paper: #e9e5de;
  --dusk: #38445a;
  --slate: #5c6980;
  --blue: #86a9bd;
  --rose: #fa786f;
  --apricot: #ffd07a;
  --lamp: #f2d46f;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; overflow-x: hidden; }
body {
  font-family: "Segoe Print", "Bradley Hand", "Comic Sans MS", "Marker Felt", cursive;
  color: var(--ink);
  background: #272f42;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}
button { font: inherit; }

.app {
  position: relative;
  min-height: 100svh;
  padding-top: var(--eazo-safe-area-top);
  padding-bottom: var(--eazo-safe-area-bottom);
  isolation: isolate;
  overflow: hidden;
  background:
    radial-gradient(circle at 68% 20%, rgba(255, 173, 126, .22), transparent 32%),
    linear-gradient(180deg, #2f3c57 0%, #596077 48%, #2a2d3e 100%);
}

.paper-world { position: absolute; inset: 0; z-index: -3; overflow: hidden; pointer-events: none; }
.moonwash {
  position: absolute; inset: -20% -30% 15% -20%;
  background: radial-gradient(circle at 60% 28%, rgba(255, 220, 144, .28), transparent 20%), radial-gradient(circle at 45% 46%, rgba(172, 207, 215, .18), transparent 36%);
  filter: blur(18px); opacity: .9;
}
.paper-layer {
  position: absolute; left: -8%; right: -8%; bottom: 0; height: 38%;
  filter: drop-shadow(0 -10px 12px rgba(17, 16, 28, .16));
}
.back-buildings { bottom: 23%; height: 31%; background: #536073; clip-path: polygon(0 100%,0 35%,8% 35%,8% 20%,19% 20%,19% 44%,30% 44%,30% 13%,42% 13%,42% 40%,55% 40%,55% 25%,65% 25%,65% 46%,77% 46%,77% 18%,90% 18%,90% 37%,100% 37%,100% 100%); opacity: .7; }
.front-buildings { bottom: 17%; height: 34%; background: #3f495d; clip-path: polygon(0 100%,0 47%,13% 47%,13% 18%,28% 18%,28% 40%,37% 40%,37% 24%,51% 24%,51% 55%,62% 55%,62% 28%,74% 28%,74% 42%,84% 42%,84% 17%,100% 17%,100% 100%); }
.street-a { bottom: -2%; height: 33%; background: #2e3143; clip-path: polygon(0 39%, 45% 4%, 100% 30%, 100% 100%, 0 100%); filter: drop-shadow(0 -12px 11px rgba(16, 15, 25, .22)); }
.street-b { bottom: -4%; height: 24%; background: #242738; clip-path: polygon(0 22%, 38% 2%, 100% 18%, 100% 100%, 0 100%); opacity:.9; }
.lamp-post { position:absolute; width: 4px; height: 36%; left: 15%; bottom: 24%; border-radius: 99px; background: rgba(31,35,48,.86); filter: drop-shadow(4px 7px 5px rgba(0,0,0,.18)); }
.lamp-post::before { content:""; position:absolute; width:46px; height:46px; left:-21px; top:-24px; border-radius: 50%; background: radial-gradient(circle, rgba(255,219,132,.9) 0 12%, rgba(255,205,108,.38) 28%, rgba(255,205,108,0) 70%); }
.lamp-post::after { content:""; position:absolute; width:18px; height:15px; left:-7px; top:-9px; border-radius: 50% 50% 46% 46%; background:#f3cf82; box-shadow: 0 0 50px 24px rgba(248,205,112,.18); }

.grain {
  position:absolute; inset:0; opacity:.13; mix-blend-mode: screen;
  background-image: radial-gradient(rgba(255,255,255,.6) 1px, transparent 1px), radial-gradient(rgba(0,0,0,.34) .7px, transparent .7px);
  background-size: 17px 19px, 23px 29px;
}

.content {
  min-height: calc(100svh - var(--eazo-safe-area-top) - var(--eazo-safe-area-bottom));
  width: min(100%, 1060px);
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 36px);
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(180px, .85fr);
  align-items: center;
  gap: clamp(12px, 4vw, 48px);
}

.lang-toggle {
  position: absolute;
  top: calc(var(--eazo-safe-area-top) + 8px);
  right: clamp(14px, 4vw, 28px);
  z-index: 5;
  min-height: 44px;
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 999px;
  background: rgba(32,36,51,.38);
  box-shadow: 0 16px 36px rgba(18,18,28,.18), inset 0 1px rgba(255,255,255,.18);
  backdrop-filter: blur(9px);
  overflow: hidden;
}
.lang-toggle button {
  min-width: 54px; min-height: 44px;
  border: 0; border-radius: 999px; color: rgba(255,255,255,.68);
  background: transparent; cursor: pointer; white-space: nowrap;
  padding: 0 12px; font-size: 15px;
}
.lang-toggle button.active { background: rgba(255,220,157,.82); color:#272636; }

.scene-panel {
  position: relative; min-width: 0; min-height: 520px;
  display: grid; place-items: center; transform: rotate(-1.2deg);
}
.scene-paper {
  position:absolute; inset: 10% 0 7% 0;
  border-radius: 44% 56% 49% 51% / 57% 45% 55% 43%;
  background: rgba(235,232,225,.08);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.09), 0 24px 50px rgba(19,20,32,.16);
  filter: blur(.1px);
}

.flecks { position:absolute; inset: 0; pointer-events:none; }
.fleck {
  position:absolute; width: var(--s); height: calc(var(--s) * .62);
  left: var(--x); top: var(--y);
  border-radius: 66% 34% 61% 39%;
  background: radial-gradient(circle at 40% 45%, rgba(255,239,185,.98), rgba(255,152,113,.68) 48%, rgba(255,152,113,.05) 73%);
  box-shadow: 0 0 18px rgba(255,180,118,.35);
  transform: rotate(var(--r));
  opacity: var(--o, 1);
  animation: drift var(--d) ease-in-out infinite alternate;
  transition: opacity 1.4s ease, filter 1.4s ease;
}
.fleck.out { opacity: .08; filter: grayscale(1) blur(.6px); box-shadow:none; }
@keyframes drift { from { translate: 0 0; } to { translate: 9px -14px; } }

.heart-wrap {
  position: relative;
  width: min(64vw, 400px);
  min-width: 250px;
  aspect-ratio: 300 / 240;
  display:grid; place-items:center;
  filter: drop-shadow(0 22px 34px rgba(20, 14, 28, .23));
}
.heart-svg { width:100%; height:100%; overflow:visible; }
#mainHeart { transform-origin: 120px 120px; animation: beat 4.8s ease-in-out infinite; }
@keyframes beat { 0%, 100% { transform: scale(.985); } 48% { transform: scale(1.015); } 55% { transform: scale(1.006); } }
.heart-body { fill: var(--heart-fill, rgba(249,109,103,.52)); transition: fill 1100ms ease, opacity 900ms ease; filter: url(#softEdge); }
.heart-ember { fill: var(--ember, #ffc771); transition: fill 1100ms ease, opacity 900ms ease, r 900ms ease; filter: url(#emberGlow); opacity: var(--ember-opacity, .92); }
.heart-line-bg { fill:none; stroke:rgba(255,255,255,.16); stroke-width:2.6; }
.heart-line { fill:none; stroke:rgba(255,224,165,.92); stroke-width:3.4; stroke-linecap:round; stroke-dasharray: 620; stroke-dashoffset: var(--dash, 174); transition: stroke-dashoffset 900ms ease, stroke 900ms ease; filter: drop-shadow(0 0 10px rgba(255,197,117,.32)); }
.other-heart { opacity: 0; transform-origin: 217px 120px; transform: translate(-30px, 6px) scale(.9); transition: opacity 1.4s ease, transform 1.4s cubic-bezier(.2,.9,.2,1); }
.arrived .other-heart { opacity: 1; transform: translate(0, 0) scale(1); }

.readout {
  align-self: center; min-width: 0; transform: rotate(.8deg);
  padding: clamp(10px, 2vw, 18px) 0;
  color: rgba(255,248,232,.88);
  text-shadow: 0 1px 0 rgba(0,0,0,.08);
}
.title { margin: 0 0 12px; font-size: clamp(28px, 7vw, 62px); line-height: .95; font-weight: 500; letter-spacing: -.03em; max-width: 10ch; }
.clock { font-size: clamp(38px, 11vw, 84px); line-height: .88; letter-spacing: -.05em; color: rgba(255,226,168,.95); }
.temp { display: inline-block; margin-top: 2px; font-size: clamp(25px, 6vw, 48px); color: var(--temp-color, #ffb980); transition: color 1s ease; }
.instruction { max-width: 33ch; margin: 18px 0 16px; font-size: clamp(14px, 3.5vw, 19px); line-height: 1.3; color: rgba(250,246,231,.82); }
.warm-button {
  min-height: 58px; min-width: 58px; max-width: min(100%, 330px);
  border: 0; border-radius: 999px 999px 999px 30px; padding: 15px 22px 16px;
  color: #2d2631;
  background: radial-gradient(circle at 30% 20%, #fff5d1, #ffc274 42%, #f28778 100%);
  box-shadow: 0 18px 42px rgba(39,24,24,.24), inset 0 1px rgba(255,255,255,.65);
  cursor: pointer; font-size: clamp(15px, 3.6vw, 18px); line-height: 1.15;
  white-space: normal; text-align: center;
  transition: opacity .45s ease, transform .25s ease, filter .45s ease;
  touch-action: manipulation;
}
.warm-button:active { transform: scale(.98); }
.warm-button:disabled { opacity: .46; filter: saturate(.45); cursor: default; }
.used-note { min-height: 22px; margin-top: 11px; color: rgba(255,248,232,.64); font-size: 14px; }

.result {
  position: absolute; left: 50%; top: 50%;
  width: min(92vw, 430px);
  max-height: calc(100svh - var(--eazo-safe-area-top) - var(--eazo-safe-area-bottom) - 22px);
  overflow: auto;
  transform: translate(-50%, -45%) rotate(-1deg) scale(.94);
  opacity: 0; pointer-events:none; z-index: 6;
  transition: opacity .8s ease, transform .8s ease;
}
.result.show { opacity:1; pointer-events:auto; transform: translate(-50%, -50%) rotate(-1deg) scale(1); }
.ticket {
  position: relative; padding: 22px 20px 18px; color:#2d2a31;
  background: linear-gradient(180deg, rgba(244,238,224,.96), rgba(227,218,205,.95));
  border-radius: 22px; box-shadow: 0 26px 55px rgba(14,15,25,.36);
  border: 1px solid rgba(255,255,255,.48);
}
.ticket::before, .ticket::after { content:""; position:absolute; top: 48%; width:22px; height:22px; border-radius:50%; background:#34384b; }
.ticket::before { left:-11px; } .ticket::after { right:-11px; }
.ticket h2 { margin: 0 0 12px; font-size: 26px; line-height:1; font-weight:500; }
.ticket-grid { display:grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.ticket-item { padding:10px; border-radius:14px; background: rgba(255,255,255,.33); min-width:0; }
.ticket-item span { display:block; font-size: 12px; opacity:.65; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.ticket-item strong { display:block; margin-top:2px; font-size: 20px; font-weight:500; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.closing { margin: 12px 0 14px; font-size: 16px; line-height:1.32; }
.actions { display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
.actions button, .details-toggle {
  min-height:44px; border:0; border-radius:999px; padding:0 16px; cursor:pointer; white-space:nowrap;
  background:#2c2a32; color:#fff7df; box-shadow: inset 0 1px rgba(255,255,255,.12);
  touch-action: manipulation;
}
.actions .share { background:#e99072; color:#241e22; }
details { margin-top: 10px; }
summary { list-style:none; display:inline-flex; align-items:center; min-height:44px; border-radius:999px; padding:0 16px; background:rgba(44,42,50,.1); cursor:pointer; white-space:nowrap; touch-action: manipulation; }
summary::-webkit-details-marker { display:none; }
.excuse-list { margin: 10px 0 0; padding-left: 20px; line-height:1.45; max-height: 130px; overflow:auto; }

.scrim { position:absolute; inset:0; background:rgba(20,22,33,.46); opacity:0; pointer-events:none; z-index:5; transition: opacity .8s ease; }
.scrim.show { opacity:1; pointer-events:auto; }

@media (max-width: 760px) {
  .content {
    min-height: calc(100svh - var(--eazo-safe-area-top) - var(--eazo-safe-area-bottom));
    grid-template-columns: 1fr;
    grid-template-rows: minmax(250px, 1fr) auto;
    align-content: center; gap: 0; padding-inline: 16px;
  }
  .scene-panel { min-height: min(48svh, 400px); transform: rotate(-1deg); }
  .heart-wrap { width: min(84vw, 360px); min-width: 240px; }
  .readout { justify-self: center; width: min(88vw, 360px); margin-top: -26px; text-align: left; transform: rotate(.9deg); }
  .title { display:none; }
  .instruction { margin: 12px 0 12px; max-width: 34ch; }
  .warm-button { width: 100%; max-width: 360px; }
  .lamp-post { left: 9%; }
  .back-buildings { bottom:22%; }
  .front-buildings { bottom:18%; }
}

@media (max-width: 390px) {
  .lang-toggle { top: calc(var(--eazo-safe-area-top) + 2px); right: 10px; }
  .scene-panel { min-height: min(44svh, 360px); }
  .heart-wrap { width: min(82vw, 320px); min-width: 220px; }
  .clock { font-size: clamp(34px, 10vw, 46px); }
  .temp { font-size: clamp(23px, 6vw, 28px); }
  .instruction { font-size: 13px; }
  .warm-button { font-size: 14px; min-height: 54px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
  .fleck { transition: opacity .2s ease; }
}
