/* ================================================================
   หน้าแรก "ไปให้ทัน" (Rush Home) — ฟอนต์โฮสต์เอง + UI คลีนต้นฉบับ
   + หน้าตั้งค่าก่อนเริ่มเกมแบบแยก 2 หน้า (#pg-step-car → #pg-step-diff)
   ================================================================ */
@font-face { font-family: 'Noto Serif Thai'; font-style: normal; font-weight: 300; font-display: swap;
  src: url('../fonts/noto-serif-thai-300-thai.woff2') format('woff2');
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Noto Serif Thai'; font-style: normal; font-weight: 300; font-display: swap;
  src: url('../fonts/noto-serif-thai-300-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Noto Serif Thai'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('../fonts/noto-serif-thai-500-thai.woff2') format('woff2');
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Noto Serif Thai'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('../fonts/noto-serif-thai-500-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Prompt'; font-style: normal; font-weight: 300; font-display: swap;
  src: url('../fonts/prompt-300-thai.woff2') format('woff2');
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Prompt'; font-style: normal; font-weight: 300; font-display: swap;
  src: url('../fonts/prompt-300-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Prompt'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('../fonts/prompt-400-thai.woff2') format('woff2');
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Prompt'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('../fonts/prompt-400-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Prompt'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('../fonts/prompt-500-thai.woff2') format('woff2');
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Prompt'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('../fonts/prompt-500-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

#rushhome,#rushhome *{box-sizing:border-box}
#rushhome{--bg:#10141b;--ink:#f1ece2;--mute:#a7abb3;--amber:#f2b560;--line:rgba(241,236,226,.16);--glass:rgba(16,20,27,.68);
 position:fixed;inset:0;z-index:50;background:var(--bg);color:var(--ink);font-family:"Prompt",system-ui,sans-serif;overflow:hidden;-webkit-tap-highlight-color:transparent}
#rushhome[hidden]{display:none}
#rushhome .h-canvas{position:fixed;inset:0;width:100%;height:100%;display:block;pointer-events:none}
#rushhome .h-shade{position:fixed;inset:0;z-index:1;pointer-events:none;background:
radial-gradient(120% 40% at 50% -5%,rgba(242,181,96,.22),transparent 70%),
linear-gradient(to bottom,rgba(16,20,27,.9) 0,rgba(16,20,27,.35) 30%,rgba(16,20,27,.2) 46%),
linear-gradient(to top,rgba(16,20,27,.98) 0,rgba(16,20,27,.86) 35%,rgba(16,20,27,.15) 68%)}
#rushhome .h-ui{position:relative;z-index:2;height:100%;max-width:460px;margin:0 auto;
 padding:calc(18px + env(safe-area-inset-top,0px)) 24px calc(24px + env(safe-area-inset-bottom,0px));display:flex;flex-direction:column;justify-content:space-between}
#rushhome .h-status{display:flex;justify-content:space-between;align-items:baseline;font-weight:300;color:var(--mute);font-size:14px}
#rushhome .h-clock{font-size:22px;color:var(--ink);font-weight:400;letter-spacing:.04em;font-variant-numeric:tabular-nums}
#rushhome .h-title{margin-top:20px}
#rushhome h1{font:300 clamp(54px,16vw,78px)/1.02 "Noto Serif Thai",serif;margin:0;letter-spacing:-.01em;color:var(--ink)}
#rushhome .h-sub{margin:12px 0 0;font-weight:300;font-size:15.5px;line-height:1.65;max-width:20em;text-wrap:balance;color:#dfd9ce}
#rushhome .h-tags{display:flex;flex-wrap:wrap;gap:6px;margin:16px 0 0;padding:0;list-style:none}
#rushhome .h-tags li{font-size:12px;font-weight:300;padding:4px 10px;border:1px solid var(--line);border-radius:999px;background:var(--glass)}
#rushhome .h-actions{display:flex;flex-direction:column;gap:10px}
#rushhome button{font:inherit;color:inherit;border:0;cursor:pointer;touch-action:manipulation;margin:0}
#rushhome .h-go{height:58px;border-radius:16px;background:var(--amber);color:#1a1408;font-weight:500;font-size:18px;letter-spacing:.02em;box-shadow:0 10px 30px rgba(242,181,96,.25)}
#rushhome .h-go:active{transform:scale(.985)}
#rushhome .h-row{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}
#rushhome .h-row button{height:48px;border-radius:13px;background:var(--glass);border:1px solid var(--line);font-weight:400;font-size:14px}
#rushhome .h-row button:active{background:rgba(241,236,226,.12)}
#rushhome button:focus-visible{outline:2px solid var(--amber);outline-offset:3px}
#rushhome .h-toast{position:fixed;left:50%;bottom:calc(env(safe-area-inset-bottom,0px) + 150px);transform:translate(-50%,10px);z-index:8;background:rgba(241,236,226,.94);color:#14181f;padding:10px 16px;border-radius:12px;font-size:14px;opacity:0;pointer-events:none;transition:.25s;max-width:86%;text-align:center}
#rushhome .h-toast.on{opacity:1;transform:translate(-50%,0)}

