:root {
  --bg-dark: #070b14;
  --bg-panel: #101726;
  --bg-panel-2: #162033;
  --border-subtle: rgba(148, 163, 184, 0.18);
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --accent-2: #818cf8;
  --danger: #f43f5e;
  --danger-soft: rgba(244, 63, 94, 0.14);
  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.14);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.16);
  --radius-lg: 20px;
  --radius-md: 14px;
  --shadow-card: 0 20px 50px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  touch-action: manipulation;
}

body {
  font-family: 'Noto Sans Thai', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100dvh;
  line-height: 1.5;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(56, 189, 248, 0.04) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(56, 189, 248, 0.04) 1px, transparent 1px);
  background-size: 42px 42px;
  pointer-events: none;
  z-index: 0;
}

.bg-glow {
  position: fixed;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.2;
  pointer-events: none;
  z-index: 0;
}

.bg-glow-1 { top: -150px; left: -120px; background: #38bdf8; }
.bg-glow-2 { bottom: -170px; right: -120px; background: #f43f5e; }

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px max(14px, env(safe-area-inset-left)) 36px max(14px, env(safe-area-inset-right));
}

.hidden { display: none !important; }

/* ---------------- HUD ---------------- */
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: rgba(16, 23, 38, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 10px 16px;
  margin-bottom: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.hud-left { display: flex; align-items: center; gap: 10px; min-width: 195px; }

.hud-avatar {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--bg-panel-2);
  border: 1px solid rgba(56, 189, 248, 0.35);
  display: grid;
  place-items: center;
  overflow: hidden;
  flex-shrink: 0;
}

.hud-avatar svg { width: 48px; height: 48px; }
.hud-name-row { display: flex; align-items: center; gap: 8px; }
.hud-player-name { font-weight: 700; font-size: 0.98rem; }

.stage-pill {
  font-size: 0.74rem;
  font-weight: 700;
  background: rgba(56, 189, 248, 0.16);
  color: var(--accent);
  border: 1px solid rgba(56, 189, 248, 0.35);
  padding: 2px 8px;
  border-radius: 999px;
}

.hud-role-label { font-size: 0.78rem; color: var(--text-muted); }
.hud-center { flex: 1; max-width: 460px; }

.hp-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.84rem;
  margin-bottom: 4px;
}

.hp-title { color: var(--text-muted); font-weight: 600; }
.hp-money {
  font-family: 'Space Grotesk', 'Noto Sans Thai', sans-serif;
  font-weight: 700;
  color: #fbbf24;
}

.hearts-row { display: flex; gap: 3px; font-size: 1rem; margin-bottom: 5px; flex-wrap: wrap; }
.heart-unit { display: inline-block; transition: transform 0.25s ease, opacity 0.25s ease; }
.heart-unit.lost { opacity: 0.22; filter: grayscale(1); transform: scale(0.85); }

.hp-bar-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.hp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #f43f5e, #fbbf24 55%, #10b981);
  border-radius: 999px;
  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.hud-right { display: flex; gap: 8px; }

.icon-btn {
  min-width: 44px;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-panel-2);
  color: var(--text-main);
  cursor: pointer;
  font-size: 1.15rem;
  transition: transform 0.15s, border-color 0.15s;
}

.icon-btn:hover { border-color: var(--accent); transform: translateY(-1px); }

/* ---------------- JOURNEY MAP ---------------- */
.journey-strip {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.journey-node {
  background: rgba(16, 23, 38, 0.78);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 6px 8px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: all 0.25s ease;
}

.journey-node.active {
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.15);
  color: var(--text-main);
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.22);
}

