/* ===========================================================
   POWER RUSH — style.css
   ธีม: Liquid Glass (มิติกระจกใส) โทนสีฟ้าพาสเทล
   ออกแบบ Mobile-first (แนวตั้ง)
   =========================================================== */

:root {
  --pastel-blue-1: #e0f2fe;
  --pastel-blue-2: #bae6fd;
  --pastel-blue-3: #7dd3fc;
  --pastel-pink:   #fdf2f8;
  --pastel-pink-2: #fbcfe8;
  --ink:           #334155;
  --ink-bold:      #0f172a;
  --white:         #ffffff;
  --soft:          rgba(51, 65, 85, 0.7);
  --line:          rgba(255, 255, 255, 0.6);
  --radius:        24px;
  --glass-bg:      rgba(255, 255, 255, 0.45);
  --glass-border:  rgba(255, 255, 255, 0.8);
  --glass-shadow:  0 8px 32px 0 rgba(100, 140, 180, 0.15);
  --green:         #4ade80;
  --red:           #fb7185;
  --amber:         #fbbf24;
}

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

html, body {
  margin: 0; height: 100%;
  font-family: "Sarabun", system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(135deg, var(--pastel-blue-1) 0%, var(--pastel-blue-2) 50%, var(--pastel-pink-2) 100%);
  overflow: hidden;
}

/* Liquid Blob Background Effect */
body::before, body::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  z-index: -1;
  filter: blur(60px);
  opacity: 0.6;
}
body::before {
  width: 300px; height: 300px;
  background: var(--pastel-blue-3);
  top: -50px; left: -50px;
  animation: blob-bounce 10s infinite alternate;
}
body::after {
  width: 400px; height: 400px;
  background: var(--pastel-pink-2);
  bottom: -100px; right: -100px;
  animation: blob-bounce 12s infinite alternate-reverse;
}
@keyframes blob-bounce {
  0% { transform: scale(1) translate(0, 0); }
  100% { transform: scale(1.1) translate(20px, 30px); }
}

#app {
  position: relative;
  width: 100vw; height: 100dvh;
  max-width: 520px; margin: 0 auto;
  overflow: hidden;
}

/* ---------- ระบบสลับหน้าจอ ---------- */
.screen { position: absolute; inset: 0; display: none; }
.screen.active { display: flex; }

/* ---------- ปุ่ม ---------- */
.btn {
  border: 1px solid var(--glass-border); border-radius: 999px;
  font-family: "Itim", "Sarabun", sans-serif;
  font-size: 20px; padding: 14px 26px;
  cursor: pointer; transition: all .15s ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.btn:active { transform: scale(.96); }
.btn-primary { 
  background: rgba(255, 255, 255, 0.7); 
  color: var(--ink-bold); 
  font-weight: 700; 
  box-shadow: 0 4px 12px rgba(125, 211, 252, 0.4); 
}
.btn-primary:active { box-shadow: 0 2px 6px rgba(125, 211, 252, 0.4); }
.btn-ghost { background: rgba(255,255,255,.2); color: var(--ink); }

/* Glassmorphism Card Base */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--glass-shadow);
}

/* ===========================================================
   หน้า 1 : LOGIN
   =========================================================== */
#screen-login {
  align-items: center; justify-content: center;
  background: transparent;
}
.login-card { 
  text-align: center; padding: 32px 24px; width: 90%; max-width: 360px; 
}
.logo {
  font-family: "Itim", sans-serif; font-size: 56px; line-height: 1;
  color: var(--pastel-blue-3); text-shadow: 0 4px 12px rgba(255,255,255,0.8);
  margin-bottom: 8px;
}
.logo span { display: block; color: #f472b6; text-shadow: 0 4px 12px rgba(255,255,255,0.8); }
.tagline { color: var(--soft); margin: 0 0 16px; font-size: 16px; font-weight: 600; }
.mascot-hero {
  width: 180px; height: auto; margin: 4px auto 20px; display: block;
  filter: drop-shadow(0 12px 18px rgba(100,140,180,.2));
  animation: float 3s ease-in-out infinite;
}
@keyframes float { 0%,100%{ transform: translateY(0) } 50%{ transform: translateY(-12px) } }
#player-name {
  width: 100%; padding: 16px; border-radius: 16px; 
  border: 1px solid var(--glass-border);
  font-size: 18px; font-family: inherit; text-align: center;
  margin-bottom: 16px; background: rgba(255,255,255,.6); color: var(--ink-bold);
  backdrop-filter: blur(8px);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}
