:root { --ui-bg: rgba(18, 22, 30, .82); --ui-fg: #f2f4f8; --accent: #e9a23b; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #000; color: var(--ui-fg); overflow: hidden;
  font-family: "Carlito", system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-tap-highlight-color: transparent; }
body { overscroll-behavior: none; }

/* ---------------------------------------------------------------- stage + slide */
#viewport { position: fixed; inset: 0; overflow: hidden; touch-action: manipulation; user-select: none; -webkit-user-select: none; cursor: default; }
.stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; overflow: hidden; background: #000; }
.slide { position: absolute; left: 0; top: 0; overflow: hidden; contain: layout paint; }
.el { position: absolute; }
.el > .geo, .el > a > .geo { position: absolute; }
.el.img img { display: block; width: 100%; height: 100%; }
.el.text { display: flex; flex-direction: column; overflow: visible; font-kerning: normal; font-variant-ligatures: none;
  -webkit-font-smoothing: antialiased; text-rendering: geometricPrecision; }
.el.text p { margin: 0; flex-shrink: 0; white-space: pre-wrap; overflow-wrap: break-word; }
.el.text a, .el a.lnk { color: inherit; text-decoration: none; cursor: pointer; }
.el.text a span { text-decoration: underline; }
.el.media { overflow: hidden; background: #000; }
.el.media .cover, .el.media video { display: block; width: 100%; height: 100%; object-fit: contain; background: #000; }
.el.media.interactive { cursor: pointer; }
.el.media .play { position: absolute; left: 50%; top: 50%; width: 150px; height: 150px; margin: -75px 0 0 -75px; padding: 0;
  border: 0; background: none; cursor: pointer; transition: transform .15s; filter: drop-shadow(0 4px 12px rgba(0,0,0,.35)); }
.el.media:hover .play { transform: scale(1.08); }
.el.media .play svg { width: 100%; height: 100%; }

/* ---------------------------------------------------------------- controls */
#bar { position: fixed; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translate(-50%, 10px);
  display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 999px; background: var(--ui-bg);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); box-shadow: 0 6px 24px rgba(0,0,0,.35);
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; z-index: 10; font-size: 15px; white-space: nowrap;
  max-width: calc(100vw - 24px); }
body.ui-on #bar { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
body.ui-on #viewport { cursor: default; }
body:not(.ui-on) #viewport { cursor: none; }
#bar button { display: inline-flex; align-items: center; gap: 6px; height: 36px; min-width: 36px; padding: 0 10px; border: 0;
  border-radius: 999px; background: transparent; color: var(--ui-fg); font: inherit; font-weight: 700; cursor: pointer; }
#bar button:hover, #bar button:focus-visible { background: rgba(255,255,255,.14); outline: none; }
#bar svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
#bar #counter { min-width: 64px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 700; }
#bar #steps { color: #aab3c2; font-size: 13px; min-width: 0; }
#bar .grow { width: 10px; }
#langs { display: inline-flex; gap: 2px; padding: 2px; border-radius: 10px; background: rgba(255,255,255,.08); }
#langs[hidden] { display: none; }
#bar #langs button { height: 30px; min-width: 34px; padding: 0 9px; font-size: 13px; font-weight: 700; letter-spacing: .02em; border-radius: 8px; }
#bar #langs button[aria-pressed="true"] { background: var(--accent); color: #111; }
#langs .short { display: none; }
@media (max-width: 560px), (max-height: 420px) { #langs .short { display: inline; } }
#bar #langs button:disabled { opacity: .35; cursor: default; background: transparent; }
#toast { position: fixed; left: 50%; bottom: calc(max(14px, env(safe-area-inset-bottom)) + 64px); transform: translateX(-50%); z-index: 30; padding: 10px 16px; border-radius: 12px;
  background: rgba(20,26,38,.92); color: #fff; font-size: 15px; pointer-events: none; opacity: 0; transition: opacity .3s; max-width: calc(100vw - 32px); text-align: center; }
#toast.on { opacity: 1; }
#btn-fs .exit { display: none; }
body.fs #btn-fs .exit { display: inline; }
body.fs #btn-fs .enter { display: none; }
#progress { position: fixed; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255,255,255,.08); z-index: 9; }
#progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
body.no-ui #bar, body.no-ui #progress, body.no-ui #rotate { display: none !important; }
body.black #viewport::after { content: ""; position: absolute; inset: 0; background: #000; z-index: 5; }

/* help */
#help { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(0,0,0,.55); z-index: 20; padding: 16px; }
body.help-open #help { display: flex; }
#help .card { position: relative; width: min(560px, 100%); max-height: 100%; overflow: auto; background: #1b2333; border-radius: 16px; padding: 22px 26px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5); font-size: 16px; line-height: 1.4; }
#help h2 { margin: 0 0 14px; font-size: 20px; color: var(--accent); }
#help dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; }
#help dt { white-space: nowrap; } #help dd { margin: 0; color: #cfd6e2; }
#help kbd { display: inline-block; min-width: 26px; padding: 1px 6px; border-radius: 6px; background: #2c3850; border-bottom: 2px solid #121826;
  font: 700 13px/1.6 system-ui, sans-serif; text-align: center; }
