:root {
  --green: #085041;
  --navy: #04342C;
  --mint: #5DCAA5;
  --yellow: #FAC775;
  --bg: #F2F7F4;
  --card: #FFFFFF;
  --text: #1A2027;
  --muted: #5B6B74;
  --border: #D9E0DD;
  --radius: 14px;
  --lv-verylow: #2E9E5B;
  --lv-low: #3DB06A;
  --lv-medium: #E0B400;
  --lv-high: #E8812B;
  --lv-veryhigh: #D23B3B;
  --maxw: 430px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Kanit", "Sarabun", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

.app-shell {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding-bottom: 24px;
}

.topbar {
  background: var(--navy);
  color: #fff;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .appname { font-weight: 600; font-size: 15px; }

.icon { display: inline-block; vertical-align: middle; flex-shrink: 0; }
.icon-box {
  width: 40px; height: 40px; border-radius: 10px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-box-sm { width: 24px; height: 24px; border-radius: 7px; }
.icon-box-lg { width: 56px; height: 56px; border-radius: 14px; }
h1 .icon-box, h2 .icon-box { margin-right: 8px; }
.heading-row { display: flex; align-items: center; gap: 8px; }
.heading-row h1, .heading-row h2 { margin-bottom: 0; }

.avatar-circle {
  border-radius: 50%;
  object-fit: cover;
  flex: none;
  border: 2px solid rgba(255, 255, 255, 0.5);
  background: #ccc;
}
.avatar-72 { width: 72px; height: 72px; }
.avatar-160 { width: 160px; height: 160px; border-width: 3px; border-color: var(--yellow); }
.avatar-40 { width: 40px; height: 40px; border-color: var(--border); }
.avatar-220 { width: 220px; height: 220px; border-width: 4px; border-color: var(--yellow); }
.instructor-row { display: flex; align-items: center; gap: 12px; }
.instructor-card { text-align: center; }
.instructor-card .avatar-160 { margin: 0 auto 10px; display: block; }
.topbar .byline { font-size: 11px; opacity: 0.8; }

.progress-wrap {
  background: #E3E8E6;
  height: 6px;
  width: 100%;
}
.progress-bar {
  background: var(--yellow);
  height: 100%;
  transition: width 0.3s ease;
}

.progress-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.progress-dots .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--border);
  transition: all 0.2s ease;
}
.progress-dots .dot.done { background: var(--mint); }
.progress-dots .dot.current { background: var(--green); width: 18px; border-radius: 4px; }

main { padding: 16px; padding-bottom: 148px; flex: 1; }
.app-shell.no-fixed-disclaimer main { padding-bottom: 96px; }

h1, h2, h3 { line-height: 1.35; margin: 0 0 8px; }
h1 { font-size: 20px; color: var(--navy); }
h2 { font-size: 17px; color: var(--navy); }
h3 { font-size: 15px; color: var(--navy); }
p { line-height: 1.6; margin: 0 0 10px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

.btn {
  min-height: 48px;
  border-radius: 12px;
  border: none;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  padding: 10px 16px;
  cursor: pointer;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  touch-action: manipulation;
}
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:active { background: #094a2f; }
.btn-accent { background: var(--yellow); color: var(--navy); }
.btn-outline { background: #fff; color: var(--navy); border: 2px solid var(--navy); }
.btn-ghost { background: transparent; color: var(--navy); }
.btn-danger { background: #D23B3B; color: #fff; }
.btn-sm { min-height: 40px; font-size: 14px; padding: 6px 12px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }

.stack { display: flex; flex-direction: column; gap: 10px; }

input[type="text"], input[type="number"], textarea, select {
  width: 100%;
  font-family: inherit;
  font-size: 16px;
  padding: 11px 12px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  min-height: 48px;
}
textarea { min-height: 120px; resize: vertical; }
label { font-size: 13px; color: var(--muted); display: block; margin-bottom: 4px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  color: #fff;
}
.badge-verylow, .badge-low { background: var(--lv-verylow); }
.badge-medium { background: var(--lv-medium); color: #3A2E00; }
.badge-high { background: var(--lv-high); }
.badge-veryhigh { background: var(--lv-veryhigh); }
.badge-unscored { background: var(--muted); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: #fff;
  cursor: pointer;
  min-height: 40px;
}
.chip.selected { border-color: var(--green); background: #E8F4EE; font-weight: 600; color: var(--green); }
.chip svg { flex: none; }

.welcome-banner {
  background: linear-gradient(135deg, var(--navy), var(--green));
  border-radius: var(--radius);
  padding: 18px 16px;
  margin-bottom: 12px;
  color: #fff;
}
.welcome-banner h1 { margin-bottom: 4px; }
.welcome-illust {
  display: flex;
  gap: 10px;
  color: var(--mint);
  margin-bottom: 10px;
}

.level-card {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  background: #fff;
  transition: border-color 0.15s, background 0.15s;
}
.level-card.selected {
  border-color: var(--lc-color, var(--green));
  background: color-mix(in srgb, var(--lc-color, var(--green)) 8%, white);
}
.level-card-compact { padding: 8px 10px; gap: 10px; margin-bottom: 8px; }
.level-card-compact:last-of-type { margin-bottom: 0; }

.prep-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: 14px;
  line-height: 1.5;
}

.hazard-card { border-left: 5px solid var(--border); }
.hazard-card.lv-verylow, .hazard-card.lv-low { border-left-color: var(--lv-verylow); }
.hazard-card.lv-medium { border-left-color: var(--lv-medium); }
.hazard-card.lv-high { border-left-color: var(--lv-high); }
.hazard-card.lv-veryhigh { border-left-color: var(--lv-veryhigh); }

.warn-box {
  background: #FFF7E0;
  border: 1px solid var(--yellow);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  color: #5B4A00;
  margin-bottom: 10px;
}
.warn-icon { display: inline-flex; vertical-align: middle; color: #B8860B; margin-right: 2px; }

/* แถบคำเตือนบรรทัดเดียว ปักอยู่ล่างสุดของจอ (ไม่ใช้ในหน้าสรุปและส่ง) */
.disclaimer-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-width: var(--maxw);
  margin: 0 auto;
  background: #FFF3CF;
  border-top: 2px solid var(--yellow);
  padding: 8px 14px;
  font-size: 12px;
  color: #5B4A00;
  line-height: 1.3;
  z-index: 16;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  white-space: nowrap;
}
.disclaimer-bar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.disclaimer-bar button {
  flex: none;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.app-shell.no-fixed-disclaimer .disclaimer-bar { display: none; }

/* กล่องคำเตือนเต็มแบบฝังในเนื้อหา (ใช้ในหน้าสรุปและส่ง) */
.disclaimer-inline {
  background: #FFF3CF;
  border: 1px solid var(--yellow);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  color: #5B4A00;
  line-height: 1.6;
  margin-bottom: 12px;
}

/* ปุ่มหลักของแต่ละหน้า ปักลอยเหนือแถบคำเตือน */
.sticky-cta {
  position: fixed;
  left: 0; right: 0; bottom: 40px;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 8px 16px;
  background: linear-gradient(to top, var(--bg) 70%, rgba(244, 246, 245, 0));
  z-index: 15;
}
.sticky-cta:empty { display: none; }
.app-shell.no-fixed-disclaimer .sticky-cta { bottom: 0; padding-bottom: 14px; }

.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(10, 20, 20, 0.5);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 50;
}
.sheet {
  background: #fff;
  width: 100%;
  max-width: var(--maxw);
  border-radius: 18px 18px 0 0;
  padding: 16px;
  max-height: 86vh;
  overflow-y: auto;
}
.sheet-handle {
  width: 40px; height: 5px; background: var(--border); border-radius: 3px;
  margin: 0 auto 12px;
}
.prompt-box {
  background: #F4F6F5;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow-y: auto;
  margin-bottom: 10px;
}

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10, 20, 20, 0.55);
  display: flex; align-items: center; justify-content: center; z-index: 60; padding: 20px;
}
.modal-box { background: #fff; border-radius: var(--radius); padding: 18px; max-width: 360px; width: 100%; }

/* Instructor-only reset confirmation dialog */
.reset-backdrop { z-index: 110; padding: 16px; background: rgba(0, 26, 23, .73); }
.reset-backdrop .reset-dialog {
  box-sizing: border-box; width: min(600px, 100%); max-width: 600px;
  max-height: min(90dvh, 900px); overflow-y: auto;
  padding: clamp(20px, 3vw, 32px); border: 1px solid #dce8e5; border-radius: 24px;
  box-shadow: 0 24px 90px rgba(0, 0, 0, .34);
  color: #123a33; text-align: left;
}
.reset-dialog-header { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.reset-dialog-icon {
  width: 60px; height: 60px; flex: 0 0 60px; display: grid; place-items: center;
  border-radius: 18px; color: #b52f2f; background: #fff0ed; font-size: 32px; font-weight: 800;
}
.reset-dialog h3 { margin: 0 0 4px; font-size: clamp(23px, 3vw, 29px); font-weight: 800; line-height: 1.25; color: #073e35; }
.reset-dialog .reset-dialog-subtitle { margin: 0; color: #60746e; font-size: 16px; line-height: 1.4; }
.reset-dialog-warning { background: #fff5f3; border: 1px solid #efc8c2; border-radius: 16px; padding: 18px 20px; }
.reset-dialog-warning strong { display: block; font-size: 18px; color: #ad2b29; margin-bottom: 7px; }
.reset-dialog-warning p { margin: 0; font-size: 16px; color: #684744; line-height: 1.65; }
.reset-dialog .reset-dialog-label { display: block; margin: 22px 0 10px; color: #17463d; font-size: 17px; font-weight: 600; }
.reset-dialog-label strong { color: #b62f2f; font-weight: 800; }
.reset-dialog #reset-confirm-word {
  display: block; width: 100%; box-sizing: border-box; min-height: 56px;
  border: 2px solid #c8d9d3; border-radius: 14px; padding: 11px 16px;
  background: #fff; color: #093e34; font-size: 19px; font-weight: 600;
}
.reset-dialog #reset-confirm-word:focus { outline: none; border-color: #12846b; box-shadow: 0 0 0 4px rgba(19, 145, 111, .15); }
.reset-dialog-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.55fr); gap: 12px; margin-top: 23px; }
.reset-dialog-actions .btn {
  min-height: 58px; padding: 12px 15px; border-radius: 13px;
  font-size: 16px; font-weight: 700; line-height: 1.4;
  white-space: normal; text-align: center;
}
.reset-dialog-actions .reset-export { background: #eff8f5; color: #075f4f; border: 1.5px solid #aad3c7; }
.reset-dialog-actions .reset-submit { grid-column: 1 / -1; font-size: 19px; background: #ce3d3d; color: #fff; }
.reset-dialog-actions .reset-submit:not(:disabled):hover { background: #ab2929; }
.reset-dialog-actions .reset-submit:disabled { opacity: .48; cursor: not-allowed; }
@media (max-width: 480px) {
  .reset-backdrop { padding: 10px; }
  .reset-backdrop .reset-dialog { padding: 20px 18px; border-radius: 18px; }
  .reset-dialog-header { gap: 12px; }
  .reset-dialog-icon { width: 48px; height: 48px; flex-basis: 48px; border-radius: 13px; }
  .reset-dialog h3 { font-size: 23px; }
  .reset-dialog-warning { padding: 14px; }
  .reset-dialog-actions { grid-template-columns: 1fr; gap: 9px; }
  .reset-dialog-actions .reset-submit { grid-column: 1; }
  .reset-dialog-actions .btn { min-height: 52px; font-size: 17px; }
}


.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  background: #1A2027; color: #fff; padding: 10px 16px; border-radius: 999px;
  font-size: 13px; z-index: 70; max-width: 90%; text-align: center;
}

table.report-table { width: 100%; border-collapse: collapse; font-size: 11px; margin-bottom: 14px; }
table.report-table th, table.report-table td {
  border: 1px solid #999; padding: 5px 6px; text-align: left; vertical-align: top;
}
table.report-table th { background: #EFEFEF; }

.matrix-table { width: 100%; border-collapse: collapse; font-size: 13px; text-align: center; }
.matrix-table th, .matrix-table td { border: 1px solid var(--border); padding: 8px 4px; }
.matrix-table th { background: #F0F3F2; font-weight: 600; font-size: 12px; }

.category-pill { display: flex; align-items: center; gap: 6px; font-size: 13px; padding: 6px 0; }

.center { text-align: center; }
.muted { color: var(--muted); font-size: 13px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mb-0 { margin-bottom: 0; }
.hidden { display: none !important; }

.countdown-num {
  font-size: 96px; font-weight: 700; color: var(--yellow); text-align: center;
  text-shadow: 0 2px 0 var(--navy);
}

.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; }
.switch { position: relative; width: 46px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; background: var(--border); border-radius: 999px; transition: 0.2s; cursor: pointer;
}
.switch .slider::before {
  content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: 0.2s;
}
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* ------- โทนจอผู้สอน (present.html) กว้างขึ้น ------- */
.present-shell { max-width: 1440px; margin: 0 auto; padding: 20px 20px 96px; min-height: 100vh; box-sizing: border-box; }
.present-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .present-grid { grid-template-columns: 1fr; } }

.present-center { text-align: center; padding-top: 10vh; }
.present-quiz { max-width: 900px; margin: 0 auto; }

.present-lobby { display: flex; flex-direction: column; min-height: calc(100vh - 40px); }
.present-lobby-top { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.present-lobby-main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: center;
}
@media (max-width: 760px) { .present-lobby-main { grid-template-columns: 1fr; } }
.present-qr-box { text-align: center; }
.present-qr-box svg { width: min(100%, 58vh); height: auto; min-height: 40vh; border-radius: 12px; }
.present-count-box { text-align: center; }

.bubble-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 20px;
  min-height: 44px;
}
@keyframes bubblePop {
  0% { opacity: 0; transform: translateY(14px) scale(0.8); }
  60% { opacity: 1; transform: translateY(-2px) scale(1.04); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
.name-bubble {
  background: var(--mint);
  color: var(--navy);
  font-weight: 600;
  font-size: 14px;
  padding: 7px 16px;
  border-radius: 999px;
  animation: bubblePop 0.4s ease-out;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}
.control-grid .btn { font-size: 13px; }
.big-number { font-size: 56px; font-weight: 700; color: var(--navy); }
.big-number-row { display: flex; align-items: center; gap: 12px; }

@keyframes cardPop {
  0% { opacity: 0; transform: translateY(-10px) scale(0.97); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
.feed-card-new { animation: cardPop 0.4s ease-out; }

@keyframes pulseOnce {
  0% { transform: scale(1); }
  30% { transform: scale(1.12); }
  100% { transform: scale(1); }
}
.pulse-once { animation: pulseOnce 0.35s ease-out; }
.icon-star-filled { color: var(--yellow); }
.icon-star-filled path { fill: var(--yellow); }
.tab-bar { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tab-btn {
  padding: 8px 14px; border-radius: 999px; border: 2px solid var(--navy); background: #fff; color: var(--navy);
  font-weight: 600; cursor: pointer; font-size: 13px;
}
.tab-btn.active { background: var(--navy); color: #fff; }

/* ========== รอบ 4: ธีมเกมสีสันแบบ Kahoot (หน้าแรก/หน้ารอ/ควิซจอฉาย/ควิซมือถือ) ========== */
:root {
  --g-bg: #04342C;
  --g-card: #085041;
  --g-mint: #9FE1CB;
  --g-yellow: #FAC775;
  --ans-a: #E24B4A;
  --ans-b: #185FA5;
  --ans-c: #BA7517;
  --ans-d: #3B6D11;
}

body.theme-game { background: var(--g-bg); }
body.theme-game .app-shell,
body.theme-game .present-shell { background: transparent; }
body.theme-game .topbar { background: var(--g-bg); }
body.theme-game .card { background: var(--g-card); border-color: rgba(255, 255, 255, 0.14); }
body.theme-game h1, body.theme-game h2, body.theme-game h3 { color: #fff; }
body.theme-game p { color: var(--g-mint); }
body.theme-game .muted { color: rgba(159, 225, 203, 0.72); }
body.theme-game .btn-outline { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.5); }
body.theme-game .prep-row { color: var(--g-mint); }
body.theme-game .level-card { background: rgba(255, 255, 255, 0.06); border-color: rgba(255, 255, 255, 0.2); }
body.theme-game .level-card strong { color: #fff; }
body.theme-game .chip { background: rgba(255, 255, 255, 0.06); border-color: rgba(255, 255, 255, 0.25); color: #fff; }
body.theme-game .big-number { color: #fff; }
.icon-box-game { background: rgba(255, 255, 255, 0.12); color: var(--g-yellow); }

.game-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(250, 199, 117, 0.15); color: var(--g-yellow);
  border: 1px solid rgba(250, 199, 117, 0.4);
  font-size: 12px; font-weight: 600; padding: 5px 12px; border-radius: 999px;
  margin-bottom: 12px;
}

.hero-illust { position: relative; width: 120px; height: 120px; margin: 4px auto 14px; }
.hero-illust-circle {
  width: 104px; height: 104px; border-radius: 50%;
  background: var(--g-yellow); color: var(--g-bg);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}
.hero-illust-phone {
  position: absolute; right: -4px; bottom: 2px;
  width: 46px; height: 46px; border-radius: 14px;
  background: var(--g-card); border: 3px solid var(--g-bg);
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.hero-illust-spark { position: absolute; top: -2px; right: 8px; color: var(--g-mint); }
.hero-illust-star { position: absolute; bottom: 16px; left: -10px; color: var(--g-mint); }

.game-title-block { text-align: center; margin-bottom: 4px; }
.game-title-block h1 { font-size: 26px; margin-bottom: 4px; }

.instructor-mini { display: flex; align-items: center; gap: 12px; }
.time-pill {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(255, 255, 255, 0.1); color: var(--g-mint);
  font-size: 12px; padding: 3px 10px; border-radius: 999px; margin-top: 4px;
}

.live-count-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; color: #fff; font-weight: 600; }
.recent-bubble-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 30px; }
.recent-bubble-row .name-bubble { font-size: 12px; padding: 5px 12px; }
.name-bubble-more {
  background: rgba(255, 255, 255, 0.15); color: #fff; font-weight: 600; font-size: 12px;
  padding: 5px 12px; border-radius: 999px;
}

.game-footer { text-align: center; font-size: 11px; color: rgba(159, 225, 203, 0.6); margin: 16px 0 4px; }

/* ---- ปุ่มคำตอบควิซบนมือถือ: 2x2 สี+รูปทรงเต็มจอ ---- */
.quiz-answer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quiz-answer-btn {
  aspect-ratio: 1 / 0.85;
  border-radius: 16px; border: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  color: #fff; font-weight: 700; font-size: 15px; font-family: inherit; text-align: center;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
  transition: transform 0.1s;
}
.quiz-answer-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2); }
.quiz-answer-btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.quiz-answer-btn.is-chosen { outline: 4px solid #fff; outline-offset: -4px; }

.quiz-topbar-mobile {
  display: flex; justify-content: space-between; align-items: center;
  color: #fff; font-size: 13px; margin-bottom: 10px;
}
.quiz-topbar-mobile strong { color: var(--g-yellow); }

.quiz-fullscreen-result {
  position: fixed; inset: 0; z-index: 90;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px; color: #fff;
  animation: fsResultIn 0.3s ease-out;
}
.quiz-fullscreen-result.correct { background: linear-gradient(160deg, #1F8A54, #0C3B26); }
.quiz-fullscreen-result.wrong { background: linear-gradient(160deg, #D14B4B, #6E1F1F); }
.quiz-fullscreen-result h1 { color: #fff; font-size: 30px; margin-bottom: 10px; }
.quiz-fullscreen-result p { color: rgba(255, 255, 255, 0.92); font-size: 16px; }
@keyframes fsResultIn {
  0% { opacity: 0; transform: scale(0.94); }
  100% { opacity: 1; transform: scale(1); }
}

/* ---- จอฉาย: ควิซสีสัน ---- */
.quiz-present-header { display: flex; justify-content: center; gap: 16px; margin-bottom: 18px; }
.quiz-present-pill {
  background: rgba(255, 255, 255, 0.1); color: var(--g-mint);
  font-size: 17px; font-weight: 600; padding: 7px 18px; border-radius: 999px;
}
.quiz-question-box {
  background: #fff; color: var(--g-bg);
  border-radius: 18px; padding: 24px 28px;
  text-align: center; font-size: clamp(24px, 2.6vw, 48px); font-weight: 700; line-height: 1.4;
  margin: 0 auto 22px; max-width: 1200px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
.quiz-question-mobile { overflow-wrap: anywhere; }
.quiz-question-mobile h2 { font-size: clamp(18px, 5vw, 28px); line-height: 1.45; }

.quiz-countdown {
  width: 76px; height: 76px; border-radius: 50%;
  border: 6px solid rgba(255, 255, 255, 0.2);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
  font-size: 30px; font-weight: 700; color: var(--g-yellow);
}
.quiz-countdown.urgent { animation: countdownShake 0.5s infinite; color: #fff; border-color: #E24B4A; }
@keyframes countdownShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

.quiz-present-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; max-width: 1200px; margin: 0 auto; }
@media (max-width: 760px) { .quiz-present-grid { grid-template-columns: 1fr; } }
.quiz-present-answer {
  border-radius: 16px; padding: 20px; min-height: 90px;
  position: relative; overflow: hidden;
  color: #fff; font-size: clamp(18px, 1.6vw, 30px); font-weight: 700;
}
.quiz-present-answer.is-correct { outline: 5px solid var(--g-yellow); outline-offset: -5px; }
.quiz-present-answer .ans-bar {
  position: absolute; left: 0; bottom: 0; top: 0; background: rgba(255, 255, 255, 0.22);
  transition: width 0.5s ease; z-index: 0;
}
.quiz-present-answer .ans-content { position: relative; z-index: 1; display: flex; align-items: center; gap: 14px; width: 100%; }
.quiz-present-answer .ans-count { margin-left: auto; font-size: 26px; }

.present-leaderboard { max-width: 700px; margin: 20px auto 0; }
.present-leaderboard-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; border-radius: 10px; background: rgba(255, 255, 255, 0.07);
  margin-bottom: 6px; color: #fff;
}
.present-leaderboard-row .lb-rank { font-weight: 700; color: var(--g-yellow); min-width: 2.6em; flex: none; }
.present-leaderboard-row .lb-name { flex: 1; text-align: left; margin-left: 8px; }

.podium-row { display: flex; align-items: flex-end; justify-content: center; gap: 16px; margin-top: 24px; }
.podium-col { text-align: center; color: #fff; }
.podium-col .podium-bar {
  width: 112px; border-radius: 10px 10px 0 0;
  display: flex; align-items: flex-start; justify-content: center; padding-top: 12px;
}
.podium-1 .podium-bar { height: 150px; background: var(--g-yellow); color: var(--g-bg); }
.podium-2 .podium-bar { height: 110px; background: #CBD8D4; color: var(--g-bg); }
.podium-3 .podium-bar { height: 82px; background: #D2A06F; color: var(--g-bg); }
.podium-col .podium-name { font-weight: 700; margin-top: 8px; }
.podium-col .podium-score { color: var(--g-mint); font-size: 13px; }

/* ========== รอบ 5: เกม 3 ด่าน (หน้าผู้เรียน) ========== */
/* แผ่นล่าง/กล่องยืนยันมีพื้นขาวเสมอ จึงต้องใช้ตัวหนังสือสีเข้มแม้เปิดบนหน้าธีมเกม */
body.theme-game .sheet h1, body.theme-game .sheet h2, body.theme-game .sheet h3,
body.theme-game .modal-box h1, body.theme-game .modal-box h2, body.theme-game .modal-box h3 { color: var(--navy); }
body.theme-game .sheet p, body.theme-game .modal-box p { color: var(--text); }
body.theme-game .sheet .muted, body.theme-game .modal-box .muted,
body.theme-game .sheet label, body.theme-game .modal-box label { color: var(--muted); }
body.theme-game .sheet .btn-outline, body.theme-game .modal-box .btn-outline { background: #fff; color: var(--navy); border-color: var(--navy); }
body.theme-game .sheet .btn-ghost, body.theme-game .modal-box .btn-ghost { color: var(--navy); }
body.theme-game label { color: var(--g-mint); }
body.theme-game .btn-ghost { color: #fff; }
body.theme-game .sticky-cta { background: linear-gradient(to top, var(--g-bg) 70%, rgba(4, 52, 44, 0)); }
body.theme-game .progress-dots { background: transparent; border-bottom-color: rgba(255, 255, 255, 0.12); }
body.theme-game .progress-dots .dot { background: rgba(255, 255, 255, 0.25); }
body.theme-game .progress-dots .dot.done { background: var(--mint); }
body.theme-game .progress-dots .dot.current { background: var(--g-yellow); }
body.theme-game .card svg.icon { color: inherit; }

.score-pill {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255, 255, 255, 0.12); border-radius: 999px; padding: 5px 12px;
  font-size: 13px; color: #fff; max-width: 55%;
}
.score-pill-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-pill-score { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; color: var(--g-yellow); flex: none; }

.fine-print { font-size: 12px; margin: 10px 0 0; }
.ai-open-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* หัวหน้าเข้าห้องแบบเตี้ย: ให้ช่องชื่อเล่นและตัวเลือก AI ขึ้นมาอยู่ในจอแรกมากที่สุด */
.hero-row { display: flex; align-items: center; gap: 16px; margin: 2px 0 12px; }
.hero-row .hero-illust { width: 84px; height: 84px; margin: 0 0 0 8px; flex: none; }
.hero-row .hero-illust-circle { width: 76px; height: 76px; }
.hero-row .hero-illust-circle svg { width: 42px; height: 42px; }
.hero-row .hero-illust-phone { width: 34px; height: 34px; border-radius: 10px; right: -4px; bottom: -2px; }
.hero-row .hero-illust-phone svg { width: 18px; height: 18px; }
.hero-row .hero-illust-spark { top: -8px; right: 0; }
.hero-row .hero-illust-star { bottom: 6px; left: -12px; }
.hero-row h1 { font-size: 22px; margin: 0; }
.hero-row p { margin: 0; }
.hero-row .game-badge { margin-bottom: 6px; }
.text-warn { color: #FFB4B3; }
.back-link { width: auto; padding-left: 0; margin-bottom: 4px; }
.big-score { font-size: 28px; font-weight: 700; color: var(--g-yellow) !important; margin: 6px 0; }
body:not(.theme-game) .big-score { color: var(--green) !important; }
.final-score { font-size: 64px; font-weight: 700; line-height: 1.1; color: var(--g-yellow) !important; margin: 0; }

.ai-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ai-chip {
  min-height: 52px; border-radius: 12px; border: 2px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.06); color: #fff;
  font-family: inherit; font-size: 16px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px; padding: 8px;
}
.ai-chip-wide { grid-column: 1 / -1; }
.ai-chip.selected { background: var(--g-yellow); border-color: var(--g-yellow); color: var(--g-bg); }
.suggest-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
body.theme-game .chip.selected { background: var(--g-yellow); border-color: var(--g-yellow); color: var(--g-bg); }

.profile-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: #fff; font-size: 15px; }
.profile-line > span { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.profile-line .btn { width: auto; flex: none; }

.stage-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.stage-head-text { flex: 1; min-width: 0; }
.stage-head-text h1 { margin: 0; font-size: 20px; }
.stage-head-text p { margin: 0; font-size: 13px; }
.timer-pill {
  flex: none; min-width: 56px; text-align: center;
  font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--g-yellow); border: 2px solid var(--g-yellow); border-radius: 999px; padding: 3px 12px;
}
.timer-pill.urgent { color: #fff; background: var(--ans-a); border-color: var(--ans-a); animation: countdownShake 0.5s infinite; }
.timer-pill.ended { color: rgba(255, 255, 255, 0.7); border-color: rgba(255, 255, 255, 0.3); }

.num-row { display: flex; align-items: flex-start; gap: 10px; margin: 8px 0; line-height: 1.5; }
.num-badge {
  flex: none; width: 28px; height: 28px; border-radius: 50%;
  background: var(--yellow); color: var(--navy); font-weight: 700; font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center;
}
body.theme-game .num-row { color: #fff; }
.rule-text { font-size: 18px; font-weight: 600; }

.formula-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.formula-item {
  border-left: 5px solid var(--seg); background: rgba(255, 255, 255, 0.07);
  border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px;
}
.formula-item strong { color: #fff; font-size: 16px; }
.formula-item span { color: var(--g-mint); font-size: 13px; line-height: 1.4; }
.prompt-preview { background: #fff; border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.prompt-seg { border-left: 5px solid var(--seg); padding: 4px 0 4px 10px; color: var(--text); font-size: 15px; line-height: 1.55; }
.prompt-seg-tag {
  display: inline-block; background: var(--seg); color: #fff; font-size: 11px; font-weight: 700;
  border-radius: 999px; padding: 1px 8px; margin-right: 6px; vertical-align: 2px;
}
.prompt-seg-plain { border-left-color: #C5CED2; color: var(--muted); }

.spot-art svg, .spot-art-img { width: 100%; height: auto; display: block; border-radius: 12px; }
.spot-scenario { font-size: 17px; font-weight: 600; color: #fff !important; margin: 10px 0 0; line-height: 1.5; }
.ai-line {
  display: flex; align-items: flex-start; gap: 10px; width: 100%; text-align: left;
  background: #fff; color: var(--text); border: 3px solid transparent; border-radius: 12px;
  padding: 10px; font-family: inherit; font-size: 15px; line-height: 1.5; cursor: pointer;
}
.ai-line.static { cursor: default; }
.ai-line-num {
  flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--g-bg); color: #fff;
  font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}
.ai-line.selected, .ai-line.is-wrong { border-color: var(--ans-a); background: #FDECEC; }
.ai-line.selected .ai-line-num, .ai-line.is-wrong .ai-line-num { background: var(--ans-a); }
.missed-opt {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; min-height: 52px;
  background: var(--opt); color: #fff; border: 3px solid transparent; border-radius: 12px;
  padding: 10px 12px; font-family: inherit; font-size: 16px; font-weight: 600; cursor: pointer; opacity: 0.88;
}
.missed-opt.selected { border-color: #fff; opacity: 1; box-shadow: 0 0 0 3px var(--g-yellow); }
.result-row { display: flex; align-items: center; gap: 8px; justify-content: center; font-size: 16px; font-weight: 600; margin: 6px 0; }
.result-row.ok { color: #8CE0B0; }
.result-row.no { color: #FFB4B3; }
.explain { color: #fff !important; font-size: 15px; margin-top: 8px; }
.code-feedback { border-left: 4px solid var(--g-mint); padding: 6px 10px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.missed-answer {
  display: flex; align-items: center; gap: 8px; background: var(--g-yellow); color: var(--g-bg);
  border-radius: 12px; padding: 10px 12px; font-weight: 700; font-size: 16px;
}
.result-explain {
  margin-top: 18px; background: rgba(0, 0, 0, 0.22); border-radius: 12px; padding: 12px 14px;
  font-size: 15px; line-height: 1.55; max-width: 420px;
}

.rating-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 6px; }
.rating-btn, .opt-btn {
  min-height: 52px; border-radius: 12px; border: 2px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.06); color: #fff;
  font-family: inherit; font-size: 18px; font-weight: 700; cursor: pointer;
}
.opt-btn { font-size: 16px; font-weight: 600; text-align: left; padding: 10px 14px; }
.rating-btn.selected, .opt-btn.selected { background: var(--g-yellow); border-color: var(--g-yellow); color: var(--g-bg); }
.breakdown { margin-top: 12px; border-top: 1px solid rgba(255, 255, 255, 0.15); padding-top: 10px; color: #fff; font-size: 15px; }
.breakdown .flex-between { padding: 3px 0; }

/* ========== รอบ 5: จอผู้สอน /present ========== */
.present-lobby-top h1 { font-size: clamp(22px, 2.3vw, 42px); }
.present-lobby-top p { font-size: clamp(13px, 1.15vw, 21px); }
.count-huge { font-size: clamp(64px, 7vw, 132px) !important; line-height: 1; }
.present-count-box .name-bubble { font-size: clamp(14px, 1.1vw, 20px); }
.feed-grid .btn-sm { font-size: 12px; padding: 4px 6px; min-height: 34px; }
.present-brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 24px; color: var(--g-mint); font-size: 15px; }
.present-url { color: var(--g-mint); font-size: clamp(15px, 1.3vw, 22px); line-height: 1.6; margin-top: 10px; }
.present-url strong { color: #fff; }
.present-explain { color: #fff !important; font-size: clamp(16px, 1.3vw, 22px); line-height: 1.6; max-width: 1200px; margin-left: auto; margin-right: auto; }
.quiz-present-header { flex-wrap: wrap; }
.quiz-present-pill strong { color: var(--g-yellow); margin-left: 4px; font-variant-numeric: tabular-nums; }
.pill-timer { background: var(--g-yellow); color: var(--g-bg); font-variant-numeric: tabular-nums; }
.pill-timer .urgent { color: var(--ans-a); }

.ai-chart-card { max-width: 520px; margin: 18px auto 0; text-align: left; }
.ai-bar-row { display: flex; align-items: center; gap: 10px; margin: 7px 0; color: #fff; font-size: clamp(14px, 1.1vw, 18px); }
.ai-bar-label { flex: none; width: 84px; }
.ai-bar-label.wide { width: 190px; }
.ai-bar-track { flex: 1; height: 16px; background: rgba(255, 255, 255, 0.12); border-radius: 999px; overflow: hidden; }
.ai-bar-fill { display: block; height: 100%; background: var(--g-yellow); border-radius: 999px; transition: width 0.5s ease; min-width: 2px; }
.ai-bar-row strong { flex: none; width: 34px; text-align: right; font-variant-numeric: tabular-nums; }

.present-timer-row { display: flex; align-items: center; justify-content: center; gap: 16px; margin-bottom: 18px; }
.present-timer-row .quiz-countdown { margin: 0; }
.quiz-countdown-wide { width: auto; min-width: 150px; height: 76px; border-radius: 999px; padding: 0 24px; font-size: 40px; font-variant-numeric: tabular-nums; }
.quiz-countdown.ended { color: rgba(255, 255, 255, 0.6); }
.present-timer-note { color: var(--g-mint); font-size: clamp(16px, 1.3vw, 22px); font-weight: 600; }
.present-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; align-items: start; max-width: 1360px; margin: 0 auto; }
@media (max-width: 860px) { .present-two-col { grid-template-columns: 1fr; } }
.formula-grid-big .formula-item { padding: 14px 16px; }
.formula-grid-big .formula-item strong { font-size: clamp(20px, 1.8vw, 30px); }
.formula-grid-big .formula-item span { font-size: clamp(14px, 1.15vw, 19px); }
.present-steps { margin-top: 18px; font-size: clamp(16px, 1.3vw, 22px); }
.prompt-preview-big .prompt-seg { font-size: clamp(15px, 1.25vw, 21px); }

.s2-present .ai-line { font-size: clamp(15px, 1.2vw, 21px); }
.s2-present .spot-scenario { font-size: clamp(17px, 1.4vw, 24px); }
.s2-present h3 { font-size: clamp(16px, 1.3vw, 22px); }
.missed-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.missed-opt.static { cursor: default; opacity: 1; font-size: clamp(15px, 1.15vw, 20px); }
.missed-opt.static span { flex: 1; }
.missed-opt.is-correct { border-color: var(--g-yellow); box-shadow: 0 0 0 3px var(--g-yellow); }
.count-chip { flex: none; background: rgba(255, 255, 255, 0.25); color: #fff; border-radius: 999px; padding: 1px 10px; font-variant-numeric: tabular-nums; }
.count-chip.dark { background: var(--g-bg); }

.present-band { background: var(--g-bg); border-radius: 16px; padding: 16px 18px; margin-bottom: 14px; }
.present-band-note { color: var(--g-mint); text-align: center; margin: 10px 0 0; font-size: 15px; }
.feed-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.feed-grid .card { margin: 0; }

.featured-backdrop { position: fixed; inset: 0; z-index: 45; background: rgba(2, 20, 17, 0.82); display: flex; align-items: center; justify-content: center; padding: 24px 24px 96px; }
.featured-card { background: #fff; color: var(--text); border-radius: 20px; padding: 24px; width: min(1000px, 100%); max-height: 100%; overflow: auto; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4); }
.featured-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.featured-card h2 { color: var(--navy) !important; font-size: clamp(20px, 1.8vw, 30px); }
.featured-card .muted { color: var(--muted) !important; }
.featured-card .icon-box-game { background: var(--g-yellow); color: var(--g-bg); }
.featured-text { white-space: pre-wrap; font-size: clamp(16px, 1.35vw, 23px); line-height: 1.65; color: var(--text); }
.featured-hazard { border-left: 5px solid var(--yellow); padding: 6px 0 6px 12px; margin-bottom: 10px; font-size: clamp(16px, 1.3vw, 22px); color: var(--text); }
.featured-card .btn-outline { background: #fff; color: var(--navy); border-color: var(--navy); }

.final-title { display: flex; align-items: center; justify-content: center; gap: 12px; font-size: clamp(28px, 2.6vw, 46px); }
.winner-line { font-size: clamp(20px, 1.9vw, 34px); color: #fff !important; }
.winner-line strong { color: var(--g-yellow); }
.podium-col .podium-bar { align-items: center; padding-top: 0; font-size: 34px; font-weight: 700; margin-top: 6px; width: clamp(110px, 12vw, 200px); }
.podium-col .podium-name { font-size: clamp(16px, 1.5vw, 26px); max-width: 260px; }
.present-leaderboard-row { font-size: clamp(15px, 1.25vw, 22px); }
.present-leaderboard h3 { margin-bottom: 10px; }

.survey-avg { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.survey-avg-num { font-size: 64px; font-weight: 700; color: var(--g-yellow); line-height: 1; }

.draw-stage { min-height: 150px; display: flex; align-items: center; justify-content: center; margin: 18px 0; }
.draw-name { font-size: clamp(40px, 5.5vw, 100px); font-weight: 700; color: #fff; line-height: 1.2; }
.draw-name.idle { color: rgba(255, 255, 255, 0.25); }
.draw-name.spinning { color: var(--g-mint); }
.draw-name.winner { color: var(--g-yellow); animation: bubblePop 0.5s ease-out; }
.draw-btn { width: auto; margin: 0 auto; padding: 14px 34px; font-size: 22px; min-height: 60px; }

#present-controls {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 46;
  display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap;
  padding: 10px 16px; background: rgba(2, 24, 20, 0.92); border-top: 1px solid rgba(255, 255, 255, 0.12);
}
#present-controls .btn { width: auto; }
#present-controls .btn-outline { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.5); }
.control-step { margin-right: auto; color: var(--g-mint); font-size: 14px; }
.control-next { min-width: 240px; font-size: 18px; }
.control-key-btn { opacity: 0.75; }

@media (max-width: 560px) {
  .control-step { width: 100%; margin: 0; }
  #present-controls .btn { flex: 1; min-width: 0; }
  .control-next { min-width: 0; }
  .missed-grid { grid-template-columns: 1fr; }
}

/* ========== รอบ 6: ลิงก์เดียว + ขั้นเปิดห้อง/ล็อบบี้ ========== */
/* ปุ่ม "ผู้สอน" สีจางมุมล่างขวา แสดงเฉพาะหน้าใส่ชื่อเล่น */
.teacher-btn {
  display: none; position: fixed; right: 10px; bottom: 54px; z-index: 17;
  background: var(--g-bg); color: rgba(255, 255, 255, 0.55); border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px; padding: 4px 12px; font-family: inherit; font-size: 12px; cursor: pointer;
}
body.on-checkin .teacher-btn { display: block; }
body:not(.theme-game) .teacher-btn { background: var(--bg); color: var(--muted); border-color: var(--border); }

/* QR พื้นขาวเสมอ (ขอบเงียบอยู่ในตัว svg แล้ว) */
.qr-frame { background: #fff; border-radius: 14px; line-height: 0; }
.qr-frame svg { width: 100%; height: 100%; display: block; }

.present-shell.is-room-view { padding-top: 10px; padding-bottom: 82px; }

/* หน้าฉายเปิดงาน: QR ยังเด่นและสแกนได้ แต่ไม่บังชื่อกิจกรรมและรายละเอียดเกม */
.open-view.open-stage {
  position: relative;
  isolation: isolate;
  width: 100%;
  height: calc(100dvh - 104px);
  min-height: 590px;
  box-sizing: border-box;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  align-items: stretch;
  gap: clamp(12px, 1.8vh, 24px);
  overflow: hidden;
  padding: clamp(18px, 2.5vw, 36px);
  border: 1px solid rgba(169, 241, 207, .25);
  border-radius: 26px;
  background:
    radial-gradient(circle at 87% 15%, rgba(47, 172, 144, .28), transparent 37%),
    radial-gradient(circle at 6% 88%, rgba(5, 122, 116, .28), transparent 45%),
    linear-gradient(125deg, #043b32 2%, #042a27 53%, #063e44 100%);
  box-shadow: 0 22px 60px rgba(0, 0, 0, .25);
  text-align: left;
}
.open-view.open-stage::before {
  content: "";
  position: absolute;
  z-index: -1;
  width: min(45vw, 620px);
  height: min(45vw, 620px);
  top: -30%;
  right: -11%;
  border: 1px solid rgba(182, 247, 218, .14);
  border-radius: 50%;
  box-shadow: 0 0 0 60px rgba(182, 247, 218, .035), 0 0 0 120px rgba(182, 247, 218, .025);
  pointer-events: none;
}
.open-stage-top, .open-stage-main, .open-stage-footer { position: relative; z-index: 1; }
.open-stage-top {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding-bottom: clamp(10px, 1.4vh, 18px);
  border-bottom: 1px solid rgba(196, 242, 221, .19);
}
.open-stage-organizer { display: flex; align-items: center; gap: 12px; min-width: 0; }
.open-stage-mark {
  display: grid; place-items: center; flex: none; width: 54px; height: 54px;
  border-radius: 15px; background: #ffca70; color: #043b32;
  font: 700 27px/1 "Kanit", sans-serif; box-shadow: 0 6px 18px rgba(0, 0, 0, .14);
}
.open-stage-organizer > div { display: flex; flex-direction: column; min-width: 0; }
.open-stage-organizer strong { color: #fff; font-size: clamp(14px, 1.4vw, 20px); font-weight: 600; line-height: 1.3; }
.open-stage-overline { color: #9fdfc8; font-size: 11px; letter-spacing: .15em; font-weight: 700; }
.open-stage-date {
  flex: none; padding: 10px 17px; border: 1px solid rgba(255, 202, 112, .42);
  border-radius: 999px; color: #ffe0a6; font-size: clamp(13px, 1.1vw, 17px);
  font-weight: 600; background: rgba(255, 202, 112, .07);
}
.open-stage-main {
  display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(330px, .85fr);
  align-items: center; gap: clamp(22px, 4vw, 70px); min-height: 0;
}
.open-stage-copy { min-width: 0; max-width: 760px; }
.open-stage-tag {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 13px;
  border-radius: 999px; background: rgba(92, 221, 168, .12);
  border: 1px solid rgba(92, 221, 168, .28);
  color: #b4f4da; font-size: clamp(12px, 1.15vw, 16px); font-weight: 600;
}
.open-stage-headline {
  margin: 13px 0 3px; font-size: clamp(36px, 5vw, 72px); line-height: 1.09;
  font-weight: 700; letter-spacing: -.025em; color: #fff;
}
.open-stage-headline span { color: #ffca70; }
.open-stage-subtitle {
  margin: 9px 0 0; font-size: clamp(19px, 2.2vw, 32px);
  line-height: 1.2; font-weight: 600; color: #b6f4da;
}
.open-stage-description {
  margin: 10px 0 19px; max-width: 660px;
  font-size: clamp(14px, 1.32vw, 19px); line-height: 1.5; color: #d3e9e0;
}
.open-stage-features { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.open-stage-feature {
  display: grid; grid-template-columns: 37px minmax(0, 1fr);
  gap: 0 10px; align-items: center; padding: 11px 12px;
  background: rgba(255, 255, 255, .07); border: 1px solid rgba(225, 250, 238, .13);
  border-radius: 12px; min-width: 0;
}
.open-stage-feature > span {
  grid-row: span 2; display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 10px;
  color: #ffe2aa; background: rgba(255, 202, 112, .12); font-weight: 700; font-size: 17px;
}
.open-stage-feature strong { color: #fff; font-size: clamp(14px, 1.1vw, 18px); line-height: 1.22; }
.open-stage-feature small { color: #bddad0; font-size: clamp(11px, .91vw, 14px); line-height: 1.25; }
.open-stage-join-steps {
  display: flex; gap: 10px; align-items: center; margin-top: 17px;
  color: #ffe0a4; font-size: clamp(13px, 1.14vw, 17px); font-weight: 500;
}
.open-stage-dot { width: 9px; height: 9px; flex: none; border-radius: 50%; background: #ffca70; box-shadow: 0 0 0 5px rgba(255, 202, 112, .12); }
.open-stage-qrpanel {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 7px; min-width: 0;
  padding: clamp(14px, 1.8vh, 24px) clamp(14px, 1.5vw, 22px);
  background: rgba(255, 255, 255, .1); border: 1px solid rgba(226, 253, 241, .22);
  border-radius: 23px; box-shadow: 0 18px 44px rgba(1, 16, 15, .15); text-align: center;
}
.open-stage-qrheading { color: #fff; font-size: clamp(22px, 2.5vw, 36px); font-weight: 700; line-height: 1.2; }
.open-stage-qrhint { margin: 0 0 3px; color: #b9e6d8; font-size: clamp(12px, 1.12vw, 16px); }
.open-stage-qrpanel .open-qr {
  width: min(42vh, 29vw, 410px); aspect-ratio: 1; height: auto;
  padding: 10px; box-sizing: border-box;
  background: #fff; border-radius: 15px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .16);
}
.open-stage-url {
  width: 100%; color: #ffe09e; font-size: clamp(13px, 1.21vw, 18px);
  font-weight: 700; overflow-wrap: anywhere; line-height: 1.35; letter-spacing: .008em;
}
.open-stage-count {
  display: inline-flex; gap: 8px; align-items: center; color: #d9f5e8;
  font-size: clamp(14px, 1.2vw, 18px);
}
.open-stage-count strong { color: #ffca70; font-size: clamp(19px, 1.65vw, 26px); font-variant-numeric: tabular-nums; }
.open-stage-footer {
  display: flex; justify-content: space-between; align-items: center; gap: 14px;
  border-top: 1px solid rgba(196, 242, 221, .17);
  padding-top: clamp(8px, 1.2vh, 14px);
  color: #a6d9c7; font-size: clamp(11px, 1vw, 15px);
}
@media (max-width: 900px) {
  .open-view.open-stage { height: auto; min-height: calc(100dvh - 104px); overflow: visible; }
  .open-stage-main { grid-template-columns: 1fr; gap: 24px; }
  .open-stage-qrpanel .open-qr { width: min(66vw, 40vh, 370px); }
  .open-stage-top, .open-stage-footer { flex-wrap: wrap; }
}
@media (max-height: 740px) and (min-width: 901px) {
  .open-view.open-stage { height: auto; min-height: calc(100dvh - 104px); overflow: visible; }
  .open-stage-headline { font-size: clamp(34px, 4vw, 56px); }
  .open-stage-qrpanel .open-qr { width: min(38vh, 30vw, 380px); }
}
@media (max-width: 560px) {
  .open-view.open-stage { padding: 16px; border-radius: 16px; }
  .open-stage-mark { width: 42px; height: 42px; font-size: 22px; }
  .open-stage-headline { font-size: clamp(35px, 10vw, 50px); }
  .open-stage-features { gap: 7px; }
  .open-stage-feature { grid-template-columns: 28px minmax(0, 1fr); padding: 8px; gap: 0 6px; }
  .open-stage-feature > span { width: 28px; height: 28px; font-size: 13px; }
  .open-stage-feature strong { font-size: 13px; }
  .open-stage-feature small { font-size: 11px; }
  .open-stage-qrpanel .open-qr { width: min(66vw, 320px); }
  .open-stage-footer { font-size: 11px; }
}

.lobby-view { height: calc(100vh - 92px); display: grid; grid-template-columns: auto 1fr; gap: clamp(16px, 2.5vw, 40px); }
.lobby-left { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.lobby-qr { width: min(46vh, 34vw); height: min(46vh, 34vw); }
.lobby-scan { font-size: clamp(18px, 3vh, 34px); font-weight: 700; color: #fff; margin-top: 1.4vh; }
.lobby-url { font-size: clamp(14px, 2.4vh, 28px); font-weight: 600; color: var(--g-yellow); word-break: break-all; }
.lobby-right { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.lobby-head { display: flex; align-items: center; gap: clamp(12px, 2vw, 32px); margin-bottom: 1.5vh; }
.lobby-count { display: flex; flex-direction: column; line-height: 1; color: #fff; flex: none; }
.lobby-count span { font-size: clamp(64px, 14vh, 160px); font-weight: 700; font-variant-numeric: tabular-nums; }
.lobby-count small { font-size: clamp(14px, 2.2vh, 24px); color: var(--g-mint); margin-top: 6px; }
.lobby-ai { flex: 1; min-width: 0; max-width: 520px; background: rgba(255, 255, 255, 0.06); border-radius: 14px; padding: 10px 14px; }
.lobby-ai h3 { margin: 0 0 2px; font-size: clamp(13px, 1.8vh, 18px); color: var(--g-mint); }
.lobby-ai .ai-bar-row { margin: 3px 0; font-size: clamp(12px, 1.7vh, 17px); }
.lobby-ai .ai-bar-track { height: clamp(8px, 1.3vh, 14px); }
.roster-tags {
  flex: 1; min-height: 0; overflow: hidden; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 8px;
  background: rgba(255, 255, 255, 0.04); border-radius: 16px; padding: 12px;
}
.roster-tag {
  background: var(--mint); color: var(--g-bg); font-weight: 700; border-radius: 999px; white-space: nowrap;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.roster-tag.is-new { background: var(--g-yellow); animation: bubblePop 0.5s ease-out; box-shadow: 0 0 0 3px rgba(250, 199, 117, 0.35); }
.roster-empty { color: var(--g-mint); font-size: clamp(16px, 2.4vh, 26px); opacity: 0.7; }
.roster-tags[data-size="xl"] .roster-tag { font-size: clamp(20px, 3vh, 32px); padding: 8px 20px; }
.roster-tags[data-size="lg"] .roster-tag { font-size: clamp(17px, 2.4vh, 26px); padding: 6px 16px; }
.roster-tags[data-size="md"] .roster-tag { font-size: clamp(14px, 1.9vh, 20px); padding: 5px 13px; }
.roster-tags[data-size="sm"] .roster-tag { font-size: clamp(12px, 1.55vh, 16px); padding: 4px 10px; }
.roster-tags[data-size="xs"] .roster-tag { font-size: 12px; padding: 3px 8px; }
.roster-tags[data-size="sm"], .roster-tags[data-size="xs"] { gap: 5px; }

/* QR เล็กมุมบนขวา สำหรับคนมาสาย (ทุกขั้นหลังล็อบบี้) */
.mini-qr {
  position: fixed; top: 10px; right: 10px; z-index: 44; width: clamp(110px, 15vh, 170px);
  background: #fff; border-radius: 12px; padding: 4px 4px 6px; text-align: center; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
.mini-qr #mini-qr-box svg { width: 100%; height: auto; display: block; }
.mini-qr span { display: block; color: var(--g-bg); font-size: 12px; font-weight: 700; line-height: 1.2; }
.present-shell.has-mini-qr { padding-right: calc(clamp(110px, 15vh, 170px) + 26px); }

.control-menu { width: auto !important; color: #fff !important; padding: 6px 10px; }
@media (max-width: 760px) {
  .lobby-view { grid-template-columns: 1fr; height: auto; }
  .lobby-qr { width: min(70vw, 46vh); height: min(70vw, 46vh); }
  .roster-tags { max-height: 40vh; }
  .present-shell.has-mini-qr { padding-right: 20px; padding-top: calc(clamp(110px, 15vh, 170px) + 40px); }
}

@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  .app-shell { max-width: none; padding: 0; }
  main { padding: 0; }
  @page { size: A4; margin: 14mm; }
  table.report-table { font-size: 10px; }
}
