/* ═══════════════════════════════════════════════
   IMPROV — Design System v7 (DM Sans + Bebas Neue)
   ═══════════════════════════════════════════════ */

:root {
    --bg: #0a0a0f;
    --bg2: #12121a;
    --bg3: #18181f;
    --surface: #1e1e28;
    --border: rgba(255, 255, 255, 0.07);
    --accent: #7c6dfa;
    --accent2: #a598ff;
    --glow: rgba(124, 109, 250, 0.35);
    --text: #f0eeff;
    --text-dim: rgba(240, 238, 255, 0.55);
    --text-muted: rgba(240, 238, 255, 0.32);
    --danger: #ff5c5c;
    --success: #3dffa0;

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --transition: 0.2s ease;
}

.light-mode {
    --bg: #f8f9fa;
    --bg2: #ffffff;
    --bg3: #f0f2f5;
    --surface: #ffffff;
    --border: rgba(0, 0, 0, 0.1);
    --accent: #5a4fcf;
    --accent2: #7c6dfa;
    --glow: rgba(90, 79, 207, 0.2);
    --text: #000000;
    --text-dim: rgba(0, 0, 0, 0.7);
    --text-muted: rgba(0, 0, 0, 0.5);

    background: var(--bg);
    color: var(--text);
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
}