.journey-node.safe { border-color: rgba(16, 185, 129, 0.5); background: var(--success-soft); color: #6ee7b7; }
.journey-node.scammed { border-color: rgba(244, 63, 94, 0.5); background: var(--danger-soft); color: #fda4af; }
.journey-node-label { font-weight: 700; }

/* ---------------- SCREENS ---------------- */
.screen { display: none; animation: fadeIn 0.35s ease; }
.screen.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------------- START SCREEN ---------------- */
.hero-card {
  background: rgba(16, 23, 38, 0.92);
  border: 1px solid var(--border-subtle);
  border-radius: 26px;
  padding: 26px;
  box-shadow: var(--shadow-card);
}

.hero-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.hero-badge {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.35);
  padding: 5px 12px;
  border-radius: 999px;
}

.credit-pill {
  display: inline-block;
  font-size: 0.84rem;
  font-weight: 700;
  color: #bae6fd;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.38);
  padding: 5px 14px;
  border-radius: 999px;
}

.hero-title {
  font-size: clamp(1.75rem, 3.8vw, 2.75rem);
  font-weight: 800;
  line-height: 1.2;
  background: linear-gradient(120deg, #ffffff 10%, #38bdf8 55%, #f472b6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  color: var(--text-muted);
  font-size: clamp(0.95rem, 1.8vw, 1.1rem);
  margin-top: 6px;
}

.howto-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 16px 0 20px;
}

.howto-pill {
  background: var(--bg-panel-2);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 11px 13px;
  font-size: 0.86rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.creator-panel {
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 22px;
  align-items: stretch;
}

.field-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: #cbd5e1;
}

.text-input {
  width: 100%;
  min-height: 48px;
  background: var(--bg-dark);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 11px 14px;
  color: var(--text-main);
  font-family: inherit;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.text-input:focus { border-color: var(--accent); }

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.avatar-card {
  background: var(--bg-panel-2);
  border: 2px solid var(--border-subtle);
  border-radius: 16px;
  padding: 10px 12px;
  min-height: 82px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  color: var(--text-main);
  font-family: inherit;
  transition: all 0.2s ease;
}

.avatar-card:hover { border-color: rgba(56, 189, 248, 0.55); transform: translateY(-2px); }
.avatar-card.selected {
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.14);
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.2);
}

.avatar-thumb { width: 58px; height: 68px; flex-shrink: 0; }
.avatar-card-title { font-weight: 700; font-size: 0.9rem; line-height: 1.25; }
.avatar-card-sub { font-size: 0.74rem; color: var(--text-muted); margin-top: 2px; }

.risk-tag {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.67rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(244, 63, 94, 0.16);
  color: #fda4af;
}

