/* Theme: empeo home (website/pages/empeo-home) */
@font-face { font-family: "Gofive"; src: url("assets/fonts/Gofive-Text.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Gofive"; src: url("assets/fonts/Gofive-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Gofive"; src: url("assets/fonts/Gofive-Semi_Bold.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Gofive"; src: url("assets/fonts/Gofive-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }
:root {
  --flame: #F05B2F;
  --flame-deep: #E54111;
  --flame-light: #FFA07E;
  --flame-grad: linear-gradient(90deg, #f08a3f 0%, #f0704b 50%, #f0485f 100%);
  --seashell: #FFF3EC;
  --soft-orange: #FFE4D6;
  --bg: #FAF9F8;
  --card: #FFFFFF;
  --charcoal: #1C1C22;
  --iron: #383842;
  --lead: #525260;
  --anchor: #6A6A7C;
  --porpoise: #A5A5B6;
  --silver: #D2D2DA;
  --cloud: #ECECF1;
  --soft-cloud: #F6F6F8;
  --sky: #4C97FF;
  --success: #21CE9B;
  --success-bg: #E1F8F1;
  --success-ink: #0E8A63; /* success as text on white: 4.6:1 (the brand #21CE9B is only 2.0:1) */
  --danger: #E5484D;
  --danger-bg: #FDECEC;

  /* Kahoot-like choice colours, warmed to sit beside Flame */
  /* Answer colours — empeo home tokens (Flame / Sky / Indigo / Green), each dark enough
     for the white 44px number (≥3:1). -d = the pressed-edge shade. */
  --c0: #F05B2F;
  --c0-d: #C9431B;
  --c1: #2F7BE5;
  --c1-d: #2260B8;
  --c2: #5E5EED;
  --c2-d: #4343C4;
  --c3: #0E9F6E;
  --c3-d: #0A7A54;

  --radius: 32px;
  --radius-sm: 16px;
  --r-btn: 45px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.10);
  --font: "Gofive", "Sarabun", "Noto Sans Thai", system-ui, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--charcoal);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overscroll-behavior: none;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

#app { min-height: 100dvh; }
.screen {
  min-height: 100dvh;
  padding: calc(16px + var(--safe-t)) calc(20px + var(--safe-r)) calc(16px + var(--safe-b)) calc(20px + var(--safe-l));
}
.game-screen, .home, .results { user-select: none; -webkit-user-select: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; padding: 0 28px; position: relative; overflow: hidden; white-space: nowrap;
  border: 0; border-radius: var(--r-btn);
  font-weight: 600; font-size: 17px;
  background: var(--flame-grad); color: #fff;
  transition: transform .15s var(--ease-out), background .2s ease;
}
.btn::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: rgba(255,255,255,0); pointer-events: none; transition: background .2s ease; }
.btn:hover::after { background: rgba(255,255,255,.2); }
.btn:active { transform: scale(.97); }
.btn:disabled { background: var(--silver); color: #fff; cursor: not-allowed; }
.btn.lg { min-height: 64px; min-width: 220px; font-size: 21px; padding: 0 40px; }

.btn.sm { min-height: 40px; font-size: 15px; padding: 0 18px; }
.icon-btn {
  width: 48px; height: 48px; border-radius: 50%;
  border: 0; background: #fff; color: var(--iron);
  display: grid; place-items: center;
  box-shadow: 0 0 0 1.5px var(--silver) inset;
}
.icon-btn:hover, .icon-btn:active { background: var(--soft-cloud); }
.icon-btn svg { width: 22px; height: 22px; }

/* ---------- Home ---------- */
.home {
  display: grid; place-items: center; text-align: center;
  background: #FFFFFF;
  position: relative; overflow: hidden;
}
.home-card { max-width: 560px; width: 100%; display: grid; gap: 20px; justify-items: center; position: relative; z-index: 1; }

.brand-logo { height: 76px; width: auto; margin: -18px 0 -22px; }

.home h1 { margin: 0; font-size: clamp(40px, 5.4vw, 56px); line-height: 1.35; font-weight: 700; }
.home h1 span { background: var(--flame-grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.home p.lede { margin: 0; font-size: 19px; color: var(--lead); line-height: 1.75; }

.home-meta { color: var(--anchor); font-size: 16px; }
.admin-link {
  position: absolute; top: calc(16px + var(--safe-t)); right: calc(20px + var(--safe-r)); z-index: 2;
}

/* ---------- Game ---------- */
.game-screen {
  height: 100dvh; display: grid; gap: 14px;
  grid-template-rows: auto auto 1fr;
  background: #FFFFFF;
  position: relative; overflow: hidden;
}
.topbar { display: flex; align-items: center; gap: 12px; }
/* balances the sound button + timer on the right so the question stays centred (no quit button for players) */
.topbar::before { content: ""; flex: none; width: 124px; }

.topbar .q { flex: 1; min-width: 0; font-size: 22px; font-weight: 700; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.timer {
  height: 14px; border-radius: 999px; background: #fff; overflow: hidden; position: relative;
  box-shadow: inset 0 0 0 1.5px var(--soft-orange);
}
.timer-fill { position: absolute; inset: 0; transform-origin: left; background: var(--flame-grad); border-radius: 999px; }
.timer-fill.low { background: var(--danger); }
.timer-num {
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center;
  background: var(--flame-grad); color: #fff; font-size: 28px; font-weight: 700; flex: none;
  box-shadow: 0 6px 16px rgba(240, 91, 47, .3);
}
.timer-num.low { background: var(--danger); box-shadow: 0 6px 16px rgba(229, 72, 77, .35); animation: pulse .5s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(1.08); } }

.play-area { display: grid; gap: 14px; min-height: 0; grid-template-rows: minmax(0, 1fr) auto; }
.photo {
  position: relative; min-height: 0; border-radius: var(--radius); overflow: hidden;
  background: var(--soft-cloud); box-shadow: var(--shadow);
  display: grid; place-items: center;
}
.photo img { width: 100%; height: 100%; object-fit: contain; }

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice {
  --c: var(--c0); --cd: var(--c0-d);
  position: relative; border: 0; border-radius: var(--radius-sm);
  background: var(--c); color: #fff;
  min-height: 96px; padding: 0 20px;
  display: flex; align-items: center; gap: 16px;
  box-shadow: 0 5px 0 var(--cd);
  font-weight: 700; font-size: 44px; line-height: 1; font-variant-numeric: tabular-nums;
  transition: transform .08s ease, box-shadow .08s ease, opacity .25s, filter .25s;
}
.choice:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--cd); }
.choice svg { width: 40px; height: 40px; flex: none; }
.choice .num { flex: 1; text-align: center; margin-right: 40px; }
.choice[data-i="1"] { --c: var(--c1); --cd: var(--c1-d); }
.choice[data-i="2"] { --c: var(--c2); --cd: var(--c2-d); }
.choice[data-i="3"] { --c: var(--c3); --cd: var(--c3-d); }
.choice:disabled { cursor: default; }
.choices.revealed .choice.wrong { opacity: .28; filter: saturate(.4); }
.choices.revealed .choice.correct { box-shadow: 0 0 0 5px #fff, 0 0 0 9px var(--success), 0 5px 0 9px var(--success); z-index: 1; }
.choices.revealed .choice.picked.wrong { opacity: .6; box-shadow: 0 0 0 5px #fff, 0 0 0 9px var(--danger); }
.choice .tag {
  position: absolute; top: -12px; right: 12px; height: 28px; padding: 0 12px; border-radius: 999px;
  background: #fff; color: var(--success-ink); font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 4px;
  box-shadow: var(--shadow);
}
.choice.picked.wrong .tag { color: var(--danger); }

/* Answers always sit under the photo — one row of four on a landscape iPad */
@media (orientation: landscape) and (min-width: 900px) {
  .choices { grid-template-columns: repeat(4, 1fr); }
  .choice { min-height: 104px; }
}

/* ---------- Interstitial (get ready) ---------- */

@keyframes pop { from { transform: scale(1.35); } to { transform: scale(1); } }
@keyframes fadeIn { from { opacity: 0; } }

/* ---------- Reveal sheet ---------- */
.reveal-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(30,34,39,.35); animation: fadeIn .2s ease; }
.reveal {
  position: fixed; left: 50%; top: 50%; z-index: 21;
  width: min(520px, calc(100% - 40px)); max-height: calc(100dvh - 40px); overflow: auto;
  transform: translate(-50%, -50%);
  background: #fff; border-radius: var(--radius); padding: 28px 32px 32px;
  box-shadow: var(--shadow-lg);
  display: grid; justify-items: center; gap: 10px; text-align: center;
  animation: modalIn .4s var(--ease-out);
}
@keyframes modalIn { from { transform: translate(-50%, -46%) scale(.94); opacity: 0; } }
.reveal img { width: 150px; height: 150px; }
.reveal.ok img { animation: hop .7s ease .15s; }
@keyframes hop { 30% { transform: translateY(-16px) rotate(-4deg); } 60% { transform: translateY(0) rotate(2deg); } }
.reveal h3 { margin: 0; font-size: 34px; }
.reveal.ok h3 { color: var(--success-ink); }
.reveal.bad h3 { color: var(--danger); }
.reveal p { margin: 0; color: var(--lead); font-size: 19px; line-height: 1.6; }
.reveal p b { color: var(--charcoal); }
.reveal .btn { margin-top: 10px; width: 100%; }

/* ---------- Results (final success state) ---------- */
.results {
  display: grid; place-items: center; text-align: center;
  background: #FFFFFF;
  position: relative; overflow: hidden;
}
.results-card { width: min(900px, 100%); display: grid; gap: 14px; justify-items: center; }
.results-card > img { width: 150px; height: 150px; }

.results h1 { margin: 0; font-size: clamp(36px, 5vw, 52px); }
.results .sub { margin: -6px 0 0; font-size: 20px; color: var(--lead); }

@keyframes starIn { from { transform: scale(0) rotate(-40deg); } }

.actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 40; }

@keyframes shake { 25% { transform: translateX(-10px); } 75% { transform: translateX(10px); } }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%); z-index: 60;
  background: var(--charcoal); color: #fff; padding: 12px 20px; border-radius: 999px; font-size: 16px;
  animation: fadeIn .2s ease;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* mascot PNGs have a white canvas — blend onto tinted backgrounds */
.results-card > img { background: #fff; border-radius: 50%; box-shadow: 0 10px 30px rgba(217, 74, 23, 0.18); }
@media (orientation: portrait) { .choice { min-height: 132px; font-size: 52px; } }

/* ================================================================ rewards */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.reward {
  position: relative; overflow: hidden; display: grid; place-items: center; text-align: center;
  background: #FFFFFF;
  user-select: none; -webkit-user-select: none;
}
.reward-card { position: relative; z-index: 1; width: min(640px, 100%); display: grid; gap: 14px; justify-items: center; }
.reward-card > .actions { margin-top: 28px; }
.reward-card .btn.lg { min-width: 280px; }
.reward-title { margin: 0; font-size: clamp(36px, 5vw, 54px); line-height: 1.15; }
.reward .sub { margin: 0; font-size: 20px; color: var(--lead); line-height: 1.5; }
.gift-btn { border: 0; background: none; padding: 0; margin: 8px 0 0; width: 280px; height: 280px; }
@keyframes giftWiggle { 0%, 60%, 100% { transform: rotate(0); } 68% { transform: rotate(-6deg) scale(1.03); } 76% { transform: rotate(6deg) scale(1.03); } 84% { transform: rotate(-3deg); } }
.gift-btn.opening .gift-btn.opening @keyframes giftShake { 0% { transform: translateX(-4px) rotate(-2deg); } 50% { transform: translateX(4px) rotate(2deg); } 100% { transform: translateX(-4px) rotate(-2deg); } }
.tap-hint { margin: 0; font-size: 22px; font-weight: 600; color: var(--flame); animation: pulse 1s ease-in-out infinite alternate; }

.reward-card.revealed > * { animation: riseIn .5s cubic-bezier(.2, 1.2, .3, 1) both; }
.reward-card.revealed > *:nth-child(2) { animation-delay: .08s; }
.reward-card.revealed > *:nth-child(3) { animation-delay: .16s; }
.reward-card.revealed > *:nth-child(n+4) { animation-delay: .24s; }
@keyframes riseIn { from { opacity: 0; transform: translateY(24px) scale(.96); } }
.eyebrow { font-size: 20px; font-weight: 600; color: var(--flame); letter-spacing: .04em; margin-bottom: 10px; }
.prize-stage {
  --tint: #FFE2D2; --tint-d: #F7632B;
  width: 300px; height: 300px; border-radius: 36px; display: grid; place-items: center; padding: 28px;
  background: radial-gradient(circle at 50% 38%, #fff 0%, var(--tint) 75%);
  box-shadow: 0 0 0 6px #fff, 0 0 0 9px var(--tint-d), var(--shadow-lg);
}
.prize-stage img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 10px 16px rgba(30, 34, 39, .18)); }
.prize-stage.sm { width: 180px; height: 180px; border-radius: 24px; padding: 16px; box-shadow: 0 0 0 4px #fff, 0 0 0 6px var(--tint-d); }

.prize-name { margin: 6px 0 0; font-size: clamp(32px, 4.4vw, 46px); line-height: 1.2; }
.auto-note { color: var(--porpoise); font-size: 15px; min-height: 20px; }
.soldout-img { width: 170px; height: 170px; border-radius: 50%; background: #fff; box-shadow: var(--shadow); }
@media (max-height: 860px) and (orientation: landscape) {
  .prize-stage { width: 230px; height: 230px; }
  .gift-btn { width: 230px; height: 230px; }
  .reward-card { gap: 10px; }
}

/* ================================================================ lose (sorry state) */
.lose { position: relative; overflow: hidden; display: grid; place-items: center; text-align: center; background: #FFFFFF; user-select: none; -webkit-user-select: none; }
.lose-card { width: min(620px, 100%); display: grid; gap: 14px; justify-items: center; }

@keyframes sulk { 0%, 100% { transform: rotate(0) translateY(0); } 30% { transform: rotate(-3deg) translateY(2px); } 60% { transform: rotate(2deg) translateY(4px); } }
.lose-title { margin: 0; font-size: clamp(38px, 5vw, 54px); line-height: 1.2; }
.lose .sub { margin: 0; font-size: 20px; color: var(--lead); line-height: 1.5; }
.answer-card {
  display: flex; align-items: center; gap: 20px; width: 100%; margin-top: 6px; padding: 14px 24px 14px 14px;
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-lg); text-align: left;
  animation: riseIn .5s cubic-bezier(.2, 1.2, .3, 1) .2s both;
}
.answer-photo { width: 220px; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 20px; background: var(--cloud); flex: none; }
.answer-body { display: grid; gap: 4px; }
.answer-label { font-size: 16px; font-weight: 600; color: var(--success-ink); }
.answer-num { font-size: 26px; font-weight: 600; color: var(--charcoal); line-height: 1.1; }
.answer-num b { font-size: 64px; font-weight: 700; color: var(--success-ink); margin-right: 4px; }
.answer-picked { font-size: 17px; color: var(--anchor); }
.answer-picked s { color: var(--danger); font-weight: 600; text-decoration-thickness: 2px; }
.lose .actions { margin-top: 20px; }
.lose .btn.lg { min-width: 220px; }
.lose > :not(.hero-bg) { position: relative; z-index: 1; }
@media (max-width: 560px) { .answer-card { flex-direction: column; text-align: center; padding: 14px; } .answer-photo { width: 100%; } }

/* ================================================================ hero background (empeo home) */
.hero-bg { position: absolute; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.hero-bg img, .hero-bg video { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); width: max(100%, 1180px); height: auto; max-width: none; }
.hero-bg img, .hero-bg video { -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 30%); mask-image: linear-gradient(180deg, transparent 0%, #000 30%); }
.hero-bg video { opacity: 0; }
.hero-bg video.on { opacity: 1; }
.home > :not(.hero-bg), .results > :not(.hero-bg), .reward > :not(.hero-bg), .game-screen > :not(.hero-bg) { position: relative; z-index: 1; }
.reward > .reward-card { z-index: 2; }
.home > .admin-link { position: absolute; z-index: 2; }
.game-screen .hero-bg { opacity: .9; }
/* portrait: show the whole skyline across the width instead of cropping its sides */
@media (orientation: portrait) {
  .hero-bg img, .hero-bg video { width: 100%; }
}

/* game logo: the gift-box mascot art has its own transparent canvas — no disc behind it */
@media (max-height: 860px) and (orientation: landscape) { .home-card { gap: 16px; } }

/* ================================================================ review fixes */
/* visible focus for keyboard / switch control, without rings on touch */
:where(button, [role="tab"], input, select, .drop):focus-visible { outline: 3px solid var(--sky); outline-offset: 3px; }
.choice:focus-visible { outline-color: #fff; outline-offset: -6px; }

/* reward gift box (inline SVG): wiggle while waiting, shake + lid pops on tap */
.gift { width: 100%; height: 100%; overflow: visible; animation: giftWiggle 1.8s ease-in-out infinite; transform-origin: 50% 90%; }
.gift-lid { transition: transform .5s cubic-bezier(.3, 1.6, .5, 1); transform-origin: 30px 100px; }
.gift-btn.opening .gift { animation: giftShake .12s linear infinite; }
.gift-btn.opening .gift-lid { transform: translate(-14px, -40px) rotate(-18deg); transition-delay: .7s; }

/* prize art is trimmed to its content at runtime; give it breathing room inside the card */
.prize-stage { padding: 36px; }
.prize-fallback-img { width: 80%; height: 80%; object-fit: contain; }
/* prize art always fits inside the card, whatever its natural size (scales small art up, big art down) */
.prize-stage { position: relative; overflow: hidden; }
.prize-stage > img { position: absolute; inset: 14%; width: 72%; height: 72%; object-fit: contain; }

/* ================================================================ home: น้องก้อน peeking up from the bottom edge */
/* Two of them, same size, overlapped and staggered — "there are several hiding around here". Static;
   the right one sits behind. Both stay flush with the bottom edge (the art is cut there). */
.home { padding-bottom: calc(150px + var(--safe-b)); }
.peek {
  position: absolute; left: 50%; bottom: 0; z-index: 1; pointer-events: none;
  width: min(640px, 76vw); aspect-ratio: 640 / 200;
  transform: translateX(-50%);
}
.peek img { position: absolute; bottom: 0; height: auto; filter: drop-shadow(0 -6px 18px rgba(30, 34, 39, .10)); }
.peek__a { left: 0; width: 58%; z-index: 2; }
.peek__b { right: 0; width: 58%; z-index: 1; }
@media (orientation: portrait) { .peek { width: min(700px, 88vw); } .home { padding-bottom: calc(190px + var(--safe-b)); } }
.home > .peek { position: absolute; } /* beat the generic ".home > :not(.hero-bg)" stacking rule */
