/* =============================================
   RESET & BASE
   ============================================= */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: "Noto Sans Thai", sans-serif;
  background-color: #000;
  overflow: hidden;         /* portrait default */
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* portrait — lock scroll */
@media (orientation: portrait) {
  body { overflow: hidden; }
  section {
    position: fixed;
    overflow: hidden;
  }
}

a, a:link, a:visited, a:hover, a:active { text-decoration: none; }

/* =============================================
   BACKGROUND IMAGE — แก้ bug ขอบขาว/ดำ
   ============================================= */
#bgIMG {
  position: fixed;
  inset: 0;
  width: 100dvw;
  height: 100dvh;
  object-fit: cover;
  object-position: center center;
  z-index: -1;
  transition: opacity 1s ease;
  opacity: 1;
  pointer-events: none;
  display: block;
}

/* =============================================
   PRELOADER
   ============================================= */
#preloader {
  position: fixed;
  inset: 0;
  background-color: #fff;
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
}

.preloader-logo { width: 160px; opacity: 0.85; }

/* =============================================
   SECTIONS
   ============================================= */
section {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

/* =============================================
   CARD (หน้า 2–8)
   ============================================= */
.card {
  background: rgba(255, 255, 255, 0.90);
  border: none;
  border-radius: 24px;
  padding: 32px 28px;
  width: 90%;
  max-width: 480px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* =============================================
   TYPOGRAPHY
   ============================================= */
.white-text { color: #fff; }
.text-center { text-align: center; }

h1.title-main {
  font-size: clamp(1.4rem, 5vw, 2rem);
  font-weight: 700;
  color: #fff;
  text-align: center;
  line-height: 1.3;
}

h2.question-title {
  font-size: clamp(1rem, 4vw, 1.2rem);
  font-weight: 700;
  color: #1a1a2e;
  line-height: 1.5;
  text-align: center;
}

p.subtitle {
  font-size: clamp(0.85rem, 3vw, 1rem);
  color: rgba(255,255,255,0.75);
  text-align: center;
  line-height: 1.6;
}

.step-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: rgba(30,30,60,0.5);
  text-transform: uppercase;
  letter-spacing: 2px;
  text-align: center;
}

/* =============================================
   PROGRESS BAR
   ============================================= */
.progress-wrap {
  width: 100%;
  height: 4px;
  background: rgba(30,30,60,0.12);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(to right, #f6a04d, #ef3838);
  border-radius: 99px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =============================================
   BUTTONS
   ============================================= */
.button-33 {
  position: relative;
  background: #fff;
  border: none;
  border-radius: 999px;
  padding: 2vw 5vw;
  font-size: 1rem;
  font-weight: 700;
  color: #000;
  font-family: "Noto Sans Thai", sans-serif;
  box-shadow: 0 8px 20px rgba(0,0,0,.12);
  z-index: 0;
}

.button-33::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 3px;
  background: linear-gradient(90deg, #33e6e6, #005cff);
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  z-index: -1;
}

/* Choice buttons */
.choice-btn {
  width: 100%;
  background: rgba(30,30,60,0.05);
  border: 1.5px solid rgba(30,30,60,0.15);
  border-radius: 14px;
  color: #1a1a2e;
  font-family: "Noto Sans Thai", sans-serif;
  font-size: clamp(0.82rem, 3vw, 0.95rem);
  padding: 12px 16px;
  text-align: left;
  cursor: pointer;
  transition: background 200ms ease, border-color 200ms ease, transform 200ms ease;
  line-height: 1.5;
  touch-action: manipulation;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  /* เริ่ม hidden รอ animate */
  opacity: 0;
  transform: translateX(24px);
}

.choice-btn.visible {
  opacity: 1;
  transform: translateX(0);
}

.choice-btn:hover, .choice-btn:active {
  background: rgba(255,200,100,0.3);
  border-color: rgba(200,120,0,0.5);
  transform: translateX(4px) !important;
}

.choice-btn .choice-label {
  font-weight: 700;
  color: #c47a00;
  min-width: 20px;
}

/* Language buttons */
.lang-btn {
  background: rgba(0, 0, 0, 0.1);
  border: 1.5px solid rgba(0, 0, 0, 0.3);
  border-radius: 16px;
  color: #000;
  font-family: "Noto Sans Thai", sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  padding: 14px 40px;
  cursor: pointer;
  transition: all 200ms ease;
  touch-action: manipulation;
  display: flex;
  align-items: center;
  gap: 10px;
}

.lang-btn:hover, .lang-btn:active {
  background: rgba(255,200,100,0.2);
  border-color: rgba(255,200,100,0.6);
  transform: scale(1.04);
}

.lang-wrap {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  align-items: center;
}

/* =============================================
   RESULT / TYPE CARD (หน้า 8 + 10)
   ============================================= */
.result-card {
  background: rgba(255, 255, 255, 0.90);
  border: none;
  border-radius: 24px;
  padding: 28px 24px;
  width: 90%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.4);
}

.result-img {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  object-fit: cover;
  /* border: 3px solid rgba(255,200,100,0.5); */
}

.result-type-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 3px;
  color: #c47a00;
  text-transform: uppercase;
}

.result-title {
  font-size: clamp(1.1rem, 4vw, 1.4rem);
  font-weight: 700;
  color: #1a1a2e;
  text-align: center;
  line-height: 1.4;
}

.result-desc {
  font-size: clamp(0.82rem, 3vw, 0.92rem);
  color: rgba(30,30,60,0.7);
  text-align: center;
  line-height: 1.7;
}

/* =============================================
   SLIDE-UP PANEL (หน้า 8)
   ============================================= */
#page8 {
  /* panel เป็น fixed ไม่ต้องการ overflow:hidden */
  justify-content: flex-end;
  padding-bottom: max(32px, env(safe-area-inset-bottom));
}

/* Panel เกาะนิ้ว — bottom:0, JS set translateY negative โผล่ขึ้นมา */
#slide-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  transform: translateY(-160px); /* JS override ทันที */
  transition: none;
  cursor: grab;
  touch-action: pan-x;
  will-change: transform;
  display: block; /* block แทน flex — ให้ child stretch เต็มความกว้าง */
  z-index: 10;
}