.risk-tag.rsu { background: rgba(236, 72, 153, 0.18); color: #f9a8d4; }

/* BIGGER 2D Character Preview */
.preview-card {
  height: 100%;
  background: linear-gradient(160deg, #121c30 0%, #0b1120 100%);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 20px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.preview-tag {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 10px;
}

.preview-stage-2d {
  width: 100%;
  height: 270px;
  border-radius: 18px;
  background: linear-gradient(180deg, #163056 0%, #214c7d 68%, #1e293b 68%, #0f172a 100%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 16px;
}

.preview-sky-cloud {
  position: absolute;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  height: 18px;
}

.preview-sky-cloud.c1 { width: 70px; top: 20px; left: 16px; animation: driftCloud 12s linear infinite; }
.preview-sky-cloud.c2 { width: 52px; top: 44px; right: 20px; animation: driftCloud 16s linear infinite reverse; }

.preview-ground {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 26px;
  background: repeating-linear-gradient(90deg, #334155 0 32px, #475569 32px 38px);
}

.preview-walker {
  width: 132px;
  height: 152px;
  z-index: 2;
  animation: previewPatrol 5s ease-in-out infinite;
}

@keyframes previewPatrol {
  0%, 100% { transform: translateX(-44px) scaleX(1); }
  45% { transform: translateX(44px) scaleX(1); }
  50% { transform: translateX(44px) scaleX(-1); }
  95% { transform: translateX(-44px) scaleX(-1); }
}

.preview-bubble {
  position: relative;
  z-index: 3;
  margin-bottom: 4px;
  font-size: 0.78rem !important;
  max-width: 90%;
}

.preview-name { font-size: 1.25rem; font-weight: 800; margin-top: 10px; }
.preview-role { font-size: 0.92rem; color: var(--accent); font-weight: 700; }
.preview-risk { font-size: 0.8rem; color: #fda4af; margin-top: 3px; font-weight: 600; }

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

.btn-share {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  border: none;
  border-radius: 14px;
  min-height: 50px;
  padding: 13px 24px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(16, 185, 129, 0.28);
  transition: transform 0.16s, filter 0.16s;
}

.btn-share:hover { transform: translateY(-2px); filter: brightness(1.08); }

.toast-share {
  position: fixed;
  bottom: max(20px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(16, 185, 129, 0.96);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.92rem;
  padding: 11px 20px;
  border-radius: 999px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  z-index: 99;
  animation: fadeIn 0.25s ease;
}

/* ---------------- BUTTONS ---------------- */
.btn-primary {
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
  color: #ffffff;
  border: none;
  border-radius: 14px;
  min-height: 50px;
  padding: 13px 28px;
  font-family: inherit;
  font-size: 1.02rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(14, 165, 233, 0.32);
  transition: transform 0.18s, box-shadow 0.18s, filter 0.18s;
}

.btn-primary:hover { transform: translateY(-2px); filter: brightness(1.08); }

.btn-secondary {
  background: var(--bg-panel-2);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  min-height: 50px;
  padding: 13px 26px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-lg { padding: 15px 38px; font-size: 1.1rem; }
.btn-full { width: 100%; }

/* ---------------- BIG 2D BATTLE STAGE ---------------- */
.scene-2d {
  position: relative;
  height: 390px;
  border-radius: 24px;
  overflow: hidden;
  border: 2px solid rgba(56, 189, 248, 0.25);
  background: linear-gradient(180deg, #0d1d38 0%, #193b6b 65%, #1e293b 65%, #111827 100%);
  margin-bottom: 18px;
  box-shadow: var(--shadow-card);
}

.scene-2d.stage-shake {
  animation: stageShake 0.45s ease;
  border-color: var(--danger);
}

@keyframes stageShake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-6px, 3px); }
  40% { transform: translate(6px, -3px); }
  60% { transform: translate(-5px, -2px); }
  80% { transform: translate(5px, 2px); }
}

.scene-sky { position: absolute; inset: 0 0 35% 0; pointer-events: none; }

.cloud {
  position: absolute;
  background: rgba(255, 255, 255, 0.13);
  border-radius: 999px;
  height: 26px;
}

.cloud::after {
  content: '';
  position: absolute;
  width: 55%;
  height: 120%;
  background: inherit;
  border-radius: 999px;
  top: -10px;
  left: 20%;
}

.cloud-1 { width: 108px; top: 52px; left: 10%; animation: driftCloud 22s linear infinite; }
.cloud-2 { width: 84px; top: 34px; left: 68%; animation: driftCloud 28s linear infinite reverse; }

@keyframes driftCloud {
  0% { transform: translateX(-25px); }
  50% { transform: translateX(35px); }
  100% { transform: translateX(-25px); }
}

.scene-badge-bar {
  position: relative;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  gap: 8px;
}

.encounter-badge,
.channel-badge {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
  backdrop-filter: blur(8px);
}

.encounter-badge {
  background: rgba(15, 23, 42, 0.78);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.channel-badge {
  background: rgba(56, 189, 248, 0.22);
  color: #bae6fd;
  border: 1px solid rgba(56, 189, 248, 0.42);
}

.scene-backdrop {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 58px;
  height: 165px;
  pointer-events: none;
  opacity: 0.78;
}

.scene-road {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 58px;
  background: #1f2937;
  border-top: 4px solid #475569;
}

.scene-road::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 25px;
  height: 4px;
  background: repeating-linear-gradient(90deg, rgba(250, 204, 21, 0.48) 0 36px, transparent 36px 68px);
}

.scene-stage-floor { position: absolute; inset: 0; z-index: 4; }

.actor {
  position: absolute;
  bottom: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  will-change: left, right, transform;
  transform: translateZ(0);
  transition: left 0.55s cubic-bezier(0.22, 1, 0.36, 1), right 0.55s cubic-bezier(0.22, 1, 0.36, 1), transform 0.35s ease;
}

.actor-player { left: 16%; }
.actor-npc { right: 16%; }

.actor-sprite {
  width: 146px;
  height: 168px;
  filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.5));
}

.actor-tag {
  margin-top: -4px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(56, 189, 248, 0.48);
  color: #e0f2fe;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 999px;
}

.actor-tag.npc-tag { border-color: rgba(245, 158, 11, 0.48); color: #fde68a; }

/* 2D Character Limb & Combat Animations */
.walking .char-body { animation: walkBob 0.4s ease-in-out infinite; }
.walking .leg-left { transform-origin: 43px 82px; animation: legSwingA 0.4s ease-in-out infinite; }
.walking .leg-right { transform-origin: 57px 82px; animation: legSwingB 0.4s ease-in-out infinite; }
.walking .arm-left { transform-origin: 34px 56px; animation: armSwingB 0.4s ease-in-out infinite; }
.walking .arm-right { transform-origin: 66px 56px; animation: armSwingA 0.4s ease-in-out infinite; }
.idle .char-body { animation: idleBreathe 2.3s ease-in-out infinite; }

.player-dash-attack { animation: playerDash 0.6s ease forwards; }
.npc-dash-attack { animation: npcDash 0.6s ease forwards; }
.npc-knockback { animation: npcKnockback 0.65s ease forwards; }
.hurt-anim { animation: actorHurt 0.55s ease; }
.safe-anim { animation: actorCelebrate 0.65s ease; }

@keyframes walkBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes legSwingA { 0%, 100% { transform: rotate(-16deg); } 50% { transform: rotate(16deg); } }
@keyframes legSwingB { 0%, 100% { transform: rotate(16deg); } 50% { transform: rotate(-16deg); } }
@keyframes armSwingA { 0%, 100% { transform: rotate(-18deg); } 50% { transform: rotate(18deg); } }
@keyframes armSwingB { 0%, 100% { transform: rotate(18deg); } 50% { transform: rotate(-18deg); } }
@keyframes idleBreathe { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }

@keyframes playerDash {
  0% { transform: translateX(0); }
  45% { transform: translateX(140px) scale(1.08); }
  100% { transform: translateX(0); }
}

@keyframes npcDash {
  0% { transform: translateX(0); }
  45% { transform: translateX(-140px) scale(1.08); }
  100% { transform: translateX(0); }
}

@keyframes npcKnockback {
  0% { transform: translateX(0) rotate(0); opacity: 1; }
  40% { transform: translateX(48px) rotate(14deg); }
  100% { transform: translateX(18px) rotate(4deg); opacity: 0.82; }
}

@keyframes actorHurt {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-18px) rotate(-8deg); }
  65% { transform: translateX(10px) rotate(4deg); }
}

@keyframes actorCelebrate {
  0%, 100% { transform: translateY(0); }
  45% { transform: translateY(-22px) scale(1.07); }
}

/* Projectile / Impact VFX Layer */
.vfx-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 7;
}

.vfx-bolt {
  position: absolute;
  bottom: 105px;
  font-size: 2.3rem;
  filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.7));
}

