/* ===== HOST (presenter) ===== */
body { background: var(--navy-900); overflow: hidden; }
.host {
  position: fixed; inset: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(124,92,255,.25), transparent 60%),
    radial-gradient(1000px 500px at 0% 110%, rgba(24,194,156,.18), transparent 55%),
    linear-gradient(160deg, #0b1f3a, #112a4d 70%);
  color: #fff;
}

/* top bar */
#topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 26px; gap: 12px;
}
.tb-left, .tb-right { display: flex; align-items: center; gap: 10px; }
.tb-brand { font-weight: 700; letter-spacing: .3px; opacity: .9; }
#tb-pin { font-weight: 700; background: rgba(255,210,63,.18); color: #ffe08a; }

/* stage */
#stage {
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  padding: 10px 48px 6px;
  min-height: 0; min-width: 0; /* let the 1fr grid row stay put so overflow:hidden clips instead of blowing up */
}
.loading { opacity: .6; }

/* persistent presenter credit (bottom-left of every slide) */
.slide-credit {
  position: absolute; left: 30px; bottom: 14px; z-index: 4;
  font-size: .92rem; line-height: 1.35; letter-spacing: .2px;
  color: rgba(255,255,255,.6); text-align: left; pointer-events: none;
}
.slide-credit b { font-weight: 700; color: rgba(255,255,255,.82); }

/* keep a Thai word from being split across lines (Thai breaks between any chars) */
.nowrap { white-space: nowrap; }

/* generic slide */
.slide-wrap { width: min(1180px, 96%); margin: 0 auto; }
.kicker {
  display: inline-block; text-transform: uppercase; letter-spacing: 2px;
  font-size: 1rem; font-weight: 700; color: var(--gold);
  background: rgba(255,210,63,.12); padding: .35em 1em; border-radius: 999px; margin-bottom: 18px;
}
.slide-title { font-size: clamp(2.2rem, 5.2vw, 4rem); font-weight: 800; line-height: 1.08; margin: 0 0 18px; }
.slide-sub { font-size: clamp(1.1rem, 2.2vw, 1.7rem); font-weight: 600; opacity: .92; margin-bottom: 12px; }
.slide-body { font-size: clamp(1.05rem, 1.9vw, 1.5rem); line-height: 1.55; opacity: .95; max-width: 60ch; }
.slide-body b { color: var(--gold); }
.bullets { list-style: none; padding: 0; margin: 18px 0 0; display: grid; gap: 14px; }
.bullets li {
  font-size: clamp(1.05rem, 1.9vw, 1.55rem); line-height: 1.4;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.10);
  padding: .7em 1em; border-radius: 14px;
}