/* Ambient glow background */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 60% 40% at 20% 10%, rgba(124, 109, 250, 0.1) 0%, transparent 70%),
        radial-gradient(ellipse 40% 30% at 80% 80%, rgba(61, 255, 160, 0.05) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* ── Screens ────────────────────────────────── */
.screen {
    position: fixed;
    inset: 0;
    display: none;
    /* Hard hide completely removes from Safari touch tree */
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    z-index: 1;
    background: var(--bg);
}

.screen.active {
    display: block;
    animation: fadeIn 0.25s ease forwards;
    z-index: 10;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ── Shared ─────────────────────────────────── */
.logo-img {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-md);
    object-fit: cover;
    margin-bottom: 1rem;
    box-shadow: 0 4px 24px rgba(124, 109, 250, 0.3);
}

.logo-img-small {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    object-fit: cover;
    vertical-align: middle;
    margin-right: 0.15rem;
}

.logo-small {
    font-family: 'Oswald', sans-serif;
    font-size: 1.1rem;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    display: flex;
    align-items: center;
}

h1 {
    font-family: 'Oswald', sans-serif;
    font-size: clamp(2.8rem, 8vw, 5rem);
    letter-spacing: 0.03em;
    line-height: 0.95;
    color: var(--text);
    margin-bottom: 0.3rem;
}

h1 span {
    color: var(--accent2);
}

h2 {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 0.4rem;
    color: var(--text-dim);
}

.prompt-heading {
    display: block;
    font-family: 'Oswald', sans-serif;
    font-size: clamp(1.4rem, 4vw, 2.2rem);
    font-weight: 500;
    margin-bottom: 0.6rem;
    color: var(--text);
    letter-spacing: 0.03em;
}

.section-label {
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    display: block;
}

/* ── Buttons ────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
    font-size: 0.82rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    text-decoration: none;
    letter-spacing: 0.01em;
}

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

.btn:disabled {
    opacity: 0.35;
    pointer-events: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #fff;
    padding: 0.7rem 1.8rem;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 20px var(--glow);
    font-size: 0.9rem;
    font-weight: 500;
}

.btn-primary:hover {
    box-shadow: 0 8px 28px rgba(124, 109, 250, 0.5);
    filter: brightness(1.08);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg2);
    color: var(--text-dim);
    padding: 0.7rem 1.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
}

.btn-secondary:hover {
    background: var(--surface);
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.14);
}

.btn-ghost {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-dim);
    padding: 5px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.09);
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.14);
}

.btn-icon {
    border-radius: 50%;
    font-size: 1.1rem;
    width: 38px;
    height: 38px;
    padding: 0;
}

.btn-model {
    font-family: 'Oswald', sans-serif;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: var(--radius-sm);
    padding: 5px 12px;
    gap: 0.3rem;
}

.btn-sm {
    font-size: 0.78rem;
    padding: 5px 11px;
}

.btn-full {
    width: 100%;
    margin-top: 0.4rem;
}

.btn-generate {
    padding: 0.9rem 2rem;
    font-family: 'Oswald', sans-serif;
    font-size: 1.35rem;
    letter-spacing: 0.1em;
    width: 100%;
    border-radius: var(--radius-md);
    position: relative;
    overflow: hidden;
}

.btn-generate::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, transparent 60%);
    opacity: 0;
    transition: opacity var(--transition);
}

.btn-generate:hover::before {
    opacity: 1;
}

.btn-generate:hover {
    transform: translateY(-1px);
}

.btn-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.1rem;
    background: var(--bg2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.85rem 1.2rem;
    width: 82px;
    font-size: 1.2rem;
}

.btn-nav small {
    font-size: 0.6rem;
    font-weight: 400;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.btn-nav:hover {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 4px 20px var(--glow);
    color: #fff;
}

.btn-nav:disabled {
    opacity: 0.25;
    pointer-events: none;
}

/* Small nav buttons used in controller bar */
.btn-nav-sm {
    background: var(--bg2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.45rem 0.85rem;
    font-size: 1rem;
}

.btn-nav-sm:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn-nav-sm:disabled {
    opacity: 0.25;
    pointer-events: none;
}

.btn-nav-sm.active-logo {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ── Form elements ──────────────────────────── */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.input-group label {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

input[type="text"],
input[type="password"],
textarea,
select {
    width: 100%;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 300;
    padding: 0.75rem 1rem;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    line-height: 1.6;
    caret-color: var(--accent2);
}

input::placeholder,
textarea::placeholder {
    color: rgba(240, 238, 255, 0.2);
    font-style: italic;
}

input:focus,
textarea:focus,
select:focus {
    border-color: rgba(124, 109, 250, 0.45);
    box-shadow: 0 0 0 3px rgba(124, 109, 250, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

input[type="number"] {
    width: 80px;
    text-align: center;
    font-size: 1rem;
    font-weight: 400;
    font-style: normal;
    color: var(--text);
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
}

textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.6;
}


.game-select {
    width: 100%;
    background: var(--bg2) url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a598ff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") no-repeat right 0.75rem center;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
    padding: 0.6rem 2.5rem 0.6rem 1rem;
    outline: none;
    appearance: none;
    cursor: pointer;
}

.prompt-cycler {
    display: flex;
    justify-content: space-between;
    gap: 0.8rem;
    margin-top: 0.8rem;
}

.btn-icon-big {
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

/* ── Hints / errors ─────────────────────────── */
.hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.75rem;
    text-align: center;
    letter-spacing: 0.01em;
}

.hint a {
    color: rgba(165, 152, 255, 0.6);
    text-decoration: none;
    font-weight: 500;
}

.hint a:hover {
    text-decoration: underline;
}

.subtitle {
    color: var(--text-muted);
    margin-bottom: 1.25rem;
    font-size: 0.82rem;
    font-weight: 300;
    letter-spacing: 0.01em;
}

.error-msg {
    background: rgba(255, 92, 92, 0.1);
    border: 1px solid rgba(255, 92, 92, 0.25);
    border-radius: var(--radius-sm);
    color: var(--danger);
    padding: 0.6rem 0.9rem;
    font-size: 0.82rem;
    margin-top: 0.75rem;
}

.hidden {
    display: none !important;
}

/* ── Spinner ────────────────────────────────── */
.spinner {
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ── Room code badge ────────────────────────── */
.room-code-badge {
    font-size: 3rem;
    font-weight: 900;
    font-family: 'Oswald', sans-serif;
    letter-spacing: 0.25em;
    color: var(--accent2);
    margin-bottom: 0.75rem;
}

.server-badge {
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.15em;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    border-radius: 100px;
    padding: 3px 10px;
    font-family: monospace;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.server-badge.status-connected .badge-icon {
    color: var(--success);
}

.server-badge.status-disconnected .badge-icon {
    color: var(--danger);
    animation: badgePulse 1s infinite ease-in-out;
}

.room-code-mini {
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.15em;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    border-radius: 100px;
    padding: 3px 10px;
    font-family: monospace;
}

.presenter-badge {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--success);
    background: rgba(61, 255, 160, 0.1);
    border: 1px solid rgba(61, 255, 160, 0.22);
    border-radius: 100px;
    padding: 4px 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    animation: badgePulse 2s infinite ease-in-out;
}

.presenter-badge .badge-icon {
    flex-shrink: 0;
    color: var(--success);
}

@keyframes badgePulse {
    0% {
        opacity: 0.85;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.05);
    }

    100% {
        opacity: 0.85;
        transform: scale(1);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.4;
        transform: scale(0.8);
    }
}

/* ── Discover msgs ──────────────────────────── */
.discover-msg {
    font-size: 0.8rem;
    margin-top: 0.4rem;
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius-sm);
}

.discover-ok {
    color: var(--success);
    background: rgba(134, 239, 172, 0.1);
}

.discover-error {
    color: var(--danger);
    background: rgba(248, 113, 113, 0.1);
}

/* ════════════════════════════════════════════
   SETTINGS SCREEN
════════════════════════════════════════════ */
.settings-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    text-align: center;
    margin: 0 auto;
}

.settings-card .input-group {
    text-align: left;
}

.model-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.model-row select {
    flex: 1;
}

.model-row .btn {
    white-space: nowrap;
    flex-shrink: 0;
}

/* ════════════════════════════════════════════
   LOBBY SCREEN
════════════════════════════════════════════ */
.lobby-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    margin: 0 auto;
}

.card-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100%;
    padding: 1.5rem;
}

.lobby-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
    margin-top: 0.5rem;
    margin-bottom: 1.5rem;
}

