/* ============================================================
   360° Safety Training Tool — Main Stylesheet
   University of Calgary
   ============================================================ */

:root {
  --sidebar-width: 240px;
  --sidebar-bg:    #1a237e;
  --sidebar-text:  #e8eaf6;
  --primary:       #1a237e;
  --accent:        #e53935;
  --success:       #2e7d32;
  --bg:            #f0f2f5;
  --card-bg:       #ffffff;
  --border:        #e0e0e0;
  --text:          #212121;
  --text-muted:    #757575;
  --radius:        10px;
  --shadow:        0 2px 8px rgba(0,0,0,.10);
  --shadow-md:     0 4px 16px rgba(0,0,0,.14);
}

*, *::before, *::after { box-sizing: border-box; }
body { font-family: 'Segoe UI', system-ui, sans-serif; color: var(--text); }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #bdbdbd; border-radius: 3px; }

/* ── Logo ────────────────────────────────────────────────── */
/* Sidebar logo (small, in the dark sidebar) */
.sidebar-logo {
  height: 30px;
  width: auto;
  object-fit: contain;
  margin-right: .5rem;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 6px;
  padding: 3px 5px;
}
/* Landing page logo (large, centred) */
.landing-logo-img {
  height: 110px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,.4));
}
/* Auth pages logo (medium, centred above form) */
.auth-logo-img {
  height: 72px;
  width: auto;
  object-fit: contain;
  display: block;
  margin: 0 auto .75rem;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  position: fixed; left: 0; top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex; flex-direction: column;
  z-index: 200;
  box-shadow: 2px 0 12px rgba(0,0,0,.2);
}
.sidebar-header {
  padding: 1.25rem 1.25rem 0.75rem;
  font-size: 1.1rem; font-weight: 700;
  letter-spacing: .5px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  display: flex; align-items: center;
}
.sidebar-title { font-size: 1rem; }
.sidebar-user {
  padding: .75rem 1.25rem;
  font-size: .8rem;
  border-bottom: 1px solid rgba(255,255,255,.10);
  color: #c5cae9;
}
.sidebar-nav { flex: 1; padding: .75rem 0; overflow-y: auto; }
.sidebar-link {
  display: flex; align-items: center; gap: .7rem;
  padding: .6rem 1.25rem;
  color: #c5cae9; text-decoration: none;
  font-size: .875rem;
  transition: background .15s, color .15s;
}
.sidebar-link:hover { background: rgba(255,255,255,.10); color: #fff; }
.sidebar-link.active { background: rgba(255,255,255,.18); color: #fff; font-weight: 600; }
.sidebar-link i { width: 18px; text-align: center; }
.sidebar-footer {
  padding: .75rem 0;
  border-top: 1px solid rgba(255,255,255,.10);
}
.sidebar-footer .sidebar-link { color: #ef9a9a; }
.sidebar-footer .sidebar-link:hover { color: #fff; background: rgba(229,57,53,.3); }

/* ── Main content areas ──────────────────────────────────── */
.main-with-sidebar {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg);
  padding: 2rem;
}
.main-full { min-height: 100vh; background: var(--bg); }
.flash-container { margin-bottom: 1rem; }

/* ── Page header ─────────────────────────────────────────── */
.page-header { margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.6rem; font-weight: 700; margin-bottom: .25rem; }

/* ── Content card ────────────────────────────────────────── */
.content-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}
.card-section-title {
  font-size: 1rem; font-weight: 600;
  margin-bottom: 1rem;
  padding-bottom: .5rem;
  border-bottom: 2px solid var(--border);
}

/* ── Stats cards ─────────────────────────────────────────── */
.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  display: flex; align-items: center; gap: 1rem;
  border-left: 4px solid;
}
.stat-blue   { border-color: #1565c0; }
.stat-purple { border-color: #6a1b9a; }
.stat-green  { border-color: #2e7d32; }
.stat-orange { border-color: #e65100; }
.stat-icon { font-size: 1.75rem; }
.stat-blue .stat-icon   { color: #1565c0; }
.stat-purple .stat-icon { color: #6a1b9a; }
.stat-green .stat-icon  { color: #2e7d32; }
.stat-orange .stat-icon { color: #e65100; }
.stat-value { font-size: 2rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: .8rem; color: var(--text-muted); }

/* ── Quick action cards ──────────────────────────────────── */
.quick-action-card {
  display: flex; align-items: center; gap: .75rem;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.25rem;
  text-decoration: none; color: var(--text);
  transition: box-shadow .15s, transform .15s;
  font-weight: 600;
}
.quick-action-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); color: var(--primary); }
.quick-action-card i { font-size: 1.5rem; color: var(--primary); }

/* ── Session code badge ──────────────────────────────────── */
.session-code-badge {
  font-family: 'Courier New', monospace;
  background: #e8eaf6; color: var(--primary);
  border-radius: 4px; padding: 2px 6px;
  font-weight: 700; letter-spacing: 2px;
  font-size: .95rem;
}

/* ── Empty state ─────────────────────────────────────────── */
.empty-state { text-align: center; padding: 4rem 2rem; color: var(--text-muted); }
.empty-state i { font-size: 4rem; margin-bottom: 1rem; opacity: .4; display: block; }
.empty-state p { font-size: 1.1rem; margin-bottom: 1.25rem; }

/* ── Landing page ────────────────────────────────────────── */
.landing-page { background: linear-gradient(135deg, #1a237e 0%, #283593 50%, #3949ab 100%); }
body.landing-page .main-full { background: transparent; }
.landing-container {
  min-height: 100vh;
  display: flex; flex-direction: column; justify-content: center;
  padding: 3rem 2rem;
}
.landing-header { color: #fff; }
.landing-logo { font-size: 4rem; color: #ffcc02; }
.landing-title { font-size: 2.5rem; font-weight: 800; color: #fff; }
.landing-subtitle { font-size: 1.2rem; color: #c5cae9; }
.landing-tagline  { font-size: .85rem; color: #9fa8da; margin-top: .25rem; }
.landing-card {
  background: rgba(255,255,255,.97);
  border-radius: 16px; padding: 2.5rem 2rem;
  text-align: center; cursor: pointer;
  transition: transform .2s, box-shadow .2s;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.landing-card:hover { transform: translateY(-6px); box-shadow: 0 16px 40px rgba(0,0,0,.3); }
.landing-card-icon { font-size: 3rem; margin-bottom: 1rem; }
.landing-card-worker .landing-card-icon     { color: #2e7d32; }
.landing-card-instructor .landing-card-icon { color: #1a237e; }
.landing-card-title { font-size: 1.5rem; font-weight: 700; color: var(--text); margin-bottom: .75rem; }
.landing-card-desc  { color: var(--text-muted); margin-bottom: 1.5rem; line-height: 1.6; }
.landing-card-btn {
  display: inline-flex; align-items: center;
  padding: .6rem 1.5rem; border-radius: 8px; font-weight: 600; font-size: .95rem;
}
.landing-card-worker .landing-card-btn     { background: #2e7d32; color: #fff; }
.landing-card-instructor .landing-card-btn { background: #1a237e; color: #fff; }

/* ── Auth pages ──────────────────────────────────────────── */
.auth-page {
  background: linear-gradient(135deg, #1a237e, #283593);
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
}
.auth-container { width: 100%; max-width: 440px; padding: 1rem; }
.auth-card {
  background: #fff; border-radius: 16px;
  padding: 2.5rem 2rem;
  box-shadow: 0 16px 48px rgba(0,0,0,.25);
}
.auth-header { text-align: center; margin-bottom: 2rem; }
.auth-header h2 { color: #1a237e !important; }
.auth-header p  { color: #555 !important; }
.auth-logo { font-size: 3rem; color: var(--primary); display: block; margin-bottom: .75rem; }
.auth-header h2 { font-weight: 700; margin-bottom: .25rem; }
.session-code-input {
  font-size: 2rem; font-weight: 800; letter-spacing: 8px;
  text-align: center; font-family: 'Courier New', monospace;
}

/* ── Scenario cards ──────────────────────────────────────── */
.scenario-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow .15s, transform .15s;
}
.scenario-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.scenario-thumb { height: 180px; position: relative; overflow: hidden; background: #263238; }
.scenario-thumb img { width: 100%; height: 100%; object-fit: cover; }
.scenario-difficulty {
  position: absolute; top: .5rem; right: .5rem;
  padding: .25rem .6rem; border-radius: 4px; font-size: .75rem; font-weight: 700;
}
.badge-diff-beginner { background: #2e7d32; color: #fff; }
.badge-diff-medium   { background: #f57f17; color: #fff; }
.badge-diff-advanced { background: #b71c1c; color: #fff; }
.scenario-shared-badge {
  position: absolute; top: .5rem; left: .5rem;
  background: rgba(0,0,0,.6); color: #fff;
  padding: .2rem .5rem; border-radius: 4px; font-size: .7rem;
}
.scenario-card-body { padding: 1rem; }
.scenario-title { font-weight: 700; font-size: 1rem; margin-bottom: .25rem; }
.scenario-location { font-size: .8rem; color: var(--text-muted); margin-bottom: .5rem; }

/* Risk chip */
.risk-summary { display: flex; flex-wrap: wrap; gap: 4px; min-height: 28px; }
.risk-chip {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 6px 2px 3px;
  border-radius: 12px; font-size: .75rem; font-weight: 700; color: #fff;
}
.risk-chip-icon { width: 16px; height: 16px; }

/* ── Session cards ───────────────────────────────────────── */
.session-card { border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); color: #fff; }
.session-active   { background: linear-gradient(135deg, #1b5e20, #2e7d32); }
.session-inactive { background: linear-gradient(135deg, #424242, #616161); }
.session-code-display { display: flex; align-items: center; gap: .75rem; margin-bottom: .75rem; }
.session-code-large {
  font-family: 'Courier New', monospace;
  font-size: 2.5rem; font-weight: 800; letter-spacing: 8px;
}
.session-meta { font-size: .85rem; }

/* ── Editor layout ───────────────────────────────────────── */
.editor-page .main-with-sidebar { padding: 0; display: flex; flex-direction: column; height: 100vh; }
.editor-layout { display: flex; height: 100vh; overflow: hidden; }
.editor-viewer-area { flex: 1; display: flex; flex-direction: column; position: relative; background: #000; min-width: 0; }
#panorama { width: 100%; height: 100%; }

.add-mode-banner {
  position: absolute; bottom: 3rem; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.82); color: #fff;
  padding: .6rem 1.25rem; border-radius: 8px;
  border-left: 4px solid #fff;
  z-index: 100; white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,.4); font-size: .9rem;
}
.viewer-hint {
  position: absolute; bottom: .75rem; right: 1rem;
  background: rgba(0,0,0,.5); color: rgba(255,255,255,.8);
  padding: .3rem .75rem; border-radius: 6px; font-size: .75rem; pointer-events: none;
}

.editor-panel {
  width: 360px; min-width: 320px;
  background: var(--card-bg);
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: -2px 0 12px rgba(0,0,0,.1);
}
.editor-tabs { border-bottom: 2px solid var(--border); padding: 0 .5rem; background: #fafafa; flex-shrink: 0; }
.editor-tabs .nav-link { font-size: .8rem; padding: .5rem .75rem; color: var(--text-muted); }
.editor-tabs .nav-link.active { color: var(--primary); font-weight: 600; }
.editor-tab-content { flex: 1; overflow-y: auto; }
.editor-panel-footer { border-top: 1px solid var(--border); padding: .5rem .75rem; flex-shrink: 0; background: #fafafa; }

.instructions-callout {
  background: #e8f5e9; border-left: 4px solid #2e7d32;
  padding: .75rem 1rem; font-size: .82rem;
}

.risk-type-row { border-bottom: 1px solid var(--border); transition: background .1s; }
.risk-type-row.risk-row-active { background: #e8eaf6; }
.risk-type-header { display: flex; align-items: center; gap: .5rem; padding: .6rem .75rem; }
.risk-icon-badge { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.risk-icon-sm { width: 20px; height: 20px; display: block; }
.risk-type-label { font-weight: 600; font-size: .875rem; flex: 1; }
.risk-count-badge { font-size: .7rem; }
.add-marker-btn { font-size: .75rem; padding: .25rem .5rem; }

.marker-list { background: #fafafa; }
.marker-list-item {
  display: flex; align-items: center; gap: .4rem; flex-wrap: wrap;
  padding: .4rem .75rem .4rem 2.5rem;
  border-top: 1px solid var(--border); font-size: .78rem;
}
.marker-idx { font-weight: 700; color: var(--text-muted); min-width: 20px; }
.marker-coords { color: var(--text-muted); font-family: monospace; font-size: .72rem; }
.btn-xs { padding: 0.15rem 0.35rem; font-size: .7rem; }

/* Pannellum hotspot overrides */
.risk-hotspot {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  border: 2px solid rgba(255,255,255,.9);
  box-shadow: 0 2px 8px rgba(0,0,0,.45);
  position: relative; transition: transform .15s;
}
.risk-hotspot:hover { transform: scale(1.2); }
.hs-high-energy { border-color: #ffee58 !important; border-width: 3px !important; }
.hs-he-badge { position: absolute; top: -6px; right: -6px; font-size: .7rem; line-height: 1; }

/* ── Worker page ─────────────────────────────────────────── */
.worker-page .main-full { display: flex; flex-direction: column; height: 100vh; }
.worker-layout { display: flex; flex-direction: column; height: 100vh; }
.worker-header { padding: .75rem 1.25rem; background: #1a237e; color: #fff; flex-shrink: 0; }
.worker-viewer { flex: 1; position: relative; min-height: 0; }
#panorama-worker { width: 100%; height: 100%; }
.worker-instructions { max-height: 35vh; overflow-y: auto; padding: 1rem 1.25rem; background: var(--bg); }
.coming-soon-box { text-align: center; padding: 2rem; background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ── Table ───────────────────────────────────────────────── */
.table td, .table th { vertical-align: middle; }

/* ── Image picker (inline row + browse button) ───────────── */
.image-picker-row {
  display: flex; gap: .5rem; align-items: stretch;
}
.image-picker-row .form-control { flex: 1; }
.btn-browse { white-space: nowrap; flex-shrink: 0; }

/* Preview strip (below the image picker on new scenario page) */
.image-preview-strip {
  display: flex; align-items: center; gap: .75rem;
  margin-top: .5rem;
  background: #f8f9fa; border: 1px solid var(--border);
  border-radius: 8px; padding: .5rem .75rem;
}
.preview-thumb {
  width: 80px; height: 40px; object-fit: cover;
  border-radius: 4px; border: 1px solid var(--border);
  background: #000;
}
.preview-info { display: flex; flex-direction: column; gap: 3px; }
.preview-dims { font-size: .75rem; color: var(--text-muted); font-family: monospace; }
.preview-status .badge { font-size: .72rem; }

/* ── File Picker Modal ───────────────────────────────────── */
.fp-layout {
  display: flex; height: 520px; overflow: hidden;
}

/* Left pane: directory listing */
.fp-left-pane {
  width: 55%; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
}
.fp-breadcrumb-bar {
  padding: .5rem .75rem;
  background: #f5f5f5;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: 38px;
}
.fp-file-list {
  flex: 1; overflow-y: auto;
}
.fp-entry {
  display: flex; align-items: center; gap: .6rem;
  padding: .45rem .75rem;
  cursor: pointer; font-size: .875rem;
  border-bottom: 1px solid #f0f0f0;
  transition: background .1s;
  user-select: none;
}
.fp-entry:hover { background: #e8eaf6; }
.fp-entry.selected { background: #c5cae9; font-weight: 600; }
.fp-entry-icon { width: 18px; text-align: center; flex-shrink: 0; }
.fp-entry-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fp-entry-size { font-size: .75rem; color: var(--text-muted); flex-shrink: 0; }
.fp-loading, .fp-error, .fp-empty {
  padding: 2rem; text-align: center; color: var(--text-muted);
}
.fp-error { color: #c62828; }

/* Right pane: preview */
.fp-right-pane {
  width: 45%; display: flex; flex-direction: column; overflow: hidden;
}
.fp-preview-area {
  flex: 1; overflow: hidden;
  background: #1a1a1a;
  display: flex; align-items: center; justify-content: center;
  min-height: 0;
}
.fp-preview-img {
  max-width: 100%; max-height: 100%;
  object-fit: contain;
}
.fp-preview-placeholder, .fp-preview-loading, .fp-preview-error {
  text-align: center; color: rgba(255,255,255,.5); padding: 1rem;
}
.fp-preview-loading { color: rgba(255,255,255,.7); }

/* Pannellum preview inside file picker */
.fp-pann-preview {
  height: 160px; position: relative; flex-shrink: 0;
  border-top: 1px solid var(--border);
}
.fp-pann-label {
  position: absolute; top: 4px; left: 8px; z-index: 10;
  background: rgba(0,0,0,.6); color: #fff;
  padding: 2px 8px; border-radius: 4px; font-size: .72rem;
}
.fp-pann-container { width: 100%; height: 100%; }

.fp-image-info {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: #fafafa;
  font-size: .78rem; min-height: 36px;
}
.fp-selected-bar {
  padding: .4rem .75rem;
  background: #f0f0f0;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  font-size: .8rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════════
   WORKER GAME PAGES
   Full-viewport, mobile-first layout.
   Assumes horizontal phone orientation for best experience.
   ═══════════════════════════════════════════════════════════════ */

/* ── Worker game page: body fills exactly the visible viewport ──
   position:fixed + inset:0 is the ONLY reliable cross-browser way
   to make an element match the visible viewport on iOS Chrome/Safari.
   100dvh / 100svh / 100vh all map to the LARGE viewport on iOS
   (excludes browser chrome), causing content to overflow off-screen.
   With position:fixed; inset:0 the body is always exactly what the
   user can see — no JavaScript needed, works on every browser/OS.   */
body.worker-game-page {
  position: fixed;
  inset: 0;
  overflow: hidden;
  padding-left:  env(safe-area-inset-left,  0px);
  padding-right: env(safe-area-inset-right, 0px);
}

/* Main content column fills the fixed body */
body.worker-game-page main.main-full {
  min-height: 0;
  height: 100%;    /* 100% of fixed body = exactly the visible viewport */
  overflow: hidden;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  position: relative;  /* needed so absolute intro screen is positioned within */
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-sizing: border-box;
}

/* ── HUD bar ──────────────────────────────────────────────── */
.worker-hud {
  height: 50px;
  min-height: 50px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 8px;
  flex-shrink: 0;
  z-index: 10;
}

.worker-hud-logo {
  height: 26px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 5px;
  padding: 2px 4px;
}

.worker-hud-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.worker-hud-name {
  font-size: .75rem;
  color: #c5cae9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.worker-hud-stage {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .3px;
  white-space: nowrap;
}

/* ── Timer ────────────────────────────────────────────────── */
.worker-timer {
  font-family: 'Courier New', monospace;
  font-size: 1.1rem;
  font-weight: 700;
  background: rgba(255,255,255,.15);
  border-radius: 6px;
  padding: 3px 10px;
  flex-shrink: 0;
  min-width: 62px;
  text-align: center;
  transition: background .3s;
}
.worker-timer.timer-warning {
  background: #f57c00;
  animation: timerPulse 1s infinite;
}
.worker-timer.timer-danger {
  background: #c62828;
  animation: timerPulse .5s infinite;
}
@keyframes timerPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .7; }
}

/* ── Submit button in HUD ─────────────────────────────────── */
.worker-submit-btn {
  background: #2e7d32;
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 6px 14px;
  font-weight: 600;
  font-size: .82rem;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
  touch-action: manipulation;
  transition: background .15s;
}
.worker-submit-btn:hover { background: #1b5e20; }
.worker-submit-btn:active { background: #388e3c; }

/* ── 360° viewer area ─────────────────────────────────────── */
.worker-pano {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 120px;   /* always show at least a bit of the viewer */
}

#worker-viewer {
  width: 100%;
  height: 100%;
}

/* ── Drag hint overlay ────────────────────────────────────── */
.worker-drag-hint {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: .72rem;
  padding: 4px 12px;
  border-radius: 20px;
  pointer-events: none;
  z-index: 5;
  white-space: nowrap;
  transition: opacity .5s;
}

/* Instructions overlay on stage start */
.worker-instructions-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}
.worker-instructions-card {
  background: #fff;
  border-radius: 12px;
  padding: 1.25rem;
  max-width: 320px;
  margin: 1rem;
  font-size: .9rem;
}

/* ── Stage intro: full-page cover screen shown before each stage ──
   position:absolute within the position:fixed main — covers the entire
   visible viewport. No z-index battles, no iOS fixed-position bugs.   */
.stage-intro-screen {
  position: absolute;
  inset: 0;
  z-index: 200;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 24px;
  box-sizing: border-box;
  animation: introScreenIn .25s ease forwards;
}
.stage-intro-screen.dismissing {
  animation: introScreenOut .38s ease forwards;
  pointer-events: none;
}
@keyframes introScreenIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes introScreenOut { from { opacity: 1; } to { opacity: 0; } }

.stage-intro-inner {
  text-align: center;
  color: #fff;
  max-width: 380px;
  width: 100%;
}
.stage-intro-icon-lg {
  font-size: 3.2rem;
  line-height: 1;
  margin-bottom: 10px;
  display: block;
}
.stage-intro-badge {
  display: inline-block;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  background: rgba(255,255,255,.22);
  color: #fff;
  border-radius: 20px;
  padding: 4px 16px;
  margin-bottom: 14px;
}
.stage-intro-heading {
  font-size: 1.55rem;
  font-weight: 900;
  color: #fff;
  margin: 0 0 12px;
  line-height: 1.2;
}
.stage-intro-body {
  font-size: .92rem;
  color: rgba(255,255,255,.88);
  line-height: 1.55;
  margin-bottom: 22px;
}
.stage-intro-timer-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.stage-intro-track {
  flex: 1;
  height: 5px;
  background: rgba(255,255,255,.28);
  border-radius: 3px;
  overflow: hidden;
}
.stage-intro-fill {
  height: 100%;
  width: 0%;
  background: #fff;
  border-radius: 3px;
  /* width transitions to 100% via JS to show countdown */
}
.stage-intro-secs {
  font-size: .78rem;
  color: rgba(255,255,255,.75);
  min-width: 28px;
  text-align: right;
}
.stage-intro-start-btn {
  background: rgba(255,255,255,.18);
  border: 2px solid rgba(255,255,255,.6);
  color: #fff;
  border-radius: 14px;
  padding: 12px 32px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  -webkit-appearance: none;
  touch-action: manipulation;
  letter-spacing: .02em;
}
.stage-intro-start-btn:active { background: rgba(255,255,255,.32); }

/* ── Stage bottom label ───────────────────────────────────── */
.worker-bottom-label {
  background: #f5f5f5;
  border-top: 1px solid var(--border);
  padding: 4px 10px;
  font-size: .7rem;
  color: #555;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* (stage intro screen styles are above, near the resize handle section) */

/* ── Stage 1 Counter bar ──────────────────────────────────── */
.worker-counter-bar {
  display: flex;
  overflow-x: auto;
  flex-shrink: 0;
  height: 90px;
  background: #fff;
  border-top: 1px solid var(--border);
  /* Show scrollbar on mobile too */
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  /* Scroll hint gradient on right edge to indicate more content */
  scroll-snap-type: x proximity;
}

.counter-item {
  flex-shrink: 0;
  min-width: 96px;
  max-width: 96px;
  border-right: 1px solid #e8e8e8;
  display: flex;
  align-items: stretch;
}

.counter-item-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 4px;
  width: 100%;
}

.counter-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  padding: 4px;
  object-fit: contain;
  flex-shrink: 0;
}

.counter-label {
  font-size: .72rem;
  color: #555;
  text-align: center;
  line-height: 1.1;
  max-width: 88px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.counter-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 1px;
}

.counter-btn {
  width: 24px;
  height: 24px;
  border: 1px solid #ccc;
  border-radius: 5px;
  background: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  line-height: 1;
  color: #333;
  transition: background .1s, color .1s;
}
.counter-btn:active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.counter-value {
  font-size: 1rem;
  font-weight: 700;
  min-width: 22px;
  text-align: center;
  transition: color .2s;
}
.counter-flash { color: var(--primary) !important; }

/* ── Stage 2/3 Toggle bar ─────────────────────────────────── */
.worker-toggle-bar {
  display: flex;
  overflow-x: auto;
  flex-shrink: 0;
  height: 90px;
  background: #fff;
  border-top: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.toggle-bar-item {
  flex-shrink: 0;
  min-width: 96px;
  max-width: 96px;
  border-right: 1px solid #e8e8e8;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  transition: background .15s;
  display: flex;
  align-items: stretch;
}
.toggle-bar-item:hover { background: #f5f5f5; }
.toggle-bar-item.toggle-bar-item--on {
  background: #fff8e1;
  border-bottom: 3px solid #f9a825;
}

.toggle-item-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 4px;
  width: 100%;
  position: relative;
}

.toggle-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  padding: 4px;
  object-fit: contain;
  flex-shrink: 0;
}

.toggle-label {
  font-size: .72rem;
  color: #555;
  text-align: center;
  line-height: 1.1;
  max-width: 88px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toggle-sublabel {
  font-size: .65rem;
  color: #888;
  text-align: center;
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toggle-checkmark {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #f9a825;
  color: #fff;
  font-size: .6rem;
  display: none;
  align-items: center;
  justify-content: center;
}
.toggle-bar-item--on .toggle-checkmark { display: flex; }

/* ── Pannellum hotspot (stages 2/3) ──────────────────────── */
.worker-hs-wrap {
  /* The outer Pannellum container — our createTooltipFunc styles the inner div */
}

/* ═══════════════════════════════════════════════════════════════
   WORKER RESULTS PAGES
   Scrollable, card-based layout for stage results and scoreboard.
   ═══════════════════════════════════════════════════════════════ */

body.worker-results-page main.main-full {
  padding: 0;
  background: var(--bg);
}

.results-container {
  max-width: 720px;
  margin: 0 auto;
  padding-bottom: 2rem;
}

/* ── Results header ───────────────────────────────────────── */
.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  background: var(--primary);
  color: #fff;
  gap: .75rem;
}

.results-header-left {
  display: flex;
  align-items: center;
  gap: .75rem;
  min-width: 0;
}

.results-logo {
  height: 30px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 5px;
  padding: 2px 5px;
}

.stage-badge {
  font-size: .72rem;
  font-weight: 700;
  padding: .3rem .7rem;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}
.stage-badge-1       { background: #1565C0; }
.stage-badge-2       { background: #f57c00; color: #fff; }
.stage-badge-3       { background: #00695c; }
.stage-badge-complete{ background: #2e7d32; }

/* ── Score card ───────────────────────────────────────────── */
.results-score-card {
  background: #fff;
  text-align: center;
  padding: 1.25rem 1rem .75rem;
  border-bottom: 1px solid var(--border);
}

.results-score-main {
  line-height: 1;
  margin-bottom: .25rem;
}
.results-score-num  { font-size: 2.8rem; font-weight: 800; color: var(--primary); }
.results-score-sep  { font-size: 1.8rem; color: #aaa; margin: 0 .15rem; }
.results-score-max  { font-size: 1.8rem; font-weight: 600; color: #555; }
.results-score-label { font-size: .8rem; color: var(--text-muted); margin-bottom: .5rem; }

.results-score-bar-wrap {
  height: 8px;
  background: #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
  margin: .5rem auto 0;
  max-width: 300px;
}
.results-score-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width .5s ease-out;
}

/* ── Results sections ─────────────────────────────────────── */
.results-section {
  background: #fff;
  margin: .75rem .75rem 0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: .75rem;
  box-shadow: var(--shadow);
}

.results-section-title {
  font-size: .9rem;
  font-weight: 700;
  margin-bottom: .5rem;
  color: var(--primary);
}

/* ── Results table ────────────────────────────────────────── */
.results-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}
.results-table th {
  background: #f5f5f5;
  padding: .4rem .6rem;
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.results-table td {
  padding: .4rem .6rem;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}
.results-table tbody tr:last-child td { border-bottom: none; }

.results-row-correct { background: #f1f8e9; }
.results-row-wrong   { background: #fce4ec; }

.risk-type-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

/* ── Results 360 viewer ───────────────────────────────────── */
.results-viewer-wrap {
  height: 260px;
  border-radius: 6px;
  overflow: hidden;
}
/* Video results: let the video determine its own height */
.results-viewer-wrap--video {
  height: auto;
  overflow: visible;
  background: #000;
  border-radius: 8px;
}

.results-viewer-wrap #results-viewer {
  width: 100%;
  height: 100%;
}

/* ── Marker result legend dots ────────────────────────────── */
.marker-legend {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid;
  vertical-align: middle;
  margin-right: 2px;
}
.marker-legend-correct { border-color: #2e7d32; background: rgba(46,125,50,.15); }
.marker-legend-wrong   { border-color: #b71c1c; background: rgba(183,28,28,.15); }

/* ── Marker note cards ────────────────────────────────────── */
.marker-note-card {
  background: #f9f9f9;
  border-left: 3px solid var(--primary);
  border-radius: 0 6px 6px 0;
  padding: .5rem .75rem;
  margin-bottom: .5rem;
}
.marker-note-title {
  font-size: .8rem;
  font-weight: 700;
  margin-bottom: .2rem;
}

/* ── Continue / action buttons ────────────────────────────── */
.results-actions {
  padding: 1rem .75rem 0;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.results-continue-btn {
  width: 100%;
  text-align: center;
}

/* ═══════════════════════════════════════════════════════════════
   COMPLETE PAGE — score hero + charts
   ═══════════════════════════════════════════════════════════════ */

.complete-hero {
  text-align: center;
  background: linear-gradient(135deg, var(--primary) 0%, #283593 100%);
  color: #fff;
  padding: 1.5rem 1rem 1rem;
}

.complete-hero-score {
  line-height: 1;
  margin-bottom: .15rem;
}
.complete-hero-num  { font-size: 3.5rem; font-weight: 800; }
.complete-hero-sep  { font-size: 2rem; opacity: .6; margin: 0 .2rem; }
.complete-hero-max  { font-size: 2rem; opacity: .8; }
.complete-hero-label { font-size: .85rem; opacity: .8; margin-bottom: .35rem; }
.complete-hero-pct {
  font-size: 1.8rem;
  font-weight: 700;
  background: rgba(255,255,255,.18);
  display: inline-block;
  padding: .1rem .8rem;
  border-radius: 20px;
  margin-bottom: .35rem;
}
.complete-hero-rank {
  font-size: .78rem;
  opacity: .85;
}

/* Competitive score display in hero */
.comp-score-box {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: rgba(255,165,0,.15);
  border: 1px solid rgba(255,165,0,.4);
  border-radius: 12px;
  padding: 6px 16px;
  margin-top: 8px;
  color: #fff;
}
.comp-score-num  { font-size: 1.4rem; font-weight: 900; color: #ffd54f; }
.comp-score-sep  { font-size: 1rem; opacity: .7; }
.comp-score-max  { font-size: .9rem; opacity: .75; }
.comp-score-label { font-size: .72rem; font-weight: 600; letter-spacing: .05em;
                    text-transform: uppercase; opacity: .8; margin-left: .3rem; }

/* Per-stage competitive points badge */
.comp-stage-pts {
  font-size: .72rem;
  font-weight: 700;
  color: #ffa500;
  margin-top: .35rem;
  text-align: center;
}

/* ── Stage summary cards ──────────────────────────────────── */
.complete-stage-cards {
  display: flex;
  gap: .5rem;
  padding: .75rem .75rem 0;
}

.complete-stage-card {
  flex: 1;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .6rem .5rem;
  text-align: center;
  box-shadow: var(--shadow);
  min-width: 0;
}

.complete-stage-card-label {
  font-size: .65rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: .5px;
  text-transform: uppercase;
}

.complete-stage-card-title {
  font-size: .7rem;
  color: var(--text-muted);
  margin-bottom: .2rem;
}

.complete-stage-card-score {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
}

.complete-stage-bar-wrap {
  height: 5px;
  background: #e0e0e0;
  border-radius: 3px;
  overflow: hidden;
  margin-top: .3rem;
}
.complete-stage-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
}

/* ── Chart wrappers ───────────────────────────────────────── */
.chart-wrap {
  position: relative;
  height: 220px;
}
.chart-wrap-sm { height: 160px; }

/* ── Scoreboard self-row highlight ───────────────────────── */
.scoreboard-self-row {
  background: #e8eaf6 !important;
  font-weight: 600;
}
.scoreboard-self-row td { border-top: 2px solid var(--primary); border-bottom: 2px solid var(--primary); }

/* ── Responsive: small phones (narrow landscape) ─────────── */
@media (max-height: 420px) {
  .worker-hud          { height: 42px; min-height: 42px; }
  .worker-hud-logo     { height: 22px; }
  .worker-timer        { font-size: .95rem; padding: 2px 7px; }
  .worker-submit-btn   { padding: 4px 10px; font-size: .78rem; }
  .worker-counter-bar,
  .worker-toggle-bar   { height: calc(72px + env(safe-area-inset-bottom, 0px)); }
  .worker-pano         { min-height: 80px; }
}

@media (max-width: 400px) {
  .worker-hud-stage { display: none; }
  .counter-item, .toggle-bar-item { min-width: 84px; max-width: 84px; }
}

/* ── iPhone safe-area adjustments ────────────────────────── */
/* Bottom bars include safe-area padding so content stays above home indicator.
   Use border-box so total height = 90px content + safe-area, not 90px + safe-area extra. */
.worker-counter-bar,
.worker-toggle-bar {
  height: calc(100px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-sizing: border-box;
}
/* (max-height 420px bar height set above in the landscape media block) */

/* ── Worker Survey Page ────────────────────────────────────────────────────── */

.survey-page {
  max-width: 680px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

.survey-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #dee2e6;
}

.survey-logo {
  height: 44px;
  width: auto;
  flex-shrink: 0;
}

.survey-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: #212529;
}

.survey-subtitle {
  font-size: 0.875rem;
  color: #6c757d;
  margin-top: 2px;
}

.survey-intro {
  background: #f0f7ff;
  border-left: 4px solid #0d6efd;
  border-radius: 6px;
  padding: 12px 16px;
  font-size: 0.9rem;
  margin-bottom: 24px;
  color: #495057;
}

/* Individual question card */
.survey-question-card {
  display: flex;
  gap: 14px;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 10px;
  padding: 18px 16px;
  margin-bottom: 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
  transition: box-shadow .15s;
}

.survey-question-card:focus-within {
  box-shadow: 0 2px 10px rgba(13,110,253,.2);
  border-color: #86b7fe;
}

.survey-q-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #0d6efd;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.survey-q-body {
  flex: 1;
}

.survey-q-text {
  font-size: 0.95rem;
  font-weight: 500;
  color: #212529;
  margin-bottom: 14px;
}

/* Likert 1–5 row */
.likert-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.likert-label-left,
.likert-label-right {
  font-size: 0.72rem;
  color: #6c757d;
  text-align: center;
  line-height: 1.2;
  min-width: 52px;
}

.likert-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  margin: 0;
}

.likert-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.likert-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid #ced4da;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: #6c757d;
  background: #fff;
  transition: border-color .15s, background .15s, color .15s;
  user-select: none;
}

.likert-option:hover .likert-circle {
  border-color: #0d6efd;
  color: #0d6efd;
}

.likert-option.selected .likert-circle {
  background: #0d6efd;
  border-color: #0d6efd;
  color: #fff;
}

/* Yes / No row */
.yesno-group {
  display: flex;
  gap: 12px;
}

.yesno-option {
  cursor: pointer;
  margin: 0;
}

.yesno-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.yesno-btn {
  display: inline-flex;
  align-items: center;
  padding: 8px 22px;
  border-radius: 8px;
  border: 2px solid #ced4da;
  font-weight: 600;
  font-size: 0.9rem;
  color: #6c757d;
  background: #fff;
  transition: border-color .15s, background .15s, color .15s;
  user-select: none;
}

.yesno-option:hover .yesno-btn { border-color: #adb5bd; }

.yesno-option.selected .yes-btn {
  background: #198754;
  border-color: #198754;
  color: #fff;
}

.yesno-option.selected .no-btn {
  background: #dc3545;
  border-color: #dc3545;
  color: #fff;
}

/* Free-text textarea */
.survey-textarea {
  font-size: 0.9rem;
  resize: vertical;
}

/* Submit + skip row */
.survey-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 28px;
}

.survey-submit-btn {
  width: 100%;
  max-width: 340px;
  padding: 12px;
  font-size: 1rem;
}

.survey-skip-btn {
  font-size: 0.85rem;
  color: #6c757d;
}

/* Mobile adjustments */
@media (max-width: 480px) {
  .likert-group { gap: 4px; }
  .likert-label-left, .likert-label-right { display: none; }
  .likert-circle { width: 34px; height: 34px; font-size: 0.8rem; }
  .yesno-btn { padding: 8px 14px; }
}

/* ── Survey Editor (Instructor Tab) ───────────────────────────────────────── */

.survey-editor-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  margin-bottom: 8px;
  background: #fff;
  font-size: 0.85rem;
}

.survey-editor-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #6c757d;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.survey-editor-main {
  flex: 1;
  min-width: 0;
}

.survey-editor-qtext {
  font-weight: 500;
  color: #343a40;
  margin-bottom: 4px;
  word-break: break-word;
}

.survey-editor-badge {
  font-size: 0.7rem;
}

.survey-editor-actions {
  display: flex;
  flex-shrink: 0;
  align-items: center;
}

.btn-xs {
  padding: 2px 7px;
  font-size: 0.75rem;
  line-height: 1.4;
  border-radius: 4px;
}

.survey-editor-add-form {
  font-size: 0.85rem;
}

/* ── Supervised session mode — shared styles ───────────────────────────── */

/* Mode badge on session cards */
.session-mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.3px;
}
.session-mode-supervised   { background: rgba(25,118,210,0.22); color: #90caf9; }
.session-mode-unsupervised { background: rgba(255,255,255,0.12); color: rgba(255,255,255,0.75); }

/* Supervised stage progress line on session cards */
.supervisor-stage-bar {
  display: flex;
  gap: 3px;
  margin-top: 6px;
}
.supervisor-stage-pip {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.2);
  transition: background 0.3s;
}
.supervisor-stage-pip.active   { background: #81c784; }
.supervisor-stage-pip.complete { background: #a5d6a7; }

/* Modal mode option cards */
.mode-option-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  border: 2px solid #dee2e6;
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: #fff;
}
.mode-option-card:hover { border-color: #90caf9; background: #f0f7ff; }
.btn-check:checked + .mode-option-card {
  border-color: var(--primary);
  background: #e8f0fe;
}
.mode-option-icon {
  font-size: 1.6rem;
  color: #6c757d;
  width: 36px;
  text-align: center;
  flex-shrink: 0;
  padding-top: 2px;
}
.btn-check:checked + .mode-option-card .mode-option-icon { color: var(--primary); }
.mode-option-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: #212529;
  margin-bottom: 3px;
}
.mode-option-desc {
  font-size: 0.8rem;
  color: #6c757d;
  line-height: 1.4;
}

/* ── Instructor Control Panel ──────────────────────────────────────────── */

.control-panel-wrap {
  display: flex;
  height: calc(100vh - 0px);
  overflow: hidden;
}

.control-panel-viewer {
  flex: 1;
  position: relative;
  background: #000;
  min-width: 0;
}
.control-panel-viewer #cp-viewer {
  width: 100%;
  height: 100%;
}

.control-panel-sidebar {
  width: 340px;
  flex-shrink: 0;
  background: #1a237e;
  color: #fff;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.cp-sidebar-header {
  padding: 16px 18px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
}
.cp-session-code {
  font-family: 'Courier New', monospace;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 6px;
  color: #fff;
}
.cp-sidebar-section {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
}
.cp-sidebar-section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.5);
  margin-bottom: 10px;
}

/* Stage stepper */
.cp-stage-stepper {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cp-stage-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  opacity: 0.45;
  transition: opacity 0.3s, background 0.3s;
}
.cp-stage-step.done    { opacity: 0.6; background: rgba(129,199,132,0.12); }
.cp-stage-step.current { opacity: 1;   background: rgba(255,255,255,0.12); font-weight: 700; }
.cp-stage-icon {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem;
  background: rgba(255,255,255,0.15);
  flex-shrink: 0;
}
.cp-stage-step.done    .cp-stage-icon { background: #2e7d32; }
.cp-stage-step.current .cp-stage-icon { background: var(--primary); }

/* Worker counts */
.cp-worker-counts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.cp-count-box {
  background: rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 8px 10px;
  text-align: center;
}
.cp-count-num {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1;
  color: #fff;
}
.cp-count-label {
  font-size: 0.68rem;
  color: rgba(255,255,255,0.55);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Control buttons */
.cp-control-btn {
  width: 100%;
  margin-bottom: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: 8px;
  padding: 10px 14px;
}
.cp-control-btn:last-child { margin-bottom: 0; }

/* Worker list */
.cp-worker-list {
  font-size: 0.8rem;
}
.cp-worker-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.cp-worker-row:last-child { border-bottom: none; }
.cp-worker-name { color: rgba(255,255,255,0.85); }
.cp-worker-stage-badge {
  font-size: 0.65rem;
  padding: 2px 7px;
  border-radius: 10px;
}

/* ── Control panel final results panel ─────────────────────── */
.cp-final-stat {
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 10px;
  padding: 10px 20px;
  text-align: center;
  min-width: 100px;
}
.cp-final-stat-num {
  font-size: 1.6rem;
  font-weight: 900;
  color: #fff;
  line-height: 1;
}
.cp-final-stat-label {
  font-size: .72rem;
  color: rgba(255,255,255,.5);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-top: 3px;
}
.cp-final-table {
  width: 100%;
  border-collapse: collapse;
  color: #e2e8f0;
  font-size: .85rem;
}
.cp-final-table thead th {
  background: rgba(255,255,255,.08);
  padding: 8px 12px;
  font-weight: 600;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: rgba(255,255,255,.6);
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.cp-final-table tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.cp-final-table tbody tr:hover td {
  background: rgba(255,255,255,.04);
}

/* ── Worker Supervised Waiting Page ───────────────────────────────────── */

/* Allow scrolling when the waiting card is shown */
body.worker-game-page main.main-full:has(.supervised-waiting-page) {
  overflow: auto;
  height: auto;
}

.supervised-waiting-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a237e 0%, #283593 60%, #1565c0 100%);
  padding: 2rem;
}

.supervised-waiting-card {
  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 18px;
  padding: 3rem 2.5rem;
  max-width: 480px;
  width: 100%;
  text-align: center;
  color: #fff;
}

.supervised-waiting-pulse {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin: 0 auto 1.5rem;
  animation: sw-pulse 2s ease-in-out infinite;
}

@keyframes sw-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,255,255,0.3); }
  50% { box-shadow: 0 0 0 18px rgba(255,255,255,0); }
}

.supervised-waiting-code {
  font-family: 'Courier New', monospace;
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: 8px;
  color: #90caf9;
  margin: 1rem 0;
}

.supervised-waiting-username {
  font-size: 0.9rem;
  color: rgba(255,255,255,0.65);
}

/* Add bottom padding to results container when supervised overlay is present */
.results-container:has(~ .supervised-wait-overlay) {
  padding-bottom: 80px;
}

/* ── Supervised waiting overlay on results pages ──────────────────────── */

.supervised-wait-overlay {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(0deg, rgba(26,35,126,0.97) 0%, rgba(26,35,126,0.85) 100%);
  color: #fff;
  padding: 20px;
  text-align: center;
  z-index: 999;
  border-top: 2px solid rgba(144,202,249,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.supervised-wait-overlay .spinner-border {
  width: 1.3rem; height: 1.3rem;
  border-width: 2px;
}
.supervised-wait-text {
  font-size: 0.9rem;
  font-weight: 600;
}
.supervised-wait-sub {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.65);
  margin-top: 1px;
}

/* ═══════════════════════════════════════════════════════════════
   VIDEO SCENARIO — Instructor Editor
   ═══════════════════════════════════════════════════════════════ */

/* Video editor wrap: sizes itself to video's natural aspect ratio */
.video-editor-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #000;
  border-radius: 4px;
}
.video-editor-wrap video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Transparent overlay that receives clicks for marker placement.
   Stops above the control bar (bottom: 40px) so controls stay clickable. */
.editor-marker-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 40px;  /* reserve space for control bar */
  z-index: 10;
  /* cursor set to crosshair by JS when in add-mode */
}

/* Control bar overlaid at the very bottom of the video wrap */
.editor-video-ctrl-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  border-radius: 0 0 4px 4px;
}

/* Marker dot placed on video frame in editor */
.editor-video-marker {
  position: absolute;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.55);
  overflow: hidden;
  cursor: pointer;
  z-index: 11;
  transition: transform 0.1s;
}
.editor-video-marker:hover {
  transform: translate(-50%, -50%) scale(1.15);
}

/* ═══════════════════════════════════════════════════════════════
   VIDEO SCENARIO — Worker Game Viewer
   ═══════════════════════════════════════════════════════════════ */

/* Outer container fills worker-pano (flex: 1) */
.video-worker-outer {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background: #000;
}

/* CSS pseudo-fullscreen: covers entire screen when native FS API unavailable (iOS) */
.video-worker-outer.pseudo-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  z-index: 9999 !important;
  width: 100vw !important;
  height: 100vh !important;  /* intentional: in pseudo-fs we want the whole screen */
  border-radius: 0 !important;
}
/* Hide game UI behind the pseudo-fullscreen overlay */
body.has-pseudo-fullscreen .worker-hud,
body.has-pseudo-fullscreen .worker-bottom-label,
body.has-pseudo-fullscreen .worker-counter-bar,
body.has-pseudo-fullscreen .worker-toggle-bar,
body.has-pseudo-fullscreen .stage-intro-screen {
  display: none !important;
}

/* Video centering area — takes all remaining height above ctrl bar */
.video-worker-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  background: #000;
}

/* Sized-to-aspect-ratio container; scaled by pinch-to-zoom */
.video-scale-container {
  position: relative;
  overflow: hidden;
  transform-origin: center center;
  transition: transform 0.05s linear;
  /* width/height set by JS */
}
.video-scale-container video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
}

/* Marker overlay on top of video */
.video-worker-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;  /* stage 1: no interaction */
}
.video-worker-overlay.interactive {
  pointer-events: auto;  /* stages 2/3: markers clickable */
}

/* Marker dot in worker view */
.video-worker-marker {
  position: absolute;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  border: 3px solid rgba(255,255,255,0.85);
  box-shadow: 0 2px 8px rgba(0,0,0,.5);
  overflow: hidden;
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  touch-action: manipulation;
  user-select: none;
}
.video-worker-marker.selected,
.video-worker-marker[style*="border: 3px solid #FFF176"] {
  box-shadow: 0 0 12px 3px rgba(255,235,59,0.7);
}

/* Custom video control bar */
.video-ctrl-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(0,0,0,0.75);
  flex-shrink: 0;
}

.video-ctrl-btn {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1rem;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 4px;
  line-height: 1;
  transition: background 0.15s;
}
.video-ctrl-btn:hover  { background: rgba(255,255,255,0.15); }
.video-ctrl-btn:active { background: rgba(255,255,255,0.3); }

/* Scrub bar */
.video-scrubber {
  flex: 1;
  height: 4px;
  accent-color: #90caf9;
  cursor: pointer;
  touch-action: auto;  /* allow horizontal drag on the range input */
}

/* ── File Picker Modal ───────────────────────────────────────────────────── */

.fp-modal-body {
  min-height: 300px;
  max-height: 60vh;
  overflow-y: auto;
}

/* Image grid */
.fp-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
}

.fp-image-card {
  border: 2px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  background: var(--bs-light, #f8f9fa);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.fp-image-card:hover {
  border-color: #86b7fe;
  box-shadow: 0 0 0 2px rgba(13,110,253,.15);
}
.fp-image-card.selected {
  border-color: #0d6efd;
  box-shadow: 0 0 0 3px rgba(13,110,253,.3);
}

.fp-thumb-wrap {
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e9ecef;
}
.fp-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.fp-card-name {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 6px 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fp-card-meta {
  font-size: 0.7rem;
  color: var(--bs-secondary, #6c757d);
  padding: 0 6px 5px;
}

/* Video list */
.fp-video-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fp-video-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 2px solid transparent;
  border-radius: 8px;
  background: var(--bs-light, #f8f9fa);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.fp-video-card:hover {
  border-color: #86b7fe;
  box-shadow: 0 0 0 2px rgba(13,110,253,.15);
}
.fp-video-card.selected {
  border-color: #0d6efd;
  box-shadow: 0 0 0 3px rgba(13,110,253,.3);
  background: #e7f1ff;
}

.fp-video-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e3f2fd;
  border-radius: 6px;
}

.fp-video-info {
  min-width: 0;
}
.fp-video-info .fp-card-name {
  padding: 0;
  font-size: 0.85rem;
}
.fp-video-info .fp-card-meta {
  padding: 2px 0 0;
  font-size: 0.75rem;
}

/* ── Admin Media Library ─────────────────────────────────────────────────── */

.media-thumb-sm {
  width: 56px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  display: block;
}

/* ── DC choice bottom sheet (worker Stage 3) ─────────────────────────────── */

.dc-choice-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1040;
}
.dc-choice-backdrop.active { display: block; }

.dc-choice-sheet {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  border-radius: 16px 16px 0 0;
  padding: 16px 16px 32px;
  z-index: 1050;
  max-height: 70vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.25s ease;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.2);
}
.dc-choice-sheet.active { transform: translateY(0); }

.dc-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 1rem;
  font-weight: 600;
}
.dc-sheet-subtitle {
  margin-bottom: 12px;
  color: #6c757d;
  font-size: 0.85rem;
}

.dc-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: #f8f9fa;
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  text-align: left;
  font-size: 0.95rem;
  transition: border-color 0.15s, background 0.15s;
}
.dc-option:hover    { border-color: #0d6efd; background: #e8f0fe; }
.dc-option--selected { border-color: #0d6efd; background: #dbeafe; }

.dc-option-radio {
  font-size: 1.2rem;
  color: #0d6efd;
  flex-shrink: 0;
  line-height: 1;
}
.dc-option-text { flex: 1; }

/* ── DC choice rows in scenario editor ───────────────────────────────────── */

.dc-choice-row {
  background: #f8f9fa;
  border-radius: 6px;
  padding: 6px 8px;
}

/* ── Toggle bar choice indicator ─────────────────────────────────────────── */

.toggle-choice-indicator {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.7);
  margin-top: 2px;
}
.toggle-bar-item--on .toggle-choice-indicator {
  color: #FFF176;
}
