:root {
  color-scheme: dark;
  --ink: #090806;
  --panel: #11100d;
  --panel-2: #191610;
  --cream: #f8e8c2;
  --muted: #b8a98a;
  --gold: #d6ad62;
  --gold-bright: #f2cc7d;
  --green: #55be78;
  --blue: #55aaf4;
  --yellow: #f2c458;
  --orange: #f18a32;
  --red: #ed5656;
  --radius: 28px;
  font-family: "Noto Sans Thai", "Leelawadee UI", Tahoma, system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; min-height: 100%; margin: 0; background: var(--ink); overscroll-behavior: none; }
body { min-height: 100dvh; color: var(--cream); overflow-x: hidden; }
button { font: inherit; }
#app { min-height: 100dvh; }

.screen {
  min-height: 100dvh;
  width: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: max(22px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  overflow: hidden;
  background:
    radial-gradient(circle at 50% -10%, rgba(231,174,76,.13), transparent 38%),
    radial-gradient(circle at 110% 90%, rgba(191,90,25,.10), transparent 36%),
    #090806;
}

.screen::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .35;
  background-image: radial-gradient(rgba(255,235,190,.42) .65px, transparent .8px);
  background-size: 22px 22px;
  mask-image: linear-gradient(to bottom, black, transparent 74%);
}

.splash { justify-content: center; gap: 30px; }
.splash.ready .brand-lockup { animation: rise-in .65s both; }
.ready-copy { font-size: clamp(28px, 8vw, 52px); font-weight: 900; letter-spacing: -.04em; animation: rise-in .55s both; }