.lobby-btn {
    width: 100%;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.9rem 1.5rem;
    font-size: 1.05rem;
}

.lobby-btn small {
    font-size: 0.75rem;
    font-weight: 400;
    opacity: 0.7;
}

.join-section {
    width: 100%;
}

.join-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.join-row {
    display: flex;
    gap: 0.5rem;
}

.code-input {
    flex: 1;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 900;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    padding: 0.6rem 0.5rem;
}

.lobby-card .btn-sm {
    margin-top: 1.2rem;
}

/* ════════════════════════════════════════════
   ROLE SCREEN
════════════════════════════════════════════ */
.role-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 0.4rem;
}

/* ════════════════════════════════════════════
   PROMPT / CONTROLLER SCREEN (shared layout)
════════════════════════════════════════════ */
.prompt-layout {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 680px;
    min-height: 100%;
    height: auto;
    padding: 1rem 1.5rem;
    margin: 0 auto;
}

.prompt-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0 1rem;
    gap: 0.5rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

#ctrl-prompt-mode {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.prompt-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1.5rem;
}

.prompt-controls {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.count-control {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
}

.count-control {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
}



/* ── Controller nav bar ─────────────────────── */
.ctrl-nav {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    margin-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.ctrl-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.75rem;
    position: relative;
    z-index: 100;
}

.ctrl-nav-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    overflow: hidden;
}

.ctrl-item-preview {
    font-size: 0.9rem;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.ctrl-progress-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
}

.ctrl-nav-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

/* ════════════════════════════════════════════
   SOLO DISPLAY SCREEN
════════════════════════════════════════════ */
#screen-display {
    background: var(--bg);
}

