/* ── CSS Variables ─────────────────────────────────────────── */
        :root {
            --bg:          #0a0a0a;
            --bg-panel:    #111111;
            --bg-raised:   #1a1a1a;
            --text:        #f0f0e8;
            --text-dim:    #888880;
            --accent:      #d4a017;
            --accent-dim:  #8b6a10;
            --accent-glow: rgba(212, 160, 23, 0.15);
            --danger:      #c0392b;
            --success:     #27ae60;
            --border:      rgba(212, 160, 23, 0.2);
            --radius:      8px;
        }

        /* ── Reset / Base ──────────────────────────────────────────── */
        *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

        body {
            background: var(--bg);
            color: var(--text);
            font-family: 'Georgia', serif;
            height: 100vh;
            overflow: hidden;
            display: flex;
            flex-direction: column;
        }

        /* ── Entry Screen ──────────────────────────────────────────── */
        #entryScreen {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            min-height: 100vh;
            gap: 32px;
            padding: calc(var(--nav-height, 60px) + 40px) 40px 40px;
            background: radial-gradient(ellipse at center, #1a1400 0%, var(--bg) 70%);
        }

        #entryScreen h1 {
            font-size: clamp(2.5rem, 6vw, 4.5rem);
            color: var(--accent);
            text-align: center;
            letter-spacing: 0.04em;
            text-shadow: 0 0 40px rgba(212, 160, 23, 0.4);
            line-height: 1.1;
        }

        #entryScreen .subtitle {
            font-size: 1.1rem;
            color: var(--text-dim);
            text-align: center;
            font-style: italic;
            letter-spacing: 0.05em;
        }

        .entry-card {
            background: var(--bg-panel);
            border: 1px solid var(--border);
            border-radius: 12px;
            padding: 36px 40px;
            width: 100%;
            max-width: 560px;
            display: flex;
            flex-direction: column;
            gap: 24px;
        }

        .entry-card label {
            display: block;
            font-size: 0.8rem;
            letter-spacing: 0.12em;
            text-transform: uppercase;
            color: var(--text-dim);
            margin-bottom: 8px;
        }

        .entry-card input[type="text"],
        .entry-card select {
            width: 100%;
            background: var(--bg-raised);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            color: var(--text);
            font-family: inherit;
            font-size: 1rem;
            padding: 10px 14px;
            outline: none;
            transition: border-color 0.2s;
        }

        .entry-card input[type="text"]:focus,
        .entry-card select:focus {
            border-color: var(--accent);
        }

        /* ── Personality Dials ─────────────────────────────────────── */
        .dials-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 16px;
        }

        .dial-row {
            display: flex;
            flex-direction: column;
            gap: 6px;
        }

        .dial-label-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .dial-label {
            font-size: 0.75rem;
            letter-spacing: 0.1em;
            text-transform: uppercase;
            color: var(--text-dim);
        }

        .dial-value {
            font-size: 0.85rem;
            color: var(--accent);
            font-variant-numeric: tabular-nums;
            min-width: 28px;
            text-align: right;
        }

        input[type="range"] {
            -webkit-appearance: none;
            width: 100%;
            height: 4px;
            background: var(--bg-raised);
            border-radius: 2px;
            outline: none;
            cursor: pointer;
        }

        input[type="range"]::-webkit-slider-thumb {
            -webkit-appearance: none;
            width: 16px;
            height: 16px;
            border-radius: 50%;
            background: var(--accent);
            cursor: pointer;
            transition: transform 0.15s;
        }

        input[type="range"]::-webkit-slider-thumb:hover {
            transform: scale(1.3);
        }

        /* Track fill via gradient, updated by JS */
        input[type="range"].filled {
            background: linear-gradient(to right, var(--accent) 0%, var(--accent) var(--pct, 50%), var(--bg-raised) var(--pct, 50%));
        }

        .character-select {
            grid-column: 1 / -1;
        }

        /* ── Buttons ───────────────────────────────────────────────── */
        .btn-stage {
            background: var(--accent);
            color: #0a0a0a;
            border: none;
            border-radius: var(--radius);
            font-family: inherit;
            font-size: 1.1rem;
            font-weight: bold;
            letter-spacing: 0.06em;
            padding: 14px 28px;
            cursor: pointer;
            transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
            width: 100%;
        }

        .btn-stage:hover {
            background: #e8b520;
            box-shadow: 0 0 20px rgba(212, 160, 23, 0.4);
        }

        .btn-stage:active { transform: scale(0.98); }

        .btn-tool {
            background: var(--bg-raised);
            color: var(--text);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            font-family: inherit;
            font-size: 0.85rem;
            letter-spacing: 0.04em;
            padding: 8px 14px;
            cursor: pointer;
            transition: background 0.15s, border-color 0.15s;
            white-space: nowrap;
        }

        .btn-tool:hover {
            background: var(--accent-glow);
            border-color: var(--accent);
            color: var(--accent);
        }

        .btn-tool:active { transform: scale(0.97); }

        .btn-tool.active {
            background: var(--accent-glow);
            border-color: var(--accent);
            color: var(--accent);
        }

        .btn-icon {
            background: none;
            border: 1px solid var(--border);
            border-radius: var(--radius);
            color: var(--text-dim);
            font-size: 1rem;
            padding: 6px 10px;
            cursor: pointer;
            transition: color 0.15s, border-color 0.15s;
        }

        .btn-icon:hover { color: var(--accent); border-color: var(--accent); }

        /* ── Classroom Layout ──────────────────────────────────────── */
        #classroomScreen {
            display: none;
            flex-direction: column;
            height: 100vh;
            overflow: hidden;
        }

        /* Top bar, session info + controls toggle */
        #topBar {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 10px 20px;
            background: var(--bg-panel);
            border-bottom: 1px solid var(--border);
            flex-shrink: 0;
            gap: 12px;
        }

        #sessionName {
            font-size: 0.9rem;
            color: var(--accent);
            letter-spacing: 0.08em;
            text-transform: uppercase;
        }

        .topbar-controls {
            display: flex;
            gap: 8px;
            align-items: center;
        }

        /* Main content row */
        #mainRow {
            display: flex;
            flex: 1;
            overflow: hidden;
        }

        /* Stage, the big display */
        #stage {
            flex: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 40px 60px;
            background: radial-gradient(ellipse at center, #140f00 0%, var(--bg) 65%);
            overflow: hidden;
            position: relative;
        }

        #stageLabel {
            position: absolute;
            top: 20px;
            left: 0;
            right: 0;
            text-align: center;
            font-size: 0.7rem;
            letter-spacing: 0.18em;
            text-transform: uppercase;
            color: var(--accent-dim);
            opacity: 0.6;
        }

        #stageText {
            font-size: clamp(2rem, 5vw, 3.5rem);
            line-height: 1.35;
            text-align: center;
            color: var(--text);
            max-width: 900px;
            text-shadow: 0 2px 20px rgba(0,0,0,0.8);
            opacity: 0;
            transform: translateY(24px);
            transition: opacity 0.5s ease, transform 0.5s ease;
        }

        #stageText.visible {
            opacity: 1;
            transform: translateY(0);
        }

        #stagePlaceholder {
            font-size: 1.2rem;
            color: var(--text-dim);
            font-style: italic;
            opacity: 0.5;
            text-align: center;
        }

        /* Loading pulse on stage */
        #stageLoader {
            display: none;
            gap: 8px;
            align-items: center;
        }

        #stageLoader span {
            width: 10px;
            height: 10px;
            background: var(--accent);
            border-radius: 50%;
            animation: pulse 1.2s ease-in-out infinite;
        }

        #stageLoader span:nth-child(2) { animation-delay: 0.2s; }
        #stageLoader span:nth-child(3) { animation-delay: 0.4s; }

        @keyframes pulse {
            0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
            40% { transform: scale(1); opacity: 1; }
        }

        /* Timer (on stage, toggled) */
        #timerDisplay {
            position: absolute;
            bottom: 24px;
            right: 28px;
            font-size: 2.4rem;
            font-variant-numeric: tabular-nums;
            color: var(--accent);
            letter-spacing: 0.05em;
            text-shadow: 0 0 20px rgba(212, 160, 23, 0.4);
            display: none;
        }

        #timerDisplay.running { display: block; }
        #timerDisplay.warning { color: #e74c3c; animation: timerBlink 0.8s steps(1) infinite; }

        @keyframes timerBlink {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.3; }
        }

        /* Scoreboard sidebar */
        #scoreboard {
            width: 220px;
            background: var(--bg-panel);
            border-left: 1px solid var(--border);
            display: none;
            flex-direction: column;
            overflow-y: auto;
            flex-shrink: 0;
        }

        #scoreboard.open { display: flex; }

        .sb-header {
            padding: 14px 16px;
            font-size: 0.7rem;
            letter-spacing: 0.15em;
            text-transform: uppercase;
            color: var(--accent);
            border-bottom: 1px solid var(--border);
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .sb-body {
            flex: 1;
            padding: 8px;
            display: flex;
            flex-direction: column;
            gap: 4px;
        }

        .sb-row {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 8px 10px;
            border-radius: var(--radius);
            background: var(--bg-raised);
            transition: background 0.2s;
        }

        .sb-row:hover { background: var(--accent-glow); }

        .sb-rank {
            font-size: 0.75rem;
            color: var(--text-dim);
            min-width: 18px;
        }

        .sb-name {
            flex: 1;
            font-size: 0.9rem;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .sb-pts {
            font-size: 1rem;
            color: var(--accent);
            font-weight: bold;
            min-width: 28px;
            text-align: right;
        }

        .sb-plus {
            background: none;
            border: 1px solid var(--border);
            border-radius: 4px;
            color: var(--text-dim);
            font-size: 0.8rem;
            padding: 2px 6px;
            cursor: pointer;
            transition: color 0.15s, border-color 0.15s;
        }

        .sb-plus:hover { color: var(--accent); border-color: var(--accent); }

        .sb-add-row {
            display: flex;
            gap: 6px;
            padding: 8px;
            border-top: 1px solid var(--border);
            margin-top: auto;
        }

        .sb-add-input {
            flex: 1;
            background: var(--bg-raised);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            color: var(--text);
            font-family: inherit;
            font-size: 0.85rem;
            padding: 6px 10px;
            outline: none;
        }

        .sb-add-input:focus { border-color: var(--accent); }

        .sb-add-btn {
            background: var(--accent);
            color: var(--bg);
            border: none;
            border-radius: var(--radius);
            font-size: 0.85rem;
            font-weight: bold;
            padding: 6px 12px;
            cursor: pointer;
        }

        /* ── Controls Panel ────────────────────────────────────────── */
        #controlsPanel {
            background: var(--bg-panel);
            border-top: 1px solid var(--border);
            padding: 12px 20px;
            flex-shrink: 0;
            display: flex;
            flex-direction: column;
            gap: 10px;
        }

        .controls-row {
            display: flex;
            gap: 8px;
            flex-wrap: wrap;
            align-items: center;
        }

        .ctrl-input {
            flex: 1;
            min-width: 180px;
            background: var(--bg-raised);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            color: var(--text);
            font-family: inherit;
            font-size: 0.9rem;
            padding: 8px 12px;
            outline: none;
        }

        .ctrl-input:focus { border-color: var(--accent); }

        .ctrl-input::placeholder { color: var(--text-dim); opacity: 0.6; }

        .ctrl-select {
            background: var(--bg-raised);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            color: var(--text);
            font-family: inherit;
            font-size: 0.85rem;
            padding: 8px 10px;
            outline: none;
        }

        /* ── Personality Panel (toggle) ────────────────────────────── */
        #personalityPanel {
            background: var(--bg-raised);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            padding: 16px;
            display: none;
            flex-direction: column;
            gap: 14px;
        }

        #personalityPanel.open { display: flex; }

        .personality-inline-grid {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 12px;
            align-items: end;
        }

        .personality-inline-grid .dial-row { gap: 4px; }

        /* ── Timer controls ────────────────────────────────────────── */
        #timerControls {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        #timerInput {
            width: 64px;
            text-align: center;
        }

        /* ── Overlay for non-coach ─────────────────────────────────── */
        #accessDenied {
            display: none;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            height: 100vh;
            gap: 20px;
            padding: 40px;
            text-align: center;
        }

        #accessDenied h2 { font-size: 2rem; color: var(--accent); }
        #accessDenied p { color: var(--text-dim); font-size: 1rem; }

        /* ── Exit link ─────────────────────────────────────────────── */
        .exit-link {
            font-size: 0.75rem;
            color: var(--text-dim);
            text-decoration: none;
            letter-spacing: 0.06em;
            transition: color 0.15s;
        }

        .exit-link:hover { color: var(--accent); }

        /* ── Utilities ─────────────────────────────────────────────── */
        .hidden { display: none !important; }
        .text-accent { color: var(--accent); }
        .divider-rule { border: none; border-top: 1px solid var(--border); }

        /* Spinning icon */
        @keyframes spin { to { transform: rotate(360deg); } }
        .spin { display: inline-block; animation: spin 0.8s linear infinite; }