.brand-lockup { position: relative; z-index: 1; text-align: center; }
.tent-mark { width: 150px; margin: 0 auto 8px; filter: drop-shadow(0 0 20px rgba(226,173,88,.18)); }
.tent-mark svg { display: block; width: 100%; }
.brand-thai { color: var(--gold-bright); font-size: 25px; font-weight: 900; letter-spacing: .02em; }
.brand-sub { margin-top: -2px; color: #ede0bd; font-size: 18px; font-weight: 800; letter-spacing: .1em; }

.topbar { width: min(100%, 520px); z-index: 2; display: flex; align-items: center; justify-content: space-between; min-height: 42px; }
.back-button, .icon-button { border: 0; color: var(--cream); background: transparent; padding: 8px; min-width: 44px; min-height: 44px; border-radius: 50%; font-size: 25px; cursor: pointer; }
.back-button:active, .icon-button:active { background: rgba(255,255,255,.08); transform: scale(.96); }
.section-kicker { color: var(--gold); font-weight: 800; font-size: 14px; letter-spacing: .08em; }

.home { justify-content: center; }
.home-inner { z-index: 1; width: min(100%, 460px); display: flex; flex-direction: column; align-items: center; }
.home .brand-lockup { transform: scale(.82); margin-bottom: 8px; }
.game-title { margin: 0; font-size: clamp(70px, 22vw, 122px); font-weight: 1000; line-height: .9; letter-spacing: -.08em; color: #f2cf7e; text-shadow: 0 3px 0 #6b451d, 0 10px 30px rgba(213,151,55,.22); }
.tagline { margin: 14px 0 30px; color: #d9c9a8; font-size: 17px; font-weight: 700; }
.menu-stack { width: 100%; display: grid; gap: 12px; }
.button {
  width: 100%; min-height: 56px; border-radius: 17px; border: 1px solid rgba(223,184,111,.34);
  color: var(--cream); background: rgba(24,20,14,.82); font-weight: 850; font-size: 18px; cursor: pointer;
  box-shadow: inset 0 1px rgba(255,255,255,.04); transition: transform .16s, border-color .16s, background .16s;
}
.button:active { transform: scale(.98); }
.button.primary { color: #1a1105; background: linear-gradient(135deg, #f4d486, #d79b45); border-color: transparent; box-shadow: 0 10px 28px rgba(213,153,63,.18); }
.button.secondary { background: #16130e; }
.button.ghost { border-color: transparent; background: transparent; color: var(--muted); font-size: 15px; min-height: 44px; }
.resume-box { width: 100%; border: 1px solid rgba(84,190,120,.34); background: rgba(84,190,120,.08); border-radius: 18px; padding: 14px; margin-bottom: 14px; text-align: center; }
.resume-box p { margin: 0 0 10px; color: #cfe7d5; }
.resume-actions { display: grid; grid-template-columns: 1.3fr .7fr; gap: 8px; }
.resume-actions .button { min-height: 46px; font-size: 15px; }

.content { z-index: 1; width: min(100%, 520px); flex: 1; display: flex; flex-direction: column; padding-top: 14px; }
.content h1 { margin: 8px 0 8px; font-size: clamp(34px, 10vw, 52px); line-height: 1.05; letter-spacing: -.04em; }
.lead { color: var(--muted); margin: 0 0 24px; line-height: 1.55; }

.mode-grid { display: grid; gap: 12px; }
.mode-card { text-align: left; padding: 18px; border: 1px solid #332c20; border-radius: 20px; background: #12100d; color: var(--cream); cursor: pointer; }
.mode-card.active { border-color: var(--gold-bright); background: linear-gradient(135deg, rgba(222,170,80,.15), #12100d); box-shadow: 0 0 0 2px rgba(235,191,105,.08); }
.mode-title { font-weight: 900; font-size: 22px; display: flex; justify-content: space-between; }
.mode-note { color: var(--muted); margin-top: 4px; font-size: 14px; }
.mode-dots { margin-top: 12px; display: flex; gap: 6px; }
.dot { width: 38px; height: 5px; border-radius: 6px; background: #393126; }
.dot.on:nth-child(1) { background: var(--blue); }
.dot.on:nth-child(2) { background: var(--yellow); }
.dot.on:nth-child(3) { background: var(--orange); }

.settings-list { display: grid; gap: 10px; }
.setting-row { display: flex; gap: 14px; align-items: center; justify-content: space-between; padding: 16px; border-radius: 18px; border: 1px solid #2e281f; background: #12100d; }
.setting-copy strong { display: block; }
.setting-copy small { display: block; margin-top: 3px; color: var(--muted); line-height: 1.35; }
.switch { flex: 0 0 auto; width: 51px; height: 30px; border: 0; border-radius: 99px; padding: 3px; background: #383229; cursor: pointer; transition: .2s; }
.switch::after { content: ""; display: block; width: 24px; height: 24px; border-radius: 50%; background: #eee4ce; transition: transform .2s; }
.switch[aria-checked="true"] { background: #d7a550; }
.switch[aria-checked="true"]::after { transform: translateX(21px); background: #171005; }
.warning-row { border-color: rgba(237,86,86,.35); }
.warning-row .setting-copy strong { color: #ff8b82; }
.save-note { min-height: 26px; margin: 12px 0 4px; text-align: center; color: #dfb968; font-size: 14px; }

.steps { display: grid; gap: 14px; counter-reset: how; }
.step { counter-increment: how; display: grid; grid-template-columns: 46px 1fr; gap: 14px; align-items: center; padding: 15px; border-radius: 18px; background: #12100d; border: 1px solid #2b261e; }
.step::before { content: counter(how); display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: #2a2114; color: var(--gold-bright); font-weight: 900; }
.step strong { font-size: 17px; }
.care-note { margin-top: auto; padding: 20px 4px 4px; text-align: center; color: #d7c7a6; font-size: 14px; }

.people-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 4px 0 14px; }
.person-button { aspect-ratio: 1.2; border-radius: 20px; border: 1px solid #332c21; background: #12100d; color: var(--cream); font-size: 30px; font-weight: 950; cursor: pointer; }
.person-button.active { color: #171005; background: var(--gold-bright); border-color: var(--gold-bright); }
.more-people { border: 1px solid #332c21; border-radius: 20px; overflow: hidden; margin-bottom: 18px; }
.more-toggle { border: 0; width: 100%; background: #12100d; color: var(--cream); padding: 16px; font-weight: 800; text-align: left; cursor: pointer; }
.stepper { display: flex; justify-content: center; align-items: center; gap: 22px; padding: 18px; background: #0e0d0b; }
.stepper button { width: 46px; height: 46px; border: 1px solid #4a3e2b; border-radius: 50%; color: var(--cream); background: #1a1712; font-size: 24px; cursor: pointer; }
.stepper strong { min-width: 58px; text-align: center; font-size: 28px; }
.round-summary { text-align: center; color: var(--muted); margin-bottom: 14px; }
.round-summary b { color: var(--cream); }

.circle-intro { justify-content: center; text-align: center; }
.circle-intro-inner { position: relative; z-index: 2; width: min(100%, 460px); animation: rise-in .45s both; }
.intro-visual { width: min(76vw, 340px); margin: 0 auto 20px; filter: drop-shadow(0 16px 34px rgba(0,0,0,.32)); }
.intro-visual svg { display: block; width: 100%; overflow: visible; }
.seat { fill: #18140e; stroke: #8e713e; stroke-width: 3; }
.phone-drawing rect, .phone-drawing path { fill: #100e0b; stroke: #f0cf86; stroke-width: 5; stroke-linecap: round; }
.phone-drawing rect:nth-child(2) { fill: #19140d; stroke-width: 2; }
.turn-arrow { fill: none; stroke: #e8bd68; stroke-width: 5; stroke-linecap: round; stroke-dasharray: 10 10; animation: arrow-pulse 1.05s ease-in-out infinite alternate; }
.turn-arrow-left { animation-delay: -.52s; }
.swipe-stroke { fill: none; stroke: #e8bd68; stroke-width: 5; stroke-linecap: round; animation: swipe-pulse .9s ease-in-out infinite; }
.circle-intro h1 { margin: 0; color: #f6e6bf; font-size: clamp(34px, 10vw, 52px); line-height: 1.1; letter-spacing: -.04em; }
.circle-intro p { margin: 12px 0 24px; color: var(--gold-bright); font-size: clamp(18px, 5vw, 24px); font-weight: 850; }
.intro-progress { width: 110px; height: 3px; margin: 0 auto; overflow: hidden; border-radius: 99px; background: #332b20; }
.intro-progress span { display: block; height: 100%; background: var(--gold-bright); transform-origin: left; animation: intro-progress 2.1s linear both; }

.game-screen { padding: max(14px, env(safe-area-inset-top)) 14px max(16px, env(safe-area-inset-bottom)); touch-action: none; user-select: none; }
.game-top { position: relative; z-index: 20; width: 100%; display: flex; align-items: center; justify-content: space-between; }
.turn-count { font-variant-numeric: tabular-nums; color: #d4c29e; font-size: 13px; font-weight: 800; letter-spacing: .08em; padding: 9px 12px; border: 1px solid rgba(229,198,137,.18); border-radius: 99px; background: rgba(10,9,7,.55); }
.deck-stage { flex: 1; width: 100%; min-height: 0; display: grid; place-items: center; position: relative; z-index: 2; }
.deck { position: relative; width: min(77vw, 410px); aspect-ratio: .68; }
.deck-layer, .playing-card { position: absolute; inset: 0; border-radius: var(--radius); }
.deck-layer { background: #15120e; border: 1px solid #6e5933; box-shadow: 0 14px 38px rgba(0,0,0,.36); }
.deck-layer:nth-child(1) { transform: translate(8px, 11px) rotate(1.1deg); opacity: .56; }
.deck-layer:nth-child(2) { transform: translate(4px, 6px) rotate(.45deg); opacity: .78; }
.playing-card { --card-color: var(--gold); overflow: hidden; background: #0d0b09; border: 2px solid var(--card-color); box-shadow: 0 22px 60px rgba(0,0,0,.5), inset 0 0 0 7px rgba(227,188,112,.025); will-change: transform, opacity; }
.playing-card::before { content: ""; position: absolute; inset: 13px; border: 1px solid color-mix(in srgb, var(--card-color) 58%, transparent); border-radius: calc(var(--radius) - 10px); pointer-events: none; }
.playing-card::after { content: ""; position: absolute; inset: 0; opacity: .28; pointer-events: none; background: radial-gradient(circle at 14% 12%, var(--card-color) 0 1px, transparent 2px), radial-gradient(circle at 82% 28%, #f5dfb1 0 1px, transparent 1.7px), radial-gradient(circle at 18% 78%, #f5dfb1 0 .8px, transparent 1.6px); background-size: 47px 47px, 79px 79px, 61px 61px; }
.card-face { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 42px 30px; transition: opacity .16s ease; }
.card-back { background: radial-gradient(circle at 50% 38%, rgba(219,161,67,.1), transparent 40%), #0d0b09; }
.card-front { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; justify-items: center; align-items: center; padding: clamp(34px, 5vh, 58px) clamp(28px, 6vw, 48px) clamp(44px, 7vh, 76px); opacity: 0; visibility: hidden; background: radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--level-color) 11%, transparent), transparent 58%), #0d0b09; }
.playing-card.revealed { --card-color: var(--level-color); animation: card-reveal .38s cubic-bezier(.2,.8,.2,1); }
.playing-card.revealed .card-back { opacity: 0; visibility: hidden; }
.playing-card.revealed .card-front { opacity: 1; visibility: visible; }
.mini-brand { align-self: start; color: #b99657; font-size: 13px; font-weight: 900; letter-spacing: .08em; }
.back-title { color: #edcb80; font-weight: 1000; line-height: .86; font-size: clamp(54px, 17vw, 90px); letter-spacing: -.08em; text-shadow: 0 2px 0 #68491f; }
.swipe-hint { position: absolute; bottom: 38px; color: #948467; font-size: 13px; font-weight: 700; }
.card-command { width: 100%; align-self: center; }
.card-headline { margin: 0; color: #f7e8c4; font-size: clamp(34px, 9.5vw, 52px); line-height: 1.08; letter-spacing: -.035em; font-weight: 950; }
.card-target { width: 100%; max-width: 96%; margin: 28px auto 0; padding: 15px 4px; border-top: 1px solid color-mix(in srgb, var(--level-color) 30%, transparent); border-bottom: 1px solid color-mix(in srgb, var(--level-color) 30%, transparent); color: #d3c4a6; font-size: clamp(17px, 4.8vw, 23px); font-weight: 750; line-height: 1.55; }
.card-target strong { color: var(--level-color); font-weight: 950; white-space: nowrap; }
.card-level { align-self: end; margin: 0; padding: 0; color: var(--level-color); font-size: clamp(42px, 12vw, 68px); line-height: 1; font-weight: 1000; letter-spacing: -.055em; text-shadow: 0 0 24px color-mix(in srgb, var(--level-color) 18%, transparent); }
.game-instruction { height: 30px; position: relative; z-index: 2; color: #94856b; font-size: 13px; font-weight: 700; text-align: center; }

.end { justify-content: center; text-align: center; }
.end-inner { z-index: 1; width: min(100%, 470px); }
.end h1 { font-size: clamp(52px, 14vw, 82px); line-height: .95; margin: 0 0 12px; color: var(--gold-bright); letter-spacing: -.06em; }
.finished { color: var(--muted); font-size: 20px; margin-bottom: 36px; }
.rating { margin-top: 28px; padding-top: 24px; border-top: 1px solid #29241c; }
.rating h2 { margin: 0 0 14px; font-size: 18px; }
.stars { display: flex; justify-content: center; gap: 7px; }
.star { border: 0; background: transparent; color: #443b2e; font-size: 40px; line-height: 1; padding: 3px; cursor: pointer; }
.star.active { color: #f2bd4d; text-shadow: 0 0 18px rgba(242,189,77,.22); }
.thanks { min-height: 24px; margin-top: 10px; color: #8fca9f; font-weight: 800; }

.toast { position: fixed; z-index: 99; left: 50%; bottom: max(25px, env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; width: max-content; max-width: calc(100vw - 40px); padding: 12px 16px; border-radius: 13px; background: #ede2c9; color: #17120a; font-size: 14px; font-weight: 800; transition: .25s; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.hidden { display: none !important; }

@keyframes rise-in { from { opacity: 0; transform: translateY(9px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes card-reveal { 0% { transform: scaleX(1); } 45% { transform: scaleX(.88); } 100% { transform: scaleX(1); } }
@keyframes arrow-pulse { from { opacity: .38; } to { opacity: 1; } }
@keyframes swipe-pulse { 0%, 100% { opacity: .35; transform: translate(-5px, 5px); } 50% { opacity: 1; transform: translate(5px, -5px); } }
@keyframes intro-progress { from { transform: scaleX(0); } to { transform: scaleX(1); } }

@media (orientation: landscape) and (max-height: 600px) {
  .home { justify-content: flex-start; overflow-y: auto; }
  .home-inner { width: min(90%, 760px); display: grid; grid-template-columns: .8fr 1fr; column-gap: 34px; }
  .home .brand-lockup { display: none; }
  .title-wrap { grid-row: 1 / span 2; align-self: center; }
  .game-title { font-size: 84px; }
  .tagline { margin-bottom: 0; }
  .menu-stack { align-self: center; }
  .deck { height: min(72vh, 430px); width: auto; }
}

@media (min-width: 720px) {
  .screen { padding-left: 34px; padding-right: 34px; }
  .deck { width: min(50vw, 420px); }
}

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