.display-layout {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.display-header {
    pointer-events: none;
    z-index: 10;
}

.presenter-theme-btn-solo {
    position: absolute;
    top: 1rem;
    left: 1.2rem;
    padding: 0.5rem;
    opacity: 0.15;
    transition: opacity 0.2s ease;
    pointer-events: auto;
}

.presenter-theme-btn-solo:hover {
    opacity: 0.5;
}

.btn-solo-new-scene {
    position: absolute;
    top: 1rem;
    right: 1.2rem;
    color: #ff5c5c;
    border: 1.5px solid rgba(255, 92, 92, 0.4);
    font-family: 'Oswald', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    pointer-events: auto;
}

.btn-solo-new-scene:hover {
    background: rgba(255, 92, 92, 0.1);
    border-color: #ff5c5c;
}

.progress-counter {
    position: absolute;
    top: calc(1rem + env(safe-area-inset-top, 0px));
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-dim);
    letter-spacing: 0.05em;
    z-index: 10;
}

.display-main {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 100px 5vw 130px 5vw;
    /* Reserve strictly defined space for absolute buttons */
    box-sizing: border-box;
}

.item-display {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
    height: 100%;
}

.item-text {
    font-size: 2rem;
    /* Fallback, adjusted by JS */
    font-weight: 600;
    text-align: center;
    max-width: 90%;
    line-height: 1.15;
    white-space: pre-wrap;
    animation: fadeIn 0.4s ease forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.display-footer {
    pointer-events: none;
    z-index: 10;
}

.btn-nav-solo {
    position: absolute;
    bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
    z-index: 10;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: var(--text);
    transition: all 0.2s ease;
    cursor: pointer;
    pointer-events: auto;
}

#btn-prev.btn-nav-solo {
    left: 1.5rem;
}

#btn-next.btn-nav-solo {
    right: 1.5rem;
}

.btn-nav-solo:hover:not(:disabled) {
    background: var(--surface);
    border-color: var(--accent);
    box-shadow: 0 4px 15px var(--glow);
    transform: translateY(-2px);
}

.btn-nav-solo:disabled {
    opacity: 0.15;
    cursor: default;
}

.btn-regen-solo {
    position: absolute;
    bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    font-weight: 700;
    color: var(--accent2);
    border: 2px solid var(--accent);
    padding: 0.8rem 1.5rem;
    border-radius: var(--radius-md);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    pointer-events: auto;
    white-space: nowrap;
}

.btn-regen-solo:hover {
    background: rgba(124, 109, 250, 0.1);
    box-shadow: 0 0 20px var(--glow);
}

/* ════════════════════════════════════════════
   PRESENTER SCREEN
════════════════════════════════════════════ */
#screen-presenter {
    background: var(--bg);
    overflow: hidden;
}

.presenter-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 4vw;
    position: relative;
}

.presenter-logo-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    animation: fadeIn 0.8s ease;
}

.presenter-logo {
    width: 60vw;
    max-width: 2000px;
    height: auto;
    border-radius: var(--radius-lg);
}

.presenter-waiting {
    font-family: 'Oswald', sans-serif;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    color: var(--text-dim);
    letter-spacing: 0.05em;
    animation: pulse 2s infinite ease-in-out;
}

.presenter-item-view {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.presenter-item-view .item-text {
    font-size: clamp(3rem, 8vw, 7rem);
    font-weight: 600;
    max-width: 90%;
    line-height: 1.2;
    white-space: pre-wrap;
}

.presenter-room-watermark {
    position: absolute;
    bottom: 20px;
    right: 30px;
    font-family: 'Oswald', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
    opacity: 0.05;
    letter-spacing: 0.1em;
    pointer-events: none;
}

.presenter-leave-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    opacity: 0.1;
}

.presenter-leave-btn:hover {
    opacity: 1;
}

.presenter-conn-indicator {
    position: absolute;
    bottom: 25px;
    left: 25px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    opacity: 0.35;
    transition: background-color 0.3s ease;
}

.presenter-conn-indicator.status-connected {
    background-color: var(--success);
}

.presenter-conn-indicator.status-disconnected {
    background-color: var(--danger);
}

/* ── Controller preview (large, in control mode) ── */
.ctrl-control-mode {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 1rem;
    padding-bottom: 0.5rem;
}

.ctrl-preview-large {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.6rem 0.9rem;
    display: flex;
    flex-direction: column;
    height: 320px;
    min-height: 320px;
    max-height: 320px;
    flex-shrink: 0;
    flex-grow: 0;
    overflow: hidden;
}