/* ---------- หน้าเตรียมออกเดินทางแบบ 2 สเต็ป (#pregame: Step 1 เลือกรถ/แต่งรถ → Step 2 เลือกความยาก) ---------- */
#pregame{position:fixed;inset:0;z-index:5;display:block;
  background:rgba(11,14,20,.95);backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px);
  overflow-y:auto;overflow-x:hidden;-webkit-overflow-scrolling:touch;animation:rhUp .2s cubic-bezier(.22,.9,.3,1)}
#pregame[hidden]{display:none !important}
#pregame .pg-step{width:100%;max-width:480px;margin:0 auto;
  padding:calc(10px + env(safe-area-inset-top,0px)) 15px calc(28px + env(safe-area-inset-bottom,0px));
  display:flex;flex-direction:column;gap:10px}
#pregame .pg-step>*{flex-shrink:0}
#pregame .pg-step[hidden]{display:none !important}
#pregame .pg-top{display:flex;align-items:center;justify-content:space-between;gap:8px;flex-shrink:0}
#pregame .pg-back{height:36px;padding:0 13px;border-radius:99px;background:rgba(255,255,255,.08);
  border:1px solid var(--line);font-size:13px;font-weight:400;color:var(--ink)}
#pregame .pg-back:active{transform:scale(.96)}
#pregame .pg-head-title{font-size:14.5px;font-weight:500;color:var(--ink)}
#pregame .pg-step-badge{font-size:11.5px;font-weight:400;color:var(--amber);background:rgba(242,181,96,.12);
  border:1px solid rgba(242,181,96,.35);padding:3px 10px;border-radius:99px;white-space:nowrap}

/* กล่องโชว์รูมรถ 3D หมุนได้ 360 องศา (ห้ามหดตัวเด็ดขาด + ลอยค้างด้านบนเวลาเลื่อนแต่งรถ) */
#pregame .pg-3d-card{position:sticky;top:6px;z-index:4;flex:0 0 auto;flex-shrink:0;min-height:242px;
  border-radius:20px;overflow:hidden;
  background:radial-gradient(ellipse at 50% 62%, #263144 0%, #111620 76%);
  border:1.5px solid rgba(242,181,96,.32);box-shadow:0 12px 32px rgba(0,0,0,.62)}
#pregame .pg-3d-box{width:100%;height:192px;min-height:192px;display:block;position:relative;cursor:grab;touch-action:none}
#pregame .pg-3d-box canvas{width:100% !important;height:192px !important;display:block}
#pregame .pg-3d-meta{display:flex;justify-content:space-between;align-items:center;
  padding:8px 14px;background:rgba(10,13,18,.88);border-top:1px solid rgba(255,255,255,.08);gap:8px}
#pregame .pg-car-name{font-size:14.5px;font-weight:500;color:var(--ink)}
#pregame .pg-car-spec{font-size:11.5px;font-weight:300;color:var(--mute)}
#pregame .pg-3d-hint{position:absolute;top:10px;right:12px;font-size:11px;color:rgba(241,236,226,.85);
  background:rgba(10,13,18,.68);padding:4px 9px;border-radius:99px;pointer-events:none;border:1px solid rgba(255,255,255,.14)}

/* แผงเลือกรถ / แต่งรถ / เลือกความยาก */
#pregame .pg-panel{flex-shrink:0;background:rgba(20,25,34,.90);border:1px solid var(--line);border-radius:16px;
  padding:11px 13px;display:flex;flex-direction:column;gap:8px}
