/* ============================================================
   style.css — CTB Web (mobile-first, responsive, print-ready)
   ธีม: Navy #0F2942 + Gold + สีระดับคะแนน 5 ระดับ
   ============================================================ */

:root {
  --navy: #0F2942;
  --navy-2: #16395C;
  --gold: #F5B301;
  --bg: #F1F5F9;
  --card: #FFFFFF;
  --text: #1F2937;
  --muted: #64748B;
  --line: #E2E8F0;

  --lv5-bg: #DCFCE7; --lv5-fg: #166534;
  --lv4-bg: #FEF9C3; --lv4-fg: #854D0E;
  --lv3-bg: #DBEAFE; --lv3-fg: #1E3A8A;
  --lv2-bg: #FED7AA; --lv2-fg: #9A3412;
  --lv1-bg: #FEE2E2; --lv1-fg: #991B1B;

  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0; padding: 0;
  font-family: 'Sarabun', 'Noto Sans Thai', system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  overflow-x: clip; /* กันเนื้อหาล้นขอบซ้าย-ขวา (ตารางกว้างอยู่ใน .table-scroll แล้ว) */
}
body { min-height: 100dvh; overscroll-behavior-y: contain; }
button { font-family: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.gold { color: var(--gold); font-weight: 700; }

/* ---------- Topbar ---------- */
#topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  display: flex; align-items: center; gap: 10px;
  background: var(--navy); color: #fff;
  padding: calc(6px + env(safe-area-inset-top, 0px)) 12px 6px;
  font-size: .95rem; font-weight: 600;
}
.tb-btn {
  border: none; background: rgba(255,255,255,.15); color: #fff;
  width: 36px; height: 36px; border-radius: 10px; font-size: 1.1rem;
  flex: 0 0 auto; cursor: pointer;
}
#tb-title { flex: 1 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-progress { flex: 0 0 auto; opacity: .85; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; cursor: pointer; user-select: none;
  padding: 10px 18px; min-height: 44px;
  border-radius: 12px; font-size: 1rem; font-weight: 700;
  transition: transform .06s ease, filter .15s ease;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-secondary { background: #E8EEF5; color: var(--navy); }
.btn-success { background: #16A34A; color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); border: 1.5px solid var(--line); }
.btn-gold { background: var(--gold); color: #3B2B00; }
.btn-lg { padding: 13px 26px; font-size: 1.08rem; }
.btn-xl { padding: 16px 40px; font-size: 1.25rem; border-radius: 16px; }
.arr { display: inline-block; margin-left: 8px; transition: transform .15s ease; }
.btn:hover .arr { transform: translateX(3px); }

/* ---------- Screen (home/form/checklist/report) ---------- */
#screen { padding: 20px 14px calc(24px + var(--safe-b)); max-width: 1080px; margin: 0 auto; }

/* ---------- Home: full-screen hero landing (liquid glass) ---------- */
#screen.at-home {
  padding: 0; max-width: none;
  background: #04101C;
}

.hl-video {
  position: fixed; inset: 0; z-index: 0;
  width: 100%; height: 100%; object-fit: cover;
  background: var(--navy);
}
@media (prefers-reduced-motion: reduce) {
  .hl-video { display: none; }
}
.hl-scrim {
  position: fixed; inset: 0; z-index: 1;
  background: linear-gradient(180deg,
    rgba(4, 14, 26, .58) 0%, rgba(4, 14, 26, .22) 38%, rgba(4, 14, 26, .60) 100%);
}

.hl-shell {
  position: relative; z-index: 2;
  min-height: 100dvh;
  display: flex; flex-direction: column;
}

/* --- liquid glass --- */
.hl-glass {
  background: rgba(255, 255, 255, 0.01);
  background-blend-mode: luminosity;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.1);
  position: relative; overflow: hidden;
}
.hl-glass::before {
  content: '';
  position: absolute; inset: 0; border-radius: inherit; padding: 1.4px;
  background: linear-gradient(to bottom,
    rgba(255, 255, 255, 0.45) 0%, rgba(255, 255, 255, 0.15) 20%,
    rgba(255, 255, 255, 0) 40%, rgba(255, 255, 255, 0) 60%,
    rgba(255, 255, 255, 0.15) 80%, rgba(255, 255, 255, 0.45) 100%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

/* --- nav --- */
.hl-nav {
  position: relative; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 24px 20px 0;
}
@media (min-width: 640px) { .hl-nav { padding: 32px 32px 0; } }
@media (min-width: 1024px) { .hl-nav { padding: 36px 80px 0; } }

.hl-logo { color: #fff; display: grid; place-items: center; width: 36px; height: 36px; }
.hl-logo svg { width: 32px; height: 32px; }
@media (min-width: 768px) { .hl-logo svg { width: 36px; height: 36px; } }

.hl-links-desktop { display: none; }
@media (min-width: 768px) {
  .hl-links-desktop {
    display: inline-flex; align-items: center;
    border-radius: 999px; padding: 12px 32px; gap: 28px;
  }
}
.hl-links-desktop a {
  font-size: .875rem; font-weight: 500; text-decoration: none;
  color: rgba(255, 255, 255, .7); transition: color .15s ease;
}
.hl-links-desktop a:hover, .hl-links-desktop a.is-active { color: #fff; }

.hl-user {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  border: none; cursor: pointer; color: rgba(255, 255, 255, .8);
}
.hl-user svg { width: 20px; height: 20px; }
@media (min-width: 768px) { .hl-only-mobile { display: none !important; } }

/* burger icon swap */
.hl-burger-icons { position: relative; width: 20px; height: 20px; display: block; }
.hl-burger-icons svg {
  position: absolute; inset: 0; width: 20px; height: 20px;
  transition: all .3s ease; color: rgba(255, 255, 255, .85);
}
.hl-burger-icons .ic-close { opacity: 0; transform: rotate(-90deg) scale(0); }
#hl-burger.open .ic-menu { opacity: 0; transform: rotate(90deg) scale(0); }
#hl-burger.open .ic-close { opacity: 1; transform: rotate(0) scale(1); }

/* --- mobile menu overlay --- */
.hl-menu {
  position: fixed; inset: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 32px;
  background: rgba(0, 0, 0, .8);
  -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .5s ease-out, visibility 0s linear .5s;
}
.hl-menu.open { opacity: 1; visibility: visible; pointer-events: auto; transition-delay: 0s; }
.hl-menu > a {
  color: #fff; text-decoration: none;
  font-size: 1.5rem; font-weight: 500;
  opacity: 0; transform: translateY(-32px);
  transition: opacity .45s ease-out .08s, transform .45s ease-out .08s;
}
.hl-menu.open > a { opacity: 1; transform: translateY(0); }

/* --- main content --- */
.hl-main {
  position: relative; z-index: 10;
  flex: 1 1 auto;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 56px 20px calc(28px + var(--safe-b));
  transition: opacity .3s ease;
}
@media (min-width: 640px) { .hl-main { padding: 80px 32px 32px; } }
@media (min-width: 1024px) { .hl-main { padding: 112px 80px 36px; } }
.hl-main.dimmed { opacity: 0; pointer-events: none; }

.hl-top { max-width: 42rem; }
.hl-badge {
  display: inline-flex; align-items: center;
  gap: 11px; border-radius: 999px;
  padding: 7px 14px; margin-bottom: 22px;
}
@media (min-width: 640px) { .hl-badge { gap: 12px; padding: 9px 16px; margin-bottom: 24px; } }
.hl-avatars { display: flex; }
.hl-avatars img {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .2); object-fit: cover;
}
.hl-avatars img + img { margin-left: -8px; }
@media (min-width: 640px) { .hl-avatars img { width: 24px; height: 24px; } }
.hl-badge-text { font-size: .78rem; font-weight: 300; color: rgba(255, 255, 255, .82); white-space: nowrap; }
@media (min-width: 640px) { .hl-badge-text { font-size: .875rem; } }

.hl-title {
  margin: 0; color: #fff;
  font-weight: 400; line-height: 1.08; letter-spacing: -.02em;
  font-size: clamp(2.3rem, 7vw, 4.5rem);
  text-wrap: balance;
}
.hl-title em { font-style: normal; color: #F5B301; }
.hl-sub {
  margin: 18px 0 0; max-width: 34em;
  font-size: .95rem; line-height: 1.75; font-weight: 300;
  color: rgba(255, 255, 255, .72);
}
@media (min-width: 640px) { .hl-sub { font-size: 1.0625rem; margin-top: 20px; } }

.hl-cta {
  margin-top: 28px; border: none; cursor: pointer;
  border-radius: 999px; padding: 13px 27px;
  font-family: inherit; font-size: .92rem; font-weight: 600; color: #fff;
  transition: background-color .3s ease, transform .06s ease;
}
@media (min-width: 640px) { .hl-cta { padding: 15px 29px; } }
.hl-cta:hover { background-color: rgba(255, 255, 255, .12); }
.hl-cta:active { transform: scale(.98); }

/* --- bottom stats --- */
.hl-stats {
  display: flex; align-items: flex-end;
  gap: 28px; padding-top: 44px; margin-top: auto;
}
@media (min-width: 640px) { .hl-stats { gap: 44px; } }
@media (min-width: 1024px) { .hl-stats { gap: 64px; } }
.hl-stat { display: flex; flex-direction: column; gap: 7px; }
.hl-stat-icon { position: relative; width: 20px; height: 20px; }
.hl-stat-icon i {
  position: absolute; width: 2.5px; height: 2.5px;
  background: rgba(255, 255, 255, .6); border-radius: .5px;
}
.hl-grid-icon {
  display: grid; grid-template-columns: repeat(3, 4px); gap: 2px;
  width: fit-content; height: 16px;
}
.hl-grid-icon i { width: 4px; height: 4px; border-radius: 1.5px; background: rgba(255, 255, 255, .6); }
.hl-grid-icon i:nth-child(even) { background: transparent; }
.hl-stat b {
  font-size: clamp(1.25rem, 3.4vw, 1.875rem);
  font-weight: 400; line-height: 1.25; color: #fff;
}
.hl-stat span { font-size: .8rem; font-weight: 300; color: rgba(255, 255, 255, .62); }
@media (min-width: 640px) { .hl-stat span { font-size: .875rem; } }

.card {
  background: var(--card); border-radius: var(--radius);
  padding: 22px 18px; box-shadow: 0 4px 18px rgba(15,41,66,.08);
}
.card h2 { margin: 0 0 16px; color: var(--navy); font-size: 1.35rem; }

/* ---------- Form ---------- */
.form-card { max-width: 780px; margin: 0 auto; }
.form-card h2 { font-size: 1.18rem; margin: 0 0 14px; }
.form-grid {
  display: grid; grid-template-columns: 1fr; gap: 10px;
}
.form-grid label {
  display: flex; flex-direction: column; gap: 5px;
  font-weight: 700; font-size: .85rem; color: var(--navy);
}
.form-grid .full { grid-column: 1 / -1; }
.form-grid input, .form-grid select, .form-grid textarea {
  font-family: inherit; font-size: 1rem; font-weight: 500;
  padding: 9px 11px; min-height: 45px;
  border: 1.5px solid var(--line); border-radius: 9px; background: #FBFDFF;
}
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus {
  outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(15,41,66,.12);
}
.form-row { display: grid; grid-column: 1 / -1; gap: 10px; grid-template-columns: repeat(3, 1fr); }
.norm-preview {
  margin-top: 12px; padding: 10px 12px; border-radius: 10px;
  background: #ECFDF5; color: #065F46; font-size: .9rem;
}
.form-actions {
  display: flex; justify-content: space-between; gap: 10px;
  margin-top: 16px; flex-wrap: wrap;
}
.form-actions .btn:last-child { margin-left: auto; }
@media (min-width: 640px) {
  .form-card h2 { font-size: 1.32rem; margin: 0 0 16px; }
  .form-grid { grid-template-columns: 1fr 1fr; gap: 12px 14px; }
  .form-grid label { font-size: .92rem; gap: 6px; }
  .form-grid input, .form-grid select, .form-grid textarea {
    font-size: 1.05rem; padding: 11px 12px; min-height: 48px; border-radius: 10px;
  }
  .form-row { gap: 14px; }
  .norm-preview { margin-top: 14px; padding: 12px 14px; font-size: 1rem; }
  .form-actions { margin-top: 20px; }
}
.form-actions .btn:last-child { margin-left: auto; }

/* ---------- Checklist ---------- */
.ck-card h2 { font-size: 1.15rem; margin: 0 0 12px; }
.check-tools { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.check-tools .btn { padding: 8px 14px; min-height: 40px; font-size: .9rem; }
.check-list { display: flex; flex-direction: column; gap: 8px; }
.check-item {
  display: grid; grid-template-columns: auto auto 1fr;
  align-items: center; gap: 3px 10px; padding: 11px 12px; cursor: pointer;
  background: #FBFDFF; border: 1.5px solid var(--line); border-radius: 12px;
  transition: border-color .15s, background .15s;
}
.check-item:hover { border-color: var(--navy-2); }
.check-item input { width: 20px; height: 20px; accent-color: var(--navy); }
.ck-no {
  width: 30px; height: 30px; display: grid; place-items: center;
  background: var(--navy); color: #fff; border-radius: 9px;
  font-weight: 800; font-size: .88rem;
}
.ck-name { font-weight: 700; font-size: .92rem; min-width: 0; overflow-wrap: break-word; }
.ck-domain {
  grid-column: 3; color: var(--muted);
  font-size: .78rem; line-height: 1.4; text-align: left;
}
@media (min-width: 640px) {
  .ck-card h2 { font-size: 1.32rem; margin: 0 0 16px; }
  .check-tools { margin-bottom: 12px; }
  .check-tools .btn { padding: 10px 18px; min-height: 44px; font-size: 1rem; }
  .ck-name { font-size: 1rem; }
}

/* ---------- Advice screens ---------- */
.nw { white-space: nowrap; }
.advice-wrap {
  max-width: 900px; margin: 0 auto;
  height: 100%; overflow-y: auto; touch-action: pan-y;
  padding: 8px 12px calc(18px + var(--safe-b));
  display: flex; flex-direction: column; gap: 12px; align-items: center;
}
.advice-title { margin: 0; text-align: center; color: var(--navy); font-size: clamp(1.15rem, 4vw, 1.6rem); }
.advice-desc {
  margin: 0 auto; text-align: center; color: var(--muted);
  font-size: clamp(1rem, 3vw, 1.2rem); line-height: 1.65;
  max-width: 34em;
}
.advice-imgbox {
  width: 100%; flex: 1 1 auto; min-height: 0;
  background: #fff; border-radius: var(--radius);
  border: 1.5px solid var(--line); padding: 8px;
  display: grid; place-items: center; touch-action: pan-y;
}
.advice-img { max-width: 100%; max-height: min(36vh, 380px); object-fit: contain; }
/* โหมดรูปเดียว — ขยายใหญ่สุดเท่ากรอบที่ว่าง (กันล้นทับปุ่มทุกขนาดจอ) */
.advice-imgbox.single {
  display: flex; align-items: center; justify-content: center;
  padding: 6px;
  min-height: clamp(160px, 34vh, 640px);
  overflow: hidden;
}
.advice-imgbox.single .advice-img {
  width: auto; height: auto;
  max-width: 100%;
  max-height: 100%;
}
.advice-nav {
  display: flex; align-items: center; gap: 14px; width: 100%;
  justify-content: space-between; max-width: 520px; flex: 0 0 auto;
}
.advice-page { font-weight: 700; color: var(--muted); }
.advice-actions {
  display: flex; gap: 10px; flex-wrap: wrap; justify-content: center;
  flex: 0 0 auto; padding-bottom: 2px;
}

/* ---------- Stage (พื้นที่ทำแบบทดสอบ) ---------- */
#stage {
  position: fixed; inset: 0; z-index: 40; overflow: hidden;
  background: var(--bg);
  padding-top: 48px;
  touch-action: none;
}
#stage.stage-black { background: #000; color: #fff; }

.center-msg {
  position: absolute; inset: 0;
  display: grid; place-items: center; text-align: center;
  font-size: clamp(1.15rem, 3.4vw, 1.7rem); font-weight: 800;
  padding: 56px 16px calc(120px + var(--safe-b));
  pointer-events: none;
}
/* หัวข้อโหมด/กติกาบนฉากทดสอบ (CRT, TMT, …) */
.mode-title { display: block; font-size: 1.5em; line-height: 1.2; }
.mode-rules {
  display: flex; flex-direction: column; align-items: center; gap: .55em;
  margin-top: .7em; font-size: .72em; font-weight: 700; opacity: .95;
}
.fix-plus { font-size: clamp(64px, 14vh, 130px); font-weight: 400; line-height: 1; }

.rt-circle {
  width: min(38vmin, 300px); height: min(38vmin, 300px);
  border-radius: 50%; background: #D32F2F;
}

.test-progress {
  position: absolute; top: 48px; left: 0; right: 0; height: 5px;
  background: rgba(128,128,128,.25); z-index: 5;
}
.test-progress-fill { height: 100%; width: 0; background: var(--gold); transition: width .2s; }

.trial-label {
  position: absolute; top: calc(54px + env(safe-area-inset-top, 0px)); right: 14px;
  font-weight: 700; opacity: .8; font-size: .95rem; z-index: 5;
}

.countdown {
  position: absolute; inset: 0; z-index: 30;
  display: grid; place-items: center;
  font-size: clamp(90px, 24vmin, 220px); font-weight: 800; color: var(--gold);
  background: rgba(0,0,0,.75);
}

.start-box {
  position: absolute; inset: auto 0 max(16vh, calc(118px + var(--safe-b))) 0;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.start-msg {
  font-size: clamp(1.1rem, 3.2vw, 1.5rem); font-weight: 800;
  color: var(--gold); text-align: center; padding: 0 18px; line-height: 1.6;
}
#stage:not(.stage-black) .start-msg { color: var(--navy); }

/* ---------- Response buttons (touch + keyboard) ---------- */
.resp-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: center; gap: 18px;
  padding: 12px 14px calc(14px + var(--safe-b));
  z-index: 10;
}
.resp-btn {
  flex: 0 1 240px; min-height: 88px;
  border: 3px solid rgba(255,255,255,.65); border-radius: 20px;
  background: rgba(255,255,255,.08); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  cursor: pointer; touch-action: manipulation;
}
.resp-key { font-size: 2rem; font-weight: 800; letter-spacing: 2px; }
.resp-hint { font-size: .82rem; opacity: .85; }
/* สว่างเฉพาะ "ขณะกด" — ปล่อยแล้วคืนสภาพเดิม */
.resp-btn.pressed {
  background: var(--gold); color: #3B2B00; border-color: var(--gold);
  transform: scale(.95);
}
#stage:not(.stage-black) .resp-btn {
  border-color: var(--navy); background: #EAF0F7; color: var(--navy);
}
#stage:not(.stage-black) .resp-btn.pressed {
  background: var(--navy); color: #fff; border-color: var(--navy);
}

/* ---------- Flanker ---------- */
.flanker-row {
  display: flex; gap: clamp(8px, 2.4vw, 24px);
  /* ใหญ่พออ่านง่ายบนมือถือ — จำกัดด้วยความกว้าง (5 ตัว+gap) และความสูงจอ กันล้นทั้งแนวตั้ง/แนวนอน */
  font-size: clamp(56px, min(21vw, 34vh), 112px); line-height: 1;
  font-weight: 700; color: #fff; align-items: center;
}
/* หลักการ: ลูกศรทุกตัว "สีเดียวกัน" แยกกลางด้วยตำแหน่งเท่านั้น */
.flanker-arrow.center { color: inherit; }

/* ---------- TMT ---------- */
.tmt-board {
  position: absolute; inset: 56px 8px calc(16px + var(--safe-b)) 8px;
}
.tmt-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.tmt-node {
  position: absolute; transform: translate(-50%, -50%);
  width: clamp(38px, 7.2vmin, 60px); height: clamp(38px, 7.2vmin, 60px);
  border-radius: 50%;
  background: #FFFDF5; border: 2.5px solid #222; color: #111;
  font-size: clamp(.85rem, 2.6vmin, 1.3rem); font-weight: 800;
  display: grid; place-items: center; cursor: pointer; padding: 0;
}
.tmt-node.hit { background: #EF4444; border-color: #991B1B; color: #fff; opacity: .85; }
.tmt-node.err { animation: shake .3s; border-color: #DC2626; box-shadow: 0 0 0 4px rgba(220,38,38,.35); }
@keyframes shake {
  25% { transform: translate(calc(-50% - 4px), -50%); }
  75% { transform: translate(calc(-50% + 4px), -50%); }
}

/* ---------- Design Fluency ---------- */
.df-hud {
  position: absolute; top: calc(54px + env(safe-area-inset-top, 0px)); left: 14px; right: 14px;
  display: flex; justify-content: space-between; flex-wrap: wrap;
  gap: 2px 12px;
  font-weight: 800; z-index: 5;
}
/* กริด 2 ช่อง/หน้า — ช่องยืดเต็มพื้นที่ที่เหลือเสมอ (1fr) จึงไม่มีวันล้นไปทับปุ่ม nav
   มือถือแนวตั้ง: ซ้อนบน-ล่าง · แนวนอน/จอกว้าง: เรียงข้างกัน · จอใหญ่จำกัดความกว้างกึ่งกลาง */
.df-grid {
  position: absolute; top: calc(88px + env(safe-area-inset-top, 0px)); left: 8px; right: 8px;
  bottom: calc(64px + var(--safe-b));
  display: grid; gap: 10px;
  grid-template-columns: 1fr; grid-auto-rows: 1fr;
}
@media (orientation: landscape), (min-width: 560px) {
  .df-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 900px) {
  .df-grid { left: 0; right: 0; max-width: 1040px; margin: 0 auto; }
}
.df-cell {
  position: relative;
  background: #FCFCF8; border: 1.5px solid #333; border-radius: 8px;
  overflow: hidden;
}
.df-cell.is-invalid { border-color: #DC2626; box-shadow: inset 0 0 0 2px rgba(220,38,38,.45); }
/* เส้นเชื่อมวาดใต้จุด (z-index -1 ใน WPF) — svg pointer-events:none */
.df-csvg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
/* จุด: พื้นที่แตะ ≥30px กันพลาดบนมือถือ · วงกลมจริงผ่าน ::before */
.df-dot5 {
  position: absolute; transform: translate(-50%, -50%);
  width: clamp(30px, 7vmin, 42px); height: clamp(30px, 7vmin, 42px);
  background: transparent; border: none; padding: 0; cursor: pointer;
  display: grid; place-items: center; z-index: 2; touch-action: manipulation;
}
.df-dot5::before {
  content: ''; width: clamp(11px, 2.6vmin, 17px); height: clamp(11px, 2.6vmin, 17px);
  border-radius: 50%; border: 2px solid #111; background: transparent;
  transition: transform .1s;
}
.df-dot5.is-filled::before { background: #111; }
.df-dot5:active::before { transform: scale(1.3); }
.df-nav {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; justify-content: center; gap: 8px; row-gap: 6px;
  flex-wrap: wrap;
  padding: 8px 10px calc(10px + var(--safe-b));
}
.df-page { font-weight: 800; min-width: 64px; text-align: center; }
.df-nav .btn { min-height: 40px; padding: 7px 12px; font-size: .9rem; }
@media (min-width: 768px) {
  .df-page { min-width: 90px; }
  .df-nav .btn { min-height: 42px; padding: 8px 14px; font-size: 1rem; }
}

/* ---------- MRT / SVT ---------- */
.mrt-wrap, .svt-wrap {
  position: absolute; inset: 56px 10px calc(14px + var(--safe-b)) 10px;
  display: flex; flex-direction: column; gap: 8px;
  touch-action: pan-y;
  overflow: hidden;
}
.mrt-head {
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 800; color: var(--navy);
  flex: 0 0 auto;
}
.mrt-score { color: #16A34A; }
.mrt-imgbox, .svt-imgbox {
  flex: 1 1 auto; min-height: 0; display: grid; place-items: center;
  background: #fff; border: 1.5px solid var(--line); border-radius: 12px; padding: 8px;
}
.mrt-img, .svt-img { max-width: 100%; max-height: 58vh; object-fit: contain; }
/* ---------- MRT (v2: crop from single image) ---------- */
.mrt2-wrap {
  position: absolute; inset: 56px 10px calc(14px + var(--safe-b)) 10px;
  display: flex; flex-direction: column; gap: 6px;
  touch-action: pan-y;
  overflow: hidden;
}
.mrt-target {
  position: relative; flex: 0 1 auto;
  width: min(60vw, 28vh, 280px); aspect-ratio: 11 / 10;
  margin: 0 auto;
  background-color: #fff; background-repeat: no-repeat;
  background-size: 476.19% 200%; background-position: 3.80% 100%;
  border: 2px solid var(--navy); border-radius: 12px;
}
.mrt-tag {
  position: absolute; top: 6px; left: 8px;
  font-size: .72rem; font-weight: 800;
  background: var(--navy); color: #fff; padding: 2px 9px; border-radius: 99px;
}
.mrt-hint { text-align: center; font-weight: 700; color: var(--muted); font-size: .85rem; flex: 0 0 auto; }
.mrt-ans { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; flex: 1 1 auto; min-height: 0; align-items: center; }
.mrt-fig {
  position: relative; width: min(38vw, 24vh, 180px); aspect-ratio: 6 / 7;
  border: 2.5px solid var(--navy); border-radius: 12px;
  background-color: #fff; background-repeat: no-repeat; cursor: pointer; padding: 0;
  touch-action: manipulation;
  flex-shrink: 1;
}
.mrt-fig-letter {
  position: absolute; top: 6px; left: 8px; font-style: normal;
  font-size: .8rem; font-weight: 800;
  background: #EAF0F7; color: var(--navy); padding: 2px 9px; border-radius: 99px;
}
.mrt-fig:active { transform: scale(.98); }
.mrt-fig.picked { border-color: #DC2626; box-shadow: 0 0 0 3px rgba(220,38,38,.35); }
.mrt-fig.picked .mrt-fig-letter { background: #DC2626; color: #fff; }

/* ---------- SVT (crop จากภาพเต็ม 1440x1080 — แตะรูปตัวเลือกโดยตรง) ---------- */
.svt-wrap { justify-content: center; }
.svt-target {
  position: relative; flex: 0 1 auto;
  width: min(96vw, 56vh, 860px); aspect-ratio: 1008 / 454;
  margin: 0 auto;
  background-color: #fff; background-repeat: no-repeat;
  border: 2px solid var(--navy); border-radius: 12px;
}
.svt-hint { text-align: center; font-weight: 700; color: var(--muted); font-size: .85rem; flex: 0 0 auto; }
.svt-ans {
  display: flex; gap: clamp(4px, 1.2vw, 10px);
  justify-content: center; align-items: center; flex: 0 0 auto;
}
.svt-fig {
  width: min(18vw, 15vh, 132px); aspect-ratio: 20 / 27;
  border: 2.5px solid var(--navy); border-radius: 10px;
  background-color: #fff; background-repeat: no-repeat;
  cursor: pointer; padding: 0;
  touch-action: manipulation;
}
/* hover แดงเหมือน MouseEnter ของต้นฉบับ (คอม) */
.svt-fig:hover { border-color: #DC2626; }
.svt-fig:active { transform: scale(.97); }
.svt-fig.picked { border-color: #DC2626; box-shadow: 0 0 0 3px rgba(220,38,38,.35); }

/* Responsive: แนวนอน/จอมือถือกว้าง — MRT เรียงใหญ่ขึ้นเมื่อจอกว้าง */
@media (orientation: landscape), (min-width: 560px) {
  .mrt2-wrap { gap: 10px; }
  .mrt-target { width: min(45vw, 38vh, 320px); }
  .mrt-fig { width: min(30vw, 24vh, 170px); }
}
@media (min-width: 900px) {
  .mrt2-wrap { max-width: 1040px; margin: 0 auto; left: 0; right: 0; }
  .mrt-target { width: min(35vw, 42vh, 360px); }
  .mrt-fig { width: min(24vw, 26vh, 180px); }
}

/* ---------- Sub-result panel ---------- */
.subresult-wrap {
  position: absolute; inset: calc(48px + env(safe-area-inset-top, 0px)) 0 0 0; z-index: 60; background: var(--bg);
  display: flex; flex-direction: column; align-items: center;
  gap: 12px; padding: 14px 16px calc(20px + var(--safe-b));
  text-align: center;
  overflow-y: auto; touch-action: pan-y;
}
.mini-table { border-collapse: collapse; margin: 6px 0; }
.mini-table td { padding: 9px 18px; border-bottom: 1px solid var(--line); }
.mini-table td.num { font-weight: 800; color: var(--navy); }

/* stat cards (สรุปผล RT/Acc หลังจบแต่ละแบบทดสอบ) */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px; width: 100%; max-width: 760px;
}
.stat-card {
  background: #fff; border: 1.5px solid var(--line); border-radius: 12px;
  padding: 12px 10px; text-align: center;
}
.stat-value { font-size: clamp(1.4rem, 4.5vw, 1.9rem); font-weight: 800; color: var(--navy); }
.stat-value small { font-size: .5em; font-weight: 700; color: var(--muted); }
.stat-label { margin-top: 3px; font-size: .8rem; color: var(--muted); font-weight: 600; line-height: 1.35; }

/* chip strip — ผลรายครั้ง */
.chip-strip {
  display: flex; flex-wrap: wrap; gap: 5px;
  justify-content: center;
  max-height: 180px; overflow-y: auto;
  padding: 8px; background: #fff; border-radius: 12px;
  border: 1.5px solid var(--line);
  max-width: min(92vw, 720px);
}
.chip-mini {
  min-width: 44px; padding: 5px 6px; border-radius: 8px;
  font-size: .72rem; font-weight: 700; line-height: 1.25; text-align: center;
  border: 1.5px solid var(--line); color: var(--muted); background: #FBFDFF;
}
.chip-mini.good { background: var(--lv5-bg); border-color: #86EFAC; color: var(--lv5-fg); }
.chip-mini.bad { background: var(--lv1-bg); border-color: #FCA5A5; color: var(--lv1-fg); }

/* ---------- Report ---------- */
.report-wrap { max-width: 1180px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }

/* hero การ์ดสรุปผล (ธีมตามระดับรวม) */
.rep-hero {
  --rar: #94A3B8;
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 24px;
  border-radius: var(--radius);
  padding: 20px 22px;
  color: #fff;
  background: linear-gradient(135deg, #0F2942 0%, #1E3A5F 70%, #16395C 100%);
  border: 2px solid var(--rar);
  box-shadow: 0 10px 28px rgba(15, 41, 66, .35);
}
.rep-hero::after {
  content: ''; position: absolute; right: -70px; top: -90px;
  width: 240px; height: 240px; border-radius: 50%;
  background: var(--rar); opacity: .12; pointer-events: none;
}
.rep-hero.rar-5 { --rar: #F5B301; }
.rep-hero.rar-4 { --rar: #A78BFA; }
.rep-hero.rar-3 { --rar: #60A5FA; }
.rep-hero.rar-2 { --rar: #FB923C; }
.rep-hero.rar-1 { --rar: #94A3B8; }
.rep-hero.rar-0 { --rar: #64748B; }

.rh-left { display: flex; flex-direction: column; gap: 8px; flex: 0 0 auto; max-width: 42%; }
.rh-avatar {
  width: 74px; height: 74px; display: grid; place-items: center;
  border-radius: 22px;
  background: rgba(255, 255, 255, .1);
  border: 2.5px solid var(--rar);
}
.rh-avatar svg { width: 42px; height: 42px; }
.rh-name { font-size: clamp(1.25rem, 4vw, 1.7rem); font-weight: 800; line-height: 1.2; }
.rh-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.rh-meta-item {
  background: rgba(255, 255, 255, .12); border-radius: 999px;
  padding: 3px 11px; font-size: .82rem; font-weight: 600;
}
.rh-right { flex: 1 1 auto; display: flex; flex-direction: column; gap: 10px; min-width: 0; position: relative; z-index: 1; }
.rh-toprow { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; justify-content: space-between; }
.rh-ovr { display: flex; align-items: center; gap: 12px; }
.rh-ovr-num { font-size: clamp(44px, 9vw, 62px); font-weight: 800; line-height: 1; color: var(--rar); }
.rh-ovr-num small { font-size: .4em; color: #CBD5E1; font-weight: 700; }
.rh-ovr-cap { font-size: .88rem; font-weight: 700; line-height: 1.35; color: #E2E8F0; }
.rh-ovr-cap small { display: block; color: #94A3B8; font-weight: 600; }
.rh-badge {
  display: flex; flex-direction: column; gap: 1px;
  background: rgba(255, 255, 255, .12);
  border: 1.5px solid var(--rar);
  border-radius: 14px; padding: 8px 16px;
  font-weight: 800; font-size: 1.15rem;
}
.rh-badge small { font-size: .7rem; font-weight: 600; opacity: .75; }
.rh-badge-gray { border-color: #64748B; }
.rep-hero .score-band-labels { color: rgba(255, 255, 255, .65); }
.rh-dist { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }

/* การ์ดผลรายหมวด */
.cat-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.cat-card {
  background: #fff; border: 1.5px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 3px 14px rgba(15, 41, 66, .06);
}
.cat-head {
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(90deg, var(--navy), var(--navy-2));
  color: #fff; padding: 11px 14px; font-weight: 800;
}
.cat-icon { display: grid; place-items: center; flex: 0 0 auto; }
.cat-icon svg { width: 19px; height: 19px; }
.cat-title { flex: 1 1 auto; min-width: 0; font-size: .98rem; }
.cat-count {
  flex: 0 0 auto; background: rgba(255, 255, 255, .16);
  border-radius: 999px; padding: 2px 11px; font-size: .78rem; font-weight: 700;
}
.cat-body { padding: 2px 14px 8px; }
.ind-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 0; border-bottom: 1px dashed var(--line);
}
.ind-row:last-child { border-bottom: none; }
.ind-row.dim { opacity: .45; }
.ind-main { flex: 1 1 auto; min-width: 180px; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.ind-name { font-weight: 600; font-size: .92rem; }
.ind-val { font-weight: 800; color: var(--navy); white-space: nowrap; }
.ind-val small { color: var(--muted); font-weight: 600; font-size: .74rem; margin-left: 3px; }
.ind-side { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; }
.pips { letter-spacing: 0; white-space: nowrap; }
.pips i {
  width: 7px; height: 7px; border-radius: 50%;
  background: #E2E8F0; display: inline-block; margin-right: 3px;
}

/* การ์ดคะแนนรวม */
.cat-total { border: 2px solid #16A34A; grid-column: 1 / -1; }
.cat-total .cat-head { background: linear-gradient(90deg, #14532D, #16A34A); }
.total-flex { display: flex; align-items: center; gap: 16px; padding: 12px 0; flex-wrap: wrap; }
.total-num { font-size: clamp(42px, 9vw, 58px); font-weight: 800; line-height: 1; }
.total-info { display: flex; flex-direction: column; gap: 7px; align-items: flex-start; }
.total-info .chip { font-size: 1.02rem; }

/* ตารางฉบับเต็มแบบพับเก็บ */
.rep-details {
  background: #fff; border: 1.5px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.rep-details summary {
  cursor: pointer; user-select: none;
  padding: 13px 16px; font-weight: 700; color: var(--navy);
  background: #F8FAFC; list-style: none;
}
.rep-details summary::before { content: '▸ '; }
.rep-details[open] summary::before { content: '▾ '; }
.rep-details summary::-webkit-details-marker { display: none; }
.table-scroll { overflow-x: auto; padding: 0 0 2px; }
.rep-details .report-table { border: none; border-top: 1.5px solid var(--line); border-radius: 0; min-width: 720px; }
/* ตารางผลดิบ (4 คอลัมน์) — พอดีจอมือถือ ไม่ต้องเลื่อนแนวนอน */
.rep-details .report-table.rt-raw { min-width: 0; }

.score-band {
  position: relative; display: flex; height: 16px;
  border-radius: 999px; overflow: visible;
}
.score-band-seg:first-child { border-radius: 999px 0 0 999px; }
.score-band-seg:last-child { border-radius: 0 999px 999px 0; }
.score-marker {
  position: absolute; top: -7px; bottom: -7px; width: 5px;
  transform: translateX(-50%);
  background: var(--gold); border-radius: 3px;
  box-shadow: 0 0 0 2.5px #fff, 0 2px 6px rgba(0, 0, 0, .35);
}
.rep-hero .score-marker { box-shadow: 0 0 0 2.5px #0F2942, 0 2px 6px rgba(0, 0, 0, .45); }
.score-band-labels {
  display: flex; justify-content: space-between;
  font-size: .74rem; color: var(--muted); font-weight: 600;
}

.report-brand { display: flex; align-items: center; gap: 14px; }
.brand-badge {
  width: 58px; height: 58px; flex: 0 0 auto;
  display: grid; place-items: center;
  background: var(--navy); color: #fff; border-radius: 16px;
}
.brand-badge svg { width: 32px; height: 32px; }
.report-head h2 { margin: 0; color: var(--navy); font-size: clamp(1.2rem, 3.6vw, 1.6rem); }
.report-info {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px 18px;
  background: #fff; border: 1.5px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px;
}
.report-info div { display: flex; gap: 8px; align-items: baseline; }
.report-info span { color: var(--muted); font-size: .88rem; min-width: 84px; }
.report-table {
  width: 100%; border-collapse: collapse; background: #fff;
  border-radius: var(--radius); overflow: hidden;
  border: 1.5px solid var(--line); font-size: .95rem;
}
.report-table th {
  background: var(--navy); color: #fff; font-weight: 700;
  padding: 10px 8px; white-space: nowrap;
}
.report-table td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: center; }
.report-table td.tl { text-align: left; font-weight: 600; }
.report-table td.val { font-weight: 800; color: var(--navy); }
.report-table tr.cat-row td {
  background: var(--navy-2); color: #fff; font-weight: 800; text-align: left;
}
.report-table tr.dim td { opacity: .45; }
.report-table tr.total-row td {
  background: #F0FDF4; color: #14532D; font-weight: 800; border-top: 2.5px solid #16A34A;
}
.chip {
  display: inline-block; padding: 5px 12px; border-radius: 999px;
  font-weight: 800; font-size: .88rem; white-space: nowrap;
}

/* จุดสีระดับ (แทน emoji) */
.dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  vertical-align: 1px; margin-right: 3px;
}
.chip .dot { width: 8px; height: 8px; margin-right: 4px; }
.rh-badge .dot { width: 11px; height: 11px; vertical-align: -1px; margin-right: 6px; }
.pc-badge .dot { width: 12px; height: 12px; vertical-align: -1px; margin-right: 7px; }
.report-note { color: var(--muted); font-size: .85rem; }
.report-actions {
  display: flex; gap: 10px; flex-wrap: wrap; justify-content: center;
  padding-bottom: calc(10px + var(--safe-b));
}

/* ---------- Power Card v3 — ธีมน้ำเงิน-ขาว (หัวกรมท่า + เนื้อขาว) ---------- */
.pcard-host {
  position: fixed; left: -20000px; top: 0;
  z-index: -1; pointer-events: none;
}
.pcard {
  --rar: #60A5FA;
  width: 1080px;
  background: #FFFFFF;
  border: 1.5px solid #DBEAFE;
  border-radius: 24px;
  color: #334155;
  overflow: hidden;
}

/* แถบหัวกรมท่า */
.pc-band {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  background: linear-gradient(120deg, #0F2942 0%, #16395C 100%);
  padding: 22px 44px;
  border-bottom: 4px solid var(--rar);
}
.pc-brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.pc-logo {
  width: 56px; height: 56px; flex: 0 0 auto;
  display: grid; place-items: center; border-radius: 15px;
  background: rgba(255, 255, 255, .09);
  border: 1.5px solid rgba(255, 255, 255, .25);
}
.pc-logo svg { width: 31px; height: 31px; color: #fff; }
.pc-btxt { min-width: 0; }
.pc-btxt b { display: block; font-size: 19px; letter-spacing: .05em; color: #FFFFFF; }
.pc-btxt i { font-style: normal; font-size: 13px; color: rgba(255, 255, 255, .62); font-weight: 600; }
.pc-rarity { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: 0 0 auto; }
.pc-pill {
  border: 1.5px solid var(--rar); color: var(--rar);
  font-size: 13px; font-weight: 800; letter-spacing: .22em;
  padding: 5px 16px; border-radius: 999px;
}
.pc-stars { font-size: 16px; letter-spacing: 3px; line-height: 1; }
.pc-stars b { color: var(--rar); font-weight: 400; }
.pc-stars i { color: rgba(255, 255, 255, .25); font-style: normal; }
.pc-rarity small { font-size: 12px; color: rgba(255, 255, 255, .55); font-weight: 600; }

/* เนื้อการ์ด */
.pc-body {
  position: relative;
  padding: 26px 44px 30px;
  background: linear-gradient(180deg, #FFFFFF 0%, #F6F9FF 100%);
}
.pc-rings { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.pc-rings i, .pc-rings b { position: absolute; border-radius: 50%; }
.pc-rings i:nth-child(1) { width: 300px; height: 300px; right: -80px; top: -80px; border: 1.5px solid #DCE9FB; }
.pc-rings i:nth-child(2) { width: 190px; height: 190px; right: -25px; top: -25px; border: 1.5px solid #E4EEFC; }
.pc-rings b { width: 96px; height: 96px; right: 42px; top: 42px; background: #EFF6FF; }

/* ชื่อผู้ทดสอบ */
.pc-head { padding: 0 0 18px; position: relative; z-index: 1; }
.pc-overline {
  font-size: 12.5px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase;
  color: #2563EB; margin-bottom: 8px;
}
.pc-name { font-size: 40px; font-weight: 800; color: var(--navy); line-height: 1.15; }
.pc-metarow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.pc-tag {
  background: #FFFFFF; border: 1px solid #DBEAFE; color: #1E3A5F;
  font-size: 13.5px; font-weight: 700; padding: 4px 14px; border-radius: 999px;
}
.pc-date { font-size: 13.5px; color: #64748B; font-weight: 600; margin-left: 4px; }

/* สรุปคะแนน */
.pc-main { display: grid; grid-template-columns: 290px 1fr; gap: 14px; margin-bottom: 18px; position: relative; z-index: 1; }
.pc-panel {
  background: #FFFFFF; border: 1.5px solid #E2EAF8; border-radius: 18px;
  padding: 18px 26px;
}
.pc-scorebox {
  text-align: center; display: flex; flex-direction: column;
  justify-content: center; gap: 7px; border-top: 4px solid #93C5FD;
}
.pc-ovr-num { font-size: 60px; font-weight: 800; color: var(--navy); line-height: 1; }
.pc-ovr-num span { font-size: 19px; color: #94A3B8; font-weight: 700; }
.pc-ovr-cap { font-size: 13.5px; color: #64748B; font-weight: 700; }
.pc-stars-body { margin-top: 2px; }
.pc-stars-body i { color: #CBD5E1; }
.pc-stars-body b { color: #3B82F6; }

.pc-lvlbox { display: flex; flex-direction: column; justify-content: center; gap: 11px; }
.pc-lvlrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.pc-badge { padding: 8px 22px; border-radius: 999px; font-size: 22px; font-weight: 800; white-space: nowrap; }
.pc-tested { font-size: 14px; color: #64748B; font-weight: 700; }
.pc-track { height: 16px; border-radius: 999px; background: #E9EFF8; overflow: hidden; }
.pc-track b { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #60A5FA, #1D4ED8); }
.pc-scale { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: #94A3B8; font-weight: 700; }
.pc-sum { font-size: 15px; color: #334155; font-weight: 700; }

/* สถิติรายหมวด */
.pc-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; position: relative; z-index: 1; }
.pc-cat {
  background: #FBFDFF; border: 1.5px solid #E2EAF8; border-radius: 16px;
  padding: 13px 17px 9px; min-width: 0;
}
.pc-cat-t { display: flex; align-items: center; gap: 9px; margin-bottom: 5px; color: #1D4ED8; }
.pc-cat-t svg { width: 19px; height: 19px; flex: 0 0 auto; }
.pc-cat-name { flex: 1 1 auto; min-width: 0; font-size: 14.5px; font-weight: 800; color: var(--navy); }
.pc-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) 86px minmax(80px, 110px) 96px;
  align-items: center; gap: 10px; padding: 6px 0;
  border-bottom: 1px dashed #EDF2FA;
}
.pc-row:last-child { border-bottom: none; }
.pc-rname { font-size: 13.5px; color: #475569; font-weight: 600; overflow-wrap: anywhere; }
.pc-rval { font-weight: 800; color: var(--navy); font-size: 14.5px; white-space: nowrap; text-align: right; }
.pc-rval i { font-style: normal; font-size: 11px; color: #94A3B8; margin-left: 2px; font-weight: 600; }
.pc-bar { height: 10px; border-radius: 999px; background: #EDF2FA; overflow: hidden; display: block; }
.pc-bar b { display: block; height: 100%; border-radius: 999px; }
.pc-chip { font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 999px; text-align: center; white-space: nowrap; }
.pc-dim { opacity: .45; }

/* footer */
.pc-foot {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: 20px; padding-top: 14px; border-top: 1.5px solid #E2EAF8;
  color: #94A3B8; font-size: 12.5px; font-weight: 600;
  position: relative; z-index: 1;
}

/* ---------- Desktop ≥768px ---------- */
@media (min-width: 768px) {
  #screen { padding: 28px 20px 40px; }
  .form-grid { grid-template-columns: repeat(3, 1fr); }
  .check-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .check-item { grid-template-columns: auto auto 1fr auto; align-items: center; gap: 12px; padding: 12px 14px; }
  .ck-domain { grid-column: auto; text-align: right; font-size: .85rem; }
  .resp-bar { gap: 40px; }
  .resp-btn { flex: 0 1 280px; }
  .report-actions { justify-content: flex-start; }
  .score-band-labels { font-size: .8rem; }
}
@media (min-width: 900px) {
  .cat-grid { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 1024px) {
  .check-list { grid-template-columns: 1fr 1fr; }
}

/* ---------- Mobile ≤640px ---------- */
@media (max-width: 640px) {
  .rep-hero { flex-direction: column; text-align: center; align-items: center; gap: 14px; }
  .rh-left { max-width: none; align-items: center; }
  .rh-meta, .rh-dist { justify-content: center; }
  .rh-toprow { flex-direction: column; gap: 10px; width: 100%; }
  .rh-badge { align-items: center; }
  .pc-track { max-width: 100%; }
  .ind-main { min-width: 130px; }
  /* ตารางเต็มกระชับลง — เหลือ scroll แนวนอนน้อยที่สุด */
  .report-table { font-size: .84rem; }
  .report-table th { padding: 8px 6px; }
  .report-table td { padding: 7px 6px; }
  .rep-details .report-table { min-width: 600px; }
  .chip { font-size: .8rem; padding: 4px 10px; }
  .cat-body { padding: 2px 12px 6px; }
  .mini-table td { padding: 7px 12px; }
  /* ปุ่มบันทึก/พิมพ์เต็มความกว้างพอดีจอ */
  .report-actions .btn { flex: 1 1 auto; }

  /* ---------- หน้ารายงาน: กระชับ ไม่ตกขอบบนมือถือ ---------- */
  .report-wrap { gap: 10px; }
  .rep-hero { padding: 16px 14px; gap: 12px; }
  .rh-avatar { width: 58px; height: 58px; border-radius: 16px; }
  .rh-avatar svg { width: 30px; height: 30px; }
  .rh-name { font-size: 1.12rem; }
  .rh-meta-item { font-size: .74rem; padding: 2px 9px; }
  .rh-ovr-num { font-size: 38px; }
  .rh-ovr-cap { font-size: .8rem; }
  .rh-badge { padding: 7px 13px; font-size: 1rem; border-radius: 12px; }
  .score-band-labels { flex-wrap: wrap; justify-content: center; gap: 1px 10px; font-size: .66rem; }
  .report-head h2 { font-size: 1.08rem; }
  .brand-badge { width: 46px; height: 46px; border-radius: 12px; }
  .brand-badge svg { width: 26px; height: 26px; }
  .report-info { padding: 10px 12px; gap: 5px 10px; }
  .report-info div { flex-wrap: wrap; }
  .report-info span { min-width: 70px; font-size: .78rem; }
  .report-info div { font-size: .86rem; }
  .ind-row { gap: 6px; padding: 8px 0; }
  .ind-main { min-width: 0; }
  .ind-name { font-size: .84rem; }
  .ind-val { font-size: .88rem; }
  .ind-val small { font-size: .68rem; }
  .ind-side { gap: 6px; }
  .cat-head { padding: 9px 11px; }
  .cat-title { font-size: .88rem; }
  .cat-count { font-size: .72rem; padding: 2px 9px; }
  .cat-icon svg { width: 16px; height: 16px; }
  .total-flex { gap: 12px; }
  .total-num { font-size: 38px; }
  .pips i { width: 6px; height: 6px; margin-right: 2px; }
  .report-note { font-size: .78rem; }
}

/* ---------- Landscape phone ---------- */
@media (max-width: 920px) and (orientation: landscape) {
  .advice-img { max-height: 44vh; }
  .mrt-img, .svt-img { max-height: 46vh; }
}

/* ---------- About modal (port CreditsControl.cs) ---------- */
.about-backdrop {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: linear-gradient(150deg, #0D1B2E, #0F2942);
  opacity: 0; transition: opacity .24s ease;
}
.about-backdrop.open { opacity: 1; }
.ab-blob {
  position: absolute; border-radius: 50%; pointer-events: none;
  filter: blur(90px);
}
.ab-blob-1 { width: 440px; height: 440px; background: #0EA5E9; opacity: .06; left: -140px; top: -120px; }
.ab-blob-2 { width: 360px; height: 360px; background: #6366F1; opacity: .05; right: -80px; bottom: -80px; }
.ab-blob-3 { width: 280px; height: 280px; background: #F59E0B; opacity: .05; right: 60px; top: 40px; }

.about-card {
  position: relative; width: min(480px, 100%);
  max-height: calc(100dvh - 32px); overflow-y: auto;
  border-radius: 28px; text-align: center;
  background: rgba(14, 165, 233, .11);
  border: 1px solid rgba(255, 255, 255, .22);
  padding: 28px 38px;
  box-shadow: 0 0 60px rgba(14, 165, 233, .39);
  transform: translateY(24px); opacity: 0;
  transition: transform .55s cubic-bezier(.22,.9,.35,1) .08s,
              opacity .55s ease-out .08s;
}
.about-backdrop.open .about-card { transform: translateY(0); opacity: 1; }

.about-close {
  position: absolute; top: 14px; right: 14px;
  width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.08); color: #CBD5E1;
  font-size: 15px; cursor: pointer;
}
.about-close:hover { background: rgba(255,255,255,.16); color: #fff; }

.about-avatar {
  position: relative; display: block;
  width: 112px; height: 112px; margin: 0 auto 12px;
  animation: ab-bob 1.1s ease-in-out infinite alternate;
}
.about-ring {
  position: absolute; inset: 10px; border-radius: 50%;
  background: linear-gradient(45deg, #0EA5E9, #F59E0B);
  box-shadow: 0 0 18px rgba(14, 165, 233, .86);
}
.about-pic {
  position: absolute; inset: 3px;
  width: calc(100% - 6px); height: calc(100% - 6px);
  border-radius: 50%; object-fit: cover;
  background: linear-gradient(135deg, #0F2942, #162B4A);
  image-rendering: pixelated;
  box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.31);
}
.about-pa {
  position: absolute; inset: 3px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #0F2942, #162B4A);
  color: #fff; font-size: 30px; font-weight: 800;
}
.ab-spark {
  position: absolute; width: 7px; height: 7px;
  transform: rotate(45deg);
  animation: ab-float 1.3s ease-in-out infinite alternate,
             ab-twinkle .9s ease-in-out infinite alternate;
}
@keyframes ab-bob { from { transform: translateY(0); } to { transform: translateY(-6px); } }
@keyframes ab-float { from { translate: 0 0; } to { translate: 0 -10px; } }
@keyframes ab-twinkle { from { opacity: .2; } to { opacity: 1; } }

.about-label {
  display: block; margin-bottom: 6px;
  color: #4B6A8A; font-size: 10.5px; font-weight: 600; letter-spacing: .04em;
}
.about-bar {
  display: block; width: 32px; height: 3px; border-radius: 2px;
  margin: 0 auto 12px;
  background: linear-gradient(90deg, #F59E0B, #FBBF24);
}
.about-name-th {
  margin: 0 0 2px; color: #fff;
  font-size: 21px; font-weight: 700;
}
.about-name-en { margin: 0 0 8px; color: #7EA9C8; font-size: 12.5px; }
.about-role {
  display: inline-block; padding: 5px 15px; border-radius: 20px;
  background: rgba(14,165,233,.18); border: 1px solid rgba(14,165,233,.31);
  color: #38BDF8; font-size: 12px; font-weight: 600;
  margin-bottom: 18px;
}
.about-divider {
  border: none; height: 1px; margin: 0 0 14px;
  background: rgba(255,255,255,.14);
}
.about-contact {
  display: flex; align-items: center; gap: 10px;
  text-align: left; margin-bottom: 9px;
}
.ab-ico {
  flex: 0 0 auto; width: 28px; height: 28px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-style: normal;
}
.ab-ico.mail { background: rgba(14,165,233,.16); color: #0EA5E9; }
.ab-ico.git { background: rgba(167,139,250,.16); color: #A78BFA; }
.ab-ct { display: flex; flex-direction: column; min-width: 0; }
.ab-ct small { color: #4B6A8A; font-size: 10px; font-weight: 600; }
.ab-ct a {
  color: #CBD5E1; font-size: 12.5px; text-decoration: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ab-ct a:hover { color: #38BDF8; }
.about-disclaimer {
  margin-top: 6px; padding: 8px 14px; border-radius: 12px;
  background: rgba(245,158,11,.12); border: 1px solid rgba(245,158,11,.31);
  color: #FCD34D; font-size: 10px; font-style: italic; line-height: 1.65;
}

@media (max-width: 480px) {
  .about-card { padding: 24px 20px; border-radius: 22px; }
}

/* ---------- Print / PDF ---------- */
@media print {
  body { background: #fff; }
  #topbar, #stage, .no-print, .pcard-host { display: none !important; }
  #screen { padding: 0; max-width: none; }
  .report-table { font-size: 10.5pt; border-collapse: collapse; }
  .report-table th { background: #0F2942 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .report-table tr.cat-row td { background: #16395C !important; color: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .report-table tr.total-row td { background: #F0FDF4 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .chip, .cat-head, .rep-hero { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .rep-details summary { display: none; }
  .rep-details { border: none; }
  .report-wrap { gap: 8px; }
}