/* ── Prompt reminder banner ──────────────────── */
.ctrl-prompt-display {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.75rem;
    margin-bottom: 0rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-style: italic;
}

.ctrl-preview-large .ctrl-preview-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.ctrl-preview-large .ctrl-preview-box {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    min-height: 0;
    text-align: center;
}

.ctrl-preview-logo img {
    width: clamp(60px, 10vw, 100px);
    height: auto;
    max-height: clamp(60px, 10vw, 100px);
    border-radius: var(--radius-md);
    object-fit: contain;
    opacity: 0.75;
}

.ctrl-preview-text {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    text-align: center;
    line-height: 1.5;
    white-space: pre-line;
    animation: fadeIn 0.3s ease;
}

.ctrl-progress-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
    gap: 1rem;
}

/* ── Big control buttons ─────────────────────── */
.ctrl-big-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.ctrl-buttons-main {
    display: flex;
    gap: 0.6rem;
}

.ctrl-buttons-secondary {
    display: flex;
    gap: 0.6rem;
}

.btn-ctrl-big {
    flex: 1;
    padding: 1rem 1.5rem;
    font-size: 1.2rem;
    font-weight: 700;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.btn-ctrl-big:hover {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 4px 20px var(--glow);
}

.btn-ctrl-big:disabled {
    opacity: 0.25;
    pointer-events: none;
}

/* .btn-ctrl-next inherits .btn-ctrl-big — no extra styles needed */

.btn-ctrl-next:hover {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 4px 20px var(--glow);
    color: #fff;
}

.btn-ctrl-md {
    flex: 1;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    font-weight: 600;
    background: var(--bg3);
    color: var(--text-dim);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.btn-ctrl-md:hover {
    background: var(--surface);
    color: var(--text);
    border-color: var(--accent2);
}

.btn-ctrl-md.active-logo {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

.btn-ctrl-new {
    color: var(--accent2);
    border-color: rgba(100, 104, 248, 0.3);
}

.btn-ctrl-new:hover {
    background: rgba(100, 104, 248, 0.1);
    color: var(--accent2);
    border-color: var(--accent);
}

/* ── Leave button ────────────────────────────── */
.btn-leave {
    font-family: 'Oswald', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--danger);
    border-color: rgba(248, 113, 113, 0.3);
}

.btn-leave:hover {
    background: rgba(248, 113, 113, 0.1);
    color: var(--danger);
    border-color: var(--danger);
}

.presenter-leave-btn {
    position: absolute;
    top: 1rem;
    right: 1.2rem;
}

.presenter-theme-btn {
    position: absolute;
    top: 1rem;
    left: 1.2rem;
    padding: 0.5rem;
    opacity: 0.15;
    transition: opacity 0.2s ease;
}

.presenter-theme-btn:hover {
    opacity: 0.5;
}

/* ════════════════════════════════════════════
   MOBILE OPTIMIZATIONS
   (applies to most phones in portrait mode)
════════════════════════════════════════════ */

/* ── Media Queries ───────────────────────────── */
@media (max-width: 600px) {
    h1 {
        font-size: 2.5rem;
    }

    .lobby-card,
    .settings-card {
        padding: 1.5rem;
    }

    /* Strict horizontal padding to protect absolute navigation buttons */
    .item-text {
        max-width: calc(100vw - 120px);
    }
}

@media (max-width: 480px) {

    /* Lobby */
    .lobby-card,
    .settings-card {
        padding: 1.5rem 1.2rem;
        border-radius: var(--radius-md);
    }

    h1 {
        font-size: 1.8rem;
    }

    h2 {
        font-size: 1.2rem;
    }

    .lobby-btn {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
    }

    /* Prompt / controller header */
    .prompt-layout {
        padding: 0.75rem 0.9rem;
    }

    .prompt-header {
        padding: 0.3rem 0 0.6rem;
        gap: 0.4rem;
    }

    .logo-small {
        font-size: 0.9rem;
    }

    .header-right {
        gap: 0.35rem;
    }

    .btn-model,
    .btn-sm {
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
    }

    /* Icon-only buttons on mobile */
    .header-right .btn-label {
        display: none;
    }

    .btn-model,
    #btn-ctrl-leave {
        padding: 0.35rem 0.55rem;
    }

    .prompt-title {
        font-size: 1.4rem;
    }

    textarea {
        min-height: 90px;
        font-size: 0.95rem;
    }

    /* Controller control mode */
    .ctrl-prompt-display {
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
    }

    .ctrl-preview-large {
        height: 320px;
        min-height: 320px;
        max-height: 320px;
    }

    .ctrl-preview-text {
        font-size: 0.82rem;
    }

    .btn-ctrl-big {
        font-size: 1rem;
        padding: 0.85rem 0.75rem;
    }

    .btn-ctrl-md {
        font-size: 0.82rem;
        padding: 0.6rem 0.5rem;
    }

    .btn-ctrl-big .btn-label,
    .presenter-badge .badge-text {
        display: none;
    }

    .presenter-badge {
        padding: 0.35rem;
    }

    .btn-ctrl-big svg {
        margin: 0 !important;
    }

    /* Presenter */
    .presenter-logo {
        width: clamp(100px, 30vw, 180px);
        height: clamp(100px, 30vw, 180px);
    }

    .presenter-leave-btn {
        top: 0.75rem;
        right: 0.75rem;
    }

    .presenter-theme-btn {
        top: 0.75rem;
        left: 0.75rem;
    }

    /* Solo display */
    .display-footer {
        padding: 0.5rem 0 0.75rem;
    }

    .btn-nav-solo {
        width: 50px;
        height: 50px;
        font-size: 1.4rem;
    }

    .item-display .item-text {
        max-width: calc(100vw - 160px) !important;
    }
}

/* Touch — ensure minimum tap target of 44px */
@media (pointer: coarse) {
    .btn {
        min-height: 44px;
    }

    .btn-sm,
    .btn-model {
        min-height: 36px;
    }

    .btn-ctrl-big {
        min-height: 56px;
    }

    .btn-ctrl-md {
        min-height: 48px;
    }
}

/* ── Admin Screen ──────────────────────────────── */
.admin-rooms-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    text-align: left;
}