/* cover layout */
.layout-cover { text-align: center; }
.layout-cover .slide-title { font-size: clamp(2.6rem, 7vw, 5.5rem); background: linear-gradient(90deg,#fff,#cdd9ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.layout-cover .kicker { font-size: 1.1rem; }

/* split (scenario) */
.layout-split .split-grid { display: grid; grid-template-columns: 1fr; gap: 20px; }

/* stage divider slide */
.layout-stage .slide-title { font-size: clamp(2.6rem, 6.5vw, 5rem); }

/* ===== LOBBY ===== */
.lobby { width: 100%; display: grid; grid-template-columns: 1.1fr 1fr; gap: 30px; align-items: center; }
.lobby-left { text-align: left; }
.lobby h1 { font-size: clamp(2rem,4vw,3.2rem); margin: 0 0 6px; }
.join-card {
  background: #fff; color: var(--ink); border-radius: 24px; padding: 26px 30px;
  box-shadow: var(--shadow-lg); display: flex; gap: 26px; align-items: center;
}
.join-card .qr { width: 200px; height: 200px; border-radius: 14px; background: #fff; flex: none; }
.join-info .lbl { color: var(--muted); font-weight: 600; font-size: .95rem; }
.join-info .url { font-size: 1.5rem; font-weight: 700; color: var(--brand); word-break: break-all; }
.pin-big { font-size: clamp(3rem, 7vw, 5.5rem); font-weight: 800; letter-spacing: .12em; line-height: 1; color: var(--ink); }
.pin-label { color: var(--muted); font-weight: 700; letter-spacing: 3px; text-transform: uppercase; font-size: .9rem; }

.roster { display: flex; flex-wrap: wrap; gap: 10px; align-content: flex-start; max-height: 46vh; overflow: auto; }
.chip {
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.14);
  padding: .5em 1em; border-radius: 999px; font-weight: 600; font-size: 1.1rem;
}
.roster-empty { opacity: .6; font-size: 1.2rem; }

/* ===== QUIZ ===== */
.quiz { width: 100%; max-width: 1200px; }
.quiz-stage-tag { color: var(--gold); font-weight: 700; letter-spacing: 1px; margin-bottom: 8px; }
.quiz-q { font-size: clamp(1.6rem, 3.6vw, 3rem); font-weight: 800; line-height: 1.12; text-align: center; margin: 0 auto 22px; max-width: 22ch; }
.quiz-meta { display: flex; justify-content: center; gap: 16px; margin-bottom: 18px; align-items: center; }
.timer-ring { font-size: 2rem; font-weight: 800; min-width: 70px; height: 70px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.12); }
.answer-count { font-size: 1.3rem; font-weight: 700; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.opt {
  display: flex; align-items: center; gap: 16px; padding: 22px 24px; border-radius: 16px;
  font-size: clamp(1.05rem, 1.9vw, 1.6rem); font-weight: 700; color: #fff; position: relative;
  transition: opacity .3s, transform .3s, filter .3s;
}
.opt .ico { font-size: 1.6rem; }
.opt.a0 { background: var(--a0); }
.opt.a1 { background: var(--a1); }
.opt.a2 { background: var(--a2); }
.opt.a3 { background: var(--a3); }
.opt.dim { opacity: .35; filter: grayscale(.4); }
.opt.correct { outline: 5px solid #fff; transform: scale(1.03); box-shadow: 0 0 0 6px rgba(255,255,255,.25); }
.opt .check { margin-left: auto; font-size: 1.8rem; }
.explain { margin-top: 18px; background: rgba(255,255,255,.1); border-left: 5px solid var(--gold); padding: 14px 18px; border-radius: 12px; font-size: 1.2rem; line-height: 1.5; }
.crit-tag { display:inline-block; margin-top: 10px; font-size: .95rem; opacity:.85; }

/* clickable source citations */
.sources { margin-top: 20px; font-size: 1rem; opacity: .92; line-height: 1.6; }
.sources .src-link { color: var(--gold); text-decoration: underline; text-underline-offset: 3px; }
.sources .src-link:hover { color: #fff; }
.sources .src-sep { margin: 0 .5em; opacity: .5; }
.quiz .sources { margin-top: 12px; font-size: .95rem; }

/* distribution bars under options when locked */
.dist { margin-top: 4px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; }
.dist .d { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.dist .d .bt { flex: 1; }

/* ===== SIM ===== */
.sim { width: 100%; max-width: 1240px; }
.sim h2 { font-size: clamp(1.5rem,3vw,2.4rem); margin: 0 0 6px; text-align: center; }
.sim .brief { text-align: center; opacity: .92; max-width: 70ch; margin: 0 auto 14px; font-size: 1.15rem; }
.sim .budget { text-align: center; font-size: 1.4rem; font-weight: 800; color: var(--gold); margin-bottom: 14px; }
.iv-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.iv {
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); border-radius: 14px; padding: 14px;
}
.iv .nm { font-weight: 700; font-size: 1.05rem; margin-bottom: 4px; }
.iv .ds { font-size: .92rem; opacity: .8; line-height: 1.35; }
.iv .cost { margin-top: 8px; font-weight: 800; color: var(--gold); }
.iv .tag { float: right; font-size: .75rem; background: rgba(255,255,255,.16); padding: .2em .6em; border-radius: 999px; }
.sim-results { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
.dim-bars { display: grid; gap: 14px; }
.dim-row .dim-name { display:flex; justify-content: space-between; font-weight:700; margin-bottom: 6px; }
.top-portfolios { display: grid; gap: 10px; }
.tp-row { display: flex; align-items: center; gap: 12px; background: rgba(255,255,255,.08); padding: 10px 14px; border-radius: 12px; }
.tp-row .rk { font-weight: 800; width: 1.6em; }
.tp-row .pts { margin-left: auto; font-weight: 800; color: var(--gold); }
.tp-row.over { outline: 2px solid var(--danger); }

/* ===== LEADERBOARD ===== */
.lb { width: 100%; max-width: 900px; }
.lb h2 { text-align: center; font-size: clamp(1.8rem,4vw,3rem); margin: 0 0 22px; }
.lb-list { display: grid; gap: 12px; }
.lb-row { display: flex; align-items: center; gap: 16px; background: rgba(255,255,255,.09); border-radius: 14px; padding: 14px 20px; font-size: 1.4rem; }
.lb-row .rk { font-weight: 800; width: 1.8em; text-align: center; }
.lb-row .nm { font-weight: 700; }
.lb-row .sc { margin-left: auto; font-weight: 800; color: var(--gold); }
.lb-row.top1 { background: linear-gradient(90deg, rgba(255,210,63,.3), rgba(255,210,63,.08)); }
.lb-row.top2 { background: linear-gradient(90deg, rgba(220,228,245,.3), rgba(220,228,245,.06)); }
.lb-row.top3 { background: linear-gradient(90deg, rgba(205,127,50,.3), rgba(205,127,50,.06)); }
.podium-emoji { font-size: 1.6rem; }

/* ===== notes & controls ===== */
.notes {
  position: fixed; right: 18px; bottom: 92px; width: min(420px, 40vw);
  background: rgba(8,18,34,.96); border: 1px solid rgba(255,255,255,.14);
  border-radius: 16px; padding: 16px 18px; box-shadow: var(--shadow-lg); z-index: 30; max-height: 50vh; overflow:auto;
}
.notes-title { font-weight: 700; margin-bottom: 8px; color: var(--gold); display:flex; gap:8px; align-items:center; }
#notes-body { font-size: 1.05rem; line-height: 1.5; opacity: .95; }
.kbd { font-size: .8rem; background: rgba(255,255,255,.15); padding: .1em .5em; border-radius: 6px; }
.hidden { display: none !important; }

/* leaderboard peek overlay (host only, key B) */
.lb-peek {
  position: fixed; inset: 0; z-index: 25;
  background: rgba(8,18,34,.92); display: grid; place-items: center; padding: 40px;
}
.sim h3 { font-size: 1.1rem; margin: 0 0 10px; }

#controls {
  display: flex; align-items: center; gap: 12px; padding: 12px 22px;
  background: rgba(8,18,34,.5); border-top: 1px solid rgba(255,255,255,.08);
}
.ctrl-mid { flex: 1; display: flex; justify-content: center; gap: 10px; }
.ctrl-tools { display: flex; gap: 8px; }
.btn.icon { padding: .6em .8em; }
.ctrl-hint { opacity: .7; font-size: .95rem; align-self: center; }

@media (max-width: 980px) {
  .lobby { grid-template-columns: 1fr; }
  .opts, .sim-results, .dist { grid-template-columns: 1fr; }
  .iv-grid { grid-template-columns: 1fr 1fr; }
}