#pregame .pg-lbl{font-size:13px;font-weight:500;color:var(--amber);display:flex;justify-content:space-between;align-items:center}
#pregame .pg-lbl small{font-size:11px;font-weight:300;color:var(--mute)}
#pregame .pg-grid4{display:grid;grid-template-columns:repeat(4,1fr);gap:6px}
#pregame .pg-grid4 button{height:40px;border-radius:11px;background:rgba(255,255,255,.06);
  border:1px solid rgba(241,236,226,.16);font-size:12.5px;font-weight:400;color:var(--ink);
  padding:0 4px;white-space:nowrap;transition:background .14s,border-color .14s,transform .08s}
#pregame .pg-grid4 button:active{transform:scale(.96)}
#pregame .pg-grid4 button.on{background:var(--amber);color:#1a1408;border-color:var(--amber);font-weight:500;
  box-shadow:0 3px 12px rgba(242,181,96,.28)}
#pregame .pg-desc{font-size:12px;font-weight:300;color:#d6d0c4;line-height:1.45}

/* การ์ดเลือกความยากแบบเต็มหน้าใน Step 2 */
#pregame .pg-diff-list{display:flex;flex-direction:column;gap:8px}
#pregame .pg-diff-card{display:flex;flex-direction:column;align-items:flex-start;gap:4px;
  padding:12px 14px;border-radius:14px;background:rgba(255,255,255,.05);
  border:1.5px solid rgba(241,236,226,.14);text-align:left;transition:background .15s,border-color .15s,transform .08s}
#pregame .pg-diff-card:active{transform:scale(.985)}
#pregame .pg-diff-card.on{background:rgba(242,181,96,.15);border-color:var(--amber);
  box-shadow:0 6px 18px rgba(242,181,96,.18)}
#pregame .pg-diff-top{width:100%;display:flex;justify-content:space-between;align-items:center}
#pregame .pg-diff-top b{font-size:15.5px;font-weight:500;color:var(--ink)}
#pregame .pg-diff-card.on .pg-diff-top b{color:var(--amber)}
#pregame .pg-diff-time{font-size:11.5px;color:var(--mute);background:rgba(0,0,0,.28);padding:2px 8px;border-radius:99px}
#pregame .pg-diff-sub{font-size:12px;font-weight:300;color:#d6d0c4;line-height:1.45}

/* การ์ดสรุปรถที่เลือกไว้ในหน้า Step 2 */
#pregame .pg-car-sum{flex-shrink:0;display:flex;align-items:center;justify-content:space-between;gap:10px;
  background:rgba(20,25,34,.88);border:1px solid var(--line);border-radius:15px;padding:10px 13px}
#pregame .pg-car-sum-left{display:flex;align-items:center;gap:10px}
#pregame .pg-car-sum-dot{width:28px;height:28px;border-radius:50%;border:2px solid rgba(255,255,255,.35);flex:0 0 auto}
#pregame .pg-car-sum-txt b{display:block;font-size:14px;font-weight:500;color:var(--ink)}
#pregame .pg-car-sum-txt small{display:block;font-size:11.5px;font-weight:300;color:var(--mute)}
#pregame .pg-car-sum-edit{height:32px;padding:0 11px;border-radius:99px;background:rgba(255,255,255,.08);
  border:1px solid var(--line);font-size:12px;color:var(--amber)}

/* แถบสเปครถ 4 ด้าน */
#pregame .pg-bars{display:grid;grid-template-columns:repeat(2,1fr);gap:6px 12px;margin-top:2px}
#pregame .pg-bar-item{display:flex;flex-direction:column;gap:2px}
#pregame .pg-bar-lbl{display:flex;justify-content:space-between;font-size:10.5px;color:var(--mute)}
#pregame .pg-bar-lbl b{color:var(--ink);font-weight:500}
#pregame .pg-bar-track{height:5px;border-radius:99px;background:rgba(255,255,255,.1);overflow:hidden}
#pregame .pg-bar-track>i{display:block;height:100%;background:var(--amber);border-radius:99px;transition:width .25s}

/* ถาดสีตัวถัง + ของแต่งรถ */
#pregame .pg-swatches{display:flex;flex-wrap:wrap;gap:7px;padding:2px 0}
#pregame .pg-sw{width:28px;height:28px;border-radius:50%;border:2px solid rgba(255,255,255,.22);
  cursor:pointer;transition:transform .12s,border-color .12s,box-shadow .12s;padding:0}