.vfx-bolt.from-player {
  left: 26%;
  animation: shootRight 0.55s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.vfx-bolt.from-npc {
  right: 26%;
  animation: shootLeft 0.55s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.vfx-burst {
  position: absolute;
  bottom: 95px;
  font-size: 3rem;
  animation: burstPop 0.6s ease forwards;
}

.vfx-burst.on-player { left: 20%; }
.vfx-burst.on-npc { right: 20%; }

@keyframes shootRight {
  0% { transform: translateX(0) scale(0.7); opacity: 1; }
  100% { transform: translateX(44vw) scale(1.25); opacity: 0; }
}

@keyframes shootLeft {
  0% { transform: translateX(0) scale(0.7); opacity: 1; }
  100% { transform: translateX(-44vw) scale(1.25); opacity: 0; }
}

@keyframes burstPop {
  0% { transform: scale(0.3); opacity: 1; }
  50% { transform: scale(1.35); opacity: 1; }
  100% { transform: scale(1.65); opacity: 0; }
}

/* 2D Comic Dialogue Bubbles */
.comic-bubble {
  position: relative;
  background: #ffffff;
  color: #0f172a;
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.35;
  padding: 9px 13px;
  border-radius: 14px;
  border: 2px solid #0f172a;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
  max-width: 245px;
  text-align: center;
  margin-bottom: 6px;
  animation: bubblePop 0.3s ease;
}

.comic-bubble::after {
  content: '';
  position: absolute;
  bottom: -9px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 9px 7px 0;
  border-style: solid;
  border-color: #ffffff transparent transparent;
}

.bubble-npc { background: #fef3c7; border-color: #92400e; }
.bubble-npc::after { border-color: #fef3c7 transparent transparent; }

@keyframes bubblePop {
  from { opacity: 0; transform: scale(0.85) translateY(6px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.floating-delta {
  position: absolute;
  top: 26px;
  font-weight: 800;
  font-size: 1rem;
  padding: 5px 11px;
  border-radius: 10px;
  animation: popUp 1.15s ease forwards;
  white-space: nowrap;
  z-index: 8;
}

.floating-delta.loss { color: #fff; background: var(--danger); }
.floating-delta.safe { color: #fff; background: var(--success); }

@keyframes popUp {
  0% { opacity: 0; transform: translateY(10px) scale(0.8); }
  25% { opacity: 1; transform: translateY(-8px) scale(1.05); }
  100% { opacity: 0; transform: translateY(-38px) scale(1); }
}

/* ---------------- GAMEPLAY PANEL ---------------- */
.game-layout {
  display: grid;
  grid-template-columns: 1.18fr 0.82fr;
  gap: 18px;
  align-items: start;
}

.battle-panel {
  background: rgba(16, 23, 38, 0.92);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
}

.stage-title { font-size: 1.25rem; font-weight: 800; margin-bottom: 4px; }
.stage-context { color: var(--text-muted); font-size: 0.92rem; margin-bottom: 12px; }

.dialogue-card {
  background: var(--bg-panel-2);
  border: 1px solid rgba(56, 189, 248, 0.28);
  border-left: 4px solid var(--accent);
  border-radius: 14px;
  padding: 13px 15px;
  margin-bottom: 12px;
}

.dialogue-speaker { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; color: #7dd3fc; margin-bottom: 4px; }
.dialogue-quote { font-size: 0.95rem; color: #f8fafc; line-height: 1.5; }

.inspect-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }

.btn-inspect {
  min-height: 44px;
  background: rgba(245, 158, 11, 0.16);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.45);
  border-radius: 12px;
  padding: 8px 15px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-inspect:disabled { opacity: 0.72; cursor: default; }
.inspect-status { font-size: 0.82rem; color: var(--text-muted); }

.choices-label { font-size: 0.86rem; font-weight: 700; color: #cbd5e1; margin-bottom: 8px; }
.choices-container { display: flex; flex-direction: column; gap: 10px; }

.choice-btn {
  width: 100%;
  min-height: 54px;
  text-align: left;
  background: var(--bg-panel-2);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 13px 15px;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.96rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.16s ease;
}

.choice-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.14);
  transform: translateX(4px);
}

.choice-key {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 0.84rem;
  font-weight: 800;
  flex-shrink: 0;
}

/* ---------------- PHONE / DEVICE SIMULATOR ---------------- */
.device-panel { display: flex; justify-content: center; }

.phone-frame {
  width: 100%;
  max-width: 375px;
  background: #060911;
  border: 4px solid #26324a;
  border-radius: 32px;
  padding: 11px 11px 9px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.phone-notch {
  width: 112px;
  height: 18px;
  background: #131b2c;
  border-radius: 999px;
  margin: 0 auto 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.notch-speaker { width: 34px; height: 4px; border-radius: 99px; background: #334155; }
.notch-cam { width: 6px; height: 6px; border-radius: 50%; background: #1e293b; }

.phone-screen {
  background: #0d1526;
  border-radius: 20px;
  min-height: 360px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.phone-home-bar { width: 96px; height: 4px; background: #334155; border-radius: 99px; margin: 9px auto 2px; }

.sim-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.74rem;
  color: var(--text-muted);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  padding-bottom: 7px;
}

.sim-call-card { text-align: center; padding: 10px 8px; border-radius: 14px; background: rgba(255, 255, 255, 0.04); }
.sim-caller-avatar {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  margin: 0 auto 6px;
  background: linear-gradient(135deg, #334155, #1e293b);
  display: grid;
  place-items: center;
  font-size: 1.7rem;
  border: 2px solid rgba(56, 189, 248, 0.35);
}

.sim-caller-name { font-weight: 800; font-size: 0.98rem; }
.sim-caller-number { font-size: 0.78rem; color: #94a3b8; font-family: 'Space Grotesk', monospace; }

.sim-speech-box {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  padding: 11px;
  font-size: 0.86rem;
  line-height: 1.48;
  color: #e2e8f0;
}

.ai-wave-box { background: rgba(56, 189, 248, 0.08); border: 1px solid rgba(56, 189, 248, 0.28); border-radius: 12px; padding: 9px; }
.ai-wave-label { font-size: 0.72rem; font-weight: 700; color: #7dd3fc; margin-bottom: 5px; display: flex; justify-content: space-between; }
.wave-bars { display: flex; align-items: center; justify-content: center; gap: 4px; height: 26px; }
.wave-bar { width: 4px; background: linear-gradient(180deg, #38bdf8, #818cf8); border-radius: 99px; animation: wavePulse 0.9s ease-in-out infinite; }
@keyframes wavePulse { 0%, 100% { height: 7px; opacity: 0.55; } 50% { height: 24px; opacity: 1; } }

.deepfake-video-frame {
  position: relative;
  border-radius: 14px;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 12px;
  text-align: center;
  overflow: hidden;
}

.deepfake-glitch-overlay {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, rgba(56, 189, 248, 0.04) 0 2px, transparent 2px 5px);
  pointer-events: none;
}

.deepfake-face { font-size: 2.7rem; display: inline-block; animation: subtleGlitch 3.2s infinite; }
@keyframes subtleGlitch { 0%, 92%, 100% { transform: translate(0); } 94% { transform: translate(-2px, 1px); } 96% { transform: translate(2px, -1px); } }

.sms-card { background: #172236; border-radius: 14px; padding: 13px; border: 1px solid rgba(255, 255, 255, 0.08); }
.sms-sender { font-weight: 800; font-size: 0.9rem; color: #38bdf8; margin-bottom: 5px; }

.fake-url-box {
  margin-top: 8px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px dashed rgba(245, 158, 11, 0.5);
  border-radius: 10px;
  padding: 8px 10px;
  font-family: 'Space Grotesk', monospace;
  font-size: 0.78rem;
  color: #fbbf24;
  word-break: break-all;
}

.chat-thread { display: flex; flex-direction: column; gap: 8px; }
.chat-bubble { padding: 9px 11px; border-radius: 13px; font-size: 0.84rem; max-width: 94%; line-height: 1.42; }
.chat-bubble.incoming { background: #1e293b; border-bottom-left-radius: 4px; align-self: flex-start; }
.chat-bubble.system {
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.25);
  align-self: center;
  text-align: center;
  font-size: 0.76rem;
  color: #bae6fd;
}

.clue-scanner-box {
  margin-top: auto;
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.5);
  border-radius: 12px;
  padding: 9px 11px;
  font-size: 0.8rem;
  color: #fde68a;
  animation: fadeIn 0.25s ease;
}

.clue-scanner-box strong { display: block; margin-bottom: 3px; color: #fbbf24; }
.clue-scanner-box ul { padding-left: 16px; }

/* ---------------- FEEDBACK OVERLAY ---------------- */
.feedback-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 15, 0.84);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 50;
}

.feedback-card {
  width: 100%;
  max-width: 590px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 24px;
  padding: 22px;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.65);
  animation: fadeIn 0.25s ease;
}

.fb-top-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.fb-badge { display: inline-block; font-size: 0.82rem; font-weight: 800; padding: 5px 14px; border-radius: 999px; }
.fb-badge.safe { background: var(--success-soft); color: #6ee7b7; border: 1px solid rgba(16, 185, 129, 0.45); }
.fb-badge.hit { background: var(--danger-soft); color: #fda4af; border: 1px solid rgba(244, 63, 94, 0.45); }
.fb-scam-reveal { font-size: 0.8rem; font-weight: 700; padding: 4px 12px; border-radius: 999px; background: rgba(129, 140, 248, 0.18); color: #c7d2fe; border: 1px solid rgba(129, 140, 248, 0.4); }
.fb-heading { font-size: 1.28rem; font-weight: 800; margin-bottom: 8px; }
.fb-money-impact { font-weight: 700; font-size: 0.94rem; margin-bottom: 10px; padding: 8px 12px; border-radius: 10px; background: rgba(255, 255, 255, 0.04); }
.fb-explanation { color: #cbd5e1; font-size: 0.92rem; margin-bottom: 12px; }

.fb-redflags-box { background: rgba(244, 63, 94, 0.08); border: 1px solid rgba(244, 63, 94, 0.28); border-radius: 14px; padding: 11px 13px; margin-bottom: 10px; }
.fb-redflags-box h4 { font-size: 0.88rem; color: #fda4af; margin-bottom: 4px; }
.fb-redflags-box ul { padding-left: 18px; font-size: 0.85rem; color: #e2e8f0; }

.fb-tip-box { background: rgba(16, 185, 129, 0.1); border: 1px solid rgba(16, 185, 129, 0.3); border-radius: 14px; padding: 11px 13px; font-size: 0.86rem; color: #d1fae5; margin-bottom: 16px; }

/* ---------------- END SCREEN & GUIDES ---------------- */
.end-hero { background: rgba(16, 23, 38, 0.92); border: 1px solid var(--border-subtle); border-radius: 26px; padding: 28px; text-align: center; box-shadow: var(--shadow-card); margin-bottom: 20px; }
.end-hero.dead { border-color: rgba(244, 63, 94, 0.55); background: linear-gradient(180deg, rgba(45, 12, 24, 0.92), rgba(16, 23, 38, 0.95)); }
.end-hero.survived { border-color: rgba(16, 185, 129, 0.5); background: linear-gradient(180deg, rgba(10, 38, 34, 0.88), rgba(16, 23, 38, 0.95)); }
.end-avatar-result { width: 130px; height: 145px; margin: 0 auto 8px; }
.end-status-pill { display: inline-block; font-size: 0.84rem; font-weight: 800; padding: 5px 14px; border-radius: 999px; margin-bottom: 10px; }
.end-title { font-size: clamp(1.5rem, 3vw, 2.1rem); font-weight: 800; margin-bottom: 6px; }
.end-subtitle { color: var(--text-muted); max-width: 680px; margin: 0 auto 18px; }
.end-stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat-box { background: rgba(255, 255, 255, 0.04); border: 1px solid var(--border-subtle); border-radius: 16px; padding: 14px; }
.stat-label { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 4px; }
.stat-value { font-family: 'Space Grotesk', 'Noto Sans Thai', sans-serif; font-size: 1.3rem; font-weight: 800; }
.text-danger { color: #fb7185; }
.text-success { color: #34d399; }

.guide-section { background: rgba(16, 23, 38, 0.88); border: 1px solid var(--border-subtle); border-radius: 22px; padding: 22px; margin-bottom: 18px; }
.section-badge { display: inline-block; font-size: 0.78rem; font-weight: 700; padding: 4px 12px; border-radius: 999px; margin-bottom: 8px; }
.section-badge.danger { background: var(--danger-soft); color: #fda4af; border: 1px solid rgba(244, 63, 94, 0.4); }
.section-badge.info { background: rgba(56, 189, 248, 0.14); color: #7dd3fc; border: 1px solid rgba(56, 189, 248, 0.35); }
.section-heading { font-size: 1.2rem; font-weight: 800; margin-bottom: 14px; }

.history-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.history-item { background: var(--bg-panel-2); border: 1px solid var(--border-subtle); border-radius: 14px; padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.history-item.safe { border-left: 4px solid var(--success); }
.history-item.hit { border-left: 4px solid var(--danger); }
.history-title { font-weight: 700; font-size: 0.9rem; }
.history-meta { font-size: 0.78rem; color: var(--text-muted); }
.history-badge { font-size: 0.78rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.history-badge.safe { background: var(--success-soft); color: #6ee7b7; }
.history-badge.hit { background: var(--danger-soft); color: #fda4af; }

.steps-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.step-card { background: var(--bg-panel-2); border: 1px solid var(--border-subtle); border-radius: 16px; padding: 15px; }
.step-num { width: 28px; height: 28px; border-radius: 9px; background: var(--danger); color: #fff; font-weight: 800; display: grid; place-items: center; margin-bottom: 8px; }
.step-card h4 { font-size: 0.98rem; margin-bottom: 4px; }
.step-card p { font-size: 0.86rem; color: #cbd5e1; }

.playbook-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.tab-btn { min-height: 44px; background: var(--bg-panel-2); border: 1px solid var(--border-subtle); color: var(--text-muted); border-radius: 12px; padding: 9px 16px; font-family: inherit; font-size: 0.9rem; font-weight: 700; cursor: pointer; }
.tab-btn.active { background: rgba(56, 189, 248, 0.18); border-color: var(--accent); color: #fff; }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 0.25s ease; }

.defense-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.defense-card { background: var(--bg-panel-2); border: 1px solid var(--border-subtle); border-radius: 16px; padding: 15px; }
.defense-card h4 { font-size: 0.95rem; margin-bottom: 5px; color: #bae6fd; }
.defense-card p { font-size: 0.84rem; color: #cbd5e1; }

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

.site-footer {
  margin-top: 26px;
  padding: 14px 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.site-footer strong { color: #7dd3fc; }

/* ---------------- IPAD / TABLET (<= 1024px) ---------------- */
@media (max-width: 1024px) {
  .scene-2d { height: 340px; }
  .actor-sprite { width: 132px; height: 152px; }
  .creator-panel { grid-template-columns: 1fr; }
  .game-layout { grid-template-columns: 1fr 0.85fr; gap: 14px; }
  .howto-bar { grid-template-columns: 1fr; }
}

/* ---------------- MOBILE & SMALL TABLET (<= 768px) ---------------- */
@media (max-width: 768px) {
  .bg-glow { display: none; }
  .hud, .encounter-badge, .location-badge, .channel-badge { backdrop-filter: none; }
  .game-layout { grid-template-columns: 1fr; }
  .device-panel { order: 1; }
  .battle-panel { order: 2; }
  .phone-frame { max-width: 100%; border-radius: 22px; padding: 8px; }
  .phone-notch, .phone-home-bar { display: none; }
  .phone-screen { min-height: auto; border-radius: 16px; }

  .scene-2d { height: 315px; }
  .actor-player { left: 6%; }
  .actor-npc { right: 6%; }
  .actor-sprite { width: 118px; height: 136px; }
  .comic-bubble { max-width: 155px; font-size: 0.74rem; padding: 7px 10px; }

  .hud { flex-wrap: wrap; padding: 10px 12px; }
  .hud-center { order: 3; min-width: 100%; }
  .journey-strip { grid-template-columns: repeat(4, 1fr); }
  .end-stats-grid, .defense-cards, .steps-grid, .history-grid { grid-template-columns: 1fr; }
}

/* Stats Mini Bar, Location Badge, Voice Button & Panic Timer */
.stats-mini-bar {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 9px 12px;
  font-size: 0.84rem;
  font-weight: 700;
  color: #cbd5e1;
}

.end-mini-stats {
  margin-top: 16px;
}

.stat-pill-bad {
  background: var(--danger-soft);
  color: #fda4af;
  border: 1px solid rgba(244, 63, 94, 0.35);
  padding: 3px 10px;
  border-radius: 999px;
}

.stat-pill-good {
  background: var(--success-soft);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.35);
  padding: 3px 10px;
  border-radius: 999px;
}

.location-badge {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.2);
  color: #a7f3d0;
  border: 1px solid rgba(16, 185, 129, 0.4);
  backdrop-filter: blur(8px);
}

.dialogue-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.btn-voice-mini {
  background: rgba(56, 189, 248, 0.16);
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 999px;
  padding: 4px 11px;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.timer-box {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 12px;
  padding: 9px 12px;
  margin-bottom: 12px;
}

.timer-box.urgent {
  background: rgba(244, 63, 94, 0.16);
  border-color: rgba(244, 63, 94, 0.65);
  animation: timerPulse 0.6s ease-in-out infinite;
}

@keyframes timerPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.015); }
}

.timer-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 5px;
  color: #fde68a;
}

.timer-box.urgent .timer-row { color: #fda4af; }

.timer-track {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.timer-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #f43f5e, #f59e0b);
  transition: width 0.25s linear;
}

@media (max-width: 520px) {
  .mode-selector { grid-template-columns: 1fr; }
  .hero-card, .battle-panel, .guide-section, .end-hero { padding: 16px; }
  .avatar-grid { grid-template-columns: 1fr; }
  .scene-2d { height: 295px; }
  .actor-sprite { width: 108px; height: 124px; }
  .preview-stage-2d { height: 235px; }
  .preview-walker { width: 116px; height: 134px; }
}