.admin-room-item {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.admin-room-info {
    display: flex;
    flex-direction: row;
    gap: 1rem;
    align-items: center;
    width: 100%;
}

.admin-room-code {
    font-family: monospace;
    font-size: 1.75rem;
    font-weight: bold;
    color: var(--primary);
}

.admin-room-stats {
    font-size: 1.1rem;
    color: var(--text-muted);
}

.admin-room-actions {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
    width: 100%;
}

.admin-btn-wide {
    flex: 1;
}

.btn-danger {
    background: linear-gradient(135deg, #e53e3e, #c53030);
    color: #fff;
    padding: 0.7rem 1.8rem;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 20px rgba(197, 48, 48, 0.3);
    border: none;
    font-size: 0.9rem;
    font-weight: 500;
}

.btn-danger:hover {
    box-shadow: 0 8px 28px rgba(197, 48, 48, 0.5);
    filter: brightness(1.08);
    transform: translateY(-1px);
}

/* ── Admin Presenter Preview ─────────────────── */
.admin-presenter-preview {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 0.75rem;
}

.admin-preview-logo {
    max-width: 60%;
    max-height: 100px;
    height: auto;
    object-fit: contain;
    opacity: 0.9;
}

.admin-preview-text {
    font-family: 'Oswald', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    text-align: center;
    line-height: 1.3;
    white-space: pre-wrap;
}

/* ── Birthday active button ─────────────────── */
.btn-birthday-active {
    background: linear-gradient(135deg, #f6c90e, #e0a800);
    color: #1a1a1a;
    padding: 0.7rem 1.8rem;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 20px rgba(240, 185, 11, 0.4);
    border: none;
    font-size: 0.9rem;
    font-weight: 700;
}

.btn-birthday-active:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
}