#pregame .pg-sw.on{border-color:var(--amber);transform:scale(1.14);box-shadow:0 0 0 3px rgba(242,181,96,.32)}
#pregame .pg-part-row{display:flex;align-items:center;gap:6px;margin-top:2px}
#pregame .pg-part-lbl{font-size:11.5px;color:var(--mute);min-width:58px;flex:0 0 auto}
#pregame .pg-part-opts{display:flex;gap:5px;flex-wrap:wrap;flex:1}
#pregame .pg-part-opts button{height:29px;padding:0 9px;border-radius:8px;font-size:11.5px;
  background:rgba(255,255,255,.06);border:1px solid rgba(241,236,226,.15);color:var(--ink)}
#pregame .pg-part-opts button.on{background:rgba(242,181,96,.22);border-color:var(--amber);color:var(--amber);font-weight:500}

/* ปุ่มเริ่มเกมด้านล่าง */
#pregame .pg-cta{flex-shrink:0;display:flex;flex-direction:column;gap:8px;padding-top:4px}
#pregame .pg-go{height:54px;border-radius:15px;background:var(--amber);color:#1a1408;font-weight:500;
  font-size:17px;letter-spacing:.01em;box-shadow:0 8px 24px rgba(242,181,96,.28)}
#pregame .pg-go:active{transform:scale(.985)}
#pregame .pg-sub-row{display:grid;grid-template-columns:1fr 1fr;gap:8px}
#pregame .pg-sub{height:42px;border-radius:12px;background:rgba(255,255,255,.07);border:1px solid var(--line);
  font-size:13px;font-weight:400;color:var(--ink)}
#pregame .pg-sub:active{background:rgba(255,255,255,.14)}

/* ---------- ชีตย่อย: สถิติ / ตั้งค่า (สไตล์เดียวกับหน้าแรก) ---------- */
#rhSheet{position:fixed;inset:0;z-index:7;display:none;align-items:flex-end;justify-content:center;
  background:rgba(8,10,14,.55);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px)}
#rhSheet.on{display:flex}
#rhSheet .rh-card{width:100%;max-width:480px;max-height:85vh;overflow-y:auto;background:#151a22;border-top-left-radius:24px;border-top-right-radius:24px;
  border-top:1px solid var(--line);padding:20px 22px calc(24px + env(safe-area-inset-bottom,0px));
  animation:rhUp .22s cubic-bezier(.22,.9,.3,1)}
@keyframes rhUp{from{transform:translateY(24px);opacity:.4}to{transform:none;opacity:1}}
#rhSheet h2{margin:0 0 4px;font-size:19px;font-weight:500;color:var(--ink)}
#rhSheet .rh-note{margin:0 0 14px;font-size:13px;font-weight:300;color:var(--mute)}
#rhSheet .rh-kv{display:flex;justify-content:space-between;gap:12px;padding:11px 0;border-bottom:1px solid rgba(241,236,226,.08);font-size:15px;font-weight:300}
#rhSheet .rh-kv b{font-weight:500;font-variant-numeric:tabular-nums}
#rhSheet .rh-kv:last-of-type{border-bottom:0}
#rhSheet .rh-slot{display:flex;gap:8px;margin:6px 0 12px}
#rhSheet .rh-slot button{flex:1;height:46px;border-radius:12px;border:1px solid var(--line);background:var(--glass);font-size:14px;font-weight:400}
#rhSheet .rh-slot button.on{background:var(--amber);color:#1a1408;border-color:var(--amber);font-weight:500}
#rhSheet .rh-btn{width:100%;height:52px;border-radius:14px;background:var(--glass);border:1px solid var(--line);
  font-size:16px;font-weight:400;margin-top:10px}
#rhSheet .rh-btn.primary{background:var(--amber);color:#1a1408;border-color:var(--amber);font-weight:500}
#rhSheet .rh-close{width:100%;height:44px;margin-top:8px;background:none;font-size:14px;font-weight:300;color:var(--mute)}

/* ปุ่มย้อนกลับจากเมนูเดิม */
#rhBack{position:fixed;z-index:60;left:14px;top:calc(58px + env(safe-area-inset-top,0px));display:none;
  height:38px;padding:0 14px;border:1px solid rgba(0,0,0,.12);border-radius:99px;
  background:rgba(255,255,255,.92);color:#1C1C1E;font:600 13.5px/1 "Prompt",system-ui,sans-serif;
  box-shadow:0 3px 10px rgba(0,0,0,.18);touch-action:manipulation}
#rhBack.on{display:block}
#rhBack:active{transform:scale(.95)}