/* Handle bar */
.slide-handle {
  width: 44px;
  height: 5px;
  background: rgba(30,30,60,0.2);
  border-radius: 99px;
  margin: 0 auto 14px;  /* center กลาง */
}

/* Card ใน panel — เต็มหน้าจอ */
.slide-inner-card {
  background: rgba(255, 255, 255, 0.90);
  border: none;
  border-radius: 24px 24px 0 0;
  padding: 24px 24px 40px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  box-shadow: 0 -8px 40px rgba(0,0,0,0.4);
}

.slide-hint-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding-bottom: 4px;
}

.slide-arrow-anim {
  font-size: 1.4rem;
  color: rgba(30,30,60,0.5);
  animation: bounceUp 1.2s ease-in-out infinite;
}

.slide-hint-text {
  font-size: 0.78rem;
  color: rgba(30,30,60,0.5);
  letter-spacing: 1px;
}

/* =============================================
   LOGO
   ============================================= */
.logo-main {
  width: clamp(160px, 90vw, 350px);
  margin-bottom: 16px;
}

/* =============================================
   QUALITYROOM credit
   ============================================= */
.qr-credit {
  position: fixed;
  bottom: max(16px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.65rem;
  color: rgba(255,255,255,0.3);
  letter-spacing: 2px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 10;
}

/* =============================================
   ANIMATIONS
   ============================================= */
@keyframes fadeIn    { from { opacity:0 }              to { opacity:1 } }
@keyframes fadeOut   { from { opacity:1 }              to { opacity:0 } }
@keyframes slideUp   { from { opacity:0; transform:translateY(40px) }  to { opacity:1; transform:translateY(0) } }
@keyframes slideDown { from { opacity:0; transform:translateY(-40px) } to { opacity:1; transform:translateY(0) } }
@keyframes scaleIn   { from { opacity:0; transform:scale(0.85) }       to { opacity:1; transform:scale(1) } }
@keyframes bounceUp  {
  0%,100% { transform:translateY(0);    opacity:0.45; }
  50%     { transform:translateY(-8px); opacity:1;    }
}

/* Utility classes */
.anim-fadeIn    { animation: fadeIn  0.4s ease forwards; }
.anim-fadeOut   { animation: fadeOut 0.4s ease forwards; }
.anim-slideUp   { animation: slideUp  0.45s ease forwards; }
.anim-slideDown { animation: slideDown 0.45s ease forwards; }
.anim-scaleIn   { animation: scaleIn 0.4s cubic-bezier(.22,.68,0,1.2) forwards; }

/* =============================================
   FORM (เผื่อใช้)
   ============================================= */
.form__group { position:relative; padding:15px 0 0; margin-top:10px; width:80%; }
.form__field {
  font-family:"Noto Sans Thai",sans-serif;
  width:100%; border:0; border-bottom:2px solid #9b9b9b;
  outline:0; font-size:1.2rem; color:#fff; padding:7px 0;
  background:transparent; transition:border-color 0.2s;
}
.form__field::placeholder { color:transparent; }
.form__field:placeholder-shown ~ .form__label { font-size:1.2rem; cursor:text; top:20px; }
.form__label { position:absolute; top:0; display:block; transition:0.2s; font-size:1rem; color:#9b9b9b; }
.form__field:focus ~ .form__label { top:0; font-size:1rem; color:#fff; font-weight:700; }
.form__field:focus {
  padding-bottom:6px; font-weight:700; border-width:3px;
  border-image:linear-gradient(to right,#993811,#ef3838); border-image-slice:1;
}
.form__field:required, .form__field:invalid { box-shadow:none; }

/* =============================================
   UTILITY
   ============================================= */
.mt-8  { margin-top:8px; }
.mt-16 { margin-top:16px; }
.mt-24 { margin-top:24px; }
.gap-12 { gap:12px; }
.w-full { width:100%; }
.flex-col { display:flex; flex-direction:column; }
.align-center { align-items:center; }

/* =============================================
   LANDSCAPE & FOLDABLE RESPONSIVE
   ============================================= */

/* แนวนอนทั่วไป — section scroll ได้ ไม่ fixed */
@media (orientation: landscape) and (max-height: 500px) {

  body {
    overflow: auto;
    overscroll-behavior: none;
  }

  section {
    position: relative; /* ออกจาก fixed — ให้ scroll ได้ */
    min-height: 100dvh;
    height: auto;
    overflow: visible;
    justify-content: flex-start;
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }

  /* แนวนอน — card ไม่สูงเต็มจอ ใช้ 2 column ถ้ากว้างพอ */
  .card {
    width: 80%;
    max-width: 600px;
    padding: 20px 24px;
    gap: 12px;
    margin: auto;
  }

  h2.question-title {
    font-size: clamp(0.9rem, 2.5vh, 1.1rem);
  }

  .choice-btn {
    padding: 8px 14px;
    font-size: clamp(0.78rem, 2vh, 0.88rem);
  }

  /* slide panel landscape — ลดความสูง */
  .slide-inner-card {
    padding: 16px 24px 24px;
    gap: 10px;
  }

  .result-img {
    width: 80px;
    height: 80px;
  }

  .result-title {
    font-size: 1rem;
  }
}

/* Foldable / tablet landscape (จอกว้างมาก) */
@media (orientation: landscape) and (min-width: 600px) and (max-height: 500px) {

  .card {
    flex-direction: row;
    flex-wrap: wrap;
    max-width: 720px;
    align-items: flex-start;
  }

  .card .progress-wrap,
  .card .step-label,
  .card .question-text {
    width: 100%; /* ยังคง full row */
  }

  .card .choice-list {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
}

/* ป้องกัน bgIMG ขาดแนวนอน */
@media (orientation: landscape) {
  #bgIMG {
    width: 100dvw;
    height: 100dvh;
    object-fit: cover;
    object-position: center center;
  }
}

/* =============================================
   ROTATE OVERLAY — บังคับแนวตั้ง
   ============================================= */
#rotate-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 99999;
  justify-content: center;
  align-items: center;
}

#rotate-overlay.active {
  display: flex;
}

.rotate-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 32px;
  text-align: center;
}

.rotate-icon {
  font-size: 3.5rem;
  animation: rotateHint 1.5s ease-in-out infinite;
}

.rotate-msg-th,
.rotate-msg-en {
  color: rgba(255,255,255,0.85);
  font-family: "Noto Sans Thai", sans-serif;
}

.rotate-msg-th { font-size: 1.1rem; font-weight: 600; }
.rotate-msg-en { font-size: 0.85rem; opacity: 0.6; }

@keyframes rotateHint {
  0%, 100% { transform: rotate(0deg); }
  30%       { transform: rotate(90deg); }
  70%       { transform: rotate(90deg); }
}

/* =============================================
   SLIDE FALLBACK BUTTON
   ============================================= */
.slide-fallback-btn {
  margin-top: 4px;
  background: transparent;
  border: 1.5px dashed rgba(30,30,60,0.25);
  border-radius: 100px;
  color: rgba(30,30,60,0.45);
  font-family: "Noto Sans Thai", sans-serif;
  font-size: 0.78rem;
  padding: 8px 20px;
  cursor: pointer;
  touch-action: manipulation;
  transition: all 200ms ease;
}

.slide-fallback-btn:hover,
.slide-fallback-btn:active {
  border-color: rgba(30,30,60,0.5);
  color: rgba(30,30,60,0.7);
  background: rgba(30,30,60,0.05);
}