#help .touch { margin: 16px 0 0; color: #aab3c2; font-size: 14px; }
#help .close { position: absolute; right: 10px; top: 8px; width: 34px; height: 34px; border: 0; border-radius: 50%; background: transparent; color: #fff; font-size: 24px; cursor: pointer; }
#help .close:hover { background: rgba(255,255,255,.12); }

#rotate { display: none; }
@media (orientation: portrait) and (max-width: 700px) {
  #rotate { display: block; position: fixed; left: 16px; right: 16px; top: max(16px, env(safe-area-inset-top)); padding: 10px 14px; border-radius: 12px;
    background: var(--ui-bg); text-align: center; font-size: 14px; z-index: 8; pointer-events: none; }
}
@media (max-width: 560px), (max-height: 420px) {
  #bar { gap: 2px; padding: 4px; font-size: 14px; bottom: max(8px, env(safe-area-inset-bottom)); }
  #bar #steps, #btn-notes span { display: none; }
  #bar #langs button { padding: 0 6px; min-width: 30px; }
  #langs .long { display: none; }
  #bar button { height: 34px; padding: 0 8px; }
}
#error { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; font-size: 18px; text-align: center; }
#error[hidden] { display: none; }

/* ---------------------------------------------------------------- presenter window */
#presenter { display: none; }
body.presenter { overflow: auto; background: #10141c; }
body.presenter #viewport, body.presenter #bar, body.presenter #progress, body.presenter #help, body.presenter #rotate { display: none !important; }
body.presenter #presenter { display: flex; flex-direction: column; min-height: 100%; padding: 14px 18px; gap: 12px; }
#presenter header { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 20px; }
#p-timer { font-variant-numeric: tabular-nums; font-size: 26px; font-weight: 700; color: var(--accent); }
.p-main { display: grid; grid-template-columns: 1.55fr 1fr; gap: 18px; flex: 1; min-height: 0; }
.p-col { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.p-frame { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: 8px; overflow: hidden; }
.p-col.side .p-frame { opacity: .92; }
.p-ctl { display: flex; align-items: center; gap: 12px; }
.p-ctl span { flex: 1; text-align: center; color: #aab3c2; }
.p-ctl button { padding: 10px 18px; border: 0; border-radius: 10px; background: #2a3550; color: #fff; font-family: inherit; font-size: 16px; font-weight: 700; line-height: 1; cursor: pointer; }
.p-ctl button:hover { background: #34426a; }
#p-next-label { color: #aab3c2; font-size: 14px; }
#presenter h3 { margin: 6px 0 0; font-size: 15px; color: var(--accent); text-transform: uppercase; letter-spacing: .06em; }
#p-notes { font-size: 22px; line-height: 1.45; white-space: pre-wrap; overflow: auto; padding-right: 6px; }
#p-wait { margin: 0; padding: 10px 14px; border-radius: 10px; background: #3a2a14; color: #ffd28a; }
@media (max-width: 800px) { .p-main { grid-template-columns: 1fr; } }

/* live scenes (wvm scene app in an iframe, driven by its audio clock) */
.el.media.live .live-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; opacity: 0; pointer-events: none; background: #000; }
.el.media.live.ready .live-frame { opacity: 1; }
.el.media.live audio { display: none; }
.live-ui { position: absolute; left: 0; right: 0; bottom: 0; height: 64px; display: flex; align-items: center; gap: 18px; padding: 0 22px;
  background: linear-gradient(transparent, rgba(0,0,0,.6)); opacity: 0; transition: opacity .25s; }
.el.media.live:hover .live-ui, .el.media.live.held .live-ui { opacity: 1; }
.live-btn { all: unset; cursor: pointer; width: 44px; height: 44px; display: grid; place-items: center; }
.live-btn svg { width: 36px; height: 36px; fill: #fff; }
.live-track { flex: 1; height: 8px; border-radius: 4px; background: rgba(255,255,255,.3); cursor: pointer; position: relative; }
.live-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: #E9A23B; }
.live-time { color: #fff; font: 600 22px/1 "Carlito", sans-serif; font-variant-numeric: tabular-nums; min-width: 110px; text-align: right; }
.live-hold { position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); display: none; flex-direction: column; align-items: center; gap: 6px;
  padding: 16px 30px; border-radius: 18px; background: rgba(31,58,95,.92); color: #fff; font: 600 26px/1.2 "Carlito", sans-serif;
  box-shadow: 0 6px 24px rgba(0,0,0,.35); pointer-events: none; }
.live-hold b { color: #E9A23B; font-size: 30px; }
.el.media.live.held .live-hold { display: flex; animation: live-pulse 1.6s ease-in-out infinite; }
@keyframes live-pulse { 50% { transform: translateX(-50%) scale(1.04); } }

/* in-slide game (heyworking.com/choi in an iframe over the slide) */
#game-layer { position: fixed; inset: 0; z-index: 50; background: #0d1420; }
#game-layer iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
#game-layer .game-x { position: absolute; right: 14px; top: 14px; z-index: 1; width: 44px; height: 44px; border-radius: 50%; border: 0;
  background: rgba(255,255,255,.92); color: #1F3A5F; font: 800 22px/44px system-ui, sans-serif; cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,.3); }
body.game-open #bar { display: none; }
