/* PAWLOWEEN 2026 - Cloud 11 tokens + Halloween accents. Light mode only, mobile first. */
@font-face { font-family: 'Diatype Thai'; src: url('/fonts/ABCDiatypeThaiLoopless-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Diatype Thai'; src: url('/fonts/ABCDiatypeThaiLoopless-Medium.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Diatype Thai'; src: url('/fonts/ABCDiatypeThaiLoopless-Bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --blue-500: #007ff7; --blue-400: #56b5f7; --blue-300: #8bd8fe; --periwinkle: #9eb1ff;
  --pink: #ffa8c3; --amber: #ffbd4a; --violet: #a825ee; --magenta: #f23bba;
  --orange: #f88546; --purple: #5f10de; --coral: #ed7272;
  --text: #171717; --muted: #5b5b6b; --surface: #ffffff; --line: #ece8f7;
  --radius: 20px;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  font-family: 'Diatype Thai', system-ui, -apple-system, 'Segoe UI', 'Noto Sans Thai', sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #f3efff 0%, #ffffff 42%) fixed, var(--surface);
  line-height: 1.5;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}
h1 { font-size: 26px; line-height: 1.25; margin: 0; font-weight: 700; color: var(--purple); }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.strong { font-weight: 700; }

.view { display: none; flex-direction: column; min-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom)); padding: 0 16px 20px; }
.view.active { display: flex; }
.stack { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 440px; margin: 0 auto; }
.center { align-items: center; text-align: center; justify-content: center; flex: 1; }

.topbar { display: flex; align-items: center; justify-content: space-between; height: 56px; max-width: 440px; width: 100%; margin: 0 auto; }
.wordmark { height: 22px; width: auto; display: block; }
.chip {
  font: inherit; font-size: 13px; font-weight: 700; min-width: 44px; height: 32px; padding: 0 12px;
  border-radius: 999px; border: 1.5px solid var(--purple); background: #fff; color: var(--purple); cursor: pointer;
}

/* loading */
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--orange); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: 0 8px 24px rgba(95, 16, 222, 0.08); }
.dev { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 320px; }
.dev[hidden] { display: none; }
.dev input { font: inherit; font-size: 16px; height: 48px; padding: 0 14px; border-radius: 12px; border: 1.5px solid var(--periwinkle); }

/* intro */
.hero { position: relative; border-radius: var(--radius); overflow: hidden; aspect-ratio: 3 / 2; box-shadow: 0 10px 28px rgba(95, 16, 222, 0.18); }
.hero-img { position: absolute; inset: 0; background: url('/img/scene.jpg?v=1') center / cover; background-image: image-set(url('/img/scene.avif?v=1') type('image/avif'), url('/img/scene.jpg?v=1') type('image/jpeg')); }
.hero-badge { position: absolute; left: 12px; bottom: 12px; background: var(--purple); color: #fff; font-weight: 700; font-size: 13px; letter-spacing: 0.06em; padding: 5px 12px; border-radius: 999px; }
.kicker { font-weight: 700; color: var(--orange); letter-spacing: 0.04em; margin-top: 4px; }
.hello { font-weight: 500; color: var(--blue-500); }
.hello:empty { display: none; }
.steps { list-style: none; padding: 0; margin: 2px 0 4px; display: grid; gap: 8px; }
.steps li { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; font-weight: 500; }
.fine { font-size: 12px; color: var(--muted); text-align: center; }

/* buttons */
.btn {
  font: inherit; font-weight: 700; font-size: 17px; min-height: 52px; padding: 12px 24px; width: 100%;
  border-radius: 999px; border: 0; cursor: pointer; transition: transform 0.08s ease, box-shadow 0.2s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: linear-gradient(135deg, var(--orange), #f2604a 45%, var(--purple)); color: #fff; box-shadow: 0 10px 22px rgba(248, 133, 70, 0.35); }
.btn-big { min-height: 60px; font-size: 19px; }
.btn-ghost { background: #fff; color: var(--purple); border: 1.5px solid var(--purple); }
.textlink { color: var(--blue-500); font-size: 14px; text-decoration: underline; }

/* game */
body[data-view='game'] { background: #1d0b45; }
#view-game { padding: 0 16px 12px; align-items: center; }
.gamebar { position: sticky; top: 0; z-index: 2; width: 100%; max-width: 440px; padding: 10px 0 8px; background: #1d0b45; color: #fff; }
.gamebar-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.timer { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 72px; }
.timer.urgent { color: var(--amber); animation: pulse 1s ease-in-out infinite; }
.found { font-weight: 500; font-size: 16px; }
.found b { font-size: 20px; color: var(--amber); }
.gamebar .chip { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.6); }
.timebar { height: 8px; border-radius: 99px; background: rgba(255, 255, 255, 0.16); margin-top: 8px; overflow: hidden; }
.timebar-fill { height: 100%; background: linear-gradient(90deg, var(--orange), var(--amber)); transform-origin: left center; }
.panels { --pw: 260px; display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 4px; }
.panel {
  position: relative; width: var(--pw); aspect-ratio: 3 / 4; border-radius: 14px; overflow: hidden; cursor: crosshair;
  background: #2a1460; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation;
}
.panel picture, .panel img { display: block; width: 100%; height: 100%; }
.panel img { object-fit: cover; object-position: 0% 50%; pointer-events: none; -webkit-touch-callout: none; -webkit-user-drag: none; user-select: none; }
.panel[data-side='right'] img { object-position: 100% 50%; }
.marks { position: absolute; inset: 0; pointer-events: none; }
.mark { position: absolute; transform: translate(-50%, -50%); border-radius: 50%; }
.mark.hit { border: 3px solid var(--amber); box-shadow: 0 0 0 3px rgba(95, 16, 222, 0.55), 0 0 18px rgba(255, 189, 74, 0.9); animation: pop 0.45s ease-out; }
.mark.miss { color: var(--coral); font-size: 26px; font-weight: 700; line-height: 1; text-shadow: 0 1px 3px #000; animation: fade 0.7s ease-out forwards; }
.panel.shake { animation: shake 0.3s ease; }
.hint { color: rgba(255, 255, 255, 0.75); font-size: 13px; margin-top: 8px; text-align: center; }
@keyframes pop { 0% { transform: translate(-50%, -50%) scale(0.3); opacity: 0; } 70% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; } 100% { transform: translate(-50%, -50%) scale(1); } }
@keyframes fade { 0% { opacity: 1; transform: translate(-50%, -50%) scale(0.8); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(1.3); } }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@keyframes pulse { 50% { opacity: 0.55; } }

/* results */
.result h1 { font-size: 28px; }
.lead { font-size: 19px; font-weight: 500; color: var(--orange); }
.unlock { font-size: 18px; font-weight: 700; background: #fff; border: 1.5px dashed var(--orange); border-radius: 16px; padding: 14px 16px; width: 100%; }
#view-success .btn-primary { animation: glow 1.8s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 10px 30px rgba(242, 59, 186, 0.55); } }

/* error */
.diag { width: 100%; text-align: left; font-size: 11px; line-height: 1.45; background: #f6f4fb; border: 1px solid var(--line); border-radius: 12px; padding: 12px; white-space: pre-wrap; word-break: break-all; user-select: text; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
