/* Kiosk: a fixed 1080x1920 artboard, scaled to fit the screen (see fitStage in src/kiosk/main.js).
   All positions below are artboard pixels, taken from "AW For App ลอยกระทง". */

@font-face { font-family: 'Kanit'; font-weight: 300; src: url('../assets/fonts/Kanit-Light.ttf') format('truetype'); font-display: block; }
@font-face { font-family: 'Kanit'; font-weight: 400; src: url('../assets/fonts/Kanit-Regular.ttf') format('truetype'); font-display: block; }
@font-face { font-family: 'Kanit'; font-weight: 500; src: url('../assets/fonts/Kanit-Medium.ttf') format('truetype'); font-display: block; }
@font-face { font-family: 'FC Mee Sakul Serif'; font-weight: 700; src: url('../assets/fonts/FCMeeSakulSerif-Bold.otf') format('opentype'); font-display: block; }

:root {
  --blue: #2a5294;
  --blue-deep: #142f66;
  --ink: #141414;
  --key: rgba(160, 184, 222, 0.74);
  --key-ink: #1b2740;
  --gold: linear-gradient(180deg, #fbe7c1 0%, #ecc994 45%, #cf9d5f 100%);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--blue-deep);
  color: #fff;
  font-family: 'Kanit', 'Segoe UI', sans-serif;
  font-weight: 400;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}

.viewport {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1080px;
  height: 1920px;
  overflow: hidden;
  transform-origin: center center;
  transform: translate(-50%, -50%) scale(var(--scale, 1));
}

.stage__bg {
  position: absolute;
  inset: 0;
  background: #24508f url('../assets/ui/bg.jpg') center / cover no-repeat;
}

/* ---------- Language toggle ---------- */

.lang {
  position: absolute;
  z-index: 5;
  left: 40px;
  top: 28px;
  padding: 12px 16px;
  font-size: 42px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.01em;
}
.lang i { font-style: normal; padding: 0 2px; }
.lang span { opacity: 0.5; transition: opacity 0.3s; }
[data-lang='th'] .lang [data-lang-option='th'],
[data-lang='en'] .lang [data-lang-option='en'] { opacity: 1; }
.screen--thanks.is-active ~ .lang, .is-releasing .lang { pointer-events: none; }

/* ---------- Screens ---------- */

/* The old screen fades out quickly first, then the new one fades in: never two screens on top of each other. */
.screen {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease-out, visibility 0s linear 0.22s;
}
.no-anim .screen { transition: none !important; }
.screen.is-active {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.4s ease-out 0.2s, visibility 0s;
}

.title {
  position: absolute;
  left: 0;
  right: 0;
  top: 238px;
  margin: 0;
  text-align: center;
  font-size: 104px;
  font-weight: 500;
  line-height: 1.2;
}
[data-lang='en'] .title { font-size: 92px; top: 250px; }
.subtitle {
  position: absolute;
  left: 0;
  right: 0;
  top: 375px;
  margin: 0;
  text-align: center;
  font-size: 50px;
  font-weight: 400;
  line-height: 1.2;
}

/* ---------- Arrows and buttons ---------- */

.arrow {
  position: absolute;
  width: 180px;
  height: 128px;
  border-radius: 64px;
  /* Go on = the warm gold of the lantern labels and the Enter key: lit from the top, a 3D edge, a soft glow. */
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, 0.85) 0%, rgba(255, 255, 255, 0) 55%),
    linear-gradient(180deg, #fff3da 0%, #f6d7a0 55%, #e8b56d 100%);
  border: 2px solid rgba(255, 249, 232, 0.95);
  display: grid;
  place-items: center;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.9),
    inset 0 -6px 12px rgba(176, 108, 36, 0.3),
    0 7px 0 #a86a2c,
    0 16px 34px rgba(255, 176, 84, 0.38);
  transition: transform 0.12s, opacity 0.3s, box-shadow 0.12s, background 0.3s;
}
.arrow svg { width: 96px; height: 48px; fill: none; stroke: #5a3712; stroke-width: 5.5; stroke-linecap: round; stroke-linejoin: round; }
.arrow:active {
  transform: translateY(6px) scale(0.97);
  box-shadow: inset 0 2px 6px rgba(150, 90, 30, 0.3), 0 1px 0 #a86a2c, 0 6px 18px rgba(255, 176, 84, 0.3);
}
/* Not ready yet (no lantern chosen): plain glass, so it does not look pressable. */
.arrow:disabled {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.45);
  box-shadow: none;
}
.arrow:disabled svg { stroke: rgba(255, 255, 255, 0.6); }
/* Back is the quiet choice: clear glass with a white outline, so "next" is the obvious one. */
.arrow--back {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.85);
  box-shadow: 0 10px 26px rgba(8, 24, 60, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.arrow--back svg { stroke: #fff; stroke-width: 5; }
.arrow--back:active { background: rgba(255, 255, 255, 0.28); box-shadow: 0 4px 12px rgba(8, 24, 60, 0.2); }
.arrow--center { left: 450px; top: 1454px; }
.arrow--back { left: 86px; top: 1646px; }
.arrow--next { left: 814px; top: 1646px; }

.pill-button {
  position: absolute;
  left: 50%;
  top: 1298px;
  min-width: 352px;
  height: 148px;
  padding: 0 52px;
  transform: translateX(-50%);
  border-radius: 74px;
  background: linear-gradient(180deg, #ffffff 0%, #e9f1ff 100%);
  color: var(--ink);
  font-size: 64px;
  font-weight: 400;
  box-shadow: 0 12px 34px rgba(8, 24, 60, 0.3);
  transition: transform 0.15s, opacity 0.4s;
}
.pill-button:active { transform: translateX(-50%) scale(0.95); }

/* ---------- 1. Lantern cards ---------- */

.cards {
  position: absolute;
  left: 126px;
  top: 590px;
  display: grid;
  grid-template-columns: repeat(3, 182px);
  grid-auto-rows: 340px;
  column-gap: 141px;
  row-gap: 112px;
}

.card {
  position: relative;
  border-radius: 91px;
  /* Light at the top behind the lantern, deep blue behind the gold name so it reads clearly. */
  background: linear-gradient(180deg, rgba(222, 232, 247, 0.96) 0%, rgba(160, 186, 226, 0.75) 30%, rgba(38, 76, 150, 0.85) 50%, rgba(26, 58, 124, 0.7) 100%);
  transition: transform 0.3s var(--ease), opacity 0.3s, box-shadow 0.3s;
}
.card__img {
  position: absolute;
  left: -24px;
  right: -24px;
  bottom: calc(100% - 140px);
  height: 236px;
  width: calc(100% + 48px);
  object-fit: contain;
  object-position: center bottom;
  pointer-events: none;
  transition: transform 0.4s var(--ease), filter 0.4s;
}
.card__name {
  position: absolute;
  left: -30px;
  right: -30px;
  top: 172px;
  margin: 0;
  text-align: center;
  white-space: pre-line;
  font-family: 'FC Mee Sakul Serif', 'Kanit', serif;
  font-weight: 700;
  font-size: 60px;
  line-height: 1.04;
  background: var(--gold);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 3px rgba(8, 22, 60, 0.7));
}
[data-lang='en'] .card__name { font-size: 40px; line-height: 1.16; top: 186px; }

.cards.has-choice .card:not(.is-selected) { opacity: 0.55; }
.card.is-selected {
  transform: translateY(-6px);
  box-shadow: 0 0 0 4px rgba(255, 236, 200, 0.95), 0 0 48px 6px rgba(255, 214, 150, 0.55);
}
.card.is-selected .card__img { transform: scale(1.1) translateY(-8px); filter: drop-shadow(0 0 26px rgba(255, 196, 110, 0.85)); }
.card:active { transform: scale(0.96); }

/* ---------- Lantern figure with the name label ---------- */

.figure-box {
  position: absolute;
  display: grid;
  place-items: end center;
  pointer-events: none;
}
.figure-box--name { left: 200px; top: 410px; width: 680px; height: 585px; }
.figure-box--wish { left: 240px; top: 1300px; width: 600px; height: 470px; }
.figure-box--rise { left: 160px; top: 186px; width: 760px; height: 976px; place-items: center; }

.figure {
  position: relative;
  /* width / height are set from the picture's shape so the label lands on the lantern. */
}
.figure__img { display: block; width: 100%; height: 100%; }
/* Rise and sway are separate animations (translate/scale vs rotate): the lantern lifts off slowly,
   floats up at an easy pace and fades high up, while a gentle sway runs on top of it. */
.screen.is-active .figure.is-flying {
  animation:
    fly-up 10s cubic-bezier(0.4, 0, 0.6, 1) forwards,
    sway 3.2s ease-in-out -1.6s infinite alternate;
}
.figure.is-flying .figure__img { animation: flame 0.35s ease-in-out infinite alternate; }

.tag {
  position: absolute;
  transform: translate(-50%, -50%);
  aspect-ratio: 991 / 659;
  container-type: inline-size;
  display: grid;
  place-items: center;
}
.tag__frame { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.96; }
.tag__name {
  position: relative;
  max-width: 70%;
  white-space: nowrap;
  font-weight: 500;
  font-size: 20cqw;
  line-height: 1.15;
  color: #6b4320;
  text-align: center;
  overflow: hidden;
}

.glow {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(closest-side, rgba(170, 220, 245, 0.92) 0%, rgba(120, 178, 225, 0.6) 45%, rgba(70, 120, 190, 0) 100%);
  transition: opacity 1.2s;
}
.glow--name { left: -120px; top: 380px; width: 1320px; height: 720px; }
/* Name screen: arrows lower, so the keyboard has room and the screen is balanced top to bottom. */
.screen--name .arrow--back,
.screen--name .arrow--next { top: 1690px; }
.glow--wish { left: -60px; top: 1370px; width: 1200px; height: 620px; opacity: 0.8; }
.glow--rise { left: -260px; top: 560px; width: 1600px; height: 760px; }
.is-releasing .glow--rise { opacity: 0; }
.is-releasing .pill-button { opacity: 0; pointer-events: none; }

/* The chosen wish, written under the lantern. */
.wish-caption {
  position: absolute;
  left: 60px;
  right: 60px;
  margin: 0;
  color: #fff;
  font-size: 52px;
  font-weight: 500;
  line-height: 1.25;
  text-align: center;
  white-space: nowrap;
  text-shadow: 0 2px 10px rgba(8, 22, 60, 0.85), 0 0 24px rgba(255, 210, 140, 0.45);
  pointer-events: none;
  transition: opacity 0.4s;
}
.wish-caption:empty { display: none; }
.wish-caption--rise { top: 1172px; }
.wish-caption--wish { top: 1784px; left: 250px; right: 250px; font-size: 40px; }
.wish-caption.pop { animation: caption-pop 0.45s var(--ease); }
@keyframes caption-pop { from { opacity: 0; scale: 0.9; } }
.screen.is-active .wish-caption--rise { animation: enter-up 0.8s var(--ease) 0.5s backwards; }
/* On release the wish stays under the lantern and flies up with it: same animations and timing as the
   lantern, turning around the lantern's centre (the middle of .figure-box--rise, y = 674). */
.is-releasing .screen.is-active .wish-caption--rise {
  transform-origin: 50% -498px;
  animation:
    fly-up 10s cubic-bezier(0.4, 0, 0.6, 1) forwards,
    sway 3.2s ease-in-out -1.6s infinite alternate;
}

@keyframes fly-up {
  from { translate: 0 0; scale: 1; opacity: 1; }
  70% { opacity: 1; }
  to { translate: 0 -1500px; scale: 0.4; opacity: 0; }
}
@keyframes sway {
  from { rotate: -3deg; }
  to { rotate: 3deg; }
}
@keyframes flame {
  from { filter: brightness(1) drop-shadow(0 0 20px rgba(255, 190, 110, 0.6)); }
  to { filter: brightness(1.12) drop-shadow(0 0 40px rgba(255, 190, 110, 0.9)); }
}

/* ---------- 2. Name field and keyboard ---------- */

.field {
  position: absolute;
  left: 182px;
  top: 250px;
  width: 716px;
  height: 128px;
  border-radius: 64px;
  background: rgba(30, 64, 136, 0.72);
  border: 2px solid rgba(255, 255, 255, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 48px;
  font-size: 56px;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  transition: box-shadow 0.2s;
}
.field__ph { position: absolute; opacity: 0.82; font-weight: 300; font-size: 48px; }
.field.has-text .field__ph { display: none; }
.field__caret {
  width: 4px;
  height: 64px;
  margin-left: 4px;
  background: #fff;
  border-radius: 2px;
  animation: blink 1.05s steps(1) infinite;
}
.field.is-shaking { box-shadow: 0 0 0 4px rgba(255, 210, 160, 0.9); }
/* Keep the entrance animation in the list, so removing the shake does not replay the entrance. */
.screen.is-active .field.is-shaking { animation: enter-down 0.8s var(--ease) 0.25s backwards, shake 0.42s; }
/* Shown inside the name box, in place of the placeholder, so the lantern never covers it. */
.field__error {
  position: absolute;
  z-index: 2;
  left: 182px;
  top: 250px;
  width: 716px;
  height: 128px;
  margin: 0;
  display: grid;
  place-items: center;
  font-size: 46px;
  font-weight: 500;
  color: #fff;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}
.field__error.is-on { opacity: 1; }
.field.has-error .field__ph { opacity: 0; }
.field.has-error .field__caret { visibility: hidden; }
/* Shown under the box for a moment when the name is full. */
.field__hint {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  top: 392px;
  margin: 0;
  text-align: center;
  font-size: 36px;
  font-weight: 500;
  color: #fff;
  text-shadow: 0 2px 8px rgba(8, 22, 60, 0.8);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}
.field__hint.is-on { opacity: 1; }
@keyframes blink { 50% { opacity: 0; } }
@keyframes shake {
  20%, 60% { transform: translateX(-16px); }
  40%, 80% { transform: translateX(16px); }
}

/* Every row is exactly --row-w wide, like a phone keyboard: 10 keys on the top row, the 9-key row
   centred, shift / backspace widened to fill the edges of the 7-key row. */
.keyboard {
  position: absolute;
  left: 0;
  right: 0;
  top: 1060px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--row-gap);
  --row-w: 940px;
  --gap: 10px;
  --row-gap: 12px;
  --kw: calc((var(--row-w) - 9 * var(--gap)) / 10);
  --kh: 96px;
}
/* Thai: 12 keys per row. */
.keyboard[data-script='th'][data-mode='alpha'] {
  --gap: 8px;
  --row-gap: 10px;
  --kw: calc((var(--row-w) - 11 * var(--gap)) / 12);
  --kh: 88px;
}
/* A frosted panel behind the keys: calmer than the moving sky, and the keys read as one group. */
.keyboard { isolation: isolate; }
.keyboard::before {
  content: '';
  position: absolute;
  z-index: -1;
  left: calc(50% - var(--row-w) / 2 - 24px);
  width: calc(var(--row-w) + 48px);
  top: -24px;
  bottom: -24px;
  border-radius: 64px;
  background: linear-gradient(180deg, rgba(28, 62, 128, 0.42), rgba(18, 44, 100, 0.5));
  border: 1.5px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 24px 60px rgba(6, 18, 50, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.kb-row { display: flex; gap: var(--gap); width: var(--row-w); justify-content: center; }
.key {
  flex: none;
  width: var(--kw);
  height: var(--kh);
  border-radius: calc(var(--kh) / 2);
  /* Glass key: light from the top, a soft shadow under it. */
  background: linear-gradient(180deg, rgba(236, 244, 255, 0.95) 0%, rgba(196, 214, 242, 0.9) 100%);
  border: 1.5px solid rgba(255, 255, 255, 0.7);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.85),
    inset 0 -4px 8px rgba(70, 104, 170, 0.18),
    0 5px 0 rgba(30, 60, 120, 0.28),
    0 10px 18px rgba(8, 24, 64, 0.22);
  color: var(--key-ink);
  font-size: 38px;
  font-weight: 400;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: background 0.12s, transform 0.08s, box-shadow 0.08s;
}
.keyboard[data-script='th'] .key { font-size: 40px; }
/* Pressed: the key sinks into its shadow and lights up warm, like a lantern. */
.keyboard .key.is-down {
  background: linear-gradient(180deg, #fff6e4 0%, #ffe0ad 100%);
  transform: translateY(4px) scale(0.96);
  box-shadow:
    inset 0 2px 6px rgba(150, 100, 40, 0.25),
    0 1px 0 rgba(30, 60, 120, 0.28),
    0 0 24px 4px rgba(255, 210, 140, 0.55);
}
/* Shift, backspace, 123, emoji, ABC: a deeper blue, so letters stand out. */
.key[data-action='shift'],
.key[data-action='backspace'],
.key--fn {
  background: linear-gradient(180deg, rgba(168, 194, 234, 0.92) 0%, rgba(126, 158, 212, 0.9) 100%);
  border-color: rgba(255, 255, 255, 0.45);
  color: #12203d;
}
.key[data-action='shift'].key--on { background: linear-gradient(180deg, #ffffff 0%, #e4eeff 100%); }
/* Enter = go on: the warm gold of the lantern labels. */
.key--enter {
  background: linear-gradient(180deg, #fff3da 0%, #f3cf92 100%);
  border-color: rgba(255, 248, 230, 0.9);
  color: #5a3712;
  font-weight: 500;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.9),
    inset 0 -4px 8px rgba(190, 130, 50, 0.25),
    0 5px 0 rgba(150, 95, 30, 0.45),
    0 10px 22px rgba(255, 190, 100, 0.3);
}
.key--space { color: #2a3a5c; }
.key svg { width: 40px; height: 40px; fill: none; stroke: var(--key-ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.key--side { width: calc((var(--row-w) - 7 * var(--kw) - 8 * var(--gap)) / 2); }
.key--blank { visibility: hidden; }
.kb-row--bottom .key { height: 96px; border-radius: 48px; }
.key--fn { width: 108px; }
.key--small { font-size: 32px; }
.key--space { flex: 1; font-size: 38px; }
.key--enter { width: 210px; font-size: 38px; }
.key--emoji { font-family: 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif; font-size: 44px; }

/* ---------- 3. Wish list ---------- */

.frame {
  position: absolute;
  left: 79px;
  top: 300px;
  width: 922px;
  margin: 0;
  padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.95);
  border-radius: 112px;
}
.frame--wish { top: 250px; height: 1040px; }
.frame__title {
  margin: 0 auto;
  padding: 0 34px;
  font-size: 92px;
  font-weight: 500;
  line-height: 1;
}
[data-lang='th'] .frame__title { font-size: 104px; }

.wishes {
  list-style: none;
  margin: 26px 0 0;
  padding: 0 52px;
}
.wish {
  position: relative;
  height: 87px;
  display: grid;
  place-items: center;
  font-size: 50px;
  font-weight: 400;
  white-space: nowrap;
  transition: color 0.25s;
}
[data-lang='th'] .wish { font-size: 46px; font-weight: 300; }
.wish::before {
  content: '';
  position: absolute;
  inset: 0 -0px;
  background: linear-gradient(90deg, rgba(190, 228, 248, 0) 0%, rgba(190, 228, 248, 0.92) 30%, rgba(214, 240, 252, 1) 50%, rgba(190, 228, 248, 0.92) 70%, rgba(190, 228, 248, 0) 100%);
  opacity: 0;
  transform: scaleX(0.6);
  transition: opacity 0.25s, transform 0.35s var(--ease);
}
.wish span { position: relative; }
.wish.is-selected { color: var(--ink); }
.wish.is-selected::before { opacity: 1; transform: none; }

/* ---------- 5. Thank you ---------- */

.frame--thanks {
  height: 1052px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 56px;
}
.thanks {
  margin: 0;
  text-align: center;
  font-size: 52px;
  font-weight: 300;
  line-height: 2.02;
}
.thanks span { display: block; }
.thanks span:first-child { font-weight: 400; }
[data-lang='th'] .thanks { font-size: 50px; line-height: 2.1; }
.thanks:empty { display: none; }

/* Venue version: the wish in sparkling gold, in the middle; then it moves up and the cookie pops in.
   The resting styles are the final layout, the animations only lead into it. */
.thanks-wish {
  position: absolute;
  left: 50%;
  top: 210px;
  margin: 0;
  translate: -50% 0;
  white-space: nowrap;
}
.thanks-wish__text {
  display: block;
  font-size: 68px;
  font-weight: 500;
  line-height: 1.5;
  background: linear-gradient(100deg, #f3c66f 0%, #fff4cf 18%, #e4a94e 36%, #fff8dc 50%, #d8963e 66%, #ffe9b0 84%, #f3c66f 100%);
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 16px rgba(255, 196, 100, 0.65)) drop-shadow(0 3px 4px rgba(60, 30, 0, 0.45));
  animation: gold-shine 3s linear infinite;
}
[data-lang='en'] .thanks-wish__text { font-size: 64px; }
@keyframes gold-shine { to { background-position: -220% 0; } }

/* Four-point twinkles around the wish. */
.spark {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 40px;
  height: 40px;
  translate: -50% -50%;
  background: radial-gradient(circle, #fff 0 18%, #ffe3a0 40%, rgba(255, 200, 110, 0) 70%);
  clip-path: polygon(50% 0, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0 50%, 40% 40%);
  animation: twinkle 1.8s ease-in-out var(--d) infinite;
}
.spark--small { width: 26px; height: 26px; }
@keyframes twinkle {
  0%, 100% { scale: 0.2; opacity: 0; rotate: 0deg; }
  50% { scale: 1; opacity: 1; rotate: 45deg; }
}

.cookie-box {
  position: absolute;
  left: 40px;
  right: 40px;
  top: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.cookie {
  display: block;
  width: 360px;
  height: auto;
  filter: drop-shadow(0 0 36px rgba(255, 196, 110, 0.55)) drop-shadow(0 14px 18px rgba(8, 24, 60, 0.35));
  transform-origin: 50% 80%;
  animation: wiggle 1.4s ease-in-out infinite;
}
/* A small happy wobble with a little hop. */
@keyframes wiggle {
  0%, 100% { rotate: 0deg; translate: 0 0; }
  15% { rotate: -9deg; translate: 0 -10px; }
  30% { rotate: 7deg; translate: 0 0; }
  45% { rotate: -5deg; translate: 0 -6px; }
  60% { rotate: 3deg; translate: 0 0; }
  75% { rotate: 0deg; }
}
.cookie-title {
  margin: 34px 0 0;
  font-size: 56px;
  font-weight: 500;
  line-height: 1.4;
  text-align: center;
  color: #fff;
  text-shadow: 0 2px 10px rgba(8, 22, 60, 0.7);
}
.cookie-note {
  margin: 14px 0 0;
  max-width: 760px;
  text-wrap: balance;
  font-size: 38px;
  font-weight: 300;
  line-height: 1.5;
  text-align: center;
  color: #fff;
  text-shadow: 0 2px 8px rgba(8, 22, 60, 0.7);
}

/* The online demo shows its own text instead. */
.is-demo .thanks-wish,
.is-demo .cookie-box { display: none; }

/* Order: the wish appears in the middle, stays, then moves up; then the cookie, its title and note. */
.screen--thanks.is-active .thanks-wish { animation: wish-first 3.4s var(--ease) 0.3s backwards; }
@keyframes wish-first {
  0% { top: 470px; opacity: 0; scale: 0.7; }
  18% { top: 470px; opacity: 1; scale: 1.08; }
  26% { top: 470px; scale: 1; }
  72% { top: 470px; }
  100% { top: 210px; }
}
.screen--thanks.is-active .cookie-box { animation: cookie-in 0.9s cubic-bezier(0.34, 1.56, 0.64, 1) 3.1s backwards; }
@keyframes cookie-in { from { opacity: 0; scale: 0.3; } }
.screen--thanks.is-active .cookie-title { animation: enter-up 0.8s var(--ease) 3.6s backwards; }
.screen--thanks.is-active .cookie-note { animation: enter-up 0.8s var(--ease) 3.85s backwards; }

/* Cookies finished: the gold wish, then the souvenir message under it. */
.no-cookie .cookie-box { display: none; }
.no-cookie .thanks-wish { top: 380px; }
.souvenir-note { display: none; }
.no-cookie .souvenir-note {
  display: block;
  position: absolute;
  left: 80px;
  right: 80px;
  top: 540px;
  margin: 0;
  font-size: 46px;
  font-weight: 400;
  line-height: 1.55;
  text-align: center;
  text-wrap: balance;
  white-space: pre-line; /* Thai has set line breaks, so a word is never cut in half */
  color: #fff;
  text-shadow: 0 2px 10px rgba(8, 22, 60, 0.7);
}
.is-demo .souvenir-note { display: none; }
.screen--thanks.no-cookie.is-active .souvenir-note { animation: enter-up 0.8s var(--ease) 1.3s backwards; }
.screen--thanks.no-cookie.is-active .thanks-wish { animation: wish-only 1.1s var(--ease) 0.3s backwards; }
@keyframes wish-only {
  0% { opacity: 0; scale: 0.7; }
  60% { opacity: 1; scale: 1.08; }
  100% { scale: 1; }
}
.screen--thanks.no-cookie.is-active .restart-hint { animation-delay: 2s; }

/* ---------- Effects layer and motion ---------- */

.fx {
  position: absolute;
  left: 0;
  top: 0;
  width: 1080px;
  height: 1920px;
  pointer-events: none;
}

/* Entrances. Only "from" is given, so each element ends on its normal style. "backwards" keeps
   it hidden during the delay and gives control back to the normal style when it ends. */
@keyframes enter-up { from { opacity: 0; translate: 0 48px; } }
@keyframes enter-down { from { opacity: 0; translate: 0 -40px; } }
@keyframes enter-zoom { from { opacity: 0; scale: 0.94; } }
@keyframes enter-card { from { opacity: 0; translate: 0 70px; scale: 0.8; } }
@keyframes enter-figure { from { opacity: 0; translate: 0 90px; scale: 0.86; } }

.screen.is-active .title { animation: enter-down 0.8s var(--ease) 0.2s backwards; }
.screen.is-active .subtitle { animation: enter-down 0.8s var(--ease) 0.32s backwards; }
.cards.intro .card { animation: enter-card 0.8s var(--ease) backwards; animation-delay: calc(0.35s + var(--i) * 0.08s); }
.screen.is-active .arrow { animation: enter-up 0.7s var(--ease) 0.6s backwards; }
.screen.is-active .field { animation: enter-down 0.8s var(--ease) 0.25s backwards; }
.screen.is-active .keyboard { animation: enter-up 0.8s var(--ease) 0.35s backwards; }
.screen.is-active .figure { animation: enter-figure 1.1s var(--ease) 0.2s backwards; }
.screen.is-active .frame--wish { animation: enter-zoom 0.8s var(--ease) 0.2s backwards; }
.wishes.intro .wish { animation: enter-up 0.6s var(--ease) backwards; animation-delay: calc(0.4s + var(--i) * 0.05s); }
.screen.is-active .pill-button { animation: enter-up 0.8s var(--ease) 0.7s backwards; }
.screen.is-active .frame--thanks { animation: enter-zoom 0.9s var(--ease) 0.15s backwards; }
.screen.is-active .thanks span { animation: enter-up 0.9s var(--ease) backwards; animation-delay: calc(0.5s + var(--i) * 0.16s); }

/* Always moving a little: lanterns float, glows breathe. */
@keyframes float { from { translate: 0 6px; } to { translate: 0 -16px; } }
@keyframes bob { from { translate: 0 4px; } to { translate: 0 -10px; } }
@keyframes breathe { from { scale: 1; } to { scale: 1.07; } }
.figure-box { animation: float 3.6s ease-in-out infinite alternate; }
.card__img { animation: bob 2.8s ease-in-out infinite alternate; animation-delay: calc(var(--i) * -0.6s); }
.glow { animation: breathe 4.5s ease-in-out infinite alternate; }

/* The chosen card glows softly. */
@keyframes card-glow {
  from { box-shadow: 0 0 0 4px rgba(255, 236, 200, 0.95), 0 0 36px 4px rgba(255, 214, 150, 0.45); }
  to { box-shadow: 0 0 0 4px rgba(255, 236, 200, 0.95), 0 0 70px 14px rgba(255, 214, 150, 0.75); }
}
.cards .card.is-selected { animation: card-glow 1.6s ease-in-out infinite alternate; }

/* "Tap me": a ring grows out of the next / release button, and the arrow nudges forward. */
@keyframes ring { from { opacity: 0.85; scale: 1; } to { opacity: 0; scale: 1.25 1.5; } }
@keyframes nudge { 0%, 55%, 100% { translate: 0 0; } 25% { translate: 10px 0; } }
.arrow--center::after,
.pill-button::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 3px solid rgba(255, 255, 255, 0.9);
  opacity: 0;
  pointer-events: none;
}
.arrow--center:not(:disabled)::after { animation: ring 1.8s ease-out 0.4s infinite; }
.screen--rise.is-active .pill-button::after { animation: ring 1.8s ease-out 1.4s infinite; }
.arrow--center:not(:disabled) svg,
.arrow--next svg { animation: nudge 1.8s ease-in-out 1s infinite; }

/* Small pops: each typed letter, the chosen wish. */
@keyframes pop { from { scale: 1.18; } }
.tag__name.pop { animation: pop 0.3s var(--ease); }
.wish.is-selected span { animation: pop 0.35s var(--ease); }

/* Release: a flash of light from the lantern. */
.burst {
  position: absolute;
  left: 140px;
  top: 274px;
  width: 800px;
  height: 800px;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(closest-side, rgba(255, 246, 220, 0.95) 0%, rgba(255, 210, 140, 0.55) 35%, rgba(255, 190, 110, 0) 100%);
}
@keyframes burst { from { opacity: 0.9; scale: 0.3; } to { opacity: 0; scale: 1.6; } }
.is-releasing .burst { animation: burst 1.1s ease-out; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-iteration-count: 1 !important; animation-duration: 0.01ms !important; animation-delay: 0s !important; }
}

/* ---------- Loading, release-screen back, hints, demo ---------- */

.loader {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 40px;
  font: 400 40px/1.3 'Segoe UI', 'Leelawadee UI', 'Noto Sans Thai', sans-serif;
  color: rgba(255, 255, 255, 0.92);
  transition: opacity 0.5s, visibility 0s linear 0.5s;
}
.loader.is-done { opacity: 0; visibility: hidden; }
.loader__lantern {
  width: 90px;
  height: 120px;
  border-radius: 40% 40% 30% 30%;
  background: radial-gradient(circle at 50% 78%, #fff3d6 0%, #ffc875 30%, #e88a3a 70%, rgba(232, 138, 58, 0) 100%);
  box-shadow: 0 0 60px 16px rgba(255, 190, 110, 0.45);
  animation: float 1.6s ease-in-out infinite alternate;
}

/* While the lantern flies, the back arrow on the release screen goes away with the button. */
.is-releasing .arrow { opacity: 0; pointer-events: none; }

.restart-hint {
  position: absolute;
  left: 0;
  right: 0;
  top: 1440px;
  margin: 0;
  text-align: center;
  font-size: 40px;
  font-weight: 300;
  opacity: 0.85;
}
.screen.is-active .restart-hint { animation: enter-up 0.8s var(--ease) 4.4s backwards; }

/* Public demo only (html.is-demo). */
.demo-note,
.demo-dome { display: none; }
.is-demo .demo-note {
  display: block;
  position: absolute;
  left: 90px;
  right: 90px;
  top: 1650px;
  margin: 0;
  text-align: center;
  font-size: 40px;
  font-weight: 400;
  line-height: 1.35;
  text-shadow: 0 2px 8px rgba(8, 22, 60, 0.7);
}
.is-demo .demo-dome {
  display: inline-flex;
  align-items: center;
  height: 120px;
  padding: 0 56px;
  border-radius: 60px;
  background: linear-gradient(180deg, #fff3da 0%, #f3cf92 100%);
  color: #5a3712;
  font-size: 46px;
  font-weight: 500;
  text-decoration: none;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.9), 0 6px 0 rgba(150, 95, 30, 0.45), 0 14px 30px rgba(255, 190, 100, 0.3);
}
.screen.is-active .demo-dome { animation: enter-up 0.8s var(--ease) 1.2s backwards; }
.demo-dome:active { translate: 0 5px; }

/* Physical keyboard (testing on a PC, accessibility): a clear focus ring, only when keys are used. */
.stage :focus { outline: none; }
.stage :focus-visible { outline: 5px solid #ffd27a; outline-offset: 6px; }
.wish:focus-visible { outline-offset: -4px; border-radius: 44px; }