#player-name:focus { outline: none; border-color: var(--pastel-blue-3); background: rgba(255,255,255,.9); }
#btn-login { width: 100%; }
.hint-text { color: var(--soft); font-size: 13px; margin-top: 14px; }

/* ===========================================================
   หน้า 2 : MAP
   =========================================================== */
#screen-map {
  flex-direction: column;
  background: transparent;
  padding: 20px 16px 26px;
}
.topbar { display: flex; justify-content: space-between; align-items: center; }
.who { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink-bold); }
.dot { width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg,var(--pastel-blue-3),var(--pastel-blue-2)); }
.stats { display: flex; gap: 10px; }
.stat { 
  display: flex; align-items: center; gap: 6px; 
  background: var(--glass-bg); padding: 8px 14px; border-radius: 999px; 
  font-weight: 700; color: var(--ink-bold);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(8px);
}
.cat-ic { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; }
.ic-star { width: 0; height: 0; }
.ic-star::before { content: "★"; color: var(--amber); font-size: 18px; }
.map-title { font-family: "Itim", sans-serif; font-weight: 400; font-size: 28px; margin: 24px 4px 16px; color: var(--ink-bold); text-align: center; }
.level-list { display: flex; flex-direction: column; gap: 14px; overflow-y: auto; flex: 1; padding-bottom: 12px; }
.level {
  display: flex; align-items: center; gap: 16px;
  padding: 16px; border-radius: var(--radius);
  cursor: pointer; transition: transform .15s ease, background .15s ease;
}
.level:active { transform: scale(.98); }
.level.locked { opacity: .6; cursor: not-allowed; filter: grayscale(0.5); }
.level .num {
  width: 52px; height: 52px; flex: 0 0 52px; border-radius: 16px;
  display: grid; place-items: center; font-family: "Itim",sans-serif; font-size: 26px;
  background: rgba(255,255,255,.8); color: var(--pastel-blue-3);
  box-shadow: 0 4px 12px rgba(125,211,252,0.3);
}
.level.locked .num { background: rgba(255,255,255,.4); color: var(--soft); box-shadow: none; }
.level.boss .num { background: #fdf2f8; color: #f472b6; box-shadow: 0 4px 12px rgba(244,114,182,0.3); }
.level .meta { flex: 1; }
.level .meta b { font-weight: 700; font-size: 17px; color: var(--ink-bold); }
.level .meta small { display: block; color: var(--soft); font-size: 14px; margin-top: 2px; }
.level .lv-stars { color: var(--amber); letter-spacing: 2px; font-size: 16px; text-shadow: 0 1px 2px rgba(0,0,0,0.1); }
#btn-logout { margin-top: 16px; align-self: center; }

/* ===========================================================
   หน้า 3 : GAME (AR)
   =========================================================== */
#screen-game { background: transparent; overflow: hidden; }
#cam {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; transform: scaleX(-1); /* กระจกเงา */
  opacity: 0.6; /* ให้เห็นฉากหลังสว่างๆ ทะลุกล้องได้หน่อย */
}
#overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* HUD บน */
.hud-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; align-items: flex-start; gap: 12px; padding: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.8), rgba(255,255,255,0));
}
.chip {
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--glass-border);
  background: var(--glass-bg); color: var(--ink-bold); font-size: 20px; cursor: pointer;
  backdrop-filter: blur(8px); display: grid; place-items: center;
}
.race-track { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.lane {
  position: relative; height: 30px; border-radius: 999px;
  background: rgba(255,255,255,.4); border: 1px solid var(--glass-border);
  backdrop-filter: blur(4px); box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}
.lane .flag { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-size: 16px; }
.racer {
  position: absolute; left: 0; top: 50%; transform: translate(-2px,-50%);
  width: 36px; height: 36px; border-radius: 50%; object-fit: cover; object-position: top center;
  border: 3px solid var(--white); transition: left .4s cubic-bezier(.2,.8,.2,1);
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
.racer-rival {
  position: absolute; left: 0; top: 50%; transform: translate(-2px,-50%);
  font-size: 24px; transition: left .4s linear; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}
.combo-chip {
  display: flex; align-items: center; gap: 6px; padding: 8px 14px;
  background: var(--glass-bg); border-radius: 999px; font-family: "Itim",sans-serif; color: var(--ink-bold);
  border: 1px solid var(--glass-border); backdrop-filter: blur(8px);
  font-size: 18px;
}

/* พื้นที่โจทย์ */
.play-area {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 4;
  padding: 24px 16px 32px;
  background: linear-gradient(0deg, rgba(255,255,255,0.95) 40%, rgba(255,255,255,0.5) 85%, transparent);
  border-top: 1px solid var(--glass-border);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-radius: 32px 32px 0 0;
}
.question {
  text-align: center; font-size: 38px; font-family: "Itim", sans-serif;
  margin-bottom: 24px; color: var(--ink-bold); text-shadow: 0 2px 4px rgba(255,255,255,0.8);
}
.question sup { font-size: .55em; }
.question img { max-width: 100%; max-height: 140px; border-radius: 16px; object-fit: contain; filter: drop-shadow(0 4px 12px rgba(0,0,0,0.1)); }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.opt {
  position: relative; min-height: 72px; border-radius: 20px;
  display: grid; place-items: center; font-size: 30px; font-family: "Itim",sans-serif;
  background: rgba(255,255,255,.8); color: var(--ink-bold);
  border: 2px solid var(--glass-border); cursor: pointer; overflow: hidden;
  transition: transform .1s ease, box-shadow .15s ease;
  box-shadow: 0 4px 12px rgba(125,211,252,0.15);
}
.opt sup { font-size: .55em; }
.opt img { max-width: 80%; max-height: 60px; object-fit: contain; }
.opt .fill {
  position: absolute; inset: 0; background: rgba(125,211,252,.5);
  transform: scaleX(0); transform-origin: left; transition: transform .08s linear;
}
.opt .label { position: relative; z-index: 2; pointer-events: none; }
.opt.hot { border-color: var(--pastel-blue-3); transform: scale(1.02); box-shadow: 0 6px 16px rgba(125,211,252,0.3); }
.opt.correct { background: var(--green); color: #fff; border-color: var(--green); box-shadow: 0 6px 16px rgba(74,222,128,0.4); }
.opt.wrong { background: var(--red); color: #fff; border-color: var(--red); box-shadow: 0 6px 16px rgba(251,113,133,0.4); }
.feedback {
  text-align: center; min-height: 24px; margin-top: 14px;
  font-size: 16px; color: var(--ink-bold); font-weight: 700;
}

/* มาสคอตผู้ช่วย */
.guide {
  position: absolute; right: 12px; bottom: 250px; z-index: 4;
  width: 110px; height: auto; pointer-events: none;
  filter: drop-shadow(0 8px 16px rgba(0,0,0,.15));
}

/* เคอร์เซอร์มือ */
.cursor {
  position: absolute; z-index: 9; width: 64px; height: 64px;
  margin: -32px 0 0 -32px; pointer-events: none; display: none;
}
.cursor .ring {
  width: 100%; height: 100%; border-radius: 50%;
  border: 4px solid var(--pastel-blue-3); background: rgba(255,255,255,.6);
  box-shadow: 0 0 20px rgba(125,211,252,.8);
  backdrop-filter: blur(4px);
}
.cursor.pinch .ring { background: var(--pastel-pink-2); border-color: #f472b6; box-shadow: 0 0 20px rgba(244,114,182,.8); }

.cam-note {
  position: absolute; left: 16px; right: 16px; top: 76px; z-index: 6;
  background: var(--glass-bg); padding: 12px 16px; border-radius: 16px;
  font-size: 14px; text-align: center; color: var(--ink-bold);
  border: 1px solid var(--glass-border); backdrop-filter: blur(12px); font-weight: 600;
  box-shadow: var(--glass-shadow);
}
.cam-note.hide { display: none; }

/* ===========================================================
   หน้า 4 : RESULT
   =========================================================== */
#screen-result {
  align-items: center; justify-content: center;
  background: transparent;
}
.result-card { text-align: center; padding: 32px 24px; width: 90%; max-width: 360px; }
.result-card h2 { font-family: "Itim",sans-serif; font-weight: 400; font-size: 40px; margin: 0; color: var(--ink-bold); }
.stars-big { font-size: 52px; color: var(--amber); letter-spacing: 6px; margin: 10px 0; text-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.stars-big .off { color: rgba(255,255,255,.5); text-shadow: none; }
.result-stats { display: flex; justify-content: center; gap: 28px; margin: 20px 0 24px; }
.result-stats div { display: flex; flex-direction: column; }
.result-stats span { font-family: "Itim",sans-serif; font-size: 28px; color: var(--ink-bold); }
.result-stats label { color: var(--soft); font-size: 14px; font-weight: 600; margin-top: 4px; }
.result-btns { display: flex; gap: 14px; }
.result-btns .btn { flex: 1; }

@media (max-width: 360px) {
  .question { font-size: 32px; }
  .question img { max-height: 100px; }
  .opt { font-size: 24px; min-height: 64px; }
  .guide { width: 90px; bottom: 230px; }
}
