/* หน้าเว็บของเกม (หน้าเปิดเกม / HUD / สรุปผล) แบบ "เกม" ให้เข้าชุดกับป้ายในฉาก (js/gameui.js)
   แผ่นป้ายหนา ขอบกรมท่าเข้ม · ไฮไลต์ขอบบน · ฐานนูนด้านล่าง · ปุ่มนูนกดยุบ · ฉากหลังน้ำเงินมีรัศมีแสง
   คงสีแบรนด์ (กรมท่า #1b1f3b · น้ำเงิน D.A.R.E. #2741c9 · เหลือง = ปุ่มสำคัญที่สุด) · ฟอนต์ Mitr + Anuphan · ไม่มี emoji */
:root {
  --ink: #1b1f3b;
  --ink-soft: #464c70;
  --line: #dfe4f2;
  --paper: #ffffff;
  --mist: #f4f6fc;
  --sky: #e8f0ff;
  --hero-sky: #dbebfb;
  --primary: #2741c9;
  --primary-deep: #1c2f9a;
  --primary-hi: #4a6cf0;
  --sun: #ffc93c;
  --sun-hi: #ffe27a;
  --sun-deep: #ffbf1a;
  --sun-lip: #b57d00;
  --sun-soft: #fff4d4;
  --navy-hi: #2c3473;
  --navy-lo: #161a3c;
  --abyss: #0a0c22;
  --refuse: #0b5fa5; --refuse-tint: #e2f0fd;
  --decide: #5b3cc4; --decide-tint: #eee9ff;
  --media: #b0246a; --media-tint: #fde7f1;
  --mind: #17723f; --mind-tint: #e1f6e8;
  --friend: #a5470b; --friend-tint: #fdeedd;
  /* แผ่นป้ายเกม: ขอบหนา + ฐานนูน + เงาตก */
  --edge: 4px solid var(--ink);
  --lip: 0 8px 0 var(--ink), 0 18px 30px -6px rgb(6 8 30 / 0.55);
  --lip-sm: 0 5px 0 var(--ink), 0 10px 18px -4px rgb(6 8 30 / 0.45);
  --gloss: inset 0 4px 0 rgb(255 255 255 / 0.85);
  --gloss-dark: inset 0 3px 0 rgb(160 180 255 / 0.35);
  --outline: -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink), 2px 2px 0 var(--ink), 0 -3px 0 var(--ink), 0 3px 0 var(--ink), -3px 0 0 var(--ink), 3px 0 0 var(--ink), 0 6px 0 var(--ink);
  --shadow-card: var(--lip-sm);
  --shadow-lift: var(--lip);
  --display: 'Mitr', 'Kanit', 'Anuphan', ui-sans-serif, system-ui, sans-serif;
  --sans: 'Anuphan', 'Sarabun', ui-sans-serif, system-ui, sans-serif;
  --text: var(--ink);
  --muted: var(--ink-soft);
  --accent: var(--sun);
  /* ฉากหลังน้ำเงินมีรัศมี (หน้าเปิดเกม / สรุป / ตั้งค่าแว่น) */
  --stage: radial-gradient(ellipse 90% 70% at 50% 18%, #5b86ea 0%, #2741c9 38%, #1a2466 72%, #0d1240 100%);
  --rays: repeating-conic-gradient(from 0deg at 50% 22%, rgb(255 255 255 / 0.07) 0deg 7deg, transparent 7deg 18deg);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0d1240; color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
::selection { background: var(--sun); color: var(--ink); }
:focus-visible { outline: 4px solid var(--sun); outline-offset: 3px; border-radius: 0.5rem; }
#app canvas { display: block; touch-action: none; cursor: grab; }
#app canvas:active { cursor: grabbing; }
.hidden { display: none !important; }

/* ── ฉากซ้อน (overlay) ──────────────────────────────── */
.overlay { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; background: var(--stage); z-index: 10; overflow: auto; overflow-x: hidden; }
.overlay::before { content: ''; position: fixed; inset: -20%; background: var(--rays); pointer-events: none; animation: spin 120s linear infinite; }
.overlay::after { content: ''; position: fixed; inset: 0; pointer-events: none; background-image: radial-gradient(2px 2px at 12% 18%, #fff4c0 50%, transparent 51%), radial-gradient(2px 2px at 82% 12%, #fff 50%, transparent 51%), radial-gradient(3px 3px at 70% 70%, #fff4c0 50%, transparent 51%), radial-gradient(2px 2px at 24% 76%, #fff 50%, transparent 51%), radial-gradient(2px 2px at 92% 48%, #fff 50%, transparent 51%), radial-gradient(3px 3px at 6% 52%, #fff4c0 50%, transparent 51%); opacity: 0.8; }
.overlay > * { position: relative; z-index: 1; }
@keyframes spin { to { transform: rotate(360deg); } }
#summary { background: rgb(10 12 34 / 0.72); }
#summary::before { opacity: 0.5; }

/* แผ่นป้ายเกม */
.card {
  width: min(520px, 100%); padding: 28px; border-radius: 28px; color: var(--ink);
  background: linear-gradient(#ffffff, #e7edfb); border: var(--edge);
  box-shadow: var(--gloss), inset 0 -6px 0 #c9d3ee, var(--lip);
  margin-bottom: 10px;
}
.card.wide { width: min(900px, 100%); }
.brand { display: flex; align-items: center; gap: 12px; font: 600 20px var(--display); color: var(--primary); }
.brand .logo { height: 56px; width: auto; }
.brand small { display: block; font: 400 13px var(--sans); color: var(--ink-soft); }
h1 { font: 600 28px/1.25 var(--display); margin: 4px 0 6px; color: var(--ink); }
.muted { color: var(--ink-soft); font-size: 15px; margin: 0 0 18px; }
label { display: block; font: 600 15px var(--display); margin-bottom: 12px; color: var(--ink); }
input, select {
  display: block; width: 100%; margin-top: 6px; padding: 12px 16px; border-radius: 14px; border: 3px solid var(--ink);
  background: #fff; color: var(--ink); font: 500 17px var(--sans);
  box-shadow: inset 0 4px 0 rgb(27 31 59 / 0.08), 0 4px 0 var(--ink); transition: box-shadow 0.15s, transform 0.1s;
}
input::placeholder { color: #9aa1bd; }
input:focus { outline: none; box-shadow: inset 0 4px 0 rgb(27 31 59 / 0.08), 0 4px 0 var(--ink), 0 0 0 5px var(--sun); }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > * { flex: 1; }

/* ปุ่มนูน: ขอบกรมท่า + ฐานนูน · กดแล้วยุบลง */
button {
  font: 600 15px var(--display); padding: 10px 18px; border-radius: 14px; border: 3px solid var(--ink); color: var(--ink); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(#ffffff, #dfe6f8); box-shadow: var(--gloss), 0 5px 0 var(--ink);
  transition: transform 0.08s, box-shadow 0.08s, filter 0.15s; position: relative;
}
button:hover { filter: brightness(1.05); transform: translateY(-1px); box-shadow: var(--gloss), 0 6px 0 var(--ink), 0 0 0 4px rgb(255 201 60 / 0.55); }
button:active { transform: translateY(4px); box-shadow: var(--gloss), 0 1px 0 var(--ink); }
button .ic { color: var(--primary); }
button.primary {
  width: 100%; margin-top: 14px; padding: 18px 20px; border-radius: 22px; border: 4px solid var(--ink);
  background: linear-gradient(var(--sun-hi), var(--sun) 55%, #ffb81a); color: var(--ink);
  font: 600 clamp(22px, 3vw, 28px) var(--display); letter-spacing: 0.01em;
  box-shadow: inset 0 5px 0 rgb(255 255 255 / 0.7), inset 0 -7px 0 #e8a400, 0 8px 0 var(--ink), 0 18px 30px -6px rgb(6 8 30 / 0.55);
}
button.primary .ic { color: var(--ink); width: 1.3em; height: 1.3em; }
button.primary:not(:disabled) { animation: pulse 2.4s ease-in-out infinite; }
button.primary:hover { filter: brightness(1.06); box-shadow: inset 0 5px 0 rgb(255 255 255 / 0.7), inset 0 -7px 0 #e8a400, 0 9px 0 var(--ink), 0 0 0 6px rgb(255 255 255 / 0.5), 0 0 40px rgb(255 201 60 / 0.8); }
button.primary:active { transform: translateY(6px); box-shadow: inset 0 5px 0 rgb(255 255 255 / 0.7), inset 0 -4px 0 #e8a400, 0 2px 0 var(--ink); }
@keyframes pulse { 0%, 100% { filter: none; } 50% { filter: brightness(1.08) drop-shadow(0 0 14px rgb(255 201 60 / 0.75)); } }
button.blue { background: linear-gradient(var(--primary-hi), var(--primary)); color: #fff; text-shadow: 0 2px 0 var(--primary-deep); }
button.blue .ic { color: #fff; }
.ic { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.18em; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: #b9bfd6; border: 2px solid var(--ink); }
.dot.on { background: #35d07a; box-shadow: 0 0 8px #35d07a; }
.dot.off { background: #c6c9d6; }
.ok { color: var(--mind); display: inline-flex; gap: 4px; align-items: center; font-weight: 600; }
.bad { color: var(--media); display: inline-flex; gap: 4px; align-items: center; font-weight: 600; }
.ic.gold { color: var(--sun-deep); width: 1.2em; height: 1.2em; margin-right: 8px; }

/* เคล็ดลับการเล่น: หลุมด้านในแบบเกม */
.help { margin: 22px 0 0; padding: 16px 18px; border-radius: 20px; list-style: none; font-size: 14px; color: var(--ink-soft); display: grid; gap: 10px; background: #dfe7fa; border: 3px solid rgb(27 31 59 / 0.18); box-shadow: inset 0 5px 0 rgb(27 31 59 / 0.07); }
.help li { display: flex; gap: 12px; align-items: center; line-height: 1.5; }
.help li > .ic { flex: none; width: 34px; height: 34px; padding: 7px; border-radius: 50%; color: #fff; background: radial-gradient(circle at 35% 30%, var(--primary-hi), var(--primary)); border: 3px solid var(--ink); box-shadow: inset 0 3px 0 rgb(255 255 255 / 0.35); }
.help b { color: var(--ink); }

/* ── HUD ระหว่างเล่น: ชิปกระจกมืดแบบเกม ───────────── */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; font-family: var(--display); }
#hud .top { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; align-items: center; gap: 12px; }
#zoneName, #timer, #netBadge, .controls button {
  background: linear-gradient(rgb(44 52 115 / 0.94), rgb(22 26 60 / 0.94)); color: #fff;
  border: 3px solid var(--abyss); box-shadow: var(--gloss-dark), 0 4px 0 var(--abyss), 0 8px 16px -4px rgb(0 0 0 / 0.5);
  backdrop-filter: blur(6px); text-shadow: 0 2px 0 var(--abyss);
}
#zoneName { font: 600 18px var(--display); padding: 6px 18px 6px 6px; border-radius: 999px; white-space: nowrap; display: flex; align-items: center; gap: 10px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#zoneName .ic { width: 32px; height: 32px; padding: 6px; border-radius: 50%; color: var(--ink); background: radial-gradient(circle at 35% 30%, var(--sun-hi), var(--sun)); border: 2px solid var(--abyss); box-shadow: inset 0 2px 0 rgb(255 255 255 / 0.6); }
#zoneName span { overflow: hidden; text-overflow: ellipsis; }
.progress { position: relative; flex: 1; height: 18px; background: linear-gradient(#0a0c22, #1d2350); border: 3px solid var(--abyss); border-radius: 999px; overflow: hidden; box-shadow: 0 3px 0 var(--abyss), inset 0 3px 4px rgb(0 0 0 / 0.5); min-width: 40px; }
#progressBar { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(#fff3a6, var(--sun) 55%, #f39a00); box-shadow: 0 0 12px rgb(255 201 60 / 0.9); transition: width 0.25s linear; }
.progress::after { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 3px), rgb(10 12 34 / 0.75) calc(10% - 3px) 10%); pointer-events: none; }
.progress::before { content: ''; position: absolute; left: 6px; right: 6px; top: 2px; height: 4px; border-radius: 4px; background: rgb(255 255 255 / 0.35); z-index: 1; pointer-events: none; }
#timer { font: 600 17px var(--display); font-variant-numeric: tabular-nums; padding: 7px 16px; border-radius: 999px; white-space: nowrap; color: var(--sun-hi); }
#crosshair { display: none; } /* ใช้จุดเล็ง 3 มิติในฉากแทน */
#quizHint {
  position: absolute; left: 50%; bottom: 84px; transform: translateX(-50%); max-width: calc(100% - 32px);
  background: linear-gradient(var(--sun-hi), var(--sun)); color: var(--ink); border: 3px solid var(--ink);
  padding: 10px 22px; border-radius: 999px; font: 600 17px var(--display); text-align: center;
  box-shadow: inset 0 3px 0 rgb(255 255 255 / 0.7), 0 5px 0 var(--ink), 0 0 26px rgb(255 201 60 / 0.65);
}
#toast {
  position: absolute; left: 50%; top: 74px; transform: translate(-50%, -14px) scale(0.85); opacity: 0;
  transition: opacity 0.25s, transform 0.35s cubic-bezier(0.34, 1.7, 0.5, 1);
  background: linear-gradient(var(--primary-hi), var(--primary)); color: #fff; border: 4px solid var(--ink);
  padding: 12px 26px; border-radius: 20px; font: 600 21px var(--display); max-width: calc(100% - 32px); text-align: center;
  text-shadow: 0 2px 0 var(--primary-deep), 0 -1px 0 var(--primary-deep); box-shadow: var(--gloss), 0 6px 0 var(--ink), 0 14px 26px -6px rgb(0 0 0 / 0.5);
}
#toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.controls { position: absolute; right: 12px; bottom: 14px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; pointer-events: auto; max-width: calc(100% - 24px); }
.controls button { padding: 8px 15px; font: 600 14px var(--display); border-radius: 999px; }
.controls button .ic { color: var(--sun); }
.controls button:hover { box-shadow: var(--gloss-dark), 0 5px 0 var(--abyss), 0 0 0 3px rgb(255 201 60 / 0.6); }
.controls button:active { box-shadow: var(--gloss-dark), 0 1px 0 var(--abyss); }

/* ── สรุปผล: หน้าจอผลด่าน ─────────────────────────── */
#summary .card { padding-top: 0; overflow: hidden; }
#summaryTitle {
  margin: 0 -28px 18px; padding: 22px 28px 20px; color: #fff; font-size: clamp(24px, 3.4vw, 34px);
  background: linear-gradient(var(--primary-hi), var(--primary)); border-bottom: 4px solid var(--ink);
  text-shadow: var(--outline);
}
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 15px; margin: 12px 0; border: 3px solid var(--ink); border-radius: 16px; overflow: hidden; background: #fff; box-shadow: 0 4px 0 var(--ink); }
th, td { padding: 10px 8px; border-bottom: 2px solid #e3e8f6; text-align: center; }
tbody tr:nth-child(even) td { background: #f2f5fd; }
tbody tr:last-child td { border-bottom: 0; }
th:first-child, td:first-child { text-align: left; }
th { color: #fff; font: 600 14px var(--display); background: linear-gradient(var(--navy-hi), var(--navy-lo)); border-bottom: 3px solid var(--ink); }
th .ic { color: var(--sun); }
td .ic { color: var(--primary); }
.score { display: inline-block; font: 600 22px var(--display); color: var(--ink); margin: 0; padding: 8px 18px; border-radius: 999px; border: 3px solid var(--ink); background: linear-gradient(var(--sun-hi), var(--sun)); box-shadow: inset 0 3px 0 rgb(255 255 255 / 0.7), 0 4px 0 var(--ink); }
.score:empty { display: none; }
#summary .row button { width: auto; margin-top: 8px; }
#summary #btnAgain { background: linear-gradient(var(--sun-hi), var(--sun) 55%, #ffb81a); box-shadow: inset 0 4px 0 rgb(255 255 255 / 0.7), inset 0 -5px 0 #e8a400, 0 6px 0 var(--ink); font-size: 18px; }
#summary #btnAgain .ic { color: var(--ink); }

@media (max-width: 640px) {
  #zoneName { font-size: 15px; }
  #hud .top { gap: 8px; }
  #timer { font-size: 14px; padding: 6px 10px; }
  .controls button { padding: 7px 11px; font-size: 13px; }
  table { font-size: 13px; }
  th:nth-child(3), td:nth-child(3), th:nth-child(4), td:nth-child(4), th:nth-child(5), td:nth-child(5), th:nth-child(6), td:nth-child(6) { display: none; }
}

/* โหมดแว่น: operator เป็นคนคุมเวลา */
#netBadge { pointer-events: auto; padding: 6px 14px; font: 600 15px var(--display); border-radius: 999px; white-space: nowrap; }
body:not(.networked) #netBadge { display: none; }
body.networked #btnPause, body.networked #btnSpeed, body.networked #btnQuit { display: none; }
#seatPicker .brand { color: var(--primary); }
#seatPicker .brand .ic { width: 40px; height: 40px; padding: 8px; border-radius: 50%; color: #fff; background: radial-gradient(circle at 35% 30%, var(--primary-hi), var(--primary)); border: 3px solid var(--ink); }
.seat-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.seat-buttons button { font: 600 34px var(--display); padding: 18px 0; border-radius: 20px; background: linear-gradient(var(--primary-hi), var(--primary)); color: #fff; text-shadow: var(--outline); box-shadow: var(--gloss), inset 0 -6px 0 var(--primary-deep), 0 6px 0 var(--ink); }

/* ผลการเล่นบนเว็บ: บันทึกแล้ว + ปุ่มเปิดเกียรติบัตร */
.web-result { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 14px 0 4px; padding: 12px 16px; border-radius: 18px; background: linear-gradient(#fff8e0, var(--sun-soft)); color: var(--ink); border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink); font-weight: 600; }
.web-result .btn-cert { display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: 14px; background: linear-gradient(var(--primary-hi), var(--primary)); color: #fff; font: 600 15px var(--display); text-decoration: none; border: 3px solid var(--ink); box-shadow: var(--gloss), 0 4px 0 var(--ink); }

/* ── หน้าเปิดเกม (launcher) ─────────────────────────── */
.hub-bg { place-items: start center; padding: 28px 16px 40px; }
.card.hub { width: min(1040px, 100%); padding: 0; overflow: hidden; border-radius: 34px; border-width: 5px; animation: popin 0.55s cubic-bezier(0.34, 1.5, 0.5, 1) both; }
@keyframes popin { from { opacity: 0; transform: translateY(24px) scale(0.96); } }
.hub-hero {
  position: relative; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; padding: 26px 32px 0; overflow: hidden;
  background: radial-gradient(ellipse 70% 120% at 85% 60%, #6f94ff 0%, #3553e0 35%, #2741c9 60%, #1c2f9a 100%);
  border-bottom: 5px solid var(--ink); color: #fff;
}
.hub-hero::before { content: ''; position: absolute; inset: -60%; background: repeating-conic-gradient(from 0deg at 72% 62%, rgb(255 255 255 / 0.10) 0deg 6deg, transparent 6deg 15deg); animation: spin 90s linear infinite; transform-origin: 72% 62%; }
.hub-hero::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 64px; background: var(--sun); clip-path: polygon(0 62%, 100% 0, 100% 100%, 0 100%); box-shadow: inset 0 4px 0 var(--sun-hi); border-top: 0; }
.hub-hero > * { position: relative; z-index: 1; }
.hub-hero .brandline { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.hub-hero .brandline img { height: 54px; width: auto; filter: drop-shadow(0 4px 6px rgb(0 0 0 / 0.4)); }
.hub-hero .brandline b { display: block; font: 600 17px/1.3 var(--display); color: #fff; text-shadow: 0 2px 0 var(--ink); }
.hub-hero .brandline span { display: block; font-size: 13px; color: #dfe6ff; }
.hub-hero h1 {
  font: 600 clamp(38px, 6.4vw, 64px)/1.15 var(--display); margin: 0 0 12px; color: #fff; letter-spacing: 0.01em;
  text-shadow: -3px -3px 0 var(--ink), 3px -3px 0 var(--ink), -3px 3px 0 var(--ink), 3px 3px 0 var(--ink), 0 -4px 0 var(--ink), 0 4px 0 var(--ink), -4px 0 0 var(--ink), 4px 0 0 var(--ink), 0 9px 0 var(--ink), 0 14px 18px rgb(0 0 0 / 0.45);
}
.hub-hero .lead { display: inline-block; font: 500 16px/1.6 var(--sans); color: #fff; margin: 0 0 76px; max-width: 40ch; padding: 10px 16px; border-radius: 16px; background: rgb(10 12 34 / 0.45); border: 2px solid rgb(255 255 255 / 0.18); }
.hub-hero .mascot { width: clamp(150px, 22vw, 250px); align-self: end; margin-bottom: 4px; filter: drop-shadow(0 6px 0 rgb(27 31 59 / 0.55)) drop-shadow(0 18px 18px rgb(0 0 0 / 0.35)); animation: rise 0.7s cubic-bezier(0.16, 1, 0.3, 1) both, bob 3.2s ease-in-out 0.8s infinite; }
.hub-hero .dots { display: none; }
.hub-hero .dots i { position: absolute; width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid var(--ink); }
.hub-hero .dots i + i { width: 10px; height: 10px; left: 22px; top: 14px; background: var(--primary-hi); }
@keyframes rise { from { opacity: 0; transform: translateY(24px); } }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-1.5deg); } }
@media (prefers-reduced-motion: reduce) { .hub-hero .mascot, .overlay::before, .hub-hero::before, button.primary, .card.hub { animation: none !important; } }
.hub-body { padding: 26px 32px 30px; background: linear-gradient(#f6f8ff, #e4ebfb); }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 26px 0 16px; flex-wrap: wrap; }
.section-title h2 {
  position: relative; font: 600 22px var(--display); margin: 0 0 0 8px; padding: 6px 26px; color: var(--ink);
  background: linear-gradient(var(--sun-hi), var(--sun)); border: 3px solid var(--ink); border-radius: 10px;
  box-shadow: inset 0 3px 0 rgb(255 255 255 / 0.7), 0 4px 0 var(--ink); transform: rotate(-1.5deg);
}
.section-title span { font: 500 14px var(--display); color: var(--ink-soft); padding: 4px 12px; border-radius: 999px; background: #fff; border: 2px solid rgb(27 31 59 / 0.15); }
.fields label { min-width: 220px; margin: 0; }

/* การ์ดภารกิจ = การ์ดเลือกด่าน */
.games { border: 0; padding: 0; margin: 0 0 22px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px 18px; }
.games legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.game {
  position: relative; display: flex; flex-direction: column; margin: 0 0 6px; border-radius: 22px; border: 4px solid var(--ink);
  background: linear-gradient(#ffffff, #e9eefb); color: var(--ink); cursor: pointer; overflow: hidden;
  box-shadow: var(--gloss), 0 7px 0 var(--ink), 0 16px 22px -8px rgb(6 8 30 / 0.45);
  transition: transform 0.15s cubic-bezier(0.34, 1.6, 0.5, 1), box-shadow 0.15s;
}
.game input { position: absolute; opacity: 0; pointer-events: none; }
.game .cover {
  position: relative; height: 126px; display: grid; place-items: center; overflow: hidden; border-bottom: 4px solid var(--ink);
  background: radial-gradient(circle at 50% 55%, color-mix(in srgb, var(--c) 55%, white) 0%, var(--c) 62%, color-mix(in srgb, var(--c) 70%, black) 100%);
}
.game .cover::before { content: ''; position: absolute; inset: -40%; background: repeating-conic-gradient(from 0deg at 50% 50%, rgb(255 255 255 / 0.16) 0deg 8deg, transparent 8deg 20deg); transition: transform 0.6s; }
.game .cover::after { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 45%; background: linear-gradient(rgb(255 255 255 / 0.22), transparent); }
.game .cover .ic { position: relative; z-index: 1; width: 64px; height: 64px; color: #fff; stroke-width: 2; filter: drop-shadow(0 3px 0 rgb(10 12 34 / 0.55)) drop-shadow(0 6px 10px rgb(0 0 0 / 0.3)); transition: transform 0.2s cubic-bezier(0.34, 1.6, 0.5, 1); }
.game .badge { position: absolute; z-index: 2; top: 10px; left: 10px; font: 600 13px var(--display); padding: 3px 12px; border-radius: 999px; background: linear-gradient(var(--sun-hi), var(--sun)); color: var(--ink); border: 2px solid var(--ink); box-shadow: inset 0 2px 0 rgb(255 255 255 / 0.7), 0 3px 0 var(--ink); }
.game.soon .badge { background: linear-gradient(var(--navy-hi), var(--navy-lo)); color: #fff; }
.game .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 4px; }
.game .chip { align-self: flex-start; font: 600 13px var(--display); padding: 2px 12px; border-radius: 999px; background: var(--c); color: #fff; border: 2px solid var(--ink); text-shadow: 0 1px 0 rgb(0 0 0 / 0.35); }
.game b { display: block; font: 600 19px/1.35 var(--display); margin-top: 6px; }
.game small { color: var(--ink-soft); font-size: 14px; line-height: 1.55; }
.game:not(.soon):hover { transform: translateY(-5px) rotate(-0.6deg); box-shadow: var(--gloss), 0 11px 0 var(--ink), 0 24px 30px -8px rgb(6 8 30 / 0.5); }
.game:not(.soon):hover .cover .ic { transform: scale(1.15) rotate(-6deg); }
.game:not(.soon):hover .cover::before { transform: rotate(25deg); }
.game:has(input:checked) { transform: translateY(-4px); box-shadow: var(--gloss), 0 9px 0 var(--ink), 0 0 0 5px var(--sun), 0 0 34px 6px rgb(255 201 60 / 0.75); }
.game:has(input:checked)::after { content: ''; position: absolute; z-index: 3; top: 8px; right: 8px; width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--ink); box-shadow: inset 0 3px 0 rgb(255 255 255 / 0.4), 0 3px 0 var(--ink); background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / 20px no-repeat, radial-gradient(circle at 35% 30%, #2fa862, var(--mind)); animation: stamp 0.35s cubic-bezier(0.34, 1.8, 0.5, 1) both; }
@keyframes stamp { from { transform: scale(0.2) rotate(-30deg); } }
.game:has(input:focus-visible) { outline: 4px solid var(--sun); outline-offset: 4px; }
.game.soon { cursor: not-allowed; }
.game.soon .cover, .game.soon .body { filter: saturate(0.2); opacity: 0.7; }
.game.skeleton { min-height: 230px; cursor: default; background: linear-gradient(90deg, #dfe6f8 25%, #f4f6fc 50%, #dfe6f8 75%) 0 0 / 200% 100%; animation: shimmer 1.3s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.options { display: flex; flex-wrap: wrap; gap: 14px 28px; align-items: center; margin-bottom: 14px; }
.opt { display: flex; align-items: center; gap: 14px; margin: 0; color: var(--ink); }
.opt-label { font-weight: 600; font-size: 14px; color: var(--ink-soft); }
.seg { display: inline-flex; padding: 4px; border-radius: 14px; background: #dfe7fa; border: 3px solid var(--ink); }
.seg button { padding: 7px 16px; font-size: 15px; border-radius: 10px; background: transparent; border: 0; box-shadow: none; color: var(--ink-soft); }
.seg button[aria-checked="true"] { background: linear-gradient(var(--primary-hi), var(--primary)); color: #fff; box-shadow: 0 3px 0 var(--ink); }
/* สวิตช์แบบเกม: รางลึก + ปุ่มเหรียญ */
.switch { cursor: pointer; padding: 10px 16px 10px 12px; border-radius: 18px; background: #fff; border: 3px solid var(--ink); box-shadow: inset 0 -4px 0 #dfe6f8, 0 4px 0 var(--ink); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { position: relative; width: 68px; height: 36px; flex: none; border-radius: 999px; background: linear-gradient(#7d84a3, #a8aec8); border: 3px solid var(--ink); box-shadow: inset 0 4px 4px rgb(0 0 0 / 0.3); transition: background 0.2s; }
.switch .thumb { position: absolute; top: 1px; left: 2px; width: 28px; height: 28px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, #dfe4f2); border: 3px solid var(--ink); transition: transform 0.25s cubic-bezier(0.34, 1.6, 0.5, 1), background 0.2s; box-shadow: inset 0 -3px 0 rgb(27 31 59 / 0.15); }
.switch input:checked + .track { background: linear-gradient(#2fa862, var(--mind)); }
.switch input:checked + .track .thumb { transform: translateX(30px); background: radial-gradient(circle at 35% 30%, var(--sun-hi), var(--sun)); }
.switch input:focus-visible + .track { outline: 4px solid var(--sun); outline-offset: 3px; }
.switch b { display: block; font: 600 15px var(--display); }
.switch small { display: block; font-size: 13px; color: var(--ink-soft); font-weight: 400; }
button.primary:disabled { opacity: 0.7; cursor: progress; animation: none; filter: saturate(0.6); }
@media (max-width: 860px) { .games { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) {
  .hub-bg { padding: 10px 10px 30px; }
  .card.hub { border-radius: 26px; }
  .hub-hero { grid-template-columns: 1fr; padding: 20px 16px 0; }
  .hub-hero .lead { margin-bottom: 20px; }
  .hub-hero .mascot { justify-self: end; width: 140px; margin-top: -40px; }
  .hub-body { padding: 18px 16px 24px; }
  .games { grid-template-columns: 1fr; }
  .fields label { min-width: 0; flex-basis: 100%; }
  .switch { padding: 10px 12px; }
}

/* ปุ่มเข้า VR (ใหญ่ เห็นชัดในแว่น) */
button.vr-big {
  width: 100%; margin-top: 12px; padding: 22px 16px; border-radius: 22px; border: 4px solid var(--ink);
  background: linear-gradient(var(--primary-hi), var(--primary) 60%, var(--primary-deep)); color: #fff; font: 600 26px var(--display);
  display: flex; align-items: center; justify-content: center; gap: 12px; text-shadow: 0 3px 0 var(--ink);
  box-shadow: inset 0 5px 0 rgb(255 255 255 / 0.35), inset 0 -7px 0 #14207a, 0 8px 0 var(--ink), 0 18px 30px -6px rgb(6 8 30 / 0.55);
}
button.vr-big .ic { color: var(--sun); width: 34px; height: 34px; }
button.vr-big:active { transform: translateY(6px); box-shadow: inset 0 5px 0 rgb(255 255 255 / 0.35), 0 2px 0 var(--ink); }
button.vr-big:disabled { opacity: 0.5; }
.vr-note { margin: 12px 0 0; padding: 12px 14px; border-radius: 16px; background: var(--sun-soft); color: var(--ink); font-size: 15px; border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink); }
#btnVR2 { background: linear-gradient(var(--primary-hi), var(--primary)); color: #fff; }
#btnVR2 .ic { color: var(--sun); }

.credits-note { margin: 16px 0 0; font-size: 12px; line-height: 1.5; opacity: 0.6; }

/* ภาพปกเกม (assets/img/covers) แทนไอคอนกลางปก */
.game .cover { background-size: cover !important; background-position: center !important; }
.game .cover::before, .game .cover::after { display: none; }
.game .cover .ic { display: none; }
.game.soon .cover { filter: grayscale(1) brightness(0.85); }

/* ไม่ใช้แสงแฉกหมุน (ดูปลอม) → แสงฟุ้งนิ่ง ๆ แบบไฟสตูดิโอ */
.overlay::before { animation: none; inset: 0; background:
  radial-gradient(60% 50% at 75% 20%, rgb(120 150 255 / 0.28), transparent 70%),
  radial-gradient(50% 60% at 15% 85%, rgb(255 201 60 / 0.10), transparent 70%); }
.hub-hero::before { animation: none; inset: 0; transform: none; background:
  radial-gradient(38% 70% at 80% 55%, rgb(255 255 255 / 0.30), transparent 70%),
  radial-gradient(70% 90% at 80% 60%, rgb(140 170 255 / 0.25), transparent 75%); }

/* เลือกภารกิจ: แถวบน 2 การ์ดใหญ่ (รถไฟ + ภารกิจ 6) · แถวล่าง ภารกิจ 1–5 การ์ดเล็ก */
.games { grid-template-columns: repeat(10, 1fr); }
.game.big { grid-column: span 5; }
.game.big .cover { height: 210px; }
.game.big .body b { font-size: 1.35rem; }
.game.small { grid-column: span 2; }
.game.small .cover { height: 92px; }
.game.small .body { padding: 10px 12px 12px; }
.game.small .body b { font-size: 0.95rem; }
.game.small .body small { display: none; }
.game.small .chip { font-size: 0.72rem; padding: 2px 8px; }
.game.small .badge { font-size: 0.7rem; padding: 2px 8px; }
@media (max-width: 860px) { .games { grid-template-columns: repeat(2, 1fr); } .game.big { grid-column: span 2; } .game.small { grid-column: span 1; } }
@media (max-width: 560px) { .games { grid-template-columns: 1fr; } .game.big, .game.small { grid-column: span 1; } }

/* Mac เป็นรีโมตของแว่น: สถานะแว่นเหนือปุ่มเริ่ม · ที่อยู่สำหรับแว่น (เล็ก ๆ ใต้โลโก้) */
.lan-note { margin: -6px 0 14px; font-size: 0.82rem; opacity: 0.85; display: flex; align-items: center; gap: 6px; }
.lan-note .ic { width: 16px; height: 16px; }
.lan-note b { font-family: ui-monospace, Menlo, monospace; letter-spacing: 0.02em; }
.vr-link { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 12px; padding: 10px 14px; border-radius: 14px; border: 3px solid var(--ink); background: #f4f6fc; font-size: 0.95rem; }
.vr-link .dot { width: 12px; height: 12px; border-radius: 50%; background: #9aa1bd; box-shadow: 0 0 0 3px rgb(154 161 189 / 0.3); }
.vr-link[data-state=ready] .dot, .vr-link[data-state=play] .dot { background: #22b35e; box-shadow: 0 0 0 3px rgb(34 179 94 / 0.3); }
.vr-link[data-state=wait] .dot { background: #f2b01e; box-shadow: 0 0 0 3px rgb(242 176 30 / 0.3); }
.vr-link[data-state=ready], .vr-link[data-state=play] { background: #e7f8ee; }
.vr-btns { margin-left: auto; display: flex; gap: 8px; }
.vr-btns button { font: inherit; font-weight: 600; padding: 6px 14px; border-radius: 10px; border: 3px solid var(--ink); background: #fff; cursor: pointer; }
/* แว่น (/vr): เหลือแค่ปุ่มเข้า VR */
body.kiosk .games, body.kiosk .games + *, body.kiosk #menuForm label, body.kiosk #menuForm button[type=submit], body.kiosk .help, body.kiosk .credits-note, body.kiosk .pick-row { display: none !important; }
body.kiosk #vrNote { font-size: 1.15rem; }
body.kiosk .section-title { display: none !important; }
.kiosk-note { display: none; }
body.kiosk .kiosk-note { display: block; margin: 8px 0 18px; font-size: 1.35rem; font-weight: 600; line-height: 1.5; text-align: center; }
body.kiosk .kiosk-note .ic { width: 28px; height: 28px; vertical-align: -5px; margin-right: 6px; }
body.kiosk .kiosk-note small { font-weight: 400; font-size: 1rem; opacity: 0.8; }

/* แถบข้ามช่วง (ทดสอบบนคอม) */
#chapters { position: absolute; left: 50%; top: 84px; transform: translateX(-50%); display: flex; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; gap: 4px 6px; align-items: center;
  max-width: min(1200px, 94vw); white-space: nowrap; padding: 6px 10px; border-radius: 14px; background: rgba(12, 16, 40, 0.72); backdrop-filter: blur(6px); pointer-events: auto; z-index: 5; font-size: 12px; }
#chapters .ch-room { color: #ffd45c; margin-left: 6px; font-weight: 700; }
#chapters button { font: inherit; color: #e8ecff; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.18); border-radius: 999px; padding: 3px 9px; cursor: pointer; }
#chapters button:hover { background: rgba(255,255,255,0.2); }
#chapters button.on { background: #ffd45c; color: #1a1f3d; border-color: #ffd45c; }
#chapters .ch-sel, #chapters .ch-sub { font: inherit; color: #1a1f3d; background: #ffd45c; border: 0; border-radius: 999px; padding: 3px 8px; font-weight: 700; }
#chapters .ch-fold { background: transparent; border: 0; color: #ffd45c; font-size: 14px; padding: 2px 4px; }
#chapters.folded > :not(.ch-fold) { display: none; }
/* Mac ดูภาพตามแว่น: ซ่อนปุ่มคุมเวลา (คุมจากแว่น/แถบรีโมทแทน) · ปุ่ม "จบ" = เลิกดู */
body.mirroring #chapters, body.mirroring #btnPause, body.mirroring #btnSpeed, body.mirroring #btnRecenter { display: none !important; }
body.mirroring #hud::after { content: 'กำลังดูภาพจากแว่น'; position: absolute; left: 50%; top: 84px; transform: translateX(-50%); padding: 4px 12px; border-radius: 999px; background: rgba(220, 40, 60, 0.85); color: #fff; font-size: 13px; font-weight: 700; }

/* จับคู่แว่น (หน้าคุมบนคอม) */
.vr-pair { display: flex; gap: 12px; flex-wrap: wrap; margin: 0 0 10px; font-size: 14px; }
.vr-pair label { display: flex; align-items: center; gap: 6px; font-weight: 700; }
.vr-pair input { width: 120px; padding: 6px 10px; border-radius: 10px; border: 2px solid #1a1f3d; font: inherit; text-transform: uppercase; }
.pair-code { text-align: center; font-size: 18px; margin: 10px 0 0; }
.pair-code b { font-size: 28px; letter-spacing: 4px; color: #ffd45c; background: #1a1f3d; padding: 2px 12px; border-radius: 10px; }
