/* ==========================================
   SalmasFllix - Premium Purple/Gold Theme
   Mobile-First Responsive Design
   ========================================== */

:root {
    /* Color Palette - Gold & Purple */
    --bg-dark: #0d0b1e;
    --bg-card: rgba(25, 20, 50, 0.55);
    --bg-glass: rgba(255, 255, 255, 0.05);
    --accent-primary: #ffd700;
    --accent-secondary: #9b59b6;
    --accent-tertiary: #8e44ad;
    --accent-glow: rgba(255, 215, 0, 0.4);
    --accent-glow-purple: rgba(155, 89, 182, 0.4);
    /* Unified button colors */
    --btn-primary-bg: linear-gradient(135deg, #ffd700, #ffec8b);
    --btn-primary-color: #0d0b1e;
    --btn-primary-shadow: rgba(255, 215, 0, 0.35);
    --btn-secondary-bg: linear-gradient(135deg, #8e44ad, #9b59b6);
    --btn-secondary-color: #fff;
    --btn-secondary-shadow: rgba(142, 68, 173, 0.35);
    --btn-danger-bg: linear-gradient(135deg, #ef4444, #dc2626);
    --btn-danger-color: #fff;
    --btn-danger-shadow: rgba(239, 68, 68, 0.3);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.4);

    /* Wordle Colors */
    --correct: #27ae60;
    --present: #f39c12;
    --absent: #2c2c3e;
    --tile-border: #3d3d5c;
    --tile-empty: #1a1a2e;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;

    /* Safe areas for mobile */
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

/* Dark Scrollbar — applied globally and explicitly to all scrollable areas */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(155, 89, 182, 0.5) rgba(13, 11, 30, 0.4);
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(13, 11, 30, 0.4);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(155, 89, 182, 0.6), rgba(100, 50, 150, 0.8));
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, rgba(175, 109, 202, 0.9), rgba(130, 70, 180, 1));
}

::-webkit-scrollbar-corner {
    background: transparent;
}

/* Force visible scrollbars on mobile for queue */
@supports (-webkit-overflow-scrolling: touch) {
    .media-queue-list {
        -webkit-overflow-scrolling: touch;
    }
}

/* Reset & Base */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

/* Remove blue focus highlights */
*:focus {
    outline: none !important;
}

button:focus,
select:focus,
input:focus,
a:focus {
    outline: none !important;
    box-shadow: none !important;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    height: 100%;
    width: 100%;
    overflow: hidden;
    position: relative;
    padding-top: var(--safe-area-top);
    padding-bottom: var(--safe-area-bottom);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Animated Moving Gradient Background */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(ellipse 80% 50% at 20% 30%, rgba(155, 89, 182, 0.3) 0%, transparent 50%),
        radial-gradient(ellipse 60% 40% at 80% 70%, rgba(168, 85, 247, 0.2) 0%, transparent 50%),
        radial-gradient(ellipse 70% 60% at 50% 50%, rgba(142, 68, 173, 0.15) 0%, transparent 60%),
        var(--bg-dark);
    background-size: 200% 200%, 200% 200%, 200% 200%, 100% 100%;
    animation: gradientMove 15s ease-in-out infinite;
}

@keyframes gradientMove {
    0% {
        background-position: 0% 0%, 100% 100%, 50% 50%, 0% 0%;
    }

    25% {
        background-position: 50% 30%, 30% 70%, 70% 30%, 0% 0%;
    }

    50% {
        background-position: 100% 100%, 0% 0%, 30% 70%, 0% 0%;
    }

    75% {
        background-position: 30% 70%, 70% 30%, 50% 50%, 0% 0%;
    }

    100% {
        background-position: 0% 0%, 100% 100%, 50% 50%, 0% 0%;
    }
}

.hidden {
    display: none !important;
}

/* Twemoji styling */
img.emoji {
    height: 1em;
    width: 1em;
    margin: 0 .05em 0 .1em;
    vertical-align: -0.1em;
}

/* Typography */
.logo {
    font-size: clamp(1.5rem, 5vw, 2.5rem);
    font-weight: 800;
    letter-spacing: -1px;
    text-transform: uppercase;
}

.logo .accent {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    background-clip: text; -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 20px var(--accent-glow));
}

/* Modern Logo */
.logo-modern {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    font-size: clamp(2rem, 8vw, 3.5rem);
    font-weight: 800;
    letter-spacing: -2px;
    margin: 0;
    position: relative;
}

.logo-modern.centered {
    justify-content: center;
    text-align: center;
    width: 100%;
}

.logo-modern .logo-icon {
    font-size: 1em;
    filter: drop-shadow(0 0 20px var(--accent-glow-purple));
    animation: iconPulse 2s ease-in-out infinite;
}

.logo-modern .logo-image {
    height: clamp(50px, 10vw, 80px);
    width: auto;
    border-radius: 50%;
    filter: drop-shadow(0 0 15px var(--accent-glow-purple));
    animation: iconPulse 2s ease-in-out infinite;
}

@keyframes iconPulse {

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

    50% {
        transform: scale(1.1);
    }
}

.logo-modern .logo-text {
    background: linear-gradient(135deg, #fff 0%, #e0e0e0 100%);
    background-clip: text; -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    position: relative;
}

.logo-modern .accent {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary), var(--accent-tertiary));
    background-clip: text; -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 30px var(--accent-glow));
    animation: accentGlow 3s ease-in-out infinite alternate;
}

@keyframes accentGlow {
    0% {
        filter: drop-shadow(0 0 20px var(--accent-glow));
    }

    100% {
        filter: drop-shadow(0 0 40px var(--accent-glow-purple));
    }
}

.tagline {
    color: var(--text-secondary);
    font-size: clamp(0.9rem, 3vw, 1.2rem);
    font-weight: 400;
    margin-top: var(--spacing-md);
    letter-spacing: 0.5px;
}

.hint {
    color: var(--text-muted);
    font-size: clamp(0.75rem, 2vw, 0.9rem);
    margin-top: var(--spacing-lg);
    font-style: italic;
}

/* ==========================================
   FALLING EMOJIS
   ========================================== */

.falling-emojis {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.falling-emoji {
    position: absolute;
    font-size: clamp(1.25rem, 3vw, 2rem);
    top: -50px;
    animation: emojiFloat linear infinite;
    opacity: 0.6;
    will-change: transform, opacity;
    contain: layout style;
}

@media (prefers-reduced-motion: reduce) {
    .falling-emoji { display: none; }
}

@keyframes emojiFloat {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 0;
    }

    10% {
        opacity: 0.6;
    }

    90% {
        opacity: 0.6;
    }

    100% {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

/* ==========================================
   FALLING SKULLS (for lose animation)
   ========================================== */

.falling-skull {
    position: absolute;
    top: -50px;
    pointer-events: none;
    animation: skullFall linear forwards;
    opacity: 0.8;
    z-index: 100;
}

@keyframes skullFall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 0;
    }

    10% {
        opacity: 0.8;
    }

    90% {
        opacity: 0.8;
    }

    100% {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

/* ==========================================
   GAME CONFETTI (for win animation)
   ========================================== */

.game-confetti-piece {
    position: absolute;
    top: -10px;
    pointer-events: none;
    animation: confettiFall linear forwards;
    z-index: 100;
}

@keyframes confettiFall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

/* ==========================================
   SHAKING HANDS (for draw animation)
   ========================================== */

.shaking-hand {
    position: absolute;
    top: -50px;
    pointer-events: none;
    animation: handShake linear forwards;
    z-index: 100;
}

@keyframes handShake {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

/* ==========================================
   WORDLE SECTION
   ========================================== */

.wordle-section {
    height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-sm);
    position: relative;
    z-index: 1;
    overflow: hidden;
}

/* Wordle/Hangman Container */
.wordle-container {
    text-align: center;
    max-width: 700px;
    width: 100%;
    max-height: 100dvh;
    background: var(--bg-card);
    padding: clamp(var(--spacing-sm), 1.5dvh, var(--spacing-md));
    border-radius: var(--radius-xl);
    border: 1px solid rgba(155, 89, 182, 0.2);
    backdrop-filter: blur(10px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden; /* No scrolling for hangman */
}

.wordle-header {
    margin-bottom: clamp(var(--spacing-xs), 1.5dvh, var(--spacing-md));
    flex-shrink: 0;
}

.wordle-header .logo-modern {
    font-size: clamp(1.2rem, 4dvh, 2rem);
}

.wordle-header .tagline {
    font-size: clamp(0.7rem, 2dvh, 0.9rem);
    margin-top: 5px;
}

/* Game Board */
.game-board {
    display: grid;
    grid-template-rows: repeat(6, 1fr);
    gap: clamp(2px, 1vw, var(--spacing-xs));
    margin: 0 auto var(--spacing-lg);
    max-width: 100%;
    width: fit-content;
}

.board-row {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: clamp(2px, 1vw, var(--spacing-xs));
    justify-content: center;
}

.tile {
    aspect-ratio: 1;
    width: clamp(20px, 6vw, 45px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(0.9rem, 3vw, 1.5rem);
    font-weight: 700;
    text-transform: uppercase;
    border: 2px solid var(--tile-border);
    background: var(--tile-empty);
    border-radius: var(--radius-sm);
    transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.tile.filled {
    border-color: var(--accent-secondary);
    animation: pop 0.1s ease;
}

.tile.correct {
    background: var(--correct);
    border-color: var(--correct);
    animation: flip 0.5s ease forwards;
}

.tile.present {
    background: var(--present);
    border-color: var(--present);
    animation: flip 0.5s ease forwards;
}

.tile.absent {
    background: var(--absent);
    border-color: var(--absent);
    animation: flip 0.5s ease forwards;
}

@keyframes pop {
    50% {
        transform: scale(1.1);
    }
}

@keyframes flip {
    0% {
        transform: rotateX(0deg);
    }

    50% {
        transform: rotateX(90deg);
    }

    100% {
        transform: rotateX(0deg);
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    20%,
    60% {
        transform: translateX(-5px);
    }

    40%,
    80% {
        transform: translateX(5px);
    }
}

.board-row.shake {
    animation: shake 0.5s ease;
}

/* Message */
.message {
    min-height: 2rem;
    margin-bottom: var(--spacing-md);
    font-size: clamp(0.875rem, 2.5vw, 1rem);
    font-weight: 600;
    color: var(--accent-primary);
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.message.show {
    opacity: 1;
}

/* Mobile Input - invisible but focusable for native keyboard */
.mobile-input {
    position: absolute;
    left: -9999px;
    opacity: 0;
    height: 1px;
    width: 1px;
}

/* Keyboard */
.keyboard {
    display: flex;
    flex-direction: column;
    gap: clamp(4px, 1vw, var(--spacing-xs));
    margin-bottom: var(--spacing-md);
    width: 100%;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: clamp(3px, 1vw, var(--spacing-xs));
}

.key {
    min-width: clamp(28px, 8vw, 45px);
    height: clamp(32px, 7dvh, 55px);
    padding: 0 clamp(4px, 1vw, var(--spacing-sm));
    font-family: inherit;
    font-size: clamp(0.75rem, 1.8dvh, 1rem);
    font-weight: 600;
    text-transform: uppercase;
    background: linear-gradient(145deg, #4a4a6a, #3a3a5a);
    color: var(--text-primary);
    border: 1px solid rgba(155, 89, 182, 0.3);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    flex-shrink: 1;
}

/* Mobile keyboard - fits below grid, full width */
@media (max-width: 600px),
(hover: none) and (pointer: coarse) {
    .wordle-section {
        transform: none;
        padding-bottom: var(--spacing-md);
    }

    .wordle-container {
        padding: var(--spacing-sm);
        max-width: 100%;
    }

    /* ... omitted keyboard styles for brevity ... */

    .keyboard {
        width: 100%;
        max-width: 500px;
        margin: 0 auto;
        padding: clamp(2px, 1dvh, var(--spacing-sm)) 2px;
        gap: clamp(2px, 1dvh, 5px);
        flex-shrink: 0;
    }

    .keyboard-row {
        gap: 4px;
        padding: 0 2px;
        justify-content: center;
    }

    /* Row 2 (ASDFGHJKL) - indent for pyramid effect */
    .keyboard-row:nth-child(2) {
        padding: 0 4%;
    }

    /* Row 3 (ZXCVBNM) - indent more for pyramid effect */
    .keyboard-row:nth-child(3) {
        padding: 0 2%;
    }

    .key {
        flex: 0 1 auto;
        width: clamp(28px, 8.5vw, 40px);
        min-width: 0;
        height: 48px;
        padding: 0;
        font-size: 0.85rem;
        font-weight: 700;
        background: #565676;
        border: 1px solid rgba(155, 89, 182, 0.4);
        border-radius: 5px;
        color: white;
    }

    .key:active {
        background: #7a7a9a;
        transform: none;
    }

    .key.correct {
        background: var(--correct);
        border-color: var(--correct);
    }

    .key.present {
        background: var(--present);
        border-color: var(--present);
    }

    .key.absent {
        background: #3a3a4c;
        border-color: #3a3a4c;
    }

    .key-wide {
        flex: 0 1 auto;
        width: clamp(40px, 12vw, 65px);
        font-size: 0.65rem;
    }

    .tile {
        width: clamp(14px, 7.5vw, 28px);
        height: clamp(14px, 7.5vw, 28px);
        font-size: clamp(0.7rem, 3.5vw, 1.1rem);
    }

    .board-row {
        grid-template-columns: repeat(8, minmax(0, 1fr));
        gap: 2px;
        justify-content: center;
    }
}

.key:hover,
.key:active {
    background: linear-gradient(145deg, #5a5a7a, #4a4a6a);
    transform: translateY(-2px);
    border-color: var(--accent-primary);
}

.key-wide {
    min-width: clamp(45px, 12vw, 70px);
    font-size: clamp(0.6rem, 1.8vw, 0.75rem);
}

.key.correct {
    background: var(--correct);
    border-color: var(--correct);
}

.key.present {
    background: var(--present);
    border-color: var(--present);
}

.key.absent {
    background: var(--absent);
    border-color: var(--absent);
}

.hint {
    color: var(--accent-primary);
    font-size: clamp(0.75rem, 2vw, 0.875rem);
    font-style: italic;
    opacity: 0.8;
}

/* Game Over Message */
#message {
    text-align: center;
    min-height: 30px;
    opacity: 0;
    transition: opacity 0.3s;
}

#message.show {
    opacity: 1;
}

#message.game-over {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.85);
    padding: var(--spacing-md);
    backdrop-filter: blur(4px);
}

.game-over-message {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    text-align: center;
    padding: 2rem 2.5rem;
    background: linear-gradient(135deg, rgba(25, 20, 50, 0.95), rgba(15, 12, 30, 0.98));
    border-radius: 16px;
    border: 1px solid rgba(168, 85, 247, 0.35);
    backdrop-filter: blur(20px);
    box-shadow: 0 0 40px rgba(168, 85, 247, 0.15), 0 20px 60px rgba(0, 0, 0, 0.5);
    max-width: 380px;
    width: 90vw;
    animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

.game-over-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #ff6b6b;
}

.game-over-text {
    font-size: 1rem;
    color: var(--text-secondary);
}

.game-over-hint {
    font-size: 0.9rem;
    color: rgba(168, 85, 247, 0.9);
    font-style: italic;
    padding: var(--spacing-sm);
    background: rgba(168, 85, 247, 0.1);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(168, 85, 247, 0.2);
}

.refresh-btn {
    padding: 10px 24px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    color: #0d0b1e;
    background: linear-gradient(135deg, #ffd700, #ffec8b);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
}

.refresh-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.4);
}

/* ==========================================
   SUCCESS POPUP
   ========================================== */

.success-popup {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--spacing-md);
    animation: fadeIn 0.3s ease;
    backdrop-filter: blur(4px);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.success-content {
    text-align: center;
    padding: 2rem 2.5rem;
    background: linear-gradient(135deg, rgba(25, 20, 50, 0.95), rgba(15, 12, 30, 0.98));
    border-radius: 16px;
    border: 1px solid rgba(168, 85, 247, 0.35);
    backdrop-filter: blur(20px);
    position: relative;
    overflow: hidden;
    animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s backwards;
    box-shadow: 0 0 40px rgba(168, 85, 247, 0.15), 0 20px 60px rgba(0, 0, 0, 0.5);
    max-width: 380px;
    width: 90vw;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.success-icon {
    font-size: clamp(3rem, 10vw, 4rem);
    margin-bottom: var(--spacing-md);
    animation: bounce 1s ease infinite;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.success-content h2 {
    font-size: clamp(1.5rem, 5vw, 2rem);
    margin-bottom: var(--spacing-xs);
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    background-clip: text; -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.success-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: var(--spacing-lg);
}

.success-content p {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xl);
}

.enter-btn {
    padding: var(--spacing-md) var(--spacing-xl);
    font-family: inherit;
    font-size: 1.1rem;
    font-weight: 700;
    color: #0d0b1e;
    background: linear-gradient(135deg, #ffd700, #ffec8b);
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: 0 4px 20px rgba(255, 215, 0, 0.35);
    -webkit-tap-highlight-color: transparent;
}

.pulse-btn {
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        box-shadow: 0 4px 20px rgba(255, 215, 0, 0.35);
    }

    50% {
        transform: scale(1.05);
        box-shadow: 0 8px 35px rgba(255, 215, 0, 0.5);
    }
}

.enter-btn:hover,
.enter-btn:active {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 30px rgba(255, 215, 0, 0.5);
    animation: none;
}

/* Confetti */
.confetti-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    top: -10px;
    animation: confettiFall 3s ease-out forwards;
}

@keyframes confettiFall {
    to {
        top: 100%;
        transform: rotate(720deg);
    }
}

/* ==========================================
   GALLERY SECTION
   ========================================== */

.gallery-section {
    height: 100%;
    width: 100%;
    display: block;
    overflow-x: hidden;
    overflow-y: auto;
    animation: fadeIn 0.5s ease;
}

.gallery-section.lock-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden !important;
}

/* When media tab is active, allow page scroll like Movies/Shows/Books */
.gallery-section.lock-layout:has(#media-content.active) {
    overflow: auto !important;
}

/* JS fallback for :has() — body[data-active-tab="media"] */
body[data-active-tab="media"] .gallery-section.lock-layout {
    overflow: auto !important;
}

/* GLOBAL SCROLL LOCK - Applied to body/html */
.lock-scroll {
    overflow: hidden !important;
    height: 100vh !important;
    height: 100dvh !important;
    position: fixed;
    width: 100%;
    touch-action: none;
    -webkit-overflow-scrolling: none;
}

.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-xl);
    padding-bottom: var(--spacing-lg);
    border-bottom: 1px solid rgba(155, 89, 182, 0.2);
    flex-wrap: wrap;
    gap: var(--spacing-md);
}

/* Modern Gallery Header */
.gallery-header-modern {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md) var(--spacing-md);
    margin-bottom: var(--spacing-sm);
    flex-shrink: 0;
    position: relative;
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    min-width: 80px;
}

.header-left {
    justify-content: flex-start;
}

.header-right {
    justify-content: flex-end;
}

.gallery-header-modern .logo-modern {
    font-size: clamp(1.8rem, 6vw, 2.8rem);
    flex: 1;
    text-align: center;
}

.gallery-header-modern .logout-btn {
    padding: var(--spacing-sm);
    font-size: 1.25rem;
    background: transparent;
    border: 1px solid rgba(155, 89, 182, 0.2);
    border-radius: var(--radius-md);
    opacity: 0.6;
    transition: all var(--transition-normal);
}

.gallery-header-modern .logout-btn:hover {
    opacity: 1;
    border-color: var(--accent-primary);
    background: var(--bg-glass);
}

.gallery-header-modern .session-status-btn {
    position: static;
    transform: none;
}

.logout-btn {
    padding: var(--spacing-sm) var(--spacing-md);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-glass);
    border: 1px solid rgba(155, 89, 182, 0.3);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-normal);
    -webkit-tap-highlight-color: transparent;
}

.logout-btn:hover,
.logout-btn:active {
    background: rgba(155, 89, 182, 0.2);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

/* ==========================================
   TAB NAVIGATION — Top centered pill
   ========================================== */

.content-nav {
    display: flex;
    justify-content: center;
    gap: 0;
    margin-bottom: var(--spacing-xl);
    padding: 4px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 50px;
    border: 1px solid rgba(155, 89, 182, 0.3);
    backdrop-filter: blur(10px);
    width: fit-content;
    min-width: 320px;
    margin-left: auto;
    margin-right: auto;
    position: relative;
}

.nav-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 24px;
    flex: 1;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-radius: 40px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
}


.nav-icon {
    font-size: 1.2rem;
    filter: grayscale(1);
    transition: all var(--transition-normal);
}

/* Hover State */
.nav-tab:not(.active):hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.nav-tab:not(.active):hover .nav-icon {
    filter: grayscale(0.5);
}

/* Active State — gradient pill per tab */
.nav-tab.active {
    transform: none;
    font-weight: 700;
}

.nav-tab.active[data-tab="movies"] {
    background: linear-gradient(135deg, #ffd700, #e6c200);
    color: #1a1a2e;
    box-shadow: 0 2px 16px rgba(255, 215, 0, 0.5);
}
.nav-tab.active[data-tab="movies"] .nav-icon,
.nav-tab.active[data-tab="movies"] .nav-label { -webkit-text-fill-color: #fff; }

.nav-tab.active[data-tab="shows"] {
    background: linear-gradient(135deg, #ffd700, #c47ed4);
    color: #1a1a2e;
    box-shadow: 0 2px 16px rgba(255, 215, 0, 0.35);
}
.nav-tab.active[data-tab="shows"] .nav-icon,
.nav-tab.active[data-tab="shows"] .nav-label { -webkit-text-fill-color: #fff; }

.nav-tab.active[data-tab="books"] {
    background: linear-gradient(135deg, #ffd700, #9b59b6);
    color: #fff;
    box-shadow: 0 2px 16px rgba(155, 89, 182, 0.4);
}
.nav-tab.active[data-tab="books"] .nav-icon,
.nav-tab.active[data-tab="books"] .nav-label { -webkit-text-fill-color: #fff; }

.nav-tab.active[data-tab="salma-ai"] {
    background: linear-gradient(135deg, #d4a800, #9b59b6);
    color: #fff;
    box-shadow: 0 2px 16px rgba(155, 89, 182, 0.4);
}
.nav-tab.active[data-tab="salma-ai"] .nav-icon,
.nav-tab.active[data-tab="salma-ai"] .nav-label { -webkit-text-fill-color: #fff; }

.nav-tab.active[data-tab="games"] {
    background: linear-gradient(135deg, #b08c00, #9b59b6);
    color: #fff;
    box-shadow: 0 2px 16px rgba(155, 89, 182, 0.4);
}
.nav-tab.active[data-tab="games"] .nav-icon,
.nav-tab.active[data-tab="games"] .nav-label { -webkit-text-fill-color: #fff; }

.nav-tab.active[data-tab="media"] {
    background: linear-gradient(135deg, #8e44ad, #9b59b6);
    color: #fff;
    box-shadow: 0 2px 16px rgba(155, 89, 182, 0.5);
}
.nav-tab.active[data-tab="media"] .nav-icon,
.nav-tab.active[data-tab="media"] .nav-label { -webkit-text-fill-color: #fff; }

.nav-tab.active .nav-icon { filter: grayscale(0); }

/* Mobile Adjustments */
@media (max-width: 480px) {
    .content-nav {
        min-width: auto;
        width: 90%;
    }

    .nav-tab {
        padding: 10px 16px;
        font-size: 0.9rem;
    }
}

/* Tab Content */
.tab-content {
    display: none;
    height: auto;
    overflow: visible;
    padding: 0 var(--spacing-md) var(--spacing-md);
}

.tab-content.active {
    display: block;
    animation: tabSlideIn 0.35s ease-out both;
}

/* Flex tabs: Therapy, Games, Media — fill viewport in lock-layout */
#salma-ai-content,
#media-content,
#games-content {
    display: none;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.lock-layout #salma-ai-content,
.lock-layout #games-content {
    flex: 1;
}

.lock-layout #media-content {
    flex: none;
    overflow: visible;
}

#salma-ai-content.active,
#games-content.active {
    display: flex;
}

#media-content.active {
    display: flex;
    overflow: visible;
    height: auto;
}

@keyframes tabSlideIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.99);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (prefers-reduced-motion: reduce) {
    .tab-content.active { animation: none; }
}

/* ========== Skeleton Shimmer ========== */
.skeleton-card {
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-card);
    border: 1px solid rgba(155, 89, 182, 0.1);
}

.skeleton-thumb {
    background: linear-gradient(135deg, #1a1a2e, #2d1f3d);
    position: relative;
    overflow: hidden;
}

.skeleton-thumb::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(155, 89, 182, 0.08) 40%, rgba(255, 215, 0, 0.06) 60%, transparent 100%);
    animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-info {
    padding: var(--spacing-sm) var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.skeleton-line {
    height: 12px;
    border-radius: 6px;
    background: rgba(155, 89, 182, 0.12);
    position: relative;
    overflow: hidden;
}

.skeleton-line::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(155, 89, 182, 0.1) 50%, transparent 100%);
    animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-line.wide { width: 80%; }
.skeleton-line.medium { width: 60%; }
.skeleton-line.short { width: 35%; }

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Gallery Grid */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr));
    gap: var(--spacing-md);
    max-width: 1400px;
    margin: 0 auto;
}

@media (min-width: 900px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
}

@media (min-width: 1200px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }
}

@media (max-width: 480px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr));
        gap: var(--spacing-sm);
    }
}

.video-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid rgba(155, 89, 182, 0.18);
    transition: transform var(--transition-normal), border-color var(--transition-normal), box-shadow var(--transition-normal), opacity var(--transition-normal);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

/* Cards without videos - fit content with minimum */
.video-card.coming-soon .video-info {
    padding: var(--spacing-sm);
    padding-bottom: var(--spacing-md);
}

.video-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent-primary);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5), 0 0 20px var(--accent-glow-purple);
}

.video-card:active {
    transform: scale(0.97);
    border-color: var(--accent-primary);
    transition-duration: 0.1s;
}

.video-thumbnail {
    position: relative;
    aspect-ratio: 16/9;
    background: linear-gradient(135deg, #1a1a2e, #2d1f3d);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.video-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumbnail-placeholder {
    font-size: 3rem;
}

.play-overlay {
    position: absolute;
    width: clamp(50px, 15vw, 70px);
    height: clamp(50px, 15vw, 70px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 50%;
    opacity: 0;
    transform: scale(0.8);
    transition: all var(--transition-normal);
    box-shadow: 0 0 30px var(--accent-glow);
}

.video-card:not(.coming-soon):hover .play-overlay,
.video-card:not(.coming-soon):active .play-overlay,
.video-card:not(.coming-soon):focus-within .play-overlay {
    opacity: 1;
    transform: scale(1.1);
}

/* On mobile, show play button slightly during scroll/touch */
@media (max-width: 768px) {
    /* Videos & Shows */
    .video-card:not(.coming-soon):active .play-overlay,
    .show-card:not(.coming-soon):active .play-overlay {
        opacity: 1;
        transform: scale(1);
    }
}

.video-card.coming-soon .play-overlay {
    display: none !important;
}

/* Show play button on touch devices (mobile) - removed forced visibility since user finds it annoying */

.lock-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.video-card.locked .lock-overlay {
    opacity: 1;
}

.video-card.locked .video-thumbnail {
    filter: blur(5px);
}

.video-card.locked .play-overlay {
    display: none;
}

.video-info {
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
    flex: 1;
}

.video-info h3 {
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
    color: var(--accent-primary);
}

.video-info p {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.video-info .video-meta {
    display: flex;
    gap: var(--spacing-md);
    font-size: 0.75rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

/* Card footer with meta + comment badge */
.video-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    padding-top: var(--spacing-sm);
}

.video-desc {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.comment-badge {
    font-size: 0.75rem;
    padding: 3px 8px;
    background: rgba(155, 89, 182, 0.15);
    border: 1px solid rgba(155, 89, 182, 0.25);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.comment-badge:hover {
    background: rgba(155, 89, 182, 0.3);
}

.comment-badge.empty {
    opacity: 0.5;
}

/* Comment Modal */
.comment-modal {
    position: fixed;
    inset: 0;
    z-index: 1500;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.comment-modal-content {
    background: linear-gradient(135deg, rgba(25, 20, 50, 0.95), rgba(15, 12, 30, 0.98));
    border: 1px solid rgba(168, 85, 247, 0.35);
    border-radius: 16px;
    box-shadow: 0 0 40px rgba(168, 85, 247, 0.15), 0 20px 60px rgba(0, 0, 0, 0.5);
    max-width: 480px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.comment-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid rgba(155, 89, 182, 0.15);
}

.comment-modal-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
}

.comment-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-md) var(--spacing-lg);
}

.comment-list {
    margin-bottom: var(--spacing-lg);
}

.no-comments {
    color: var(--text-muted);
    text-align: center;
    padding: var(--spacing-lg) 0;
    font-size: 0.9rem;
}

.comment-item {
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-glass);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-sm);
    position: relative;
}

.comment-item .delete-review {
    position: absolute;
    top: 6px;
    right: 8px;
    cursor: pointer;
    font-size: 0.7rem;
}

.comment-author {
    color: #e056fd;
    font-weight: 600;
    font-size: 0.85rem;
}

.comment-stars {
    font-size: 0.7rem;
    color: #feca57;
    margin-top: 2px;
}

.comment-text {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-style: italic;
    margin-top: 4px;
}

.comment-date {
    color: rgba(255,255,255,0.3);
    font-size: 0.7rem;
    margin-top: 4px;
}

.comment-form {
    border-top: 1px solid rgba(155, 89, 182, 0.15);
    padding-top: var(--spacing-md);
}

/* ===== Detail Modal ===== */
.detail-modal {
    position: fixed;
    inset: 0;
    z-index: 1500;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: fadeIn 0.2s ease;
    overflow: hidden;
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.detail-modal-content {
    background: linear-gradient(135deg, rgba(25, 20, 50, 0.95), rgba(15, 12, 30, 0.98));
    border: 1px solid rgba(168, 85, 247, 0.35);
    border-radius: 16px;
    max-width: 560px;
    width: 100%;
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    position: relative;
    box-shadow: 0 0 40px rgba(168, 85, 247, 0.15), 0 20px 60px rgba(0, 0, 0, 0.5);
}

.detail-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 10;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    transition: background 0.2s;
}

.detail-close-btn:hover {
    background: rgba(155, 89, 182, 0.5);
}

.detail-hero {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    overflow: hidden;
}

.detail-hero img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.detail-hero-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    background: linear-gradient(135deg, #1a1a2e, #2d1f3d);
}

.detail-hero-gradient {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60%;
    background: linear-gradient(transparent, #1a1530);
    pointer-events: none;
}

.detail-body {
    padding: var(--spacing-lg) var(--spacing-xl);
    padding-top: 0;
    padding-bottom: clamp(20px, 4dvh, 40px);
}

.detail-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-primary);
    margin-bottom: var(--spacing-sm);
    margin-top: calc(var(--spacing-md) * -1);
    position: relative;
}

.detail-meta {
    display: flex;
    gap: var(--spacing-md);
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
    flex-wrap: wrap;
}

.detail-moods {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: var(--spacing-md);
}

.detail-mood-tag {
    font-size: 0.75rem;
    padding: 3px 10px;
    border-radius: 12px;
    background: rgba(155, 89, 182, 0.15);
    border: 1px solid rgba(155, 89, 182, 0.25);
    color: var(--text-secondary);
}

.detail-show-info {
    display: flex;
    gap: var(--spacing-md);
    font-size: 0.85rem;
    color: var(--accent-secondary);
    margin-bottom: var(--spacing-sm);
}

.detail-description {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.65;
    margin-bottom: var(--spacing-md);
}

.detail-note {
    font-size: 0.9rem;
    color: #e056fd;
    font-style: italic;
    padding: var(--spacing-sm) var(--spacing-md);
    background: rgba(155, 89, 182, 0.08);
    border-left: 3px solid var(--accent-secondary);
    border-radius: var(--radius-sm);
    margin-bottom: var(--spacing-md);
}

.detail-actions {
    margin-bottom: var(--spacing-lg);
}

.detail-play-btn {
    padding: 10px 28px;
    border: none;
    border-radius: var(--radius-xl);
    background: linear-gradient(135deg, #ffd700, #9b59b6);
    color: #0d0b1e;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.detail-play-btn:hover {
    transform: scale(1.04);
    box-shadow: 0 4px 20px rgba(255, 215, 0, 0.4);
}

.detail-comments-section {
    border-top: 1px solid rgba(155, 89, 182, 0.15);
    padding-top: var(--spacing-md);
}

.detail-comments-section h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
}

@media (max-width: 600px) {
    .detail-modal {
        padding: 10px;
    }
    .detail-modal-content {
        max-height: calc(100dvh - 20px);
        overflow-y: auto;
        border-radius: 16px;
        width: 100%;
        max-width: 100%;
    }
    .detail-body {
        padding: var(--spacing-md) var(--spacing-lg);
        padding-top: 0;
    }
    .detail-title {
        font-size: 1.25rem;
    }
}

.video-rating {
    font-size: 0.9rem;
    margin-top: var(--spacing-sm);
    letter-spacing: 2px;
}

.video-comment {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: var(--spacing-sm);
    font-style: italic;
    padding: var(--spacing-sm);
    background: var(--bg-glass);
    border-radius: var(--radius-sm);
    border-left: 2px solid var(--accent-primary);
}

/* User Reviews */
.reviews-header {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-primary);
    margin-top: var(--spacing-sm);
    margin-bottom: var(--spacing-xs);
}

.user-reviews {
    margin-top: var(--spacing-sm);
    border-top: 1px solid rgba(155, 89, 182, 0.2);
    padding-top: var(--spacing-sm);
}

.user-review {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
    font-size: 0.75rem;
    margin-bottom: var(--spacing-xs);
    padding: var(--spacing-xs);
    background: var(--bg-glass);
    border-radius: var(--radius-sm);
}

.reviewer-name {
    color: #e056fd;
    font-weight: 600;
}

.reviewer-rating {
    font-size: 0.65rem;
    color: #feca57;
}

.half-star-display {
    background: linear-gradient(90deg, #feca57 50%, #666 50%);
    background-clip: text; -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.reviewer-comment {
    color: var(--text-muted);
    font-style: italic;
    width: 100%;
}

.delete-review {
    cursor: pointer;
    font-size: 0.7rem;
    opacity: 0.7;
    transition: all var(--transition-fast);
    margin-right: var(--spacing-xs);
}

.delete-review:hover {
    opacity: 1;
    transform: scale(1.2);
}

/* Rating Form */
.rating-form {
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-md);
    border-top: 1px solid rgba(155, 89, 182, 0.2);
}

.rating-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: var(--spacing-sm);
    font-style: italic;
}

.thank-you-message {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent-primary);
    text-align: center;
    padding: var(--spacing-md);
}

/* Star Rating */
.star-rating {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing-sm);
}

.star-item {
    font-size: 1.5rem;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.2);
    transition: all var(--transition-fast);
    position: relative;
    -webkit-text-stroke: 1px rgba(168, 85, 247, 0.25);
}

.star-item:hover {
    transform: scale(1.2);
}

.star-item.full {
    color: var(--accent-primary);
    text-shadow: 0 0 10px var(--accent-glow);
}

.star-item.half {
    background: linear-gradient(90deg, var(--accent-primary) 50%, rgba(255, 255, 255, 0.2) 50%);
    background-clip: text; -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.rating-value {
    font-size: 0.8rem;
    color: var(--accent-primary);
    font-weight: 600;
    margin-left: var(--spacing-xs);
}

.rating-name,
.rating-comment {
    width: 100%;
    padding: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
    font-family: inherit;
    font-size: 0.85rem;
    color: var(--text-primary);
    background: var(--bg-glass);
    border: 1px solid rgba(155, 89, 182, 0.3);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition-fast);
}

.rating-name:focus,
.rating-comment:focus {
    border-color: var(--accent-primary);
}

.rating-name::placeholder,
.rating-comment::placeholder {
    color: var(--text-muted);
}

.submit-rating {
    width: 100%;
    padding: var(--spacing-sm);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    color: #0d0b1e;
    background: linear-gradient(135deg, #ffd700, #ffec8b);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-normal);
}

.submit-rating:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px var(--accent-glow);
}

.upload-hint {
    text-align: center;
    margin-top: var(--spacing-2xl);
    padding: var(--spacing-lg);
    background: var(--bg-glass);
    border-radius: var(--radius-lg);
    border: 1px dashed rgba(155, 89, 182, 0.3);
}

.upload-hint p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.upload-hint code {
    background: rgba(155, 89, 182, 0.2);
    padding: 0.2em 0.4em;
    border-radius: var(--radius-sm);
    color: var(--accent-primary);
}

/* ==========================================
   VIDEO PLAYER MODAL - FULLY RESPONSIVE
   ========================================== */

.video-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    padding: 0;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.98);
}

.modal-content {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    background: #000;
    display: flex;
    flex-direction: column;
    z-index: 1;
}

@media (min-width: 769px) {
    .video-modal {
        padding: var(--spacing-lg);
    }

    .modal-content {
        max-width: 1200px;
        max-height: 90vh;
        height: auto;
        border-radius: var(--radius-xl);
        border: 1px solid rgba(155, 89, 182, 0.3);
        box-shadow: 0 0 80px var(--accent-glow-purple);
        overflow: hidden;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-md);
    background: rgba(0, 0, 0, 0.8);
    border-bottom: 1px solid rgba(155, 89, 182, 0.2);
    flex-shrink: 0;
    gap: var(--spacing-sm);
}

.modal-header h2 {
    font-size: clamp(0.75rem, 3vw, 1.25rem);
    font-weight: 600;
    color: var(--accent-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    text-align: left;
    min-width: 0;
}

.close-modal {
    width: 32px;
    height: 32px;
    min-width: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.close-modal:hover,
.close-modal:active {
    background: var(--accent-secondary);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    flex-shrink: 0;
}

.subtitle-select {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 500;
    color: #fff;
    background: #222;
    border: 1px solid rgba(155, 89, 182, 0.3);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.subtitle-select option {
    color: #fff;
    background: #222;
}

.subtitle-select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.video-hint {
    text-align: center;
    padding: var(--spacing-xs);
    font-size: 0.7rem;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.8);
}

.video-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    width: 100%;
    overflow: hidden;
}

#video-player {
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: 70vh;
    display: block;
    background: #000;
}

@media (max-width: 768px) {
    #video-player {
        max-height: 50vh;
    }
}

.video-reactions-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
    overflow: hidden;
}

.video-floating-emoji {
    position: absolute;
    font-size: 2rem;
    animation: floatUpEmoji 2s ease-out forwards;
    pointer-events: none;
}

@keyframes floatUpEmoji {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-120px) scale(1.5); }
}

.video-reaction-bar {
    display: flex;
    justify-content: center;
    gap: 4px;
    padding: 8px;
    background: rgba(0,0,0,0.6);
    flex-wrap: wrap;
}

.video-reaction-btn {
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 20px;
    padding: 6px 10px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.15s, background 0.15s;
}

.video-reaction-btn:hover {
    background: rgba(255,255,255,0.2);
    transform: scale(1.2);
}

/* Hide download button in video controls */
video::-webkit-media-controls-download-button {
    display: none !important;
}

video::-webkit-media-controls-enclosure {
    overflow: hidden;
}

video::-webkit-media-controls-panel {
    width: calc(100% + 30px);
}

/* Transparent subtitle background */
video::cue {
    background: transparent;
    color: white;
    font-size: clamp(0.9rem, 2.5vw, 1.8rem);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.9), -1px -1px 2px rgba(0, 0, 0, 0.9);
}

/* Larger subtitles in fullscreen / landscape */
video:fullscreen::cue,
*:fullscreen video::cue {
    font-size: clamp(1.2rem, 3vw, 2.5rem);
}

/* Portrait mobile - smaller subtitles */
@media (orientation: portrait) and (max-width: 768px) {
    video::cue {
        font-size: clamp(0.75rem, 3.5vw, 1.2rem);
    }
}

/* Custom Video Controls */
.custom-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-md);
    background: rgba(0, 0, 0, 0.9);
    border-top: 1px solid rgba(155, 89, 182, 0.2);
    flex-wrap: wrap;
}

.control-btn {
    padding: var(--spacing-xs) var(--spacing-md);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    background: linear-gradient(145deg, #4a4a6a, #3a3a5a);
    border: 1px solid rgba(155, 89, 182, 0.3);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.control-btn:hover {
    background: linear-gradient(145deg, #5a5a7a, #4a4a6a);
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

.speed-select {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    background: linear-gradient(145deg, #4a4a6a, #3a3a5a);
    border: 1px solid rgba(155, 89, 182, 0.3);
    border-radius: var(--radius-md);
    cursor: pointer;
}

.speed-select:focus {
    outline: none;
    border-color: #ffd700;
}

.download-btn {
    background: linear-gradient(135deg, #ffd700, #ffec8b);
    color: #0d0b1e;
}

.download-btn:hover {
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.5);
}


/* Video Loading Overlay */
.video-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    gap: var(--spacing-md);
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Custom Video Controls */
.video-controls {
    display: flex;
    align-items: center;
    gap: clamp(4px, 2vw, var(--spacing-md));
    padding: var(--spacing-sm) var(--spacing-md);
    padding-bottom: calc(var(--spacing-sm) + var(--safe-area-bottom));
    background: linear-gradient(to top, rgba(0, 0, 0, 0.95), rgba(0, 0, 0, 0.7));
    flex-wrap: wrap;
    flex-shrink: 0;
}

/* Hide controls on touch devices until tapped */
@media (hover: none) and (pointer: coarse) {
    .video-controls {
        transition: opacity var(--transition-normal);
    }

    .video-controls.visible {
        opacity: 1;
    }
}

.control-btn {
    width: clamp(32px, 10vw, 44px);
    height: clamp(32px, 10vw, 44px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1rem, 4vw, 1.25rem);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}

.control-btn:hover,
.control-btn:active {
    background: var(--accent-primary);
    color: #0d0b1e;
}

.progress-container {
    flex: 1;
    min-width: 100px;
    height: clamp(6px, 2vw, 10px);
    background: rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    cursor: pointer;
    position: relative;
    order: 10;
    width: 100%;
    margin-top: var(--spacing-xs);
}

@media (min-width: 600px) {
    .progress-container {
        order: 0;
        width: auto;
        margin-top: 0;
    }
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 5px;
    width: 0%;
    transition: width 0.1s linear;
    pointer-events: none;
}

.progress-thumb {
    position: absolute;
    top: 50%;
    width: 16px;
    height: 16px;
    background: var(--accent-primary);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    left: 0%;
    box-shadow: 0 0 10px var(--accent-glow);
    pointer-events: none;
}

.time-display {
    font-size: clamp(0.7rem, 2.5vw, 0.875rem);
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    min-width: fit-content;
    text-align: center;
    white-space: nowrap;
}

.volume-container {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

/* Mobile Optimization for Hangman */
@media (max-width: 600px) {
    .hangman-game-area {
        gap: 0;
        padding: 0.3rem;
        min-height: auto;
    }

    .hangman-svg-wrap {
        width: 110px;
        height: auto;
        margin-bottom: 0;
        overflow: visible;
    }

    .hangman-phrase {
        margin: 0.1rem 0;
        min-height: auto;
        padding: 0;
        gap: 6px;
    }

    .hangman-word {
        font-size: 1.2rem;
        letter-spacing: 0.05rem;
        margin: 0;
    }

    .hangman-letter {
        width: 22px;
        height: 32px;
        font-size: 1.1rem;
        border-bottom-width: 2px;
    }

    /* Hangman-specific keyboard: QWERTY reverse-pyramid layout */
    .hangman-game-area .keyboard {
        gap: 5px;
        margin-top: 0.3rem;
        padding: 0 2px;
        width: 100%;
        max-width: 360px;
        margin-left: auto;
        margin-right: auto;
    }

    .hangman-game-area .keyboard-row {
        gap: 4px;
        justify-content: center;
    }

    /* Row 2 (ASDFGHJKL) - indent slightly for pyramid effect */
    .hangman-game-area .keyboard-row:nth-child(2) {
        padding: 0 5%;
    }

    /* Row 3 (ZXCVBNM) - indent more for pyramid effect */
    .hangman-game-area .keyboard-row:nth-child(3) {
        padding: 0 10%;
    }

    .hangman-game-area .key {
        flex: 1;
        min-width: 0;
        max-width: 36px;
        height: 36px;
        font-size: 0.75rem;
        font-weight: 700;
        padding: 0;
        border-radius: 6px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(155, 89, 182, 0.2);
        border: 1px solid rgba(155, 89, 182, 0.4);
        color: #e8e8e8;
    }

    .hangman-game-area .key:active {
        background: rgba(155, 89, 182, 0.5);
        transform: scale(0.95);
    }

    .hangman-game-area .key.used {
        opacity: 0.3;
        pointer-events: none;
    }

    .hangman-game-area .key.correct {
        background: rgba(39, 174, 96, 0.4);
        border-color: rgba(39, 174, 96, 0.6);
    }

    .hangman-game-area .key.wrong {
        background: rgba(231, 76, 60, 0.3);
        border-color: rgba(231, 76, 60, 0.5);
    }
}


/* Hide Hangman Status (Chances left) */
.hangman-status {
    display: none !important;
}

/* Hangman Hint Removed */

/* ==========================================
   Unified Confirm/Alert Modal (SFX Modal)
   ========================================== */
.sfx-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 1rem;
    animation: fadeIn 0.2s ease;
    backdrop-filter: blur(4px);
}
.sfx-modal.hidden {
    display: none;
}
.sfx-modal-content {
    text-align: center;
    padding: 2rem 2.5rem;
    background: linear-gradient(135deg, rgba(25, 20, 50, 0.95), rgba(15, 12, 30, 0.98));
    border-radius: 16px;
    border: 1px solid rgba(168, 85, 247, 0.35);
    position: relative;
    overflow: hidden;
    animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 0 40px rgba(168, 85, 247, 0.15), 0 20px 60px rgba(0, 0, 0, 0.5);
    max-width: 380px;
    width: 90vw;
}
.sfx-modal-icon {
    font-size: 3rem;
    margin-bottom: 0.75rem;
}
.sfx-modal-text {
    font-size: 1.1rem;
    font-weight: 500;
    color: #e0e0e0;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}
.sfx-modal-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}
.sfx-modal-btn {
    padding: 10px 24px;
    border: none;
    border-radius: 10px;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 100px;
}
.sfx-modal-btn:hover {
    transform: translateY(-1px);
}
.sfx-btn-primary {
    background: linear-gradient(135deg, #ffd700, #ffec8b);
    color: #0d0b1e;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.35);
}
.sfx-btn-primary:hover {
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.5);
}
.sfx-btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.15);
}
.sfx-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
    color: white;
}
.sfx-btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}
.sfx-btn-danger:hover {
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

/* Hide volume slider on mobile */
@media (max-width: 600px) {
    .volume-slider {
        display: none;
    }
}

.volume-slider {
    width: clamp(50px, 10vw, 80px);
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--accent-primary);
    border-radius: 50%;
    cursor: pointer;
}

.volume-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--accent-primary);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.speed-select {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-family: inherit;
    font-size: clamp(0.75rem, 2vw, 0.875rem);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.speed-select:hover,
.speed-select:focus {
    border-color: var(--accent-primary);
    outline: none;
}

/* Hide less essential controls on very small screens */
@media (max-width: 400px) {

    #pip-btn,
    #rewind-btn,
    #forward-btn {
        display: none;
    }
}

/* ==========================================
   FULLSCREEN STYLES
   ========================================== */

.modal-content:fullscreen,
.modal-content:-webkit-full-screen {
    max-width: 100%;
    max-height: 100%;
    width: 100%;
    height: 100%;
    border-radius: 0;
}

.modal-content:fullscreen .video-wrapper,
.modal-content:-webkit-full-screen .video-wrapper {
    flex: 1;
}

.modal-content:fullscreen #video-player,
.modal-content:-webkit-full-screen #video-player {
    max-height: 100%;
}

/* ==========================================
   RESPONSIVE BREAKPOINTS
   ========================================== */

@media (max-width: 768px) {
    .gallery-header {
        justify-content: center;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .wordle-container {
        padding: var(--spacing-sm);
    }

    .game-board {
        margin-bottom: var(--spacing-md);
    }

    .keyboard {
        margin-bottom: var(--spacing-sm);
    }
}

/* Landscape phone optimization */
@media (max-height: 500px) and (orientation: landscape) {
    .wordle-section {
        padding: var(--spacing-sm);
    }

    .wordle-container {
        padding: var(--spacing-sm);
    }

    .wordle-header {
        margin-bottom: var(--spacing-sm);
    }

    .tile {
        width: clamp(24px, 6vh, 40px);
    }
}

/* Show Cards now use .video-card styles for consistency */

.show-progress-badge {
    position: absolute;
    bottom: var(--spacing-sm);
    left: var(--spacing-sm);
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.8);
    color: var(--accent-primary);
    border-radius: var(--radius-sm);
    backdrop-filter: blur(10px);
}

.new-badge {
    position: absolute;
    top: var(--spacing-sm);
    right: var(--spacing-sm);
    padding: 3px 10px;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #8e44ad, #a855f7);
    color: #fff;
    border-radius: 4px;
    text-transform: uppercase;
    box-shadow: 0 2px 8px rgba(142, 68, 173, 0.4);
    z-index: 2;
    animation: newBadgePulse 2s ease-in-out infinite;
}

@keyframes newBadgePulse {
    0%, 100% { box-shadow: 0 2px 8px rgba(142, 68, 173, 0.4); }
    50% { box-shadow: 0 2px 16px rgba(142, 68, 173, 0.7); }
}

/* ========== Pull to Refresh ========== */
.pull-refresh-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 0;
    opacity: 0;
    overflow: hidden;
    transition: height 0.25s ease, opacity 0.25s ease;
}

.pull-refresh-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(155, 89, 182, 0.2);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
}

.pull-refresh-indicator.ready .pull-refresh-spinner {
    transform: rotate(180deg);
}

.pull-refresh-indicator.refreshing .pull-refresh-spinner {
    animation: pullSpin 0.6s linear infinite;
}

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

/* ========== Book Card Styles ========== */

.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr));
    gap: var(--spacing-md);
    max-width: 1400px;
    margin: 0 auto;
}

@media (min-width: 900px) {
    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
}

@media (min-width: 1200px) {
    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }
}

.book-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid rgba(155, 89, 182, 0.18);
    transition: transform var(--transition-normal), border-color var(--transition-normal), box-shadow var(--transition-normal), opacity var(--transition-normal);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.book-card:hover,
.book-card:active {
    transform: translateY(-5px);
    border-color: var(--accent-primary);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5), 0 0 20px var(--accent-glow-purple);
}

.book-thumbnail {
    position: relative;
    height: 400px;
    background: linear-gradient(135deg, #1a1a2e, #2d1f3d);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.book-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.read-overlay {
    position: absolute;
    width: clamp(50px, 15vw, 70px);
    height: clamp(50px, 15vw, 70px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: var(--radius-lg);
    opacity: 0;
    transform: scale(0.8);
    transition: all var(--transition-normal);
    box-shadow: 0 0 30px var(--accent-glow);
}

.book-card:hover .read-overlay,
.book-card:active .read-overlay,
.book-card:focus-within .read-overlay {
    opacity: 1;
    transform: scale(1.1);
}

@media (max-width: 768px) {
    .book-card:not(.locked):active .read-overlay {
        opacity: 1;
        transform: scale(1);
    }
}

/* Force read-overlay on mobile removed */

.book-progress-badge {
    position: absolute;
    bottom: var(--spacing-sm);
    left: var(--spacing-sm);
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.8);
    color: var(--accent-primary);
    border-radius: var(--radius-sm);
    backdrop-filter: blur(10px);
}

/* Book Reader Modal */
.book-reader-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100vh;
    height: 100dvh;
    background: #0f0e17;
    display: flex;
    flex-direction: column;
    z-index: 2000;
    animation: fadeIn 0.3s ease;
    overscroll-behavior: none;
    overflow: hidden;
    touch-action: pinch-zoom;
}

.book-reader-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-lg);
    background: linear-gradient(180deg, #151321 0%, #0f0e17 100%);
    border-bottom: 1px solid rgba(155, 89, 182, 0.15);
    flex-shrink: 0;
    min-height: 52px;
}

.book-reader-header .book-reader-close {
    background: rgba(155, 89, 182, 0.12);
    border: 1px solid rgba(155, 89, 182, 0.25);
    color: var(--text-primary);
    font-size: 1.1rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-normal);
    flex-shrink: 0;
}

.book-reader-header .book-reader-close:hover {
    background: rgba(231, 76, 60, 0.3);
    border-color: rgba(231, 76, 60, 0.5);
}

.book-reader-header .book-reader-title {
    font-size: clamp(0.85rem, 2.5vw, 1rem);
    font-weight: 600;
    color: #e8e0f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.book-reader-header .book-reader-controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    flex-shrink: 0;
}

.book-reader-header .book-reader-chapter {
    font-size: 0.75rem;
    color: rgba(155, 89, 182, 0.7);
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.book-reader-header .book-reader-progress {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-primary);
    white-space: nowrap;
    min-width: 36px;
    text-align: right;
}

.book-reader-area {
    flex: 1;
    width: 100%;
    overflow: hidden;
    position: relative;
    background: #141220;
    min-height: 0; /* critical for flex children */
    touch-action: pinch-zoom;
    overscroll-behavior: none;
}

/* Book Reader Bottom Nav Bar */
.book-reader-nav {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-lg);
    background: linear-gradient(180deg, #0f0e17 0%, #151321 100%);
    border-top: 1px solid rgba(155, 89, 182, 0.15);
    flex-shrink: 0;
    min-height: 52px;
}

.book-nav-btn {
    background: rgba(155, 89, 182, 0.12);
    border: 1px solid rgba(155, 89, 182, 0.25);
    color: var(--text-primary);
    font-size: 1.1rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.book-nav-btn:hover {
    background: rgba(155, 89, 182, 0.3);
    border-color: var(--accent-primary);
    transform: scale(1.05);
}

.book-nav-btn:active {
    transform: scale(0.95);
}

.book-reader-tracker {
    flex: 1;
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.book-tracker-bar {
    flex: 1;
    height: 6px;
    background: rgba(155, 89, 182, 0.12);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.book-tracker-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 3px;
    width: 0%;
    transition: width 0.4s ease;
    box-shadow: 0 0 8px rgba(155, 89, 182, 0.4);
}

.book-tracker-text {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent-primary);
    min-width: 40px;
    text-align: center;
    white-space: nowrap;
}

.book-jump-form {
    display: flex;
    align-items: center;
    background: rgba(155, 89, 182, 0.12);
    border: 1px solid rgba(155, 89, 182, 0.25);
    border-radius: 20px;
    padding: 4px 14px;
    min-width: 80px;
    justify-content: center;
}

.book-page-num {
    cursor: pointer;
    user-select: none;
    transition: color 0.15s;
}

.book-page-num:hover { color: #c9a0ff; }

.book-jump-input {
    background: transparent;
    border: none;
    outline: none;
    color: #e8e0f0;
    font-size: 0.85rem;
    font-weight: 700;
    width: 80px;
    text-align: center;
    font-family: inherit;
    letter-spacing: 0.02em;
}

.book-jump-input::-webkit-inner-spin-button,
.book-jump-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* Mobile adjustments for reader */
@media (max-width: 768px) {
    .book-reader-header {
        padding: 8px 14px;
        min-height: 48px;
        gap: 10px;
    }
    .book-reader-header .book-reader-title {
        font-size: 0.9rem;
    }
    .book-reader-header .book-reader-chapter {
        display: none;
    }
    .book-reader-nav {
        padding: 8px 14px;
        min-height: 56px;
        gap: 10px;
    }
    .book-nav-btn {
        width: 44px;
        height: 44px;
        font-size: 1.2rem;
    }
    .book-reader-area {
        max-width: 100%;
        background: #141220;
    }
    .book-jump-input {
        width: 48px;
        font-size: 0.75rem;
    }
    .book-jump-form {
        padding: 3px 8px;
        gap: 6px;
    }
}


/* Show Modal (Season/Episode Selector) */
.show-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--spacing-md);
    animation: fadeIn 0.2s ease;
    backdrop-filter: blur(4px);
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 600px) {
    .show-modal {
        padding: 10px;
    }
    .show-modal-content {
        max-height: calc(100dvh - 20px);
        border-radius: 16px;
        width: 100%;
        max-width: 100%;
    }
}

.show-modal-content {
    background: linear-gradient(135deg, rgba(25, 20, 50, 0.95), rgba(15, 12, 30, 0.98));
    border-radius: 16px;
    border: 1px solid rgba(168, 85, 247, 0.35);
    box-shadow: 0 0 40px rgba(168, 85, 247, 0.15), 0 20px 60px rgba(0, 0, 0, 0.5);
    max-width: 600px;
    width: 100%;
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
}

.show-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md) var(--spacing-lg);
    /* Reduced vertical padding slightly to match player */
    background: rgba(0, 0, 0, 0.95);
    /* Match player header style (very dark) */
    border-bottom: 1px solid rgba(155, 89, 182, 0.2);
}

.show-modal-header h2 {
    font-size: 1.25rem;
    color: var(--accent-primary);
}

.season-selector {
    padding: 6px 12px;
    /* Fixed padding for better vertical alignment */
    height: 36px;
    /* Explicit height */
    line-height: 1.2;
    /* Better line height for text */
    font-family: inherit;
    font-size: 0.9rem;
    background: var(--bg-glass);
    color: var(--text-primary);
    border: 1px solid rgba(155, 89, 182, 0.3);
    border-radius: var(--radius-md);
    cursor: pointer;
}

.season-selector:focus {
    border-color: var(--accent-primary);
    outline: none;
}

.episode-list {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-md);
    padding-bottom: clamp(20px, 4dvh, 40px);
    -webkit-overflow-scrolling: touch;
}

.episode-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--bg-glass);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-sm);
    cursor: pointer;
    transition: all var(--transition-normal);

    /* Unwatched: Bright Theme Accent */
    background: linear-gradient(90deg, rgba(142, 68, 173, 0.1), transparent);
    border: 1px solid rgba(142, 68, 173, 0.2);
    border-left: 4px solid var(--accent-primary);
}

.episode-item:hover {
    border-color: var(--accent-primary);
    background: linear-gradient(90deg, rgba(142, 68, 173, 0.2), transparent);
    transform: translateX(5px);
}

.episode-item.watched {
    /* Watched: Green/Done State - Distinct from Unwatched */
    opacity: 0.8;
    background: linear-gradient(90deg, rgba(46, 204, 113, 0.1), transparent);
    border-color: rgba(46, 204, 113, 0.2);
    border-left-color: #2ecc71;
}

.episode-item.watched .episode-title {
    color: #2ecc71;
    text-decoration: none;
}

.episode-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-secondary);
    min-width: 40px;
}

.episode-info {
    flex: 1;
}

.episode-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
}

.episode-duration {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.episode-play {
    font-size: 1.5rem;
    opacity: 0.7;
    transition: all var(--transition-fast);
}

.episode-item:hover .episode-play {
    opacity: 1;
    transform: scale(1.2);
}

/* ==========================================
   PLAYLIST CARDS (MUSIC)
   ========================================== */

.playlist-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid rgba(155, 89, 182, 0.15);
    transition: transform var(--transition-normal), border-color var(--transition-normal), box-shadow var(--transition-normal), opacity var(--transition-normal);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.playlist-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent-primary);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5), 0 0 20px var(--accent-glow-purple);
}

.playlist-thumbnail {
    position: relative;
    aspect-ratio: 1/1;
    overflow: hidden;
    background: linear-gradient(135deg, #1a1a2e, #2d1f3d);
}

.playlist-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.playlist-play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.playlist-card:hover .playlist-play-overlay {
    opacity: 1;
}

@media (max-width: 768px) {
    .playlist-card:active .playlist-play-overlay {
        opacity: 1;
    }
}

.playlist-play-btn {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 50%;
    transform: scale(0.8);
    transition: transform var(--transition-normal);
    box-shadow: 0 0 30px var(--accent-glow);
}

.playlist-card:hover .playlist-play-btn {
    transform: scale(1);
}

.playlist-info {
    padding: var(--spacing-md);
}

.playlist-info h3 {
    font-size: clamp(0.95rem, 2.5vw, 1.1rem);
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
    color: var(--accent-primary);
}

.playlist-info p {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: var(--spacing-sm);
}

.playlist-note {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
    padding: var(--spacing-sm);
    background: var(--bg-glass);
    border-radius: var(--radius-sm);
    border-left: 2px solid var(--accent-secondary);
}

.mood-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
    margin-top: var(--spacing-sm);
}

.mood-tag {
    padding: 2px 8px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(155, 89, 182, 0.2);
    color: var(--accent-secondary);
    border-radius: var(--radius-sm);
}

/* Media Modal (Embed Player) */
.media-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--spacing-md);
    animation: fadeIn 0.3s ease;
}

.media-modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    border: 1px solid rgba(155, 89, 182, 0.3);
    max-width: 500px;
    width: 100%;
    overflow: hidden;
}

.media-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-lg);
    border-bottom: 1px solid rgba(155, 89, 182, 0.2);
}

.media-modal-header h2 {
    font-size: 1.25rem;
    color: var(--accent-primary);
}

.media-modal-body {
    padding: var(--spacing-lg);
}

.media-embed {
    width: 100%;
    aspect-ratio: 1/1;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #121212;
    margin-bottom: var(--spacing-lg);
}

.media-embed iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.media-placeholder {
    width: 100%;
    height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-md);
    background: linear-gradient(135deg, rgba(155, 89, 182, 0.2), rgba(168, 85, 247, 0.1));
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-lg);
}

.media-placeholder-icon {
    font-size: 3rem;
    animation: bounce 1s ease infinite;
}

.media-placeholder-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
}

.media-note {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-style: italic;
    padding: var(--spacing-md);
    background: var(--bg-glass);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--accent-secondary);
}

.close-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    background: transparent;
    border: 1px solid rgba(155, 89, 182, 0.3);
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-normal);
}

.close-btn:hover {
    background: rgba(155, 89, 182, 0.2);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

/* ==========================================
   TIC TAC TOE GAME STYLES
   ========================================== */

.ttt-container {
    max-width: 500px;
    margin: 0 auto;
    padding: var(--spacing-lg);
    text-align: center;
}

.ttt-title {
    font-size: clamp(1.5rem, 5vw, 2rem);
    font-weight: 700;
    margin-bottom: var(--spacing-lg);
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    background-clip: text; -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Score Display */
.ttt-scores {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--spacing-lg);
    margin-bottom: clamp(4px, 1.5dvh, var(--spacing-xl));
}

.score-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-md);
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 2px solid transparent;
    transition: all var(--transition-normal);
    min-width: 100px;
}

.score-card.active {
    border-color: var(--accent-primary);
    box-shadow: 0 0 20px var(--accent-glow);
    transform: scale(1.05);
}

.score-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--accent-secondary);
    box-shadow: 0 0 15px var(--accent-glow-purple);
}

.score-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.score-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--accent-primary);
}

.score-vs {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-muted);
}

/* Leave Cross Button - positioned above avatar */
.leave-cross-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: bold;
    cursor: pointer;
    z-index: 100;
    box-shadow: 0 3px 10px rgba(231, 76, 60, 0.4);
    transition: all 0.2s ease;
    line-height: 1;
    padding: 0;
}

.leave-cross-btn:hover {
    background: linear-gradient(135deg, #ff6b6b, #e74c3c);
    transform: scale(1.15);
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.6);
}

.leave-cross-btn:active {
    transform: scale(0.9);
}

/* Game Grid */
.ttt-grid {
    display: grid;
    grid-template-columns: repeat(3, clamp(60px, 10dvh, 80px));
    gap: clamp(4px, 0.8dvh, 8px);
    justify-content: center;
    margin: 0 auto clamp(4px, 1dvh, var(--spacing-lg));
    padding: clamp(6px, 1dvh, var(--spacing-md));
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(155, 89, 182, 0.3);
}

.ttt-cell {
    width: clamp(60px, 10dvh, 80px);
    height: clamp(60px, 10dvh, 80px);
    background: var(--tile-empty);
    border: 2px solid var(--tile-border);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast);
    padding: 8px;
    overflow: hidden;
}

.ttt-cell:hover:not(.filled) {
    border-color: var(--accent-primary);
    background: rgba(168, 85, 247, 0.1);
}

.ttt-cell.filled {
    cursor: default;
}

.ttt-cell img {
    width: clamp(40px, 8dvh, 56px);
    height: clamp(40px, 8dvh, 56px);
    object-fit: cover;
    border-radius: 50%;
    animation: popIn 0.3s ease;
    flex-shrink: 0;
}

@keyframes popIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    50% {
        transform: scale(1.2);
    }

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

/* Turn Indicator */
.ttt-turn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: clamp(4px, 1dvh, var(--spacing-lg));
}

.turn-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent-primary);
}

/* Controls */
.ttt-controls {
    display: flex;
    justify-content: center;
    gap: var(--spacing-md);
    flex-wrap: wrap;
}

.ttt-btn {
    padding: var(--spacing-sm) var(--spacing-lg);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    color: #0d0b1e;
    background: linear-gradient(135deg, #ffd700, #ffec8b);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.35);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.ttt-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.5);
}

.ttt-btn.secondary {
    background: linear-gradient(135deg, #8e44ad, #9b59b6);
    color: #fff;
    box-shadow: 0 4px 15px rgba(142, 68, 173, 0.3);
    border: none;
}

.ttt-btn.secondary:hover {
    background: linear-gradient(135deg, #9b59b6, #a96bc8);
    box-shadow: 0 6px 20px rgba(142, 68, 173, 0.4);
    color: #fff;
}

.ttt-btn.danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
    font-size: 0.85rem;
}

.ttt-btn.danger:hover {
    background: linear-gradient(135deg, #ff6b6b, #ef4444);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

/* Result Modal */
.ttt-result-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    padding: var(--spacing-md);
    animation: fadeIn 0.2s ease;
    backdrop-filter: blur(4px);
}

.ttt-result-content {
    text-align: center;
    padding: 2rem 2.5rem;
    background: linear-gradient(135deg, rgba(25, 20, 50, 0.95), rgba(15, 12, 30, 0.98));
    border-radius: 16px;
    border: 1px solid rgba(168, 85, 247, 0.35);
    backdrop-filter: blur(20px);
    position: relative;
    overflow: hidden;
    animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 0 40px rgba(168, 85, 247, 0.15), 0 20px 60px rgba(0, 0, 0, 0.5);
    max-width: 380px;
    width: 90vw;
}

.ttt-result-icon {
    font-size: 3rem;
    margin-bottom: 0.75rem;
}

.ttt-result-icon img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid rgba(168, 85, 247, 0.6);
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.3);
    animation: bounce 1s ease infinite;
}

.ttt-result-text {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    color: #e0e0e0;
}

/* Unified button style inside modals */
.ttt-result-modal .ttt-btn {
    padding: 10px 24px;
    border-radius: 10px;
    font-size: 0.95rem;
    background: linear-gradient(135deg, #ffd700, #ffec8b);
    color: #0d0b1e;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.35);
}
.ttt-result-modal .ttt-btn:hover {
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.5);
}
.ttt-result-modal .ttt-btn.secondary {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: none;
}
.ttt-result-modal .ttt-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.12);
    color: white;
}
.ttt-result-modal .purple-btn {
    background: linear-gradient(135deg, #8e44ad, #9b59b6);
    color: #fff;
    box-shadow: 0 4px 15px rgba(142, 68, 173, 0.3);
}

.ttt-confetti {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .ttt-scores {
        gap: var(--spacing-sm);
        margin-bottom: clamp(2px, 1dvh, var(--spacing-md));
    }

    .score-card {
        padding: clamp(4px, 0.8dvh, var(--spacing-sm));
        min-width: 70px;
    }

    .score-avatar {
        width: clamp(28px, 5dvh, 45px);
        height: clamp(28px, 5dvh, 45px);
    }

    .score-value {
        font-size: clamp(1rem, 2.5dvh, 1.5rem);
    }

    .ttt-grid {
        max-width: 280px;
        gap: 4px;
        padding: 6px;
    }

    .ttt-cell {
        padding: 4px;
    }

    .ttt-controls {
        flex-direction: row;
        gap: var(--spacing-sm);
        flex-wrap: wrap;
        justify-content: center;
    }

    .ttt-btn {
        flex: 1;
        min-width: 100px;
        max-width: 200px;
        font-size: clamp(0.7rem, 1.8dvh, 0.9rem);
    }

    .game-container {
        padding: var(--spacing-sm);
    }

    .game-picker {
        padding: var(--spacing-sm);
    }

}

/* ==========================================
   HANGMAN GAME STYLES
   ========================================== */

.hangman-game-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md) 0;
}

.hangman-svg-wrap {
    width: 100%;
    max-width: 220px;
    margin: 0 auto;
    overflow: visible;
}

.hangman-svg {
    width: 100%;
    height: auto;
    overflow: visible;
    filter: drop-shadow(0 0 10px rgba(155, 89, 182, 0.3));
}

.hm-part {
    opacity: 0;
    transition: opacity 0.4s ease;
}

.hm-part.hidden {
    opacity: 0;
}

.hm-part.reveal-anim {
    opacity: 1;
    animation: hmReveal 0.5s ease;
}

@keyframes hmReveal {
    0% {
        opacity: 0;
        stroke: #e74c3c;
        stroke-width: 5;
    }

    50% {
        stroke: #e74c3c;
        stroke-width: 5;
    }

    100% {
        opacity: 1;
        stroke: #e8e8e8;
        stroke-width: 3;
    }
}

.hangman-lives {
    font-size: 0.95rem;
    margin: var(--spacing-sm) 0;
    text-align: center;
    color: var(--text-secondary);
    font-weight: 500;
}

.lives-count {
    font-family: 'Outfit', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    color: #e74c3c;
    margin-left: 6px;
    background: rgba(231, 76, 60, 0.15);
    padding: 2px 10px;
    border-radius: var(--radius-sm);
}

.hangman-phrase {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: var(--spacing-sm) var(--spacing-md);
    min-height: 40px;
    max-width: 400px;
    margin: 0 auto;
}

.hangman-word {
    display: flex;
    gap: 6px;
}

.hangman-space {
    width: 16px;
}

.hangman-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: clamp(28px, 7vw, 42px);
    height: clamp(36px, 9vw, 52px);
    font-size: clamp(1.2rem, 4vw, 1.6rem);
    font-weight: 700;
    color: var(--text-muted);
    border-bottom: 3px solid rgba(155, 89, 182, 0.5);
    transition: all 0.3s ease;
    font-family: 'Outfit', sans-serif;
}

.hangman-letter.revealed {
    background: linear-gradient(135deg, #fff700, #e0c2ff);
    background-clip: text; -webkit-background-clip: text;
    background-clip: text; /* standard */
    -webkit-text-fill-color: transparent;
    border-bottom-color: #fff700;
    animation: letterReveal 0.4s ease;
    filter: drop-shadow(0 0 8px rgba(255, 247, 0, 1)) drop-shadow(0 0 20px rgba(168, 85, 247, 0.9));
    text-shadow: 0 0 10px rgba(255, 247, 0, 0.4);
}

@keyframes letterReveal {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    60% {
        transform: scale(1.2);
    }

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

/* ==========================================
   TTT SESSION LOBBY STYLES
   ========================================== */

.ttt-lobby {
    margin-bottom: var(--spacing-xl);
}

.lobby-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-lg);
}

.lobby-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-md);
}

.lobby-card {
    padding: var(--spacing-lg);
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(155, 89, 182, 0.2);
    transition: all var(--transition-normal);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-sm);
    text-align: center;
}

.lobby-card:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 0 20px var(--accent-glow);
    transform: translateY(-3px);
}

.lobby-card-icon {
    font-size: 2.5rem;
    margin-bottom: var(--spacing-xs);
}

.lobby-card h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.lobby-card p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: var(--spacing-sm);
}

.lobby-input {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    font-family: 'Outfit', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    text-align: center;
    letter-spacing: 6px;
    text-transform: uppercase;
    color: var(--accent-primary);
    background: var(--bg-glass);
    border: 2px solid rgba(155, 89, 182, 0.3);
    border-radius: var(--radius-md);
    outline: none;
    transition: all var(--transition-fast);
}

.lobby-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 15px var(--accent-glow);
}

.lobby-input::placeholder {
    letter-spacing: 2px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.lobby-status {
    font-size: 0.9rem;
    padding: var(--spacing-sm);
    min-height: 24px;
    transition: all var(--transition-fast);
}

.lobby-status.error {
    color: #e74c3c;
}

.lobby-status.success {
    color: #2ecc71;
}

/* Session Key Display */
.ttt-key-display {
    text-align: center;
    padding: var(--spacing-xl);
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(168, 85, 247, 0.25);
    margin-bottom: var(--spacing-lg);
    position: relative;
}

.session-close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    border-radius: 50%;
    transition: all var(--transition-fast);
}

.session-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #e74c3c;
}

.ttt-key-display p {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
}

.session-key-box {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.session-key-text {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: 10px;
    color: var(--accent-primary);
    text-shadow: 0 0 20px var(--accent-glow);
    font-family: 'Outfit', monospace;
}

.ttt-btn.small {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 1.2rem;
    border-radius: var(--radius-sm);
}

.waiting-text {
    color: var(--text-muted);
    font-size: 0.95rem;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Connection Status */
.ttt-connection-status {
    padding: var(--spacing-sm) var(--spacing-md);
    background: rgba(231, 76, 60, 0.2);
    border: 1px solid rgba(231, 76, 60, 0.4);
    border-radius: var(--radius-md);
    color: #e74c3c;
    font-weight: 600;
    text-align: center;
    margin-bottom: var(--spacing-md);
    animation: fadeIn 0.3s ease;
}

/* TTT cell clickable state */
.ttt-cell.clickable {
    cursor: pointer;
}

.ttt-cell.clickable:hover {
    border-color: var(--accent-primary);
    background: rgba(168, 85, 247, 0.15);
    transform: scale(1.05);
}

/* Mobile Responsive - Lobby */
@media (max-width: 480px) {
    .lobby-cards {
        grid-template-columns: 1fr 1fr; /* 2x2 Grid */
        gap: var(--spacing-sm);
        margin-bottom: var(--spacing-sm);
    }

    .lobby-card {
        padding: clamp(var(--spacing-sm), 2dvh, var(--spacing-md));
        gap: 4px;
        text-align: center;
    }

    .lobby-card-icon {
        font-size: 1.5rem;
    }

    .lobby-card h3 {
        font-size: 0.9rem;
    }

    .lobby-card p {
        font-size: 0.7rem;
        display: none; /* Hide descriptions on tiny mobiles to guarantee fit */
    }

    .session-key-text {
        font-size: 1.8rem;
        letter-spacing: 6px;
    }

    .hangman-phrase {
        gap: 8px;
    }

    .hangman-letter {
        width: clamp(22px, 7vw, 32px);
        height: clamp(30px, 9vw, 42px);
        font-size: clamp(1rem, 4vw, 1.3rem);
    }

    .hangman-svg-wrap {
        max-width: 180px;
    }
}

/* Role Selection Cards */
.role-select {
    text-align: center;
}

.role-cards {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: var(--spacing-md);
}

.role-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px 28px;
    background: rgba(255, 255, 255, 0.04);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-primary);
    font-family: 'Outfit', sans-serif;
}

.role-card:hover {
    border-color: var(--accent-primary);
    background: rgba(168, 85, 247, 0.08);
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(168, 85, 247, 0.15);
}

.role-card.selected {
    border-color: var(--accent-primary);
    background: rgba(168, 85, 247, 0.12);
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.2);
}

.role-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.15);
}

.role-name {
    font-size: 1.1rem;
    font-weight: 700;
}

/* YOU Badge on Score Card */
.score-you-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 10px;
    letter-spacing: 1px;
    box-shadow: 0 2px 8px rgba(46, 204, 113, 0.4);
}

.score-card {
    position: relative;
}

/* TTT Container Centering */
.ttt-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-height: 0;
    justify-content: center;
}

.ttt-grid {
    width: 100%;
}

/* Mobile Centering Fix */
@media (max-width: 480px) {
    .ttt-container {
        padding: var(--spacing-sm);
    }

    .ttt-scores {
        gap: var(--spacing-md);
    }

    .score-card {
        min-width: 80px;
        padding: var(--spacing-sm);
    }

    .score-avatar {
        width: 44px;
        height: 44px;
    }

    .ttt-grid {
        grid-template-columns: repeat(3, 70px);
        gap: 6px;
        max-width: 260px;
    }

    .ttt-cell {
        width: 70px;
        height: 70px;
        padding: 6px;
    }

    .ttt-cell img {
        width: 48px;
        height: 48px;
    }

    .ttt-controls {
        gap: var(--spacing-sm);
    }

    .ttt-btn {
        padding: var(--spacing-xs) var(--spacing-md);
        font-size: 0.9rem;
    }

    .role-cards {
        gap: 12px;
    }

    .role-card {
        padding: 14px 18px;
    }

    .role-avatar {
        width: 50px;
        height: 50px;
    }

    .hangman-game-area {
        padding: var(--spacing-sm) 0;
    }

    .wordle-container {
        padding: var(--spacing-sm);
    }
}

/* ==========================================
   TIC TAC TOE BASE STYLES (Fix)
   ========================================== */

.ttt-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 20px auto;
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 16px;
    max-width: 320px;
    /* Ensure grid doesn't shift */
    width: fit-content;
}

.ttt-cell {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s;
    /* Key fixes for layout shift */
    overflow: hidden;
    position: relative;
    box-sizing: border-box;
}

.ttt-cell:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #a855f7;
}

.ttt-cell.filled {
    cursor: default;
    background: rgba(0, 0, 0, 0.2);
}

.ttt-cell img {
    /* Constrain image to cell size */
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 8px;
    display: block;
}

/* Ensure container centers the grid */
.ttt-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

/* ==========================================
   HANGMAN STYLES (Fix)
   ========================================== */

.hangman-game-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.hangman-svg-wrap {
    display: flex;
    justify-content: center;
    width: 100%;
    margin-bottom: clamp(5px, 1dvh, var(--spacing-sm));
    flex-shrink: 1;
    min-height: 0;
}

.hangman-svg {
    height: clamp(80px, 20dvh, 250px);
    width: auto;
    filter: drop-shadow(0 0 10px rgba(155, 89, 182, 0.3));
}

.hangman-phrase {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-bottom: var(--spacing-sm);
}

.hangman-word {
    display: flex;
    margin: 0 5px;
}

.hangman-letter {
    width: 30px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.4);
    margin: 0 2px;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    min-height: 40px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 2px;
}

.hangman-letter.revealed {
    border-bottom-color: #a855f7;
    color: #a855f7;
    text-shadow: 0 0 12px rgba(168, 85, 247, 0.5);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.hangman-space {
    width: 15px;
}

.hangman-lives {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-style: italic;
}

/* SVG Line Animations */
.hm-part {
    transition: opacity 0.5s ease;
}

.hm-part.hidden {
    opacity: 0;
}

.hm-part.reveal-anim {
    animation: drawLine 1s ease forwards;
}

@keyframes drawLine {
    from {
        stroke-dashoffset: 100%;
        opacity: 0;
    }

    to {
        stroke-dashoffset: 0;
        opacity: 1;
    }
}

/* Tear Drop Animation */
.tear-drop-anim {
    animation: tearDrop 2s ease-in infinite;
    transform-origin: center;
}

@keyframes tearDrop {
    0% {
        transform: translateY(0) scale(1);
        opacity: 0;
    }

    20% {
        opacity: 1;
    }

    80% {
        transform: translateY(20px) scale(1.2);
        opacity: 1;
    }

    100% {
        transform: translateY(30px) scale(0.5);
        opacity: 0;
    }
}

/* ========================================
   SHARED LOBBY
   ======================================== */

.shared-lobby {
    text-align: center;
    padding: var(--spacing-sm);
}

.lobby-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
}

.role-select {
    margin-bottom: var(--spacing-lg);
}

.role-cards {
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-sm);
}

.role-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: var(--spacing-sm) var(--spacing-md);
    background: linear-gradient(145deg, rgba(155, 89, 182, 0.1), rgba(52, 73, 94, 0.25));
    border: 2px solid rgba(155, 89, 182, 0.25);
    border-radius: var(--radius-md);
    flex: 1;
    min-width: 130px;
    min-height: 180px;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    color: var(--text-primary);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.role-card:hover {
    transform: translateY(-4px);
    border-color: rgba(155, 89, 182, 0.6);
    box-shadow: 0 8px 25px rgba(155, 89, 182, 0.2);
}

.role-card.selected {
    border-color: #a855f7;
    background: linear-gradient(145deg, rgba(168, 85, 247, 0.1), rgba(155, 89, 182, 0.2));
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.15);
}

.role-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(155, 89, 182, 0.4);
}

.role-card.selected .role-avatar {
    border-color: #a855f7;
}

.role-name {
    font-weight: 700;
    font-size: 1.1rem;
}

.lobby-cards {
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
    margin-top: 0;
}

.lobby-card {
    background: linear-gradient(145deg, rgba(155, 89, 182, 0.1), rgba(52, 73, 94, 0.2));
    border: 1px solid rgba(155, 89, 182, 0.2);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm);
    min-width: 150px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex: 1;
    min-height: 140px;
    justify-content: center;
}

.lobby-card-icon {
    font-size: 2rem;
}

.lobby-card h3 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
}

.lobby-card p {
    display: none; /* Hide descriptions to save space */
}

.lobby-card .ttt-btn {
    min-height: 44px;
    min-width: 44px;
    max-width: none;
    flex: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    z-index: 1;
}

.lobby-input {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid rgba(155, 89, 182, 0.3);
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 3px;
    font-weight: 700;
    margin-bottom: 8px;
}

.lobby-input:focus {
    outline: none;
    border-color: #a855f7;
}

.lobby-status {
    margin-top: var(--spacing-md);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.lobby-status.error {
    color: #e74c3c;
}

/* ========================================
   GAME PICKER
   ======================================== */

.game-picker {
    text-align: center;
    padding: var(--spacing-lg);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.games-title {
    font-size: clamp(1.2rem, 3.5dvh, 2rem);
    font-weight: 800;
    margin-bottom: clamp(6px, 1.5dvh, var(--spacing-lg));
    background: linear-gradient(135deg, var(--accent-secondary), var(--accent-primary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.game-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--spacing-md);
    max-width: 700px;
    margin: 0 auto;
}

.game-pick-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: clamp(4px, 0.8dvh, 10px);
    padding: clamp(var(--spacing-sm), 2dvh, var(--spacing-lg)) clamp(var(--spacing-sm), 2vw, var(--spacing-lg));
    background: rgba(25, 20, 50, 0.45);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(155, 89, 182, 0.2);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 1;
    min-height: 0;
}

.game-pick-icon {
    font-size: clamp(1.5rem, 4dvh, 2.5rem);
    line-height: 1;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.3));
}

.game-pick-name {
    font-size: clamp(0.75rem, 1.8dvh, 1rem);
    font-weight: 700;
    text-align: center;
    color: rgba(255, 255, 255, 0.9);
}

.game-pick-card:hover {
    transform: translateY(-4px);
    border-color: rgba(155, 89, 182, 0.5);
    box-shadow: 0 8px 25px rgba(155, 89, 182, 0.2);
    background: rgba(155, 89, 182, 0.15);
}

.game-pick-desc {
    font-size: clamp(0.6rem, 1.3dvh, 0.8rem);
    color: rgba(255, 255, 255, 0.4);
}

/* ========================================
   SHARED GAME STYLES
   ======================================== */

.game-container {
    padding: var(--spacing-md);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.game-inner-container {
    max-width: 600px;
    margin: 0 auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.quiz-container.game-inner-container {
    max-width: 700px;
    min-height: 0;
    text-align: center;
}

.game-title {
    font-size: clamp(1.3rem, 3.5vw, 1.8rem);
    font-weight: 800;
    margin-bottom: var(--spacing-md);
    background: linear-gradient(135deg, #9b59b6, #e74c3c);
    background-clip: text; -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.game-back-btn {
    display: inline-block;
    background: none;
    border: 1px solid rgba(155, 89, 182, 0.4);
    color: var(--text-muted);
    padding: 6px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    margin-bottom: var(--spacing-md);
    transition: all 0.2s;
}

.game-back-btn:hover {
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

/* ========================================
   CONNECT FOUR — Fixed Grid + Image Discs
   ======================================== */

.cf-board-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: clamp(4px, 1dvh, var(--spacing-md)) 0;
}

.cf-drop-arrows {
    display: grid;
    grid-template-columns: repeat(7, clamp(36px, 10vw, 48px));
    gap: clamp(2px, 0.5vw, 4px);
    padding: 0 10px;
    margin-bottom: 4px;
}

.cf-board {
    display: grid;
    grid-template-columns: repeat(7, clamp(36px, 10vw, 48px));
    grid-template-rows: repeat(6, clamp(36px, 10vw, 48px));
    gap: clamp(2px, 0.5vw, 4px);
    background: linear-gradient(145deg, #1a3a6b, #0d2456);
    border-radius: var(--radius-lg);
    padding: clamp(6px, 1.5vw, 10px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    width: fit-content;
}

.cf-drop-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.3);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
    transition: all 0.2s;
    font-family: inherit;
    width: clamp(36px, 10vw, 48px);
    height: 28px;
}

.cf-drop-btn:hover {
    color: #a855f7;
    transform: scale(1.3);
}

.cf-cell {
    width: clamp(36px, 10vw, 48px);
    height: clamp(36px, 10vw, 48px);
    background: rgba(0, 0, 0, 0.35);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.cf-piece {
    width: clamp(28px, 8vw, 40px);
    height: clamp(28px, 8vw, 40px);
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.cf-piece.cf-animate {
    animation: cf-drop 0.35s ease-in;
}

.cf-disc-empty {
    width: clamp(28px, 8vw, 40px);
    height: clamp(28px, 8vw, 40px);
    border-radius: 50%;
}

@keyframes cf-drop {
    0% {
        transform: translateY(-200px);
        opacity: 0.5;
    }

    70% {
        transform: translateY(5px);
    }

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

/* ========================================
   ROCK PAPER SCISSORS — Battle Layout
   ======================================== */

.rps-arena {
    padding: var(--spacing-md);
}

.rps-battle-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    min-height: 150px;
}

.rps-player-side {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    max-width: 200px;
}

.rps-player-label {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.rps-player-choice {
    width: 100px;
    height: 100px;
    background: linear-gradient(145deg, rgba(155, 89, 182, 0.15), rgba(52, 73, 94, 0.3));
    border: 2px solid rgba(155, 89, 182, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rps-big-q {
    font-size: 2.5rem;
    opacity: 0.4;
}

.rps-big-emoji {
    font-size: 3rem;
    line-height: 1;
}

.rps-opponent-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
}

.rps-center-vs {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.rps-vs-badge {
    font-size: 1.5rem;
    font-weight: 800;
    color: #a855f7;
    text-shadow: 0 0 12px rgba(168, 85, 247, 0.3);
}

.rps-round-badge {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    background: rgba(155, 89, 182, 0.15);
    padding: 3px 10px;
    border-radius: 20px;
}

.rps-choices {
    display: flex;
    justify-content: center;
    gap: var(--spacing-md);
    flex-wrap: wrap;
}

.rps-choice-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: var(--spacing-lg) var(--spacing-xl);
    background: linear-gradient(145deg, rgba(155, 89, 182, 0.1), rgba(52, 73, 94, 0.25));
    border: 2px solid rgba(155, 89, 182, 0.3);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    color: var(--text-primary);
    min-width: 100px;
}

.rps-choice-btn:hover {
    transform: translateY(-6px) scale(1.05);
    border-color: rgba(155, 89, 182, 0.6);
    box-shadow: 0 12px 30px rgba(155, 89, 182, 0.25);
    background: linear-gradient(145deg, rgba(155, 89, 182, 0.2), rgba(52, 73, 94, 0.35));
}

.rps-choice-btn.selected {
    border-color: #27ae60;
    background: rgba(39, 174, 96, 0.2);
    transform: scale(1.1);
    box-shadow: 0 0 25px rgba(39, 174, 96, 0.3);
    pointer-events: none;
}

.rps-emoji {
    font-size: 3rem;
    line-height: 1;
}

.rps-label {
    font-weight: 700;
    font-size: 0.9rem;
}

.rps-round-result {
    font-size: 1.5rem;
    font-weight: 800;
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-lg);
    margin-top: var(--spacing-md);
    text-align: center;
    animation: bounce-in 0.4s ease;
}

.rps-win {
    color: #27ae60;
    background: rgba(39, 174, 96, 0.15);
    border: 1px solid rgba(39, 174, 96, 0.3);
}

.rps-lose {
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.15);
    border: 1px solid rgba(231, 76, 60, 0.3);
}

.rps-draw {
    color: #f39c12;
    background: rgba(243, 156, 18, 0.15);
    border: 1px solid rgba(243, 156, 18, 0.3);
}

.rps-reveal-state .rps-player-choice {
    border-color: rgba(168, 85, 247, 0.3);
    background: linear-gradient(145deg, rgba(168, 85, 247, 0.05), rgba(155, 89, 182, 0.15));
}

@keyframes bounce-in {
    0% {
        transform: scale(0);
    }

    60% {
        transform: scale(1.15);
    }

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

.bounce-in {
    animation: bounce-in 0.5s ease;
}

/* ========================================
   BATTLESHIP — Ocean Theme
   ======================================== */

.bs-game-area {
    padding: var(--spacing-sm);
}

.bs-placement-section {
    text-align: center;
    max-width: 380px;
    margin: 0 auto;
}

.bs-ship-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin-bottom: var(--spacing-md);
}

.bs-ship-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    background: rgba(52, 152, 219, 0.15);
    border: 1px solid rgba(52, 152, 219, 0.3);
    color: var(--text-secondary);
    transition: all 0.3s;
}

.bs-ship-badge.placed {
    background: rgba(39, 174, 96, 0.15);
    border-color: rgba(39, 174, 96, 0.4);
    color: #27ae60;
}

.bs-ship-badge.current {
    background: rgba(168, 85, 247, 0.15);
    border-color: rgba(168, 85, 247, 0.4);
    color: #a855f7;
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.15);
}

.bs-battle-grids {
    display: flex;
    gap: var(--spacing-lg);
    justify-content: center;
    flex-wrap: wrap;
}

.bs-grid-section {
    text-align: center;
}

.bs-grid-label {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: var(--spacing-xs);
    color: var(--text-secondary);
}

.bs-grid {
    display: grid;
    grid-template-columns: 24px repeat(10, 1fr);
    grid-template-rows: 24px repeat(10, 1fr);
    gap: 2px;
    background: linear-gradient(180deg, rgba(13, 36, 86, 0.6), rgba(0, 20, 50, 0.8));
    border: 2px solid rgba(52, 152, 219, 0.2);
    border-radius: var(--radius-md);
    padding: 4px;
    max-width: 360px;
    width: 100%;
}

.bs-grid-small {
    max-width: 220px;
}

.bs-grid-small .bs-cell {
    min-width: 16px;
    min-height: 16px;
    font-size: 0.55rem;
}

.bs-label {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    color: rgba(52, 152, 219, 0.6);
}

.bs-cell {
    aspect-ratio: 1;
    min-width: 24px;
    min-height: 24px;
    background: rgba(20, 50, 80, 0.5);
    border: 1px solid rgba(52, 152, 219, 0.12);
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

.bs-cell:hover {
    background: rgba(52, 152, 219, 0.25);
    border-color: rgba(52, 152, 219, 0.4);
}

.bs-cell.ship {
    background: rgba(52, 152, 219, 0.35);
    border-color: rgba(52, 152, 219, 0.5);
    box-shadow: inset 0 0 6px rgba(52, 152, 219, 0.2);
}

.bs-cell.preview-valid {
    background: rgba(39, 174, 96, 0.4);
    border-color: rgba(39, 174, 96, 0.7);
    box-shadow: 0 0 6px rgba(39, 174, 96, 0.2);
}

.bs-cell.preview-invalid {
    background: rgba(231, 76, 60, 0.4);
    border-color: rgba(231, 76, 60, 0.7);
}

.bs-cell.hit {
    background: rgba(231, 76, 60, 0.5) !important;
    border-color: rgba(231, 76, 60, 0.7);
    animation: bs-explode 0.4s ease;
}

.bs-cell.miss {
    background: rgba(127, 140, 141, 0.2);
    color: rgba(255, 255, 255, 0.25);
}

.bs-cell.attack-cell:hover:not(.hit):not(.miss) {
    background: rgba(231, 76, 60, 0.25);
    border-color: rgba(231, 76, 60, 0.5);
    cursor: crosshair;
}

@keyframes bs-explode {
    0% {
        transform: scale(0.5);
        background: rgba(255, 200, 50, 0.8);
    }

    50% {
        transform: scale(1.2);
    }

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

/* ========================================
   MOBILE RESPONSIVE - GAMES
   ======================================== */

@media (max-width: 600px) {
    .role-cards {
        flex-direction: row;
        justify-content: center;
        gap: 12px;
    }

    .role-card {
        flex: 1;
        max-width: 160px;
        padding: 12px 8px;
    }

    .role-card .role-avatar {
        width: 50px;
        height: 50px;
    }

    .role-card .role-name {
        font-size: 0.9rem;
    }

    .lobby-cards {
        flex-direction: column;
        align-items: center;
    }

    .game-picker-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-sm);
    }

    .game-pick-card {
        padding: var(--spacing-md) var(--spacing-sm);
    }

    .game-pick-icon {
        font-size: 1.8rem;
    }

    .cf-board {
        grid-template-columns: repeat(7, 38px);
        grid-template-rows: repeat(6, 38px);
        padding: 6px;
        gap: 3px;
    }

    .cf-drop-arrows {
        grid-template-columns: repeat(7, 38px);
        gap: 3px;
        padding: 0 6px;
        margin-bottom: 3px;
    }

    .cf-drop-btn {
        width: 38px;
        height: 22px;
        font-size: 1rem;
    }

    .cf-cell {
        width: 38px;
        height: 38px;
    }

    .cf-piece {
        width: 32px;
        height: 32px;
    }

    .rps-battle-layout {
        gap: var(--spacing-sm);
    }

    .rps-player-choice {
        width: auto;
        height: auto;
    }

    .rps-big-emoji {
        font-size: 2.2rem;
    }

    .rps-choice-btn {
        min-width: 80px;
        padding: var(--spacing-md);
    }

    .rps-emoji {
        font-size: 2.5rem;
    }

    .bs-battle-grids {
        flex-direction: column;
        align-items: center;
    }

    .bs-grid {
        max-width: 300px;
    }

    .bs-cell {
        min-width: 20px;
        min-height: 20px;
    }

    .bs-grid-small {
        max-width: 200px;
    }

    .bs-grid-small .bs-cell {
        min-width: 14px;
        min-height: 14px;
    }
}

/* New UI Refinements */
.picker-controls {
    margin-top: clamp(1rem, 3dvh, 3rem);
    width: 100%;
    display: flex;
    justify-content: center;
}

#shared-waiting {
    max-width: 500px !important;
    width: 90% !important;
    margin: 2rem auto;
    left: auto !important;
    transform: none !important;
    position: relative;
    display: block;
}

.ttt-controls {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    align-items: center;
    gap: clamp(0.5rem, 1.5dvh, 1.5rem);
    margin-top: clamp(4px, 1dvh, var(--spacing-lg));
    width: 100%;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
    padding: clamp(6px, 1dvh, var(--spacing-md));
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Scoped fix for in-game controls only */
.ttt-controls .ttt-btn {
    width: 100%;
    height: clamp(36px, 6dvh, 56px);
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    white-space: nowrap;
    min-width: 0;
    /* Override generic style */
    max-width: none;
    /* Override generic style */
}

/* Specific fix for RPS which only has one button (Back) */
#rps-controls {
    grid-template-columns: 1fr;
    place-items: center;
}

#rps-controls .ttt-btn {
    max-width: 300px;
    /* Restore max-width constraint for single button */
}

.ttt-btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 1rem 1.5rem;
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 700;
    color: #0d0b1e;
    background: linear-gradient(135deg, #ffd700, #ffec8b);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.35);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-width: 140px;
    position: relative;
    overflow: hidden;
}

.ttt-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 215, 0, 0.5);
    background: linear-gradient(135deg, #ffec8b, #ffd700);
}

.ttt-btn:active {
    transform: translateY(1px);
    box-shadow: 0 2px 10px rgba(255, 215, 0, 0.3);
}

.ttt-btn.purple-btn {
    background: linear-gradient(135deg, #8e44ad, #9b59b6);
    color: #fff;
    box-shadow: 0 4px 15px rgba(142, 68, 173, 0.3);
}

.ttt-btn.purple-btn:hover {
    background: linear-gradient(135deg, #9b59b6, #a96bc8);
    box-shadow: 0 8px 25px rgba(142, 68, 173, 0.4);
}

.glass-btn {
    /* Keep just in case, or remove if unused */
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.7);
    box-shadow: none;
}

.glass-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.4);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.05);
}

.ttt-btn.danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
    color: #fff;
}

.ttt-btn.danger:hover {
    background: linear-gradient(135deg, #ff6b6b, #ef4444);
    box-shadow: 0 8px 25px rgba(239, 68, 68, 0.5);
}

.ttt-btn.small {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    min-width: auto;
    border-radius: 8px;
}

.toast-notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(46, 204, 113, 0.9);
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    font-weight: 600;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 20000;
    /* Ensure it's above everything */
}

.session-close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
    transition: all 0.2s;
    line-height: 1;
    z-index: 10;
}

.session-close-btn:hover {
    color: #fff;
    transform: scale(1.1) rotate(90deg);
}

.toast-notification.show {
    transform: translateX(-50%) translateY(0);
}

/* =========================================
   GENERIC MODAL STYLES (Added for Leave Session)
   ========================================= */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal.hidden {
    display: none;
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: #151525;
    padding: 2rem 2.5rem;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05);
    max-width: 420px;
    width: 90%;
    max-height: 80vh;
    text-align: center;
    animation: modalPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalPop {
    from {
        transform: scale(0.9) translateY(20px);
        opacity: 0;
    }

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

.modal-title {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #fff 0%, #a5a5a5 100%);
    background-clip: text; -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
}

.modal-text {
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 2rem;
    font-size: 1.1rem;
    line-height: 1.6;
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.modal-buttons .ttt-btn {
    min-width: 120px;
    padding: 0.8rem 1.5rem;
}


.role-prompt {
    font-size: 2.5rem;
    color: #ff6b6b;
    /* Reddish */
    margin-bottom: 2rem;
    font-weight: 800;
    text-shadow: 0 4px 15px rgba(255, 107, 107, 0.2);
    text-align: center;
}


/* =========================================
   OVERRIDES (User requested sizing updates)
   ========================================= */
.ttt-result-modal .role-prompt {
    font-size: 1.8rem;
}

.ttt-result-modal .role-avatar {
    width: 130px;
    height: 130px;
    border-width: 5px;
}

.ttt-result-modal .role-name {
    font-size: 1.8rem;
    margin-top: 10px;
}


/* =========================================
   MOBILE & SIZING REFINEMENTS (User Requested)
   ========================================= */

/* Game modal button sizing refinements */
.ttt-result-modal .modal-buttons .ttt-btn {
    min-width: 0;
    width: auto;
    padding: 0.6rem 1.2rem;
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    border-radius: 12px;
    white-space: normal;
    line-height: 1.2;
}

.ttt-result-modal .modal-content {
    padding: 1.5rem;
    width: 85%;
    max-width: 380px;
    border-radius: 16px;
}

.ttt-result-modal .modal-title {
    font-size: clamp(1.4rem, 4vw, 1.8rem);
    margin-bottom: 0.5rem;
}

.ttt-result-modal .modal-text {
    font-size: clamp(0.9rem, 3vw, 1.1rem);
    margin-bottom: 1.5rem;
}

.ttt-result-modal .role-prompt {
    font-size: clamp(1.5rem, 5vw, 1.8rem);
}

.ttt-result-modal .role-avatar {
    width: clamp(80px, 20vw, 130px);
    height: clamp(80px, 20vw, 130px);
}

/* General button mobile friendliness */
.ttt-btn {
    padding: 0.6rem 1.2rem;
    font-size: clamp(0.9rem, 3vw, 1rem);
}


/* =========================================
   SESSION EXIT BUTTON (User Requested)
   ========================================= */
.session-exit-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: linear-gradient(135deg, #900C3F, #C70039);
    /* Purplish-Red */
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(144, 12, 63, 0.4);
    transition: all 0.2s ease;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 5px;
}

.session-exit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(144, 12, 63, 0.6);
    background: linear-gradient(135deg, #C70039, #FF5733);
}

.session-exit-btn.hidden {
    display: none !important;
}

/* Ensure game containers are relative for absolute positioning */
.ttt-container,
.cf-container,
.rps-arena,
.bs-container {
    position: relative;
}


/* =========================================
   USER FEEDBACK REFINEMENTS (Purple Exit, Font Sizing)
   ========================================= */

/* Update Session Exit Button to Purple */
.session-exit-btn {
    background: linear-gradient(135deg, #8e44ad, #9b59b6) !important;
    /* Purple */
    box-shadow: 0 4px 10px rgba(142, 68, 173, 0.4) !important;
    top: 10px !important;
    right: 10px !important;
    padding: 6px 10px !important;
    font-size: 0.75rem !important;
}

.session-exit-btn:hover {
    background: linear-gradient(135deg, #9b59b6, #be93d4) !important;
    box-shadow: 0 6px 15px rgba(142, 68, 173, 0.6) !important;
}

/* Helper for smaller text on specific buttons */
.ttt-btn.text-sm {
    font-size: clamp(0.7rem, 2.5vw, 0.85rem) !important;
    padding: 0.6rem 0.8rem !important;
    line-height: 1.1;
    min-width: 0 !important;
    white-space: normal;
    text-align: center;
}


/* Ensure game controls (bottom buttons) are side-by-side on mobile */
.ttt-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    /* allow wrap if VERY small */
    width: 100%;
}

.ttt-controls .ttt-btn {
    flex: 1;
    /* Distribute space */
    min-width: 120px;
    /* But don't squish too much */
    max-width: 200px;
}


/* =========================================
/* =========================================
   TRANSPARENT GAME CONTROLS CONTAINER (User Requested)
   ========================================= */
.ttt-controls {
    background: transparent !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    padding: 10px 0;
    /* Keep spacing but no background */
}

/* Restore solid buttons */
.ttt-controls .ttt-btn {
    background: linear-gradient(135deg, #ffd700, #ffec8b) !important;
    border: none !important;
    color: #0d0b1e !important;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.35) !important;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.ttt-controls .ttt-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 215, 0, 0.5) !important;
    background: linear-gradient(135deg, #ffec8b, #ffd700) !important;
}

.ttt-controls .ttt-btn.purple-btn {
    background: linear-gradient(135deg, #8e44ad, #9b59b6) !important;
    color: #fff !important;
    box-shadow: 0 4px 15px rgba(142, 68, 173, 0.3) !important;
}

.ttt-controls .ttt-btn.purple-btn:hover {
    background: linear-gradient(135deg, #9b59b6, #a96bc8) !important;
    box-shadow: 0 8px 25px rgba(142, 68, 173, 0.4) !important;
}

/* =========================================
   FINAL STANDARDIZATION & COLOR TWEAKS
   ========================================= */

/* Force relative positioning on all game containers to capture the absolute exit button */
.ttt-container,
.cf-container,
.rps-container,
.bs-container,
.game-inner-container {
    position: relative !important;
}

/* Updated Exit Button Color (Raspberry/Wine) - Distinct from Purple but matches Dark Theme */
.session-exit-btn {
    background: linear-gradient(135deg, #ad1457, #d81b60) !important;
    box-shadow: 0 4px 10px rgba(173, 20, 87, 0.4) !important;
    /* Ensure consistent positioning */
    top: 15px !important;
    right: 15px !important;
}

.session-exit-btn:hover {
    background: linear-gradient(135deg, #d81b60, #e91e63) !important;
    box-shadow: 0 6px 15px rgba(173, 20, 87, 0.6) !important;
}

/* Ensure RPS container has height/block formatting context if needed */
.rps-container {
    display: flex;
    /* It was likely block, but flex might help if vertically centered */
    flex-direction: column;
    align-items: center;
    width: 100%;
}


/* =========================================
   Universal Single-Line Button Fix (User Requested)
   ========================================= */

/* Force all game buttons to be single line */
.ttt-btn,
.game-back-btn,
.session-exit-btn,
.ttt-controls button {
    white-space: nowrap !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    width: auto !important;
    /* Allow growing */
    max-width: none !important;
    /* Remove constraints */
    min-width: 0 !important;
    /* Allow shrinking if needed */
}

/* Drastically reduce font size for small screens to fit long text */
.ttt-btn.text-sm {
    font-size: clamp(0.6rem, 2.2vw, 0.8rem) !important;
    padding: 0.6rem 0.6rem !important;
    /* Tighter padding */
    letter-spacing: -0.2px !important;
    /* Squeeze text slightly */
}

/* Update general TTT buttons to be smaller too */
.ttt-btn {
    font-size: clamp(0.7rem, 2.5vw, 0.95rem) !important;
    padding: 0.7rem 1rem !important;
}

/* Adjust the controls container to allow buttons to take full width if needed */
.ttt-controls {
    flex-wrap: nowrap !important;
    /* Prevent stacking if possible, or allow scrolling? No, user wants one line text. */
    /* If screen is too narrow, buttons might shrink. */
    width: 100%;
    gap: 8px !important;
}

.ttt-controls .ttt-btn {
    flex: 1 1 auto !important;
    /* Grow and shrink */
}


/* =========================================
   WRAP & COPY BTN FINAL FIXES
   ========================================= */

/* 1. Modal Buttons: FORCE SINGLE LINE (Reverse previous 'normal') */
.modal-buttons .ttt-btn {
    white-space: nowrap !important;
    font-size: clamp(0.65rem, 2.5vw, 0.9rem) !important;
    padding: 0.6rem 1rem !important;
    min-width: 0 !important;
    width: auto !important;
    flex: 0 1 auto !important;
    /* Don't stretch needlessly */
}

/* 2. Session Key Copy Button: Fix 'Way Larger' Issue */
#shared-copy-key {
    padding: 0 !important;
    width: 36px !important;
    height: 36px !important;
    font-size: 1.1rem !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2) !important;
    background: rgba(255, 255, 255, 0.1) !important;
    /* Subtle glass style */
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
}

#shared-copy-key:hover {
    background: rgba(255, 255, 255, 0.2) !important;
    transform: scale(1.05);
}

/* 3. Text Alignment for Session Key */
.session-key-box {
    align-items: center !important;
    gap: 12px !important;
}


/* =========================================
   MOBILE MODAL FIX (STACK BUTTONS)
   ========================================= */

@media (max-width: 600px) {
    .modal-buttons {
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        gap: 10px !important;
    }

    .modal-buttons .ttt-btn {
        flex: 1 !important;
        min-width: 0 !important;
        font-size: 0.85rem !important;
        padding: 0.7rem 0.8rem !important;
    }

    .modal-content {
        max-width: 320px !important;
        padding: 1.5rem !important;
    }
}

/* Ensure no overflow on very narrow screens even when stacked */
.modal-buttons .ttt-btn {
    text-overflow: ellipsis;
    /* Just in case */
    overflow: hidden;
}


/* =========================================
   STRICTER MODAL BUTTON SIZING (Fix Overflow)
   ========================================= */

/* 1. Allow wrapping so buttons stack naturally if they don't fit */
.modal-buttons {
    flex-wrap: wrap !important;
    justify-content: center !important;
    gap: 12px !important;
}

/* 2. Enforce minimum width to trigger stacking, but allow full width when stacked */
.modal-buttons .ttt-btn {
    min-width: 140px !important;
    /* Force stack if container < ~300px */
    flex: 1 1 auto !important;
    /* Grow to fill space */
    width: auto !important;
    max-width: 100% !important;

    /* 3. Text Sizing - Smaller as requested */
    font-size: 0.75rem !important;
    /* 12px - Small but readable */
    padding: 0.8rem 0.5rem !important;
    /* Tight padding */
    letter-spacing: -0.3px !important;
    /* Squeeze text */

    /* 4. Layout */
    white-space: nowrap !important;
    /* Never wrap text */
    overflow: hidden !important;
    text-overflow: clip !important;
    /* User prefers fit over ellipsis? Or stack. */
}

/* Emoji sizing specifically */
.modal-buttons .ttt-btn .emoji-sized {
    /* Assuming I can target emoji if wrapped in span, but it's raw text usually. 
       Font-size affects emoji too. */
}

/* Ensure modal content allows width */
.ttt-result-content {
    width: 90vw;
    max-width: 380px;
    padding: 2rem 2.5rem;
}


/* =========================================
   UNIFIED GAME RESULT OVERLAY (Middle of Screen)
   ========================================= */

.game-result-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(20, 20, 30, 0.95);
    padding: 2rem 3rem;
    border-radius: 20px;
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 800;
    text-align: center;
    z-index: 100;
    backdrop-filter: blur(8px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6);
    border: 3px solid rgba(255, 255, 255, 0.1);
    animation: popInResult 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
    /* Allow seeing behind? Or block interaction. Block better. */
    pointer-events: auto;
    min-width: 280px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.game-result-overlay.win {
    color: #2ecc71;
    border-color: #2ecc71;
    box-shadow: 0 0 30px rgba(46, 204, 113, 0.4);
}

.game-result-overlay.lose {
    color: #e74c3c;
    border-color: #e74c3c;
    box-shadow: 0 0 30px rgba(231, 76, 60, 0.4);
}

.game-result-overlay.draw {
    color: #f1c40f;
    border-color: #f1c40f;
    box-shadow: 0 0 30px rgba(241, 196, 15, 0.4);
}

@keyframes popInResult {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }

    70% {
        transform: translate(-50%, -50%) scale(1.1);
    }

    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.result-subtitle {
    font-size: 1rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 5px;
}

/* =========================================
   COUNTDOWN OVERLAY & REMATCH BUTTONS
   ========================================= */

/* =========================================
   COUNTDOWN OVERLAY & REMATCH BUTTONS
   ========================================= */

.game-countdown-overlay {
    position: absolute;
    /* Changed from fixed to absolute */
    inset: 0;
    /* Covers parent container */
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    /* High enough for game container */
    pointer-events: none;
    /* Let clicks pass? No, usually blocks. */
    pointer-events: all;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border-radius: 20px;
    /* Match container radius */
}

.countdown-number {
    font-size: clamp(4rem, 15vw, 8rem);
    /* Slightly smaller since inside container */
    font-weight: 900;
    color: #f1c40f;
    text-shadow: 0 0 30px rgba(241, 196, 15, 0.6);
    animation: countdownPulse 0.9s ease-in-out infinite;
}

@keyframes countdownPulse {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

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

    80% {
        transform: scale(1);
        opacity: 1;
    }

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

/* Small countdown for RPS */
.rps-small-countdown {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: clamp(2rem, 8vw, 4rem);
    font-weight: 900;
    color: #f1c40f;
    text-shadow: 0 0 20px rgba(241, 196, 15, 0.6);
    animation: rpsCountdownPulse 0.9s ease-in-out infinite;
    z-index: 100;
    pointer-events: none;
}

@keyframes rpsCountdownPulse {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0;
    }

    50% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 1;
    }

    80% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }

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

/* LEAVE MODAL FIXES */
#leave-session-modal .modal-content {
    width: auto !important;
    min-width: 280px !important;
    max-width: 90vw !important;
    padding: 1.5rem !important;
}

/* Confirm Modal Buttons (Golden Purple Theme) */
#ttt-confirm-yes {
    background: linear-gradient(135deg, #f1c40f, #f39c12) !important;
    color: #2c3e50 !important;
    box-shadow: 0 0 15px rgba(241, 196, 15, 0.4) !important;
    border: 2px solid rgba(255, 255, 255, 0.2) !important;
    font-weight: 800 !important;
}

#ttt-confirm-no {
    background: linear-gradient(135deg, #8e44ad, #9b59b6) !important;
    color: white !important;
    box-shadow: 0 0 15px rgba(142, 68, 173, 0.4) !important;
}

/* SESSION EXIT BUTTON FIXES */
.session-exit-btn {
    top: 20px !important;
    right: 20px !important;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* =========================================
   SHARED GAME RESULT MODAL (Unified)
   ========================================= */

.game-result-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    /* No backdrop */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    pointer-events: none;
    /* Let clicks pass */
    border-radius: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.game-result-modal:not(.hidden) {
    opacity: 1;
    pointer-events: none;
    /* Wrapper allows clicks through */
}

/* But content needs to be clickable? User said 'everything under or below the modal to be clickable' */
/* If content is non-interactive images/text, maybe pass through? */
/* But 'You Lose' badge might block. User said 'Do not add buttons'. */
/* If the user wants to click 'Rematch' which is BELOW the modal, then pointer-events: none on modal is correct. */
/* But if pointer-events is none, the tooltip/hover on modal won't work. That's fine. */

.game-result-content {
    background: linear-gradient(135deg, rgba(25, 20, 50, 0.95), rgba(15, 12, 30, 0.98));
    border: 1px solid rgba(168, 85, 247, 0.35);
    box-shadow: 0 0 40px rgba(168, 85, 247, 0.15), 0 20px 60px rgba(0, 0, 0, 0.5);
    padding: 1.5rem;
    border-radius: 16px;
    text-align: center;
    position: relative;
    max-width: 90%;
    width: 300px;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
}



.game-result-modal:not(.hidden) .game-result-content {
    transform: scale(1);
}

.game-result-icon {
    font-size: 5rem;
    margin-bottom: 1rem;
    filter: drop-shadow(0 0 10px rgba(168, 85, 247, 0.4));
    animation: bounceIn 0.8s;
}

.game-result-text {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 2rem;
    background: linear-gradient(135deg, #f1c40f, #e67e22, #9b59b6);
    background-clip: text; -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.game-confetti {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

@keyframes bounceIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    60% {
        transform: scale(1.1);
        opacity: 1;
    }

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

.rps-player-choice {
    display: flex !important;
    flex-direction: column !important;
    align-items: center;
    justify-content: center;
    width: auto !important;
    height: auto !important;
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    overflow: visible !important;
}

.rps-reveal-circle {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 4px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(5px);
    flex-shrink: 0;
}

.rps-choice-text {
    font-size: 2rem;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.9);
    margin-top: 30px;
    letter-spacing: 2px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    text-align: center;
    animation: fadeIn 0.5s ease-out;
    text-transform: capitalize;
}

.rps-big-emoji {
    font-size: 5rem;
    filter: drop-shadow(0 0 10px rgba(0, 0, 0, 0.3));
}

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

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

/* ==========================================
   SESSION LEAVE BUTTON - SLEEK REDESIGN
   ========================================== */
/* ==========================================
   SESSION LEAVE BUTTON - CROSS ON AVATAR
   ========================================== */
.leave-cross-btn {
    position: absolute !important;
    top: -10px !important;
    left: -10px !important;
    width: 28px !important;
    height: 28px !important;
    border-radius: 50% !important;
    background: #e74c3c !important;
    color: white !important;
    border: 2px solid white !important;
    font-size: 16px !important;
    font-weight: bold !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    z-index: 9999 !important;
    /* Force top z-index */
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5) !important;
    transition: all 0.2s ease !important;
    padding: 0 !important;
    line-height: 1 !important;
}

.leave-cross-btn:hover {
    background: #c0392b !important;
    transform: scale(1.1) !important;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.6) !important;
}

.score-card {
    position: relative !important;
    overflow: visible !important;
    /* Ensure button is not clipped */
    z-index: 10 !important;
}

/* Ensure container also doesn't clip */
.ttt-scores {
    overflow: visible !important;
}

/* ==========================================
   SESSION LEAVE BUTTON - REDESIGN (BOTTOM)
   ========================================== */
.session-exit-btn {
    position: relative !important;
    top: auto !important;
    right: auto !important;
    margin: 1.5rem auto 0 auto !important;
    padding: 0.5rem 1rem !important;
    border-radius: 0 0 10px 10px !important;
    /* Inverse pyramid hint */
    clip-path: polygon(0 0, 100% 0, 85% 100%, 15% 100%) !important;
    /* Inverse Trapezoid */
    border: none !important;
    background: linear-gradient(180deg, rgba(231, 76, 60, 0.8), rgba(192, 57, 43, 0.9)) !important;
    color: #fff !important;
    font-family: 'Outfit', sans-serif !important;
    font-size: 0.8rem !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    cursor: pointer !important;
    backdrop-filter: blur(5px) !important;
    -webkit-backdrop-filter: blur(5px) !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3) !important;
    width: fit-content !important;
    min-width: 120px !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 0.5rem !important;
    letter-spacing: 1px !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3) !important;
}

.session-exit-btn:hover {
    background: linear-gradient(180deg, rgba(231, 76, 60, 1), rgba(192, 57, 43, 1)) !important;
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.5) !important;
    transform: translateY(-2px) !important;
    padding-bottom: 0.8rem !important;
    /* Visual feedback */
}

.session-exit-btn:active {
    transform: translateY(0) !important;
    box-shadow: 0 2px 10px rgba(231, 76, 60, 0.3) !important;
}

/* Mobile adjustments */
@media (max-width: 600px) {
    .session-exit-btn {
        margin-top: 1rem !important;
        font-size: 0.75rem !important;
        padding: 0.5rem 1.5rem !important;
        width: 140px !important;
    }

    .leave-cross-btn {
        width: 28px;
        height: 28px;
        font-size: 16px;
        top: -10px;
        left: -10px;
    }

    /* Reset game title margins since button is moved */
    .game-title,
    .ttt-title {
        margin-top: 0 !important;
        display: block !important;
    }
}

/* Ensure absolute positioning works relative to the container */
.game-inner-container,
.ttt-container,
.cf-container,
.rps-container,
.bs-container,
.quiz-container {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    justify-content: center;
}

/* ========================================
   MOOD SECTION
   ======================================== */

.mood-section {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-dark);
    padding: var(--spacing-sm);
    overflow: hidden; /* STRICT NO SCROLL */
}

.mood-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-height: 100dvh;
    width: 100%;
    gap: clamp(var(--spacing-sm), 2dvh, var(--spacing-lg));
}

.mood-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: clamp(var(--spacing-sm), 2dvh, var(--spacing-lg));
    max-width: 600px;
    width: 100%;
}

/* Letter Section (between mood and gallery) */
.letter-section {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-dark);
    animation: fadeIn 0.5s ease;
    overflow: hidden; /* STRICT NO SCROLL */
}

.letter-envelope-scene {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 92%;
    max-width: 700px;
    padding: var(--spacing-xl);
}

/* === Envelope Wrapper (envelope + sliding letter) === */
.envelope-wrapper {
    position: relative;
    width: clamp(280px, 80vw, 350px);
    height: clamp(180px, 40dvh, 220px);
    cursor: pointer;
    animation: envelopeBounce 2s ease infinite;
}

.envelope-wrapper.animating {
    animation: none;
}

.envelope-wrapper:hover {
    transform: scale(1.05);
}

/* The folded letter that slides out of the envelope */
.letter-slide {
    position: absolute;
    left: 10%;
    right: 10%;
    bottom: 40%;
    height: 60%;
    background: #f4e4c1;
    border-radius: 2px;
    z-index: 0;
    transform: translateY(0);
    transition: transform 1.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 -2px 8px rgba(0,0,0,0.15);
}

.letter-slide.sliding-out {
    z-index: 4;
    transform: translateY(-180%);
}

.letter-slide.sliding-in {
    z-index: 1;
    transform: translateY(0);
    transition: transform 1s cubic-bezier(0.4, 0, 0.2, 1);
}

/* === Envelope === */
.envelope {
    position: absolute;
    inset: 0;
    perspective: 800px;
}

.envelope-back {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #c9956b, #a67853);
    border-radius: 8px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.envelope-front {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 65%;
    background: linear-gradient(180deg, #d4a574, #c9956b);
    border-radius: 0 0 8px 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.envelope-label {
    font-family: 'Special Elite', 'Courier New', monospace;
    font-size: 1.3rem;
    color: #4a2c17;
    font-weight: 400;
    text-shadow: 0 1px 0 rgba(255,255,255,0.2);
}

.envelope-icon-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.envelope-mood-emoji {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.5em;
    line-height: 1;
    pointer-events: none;
}

.envelope-flap {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(180deg, #d4a574, #c9956b);
    clip-path: polygon(0 0, 50% 100%, 100% 0);
    transform-origin: top center;
    transition: transform 0.8s ease;
    z-index: 3;
}

.envelope-wrapper.flap-open .envelope-flap {
    transform: rotateX(180deg);
    z-index: 0;
}

.envelope-wrapper.flap-closed .envelope-flap {
    transform: rotateX(0deg);
    z-index: 3;
}

@keyframes envelopeBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

/* === Letter Paper === */
.letter-paper {
    width: 100%;
    transform-origin: bottom center;
}

.letter-paper.hidden {
    display: none;
}

.letter-paper.unfolding {
    animation: letterUnfold 1s cubic-bezier(0.4, 0, 0.2, 1) both;
}

@keyframes letterUnfold {
    0% {
        opacity: 0;
        transform: perspective(1000px) rotateX(90deg) scaleY(0.5);
    }
    40% {
        opacity: 1;
        transform: perspective(1000px) rotateX(45deg) scaleY(0.75);
    }
    70% {
        transform: perspective(1000px) rotateX(10deg) scaleY(0.95);
    }
    100% {
        opacity: 1;
        transform: perspective(1000px) rotateX(0deg) scaleY(1);
    }
}

.letter-paper.folding {
    animation: letterFold 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes letterFold {
    0% {
        opacity: 1;
        transform: perspective(1000px) rotateX(0deg) scaleY(1);
    }
    40% {
        transform: perspective(1000px) rotateX(30deg) scaleY(0.85);
    }
    100% {
        opacity: 0;
        transform: perspective(1000px) rotateX(90deg) scaleY(0.5);
    }
}

/* === Letter Flip === */
.letter-flip-container {
    perspective: 1200px;
    width: 100%;
}

.letter-flipper {
    position: relative;
    width: 100%;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

.letter-flipper.flipped {
    transform: rotateY(180deg);
}

/* Both faces share the same base style */
.letter-face {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    width: 100%;
}

.letter-face.letter-front {
    position: relative;
}

.letter-face.letter-back {
    position: absolute;
    top: 0;
    height: 100%;
    left: 0;
    width: 100%;
    height: 100%;
    transform: rotateY(180deg);
}

/* The parchment inside back fills the face completely */
.letter-face.letter-back .about-letter.parchment {
    height: 100%;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
}

.letter-back-pic-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 2;
}

.letter-back-pic {
    max-width: 75%;
    max-height: 80%;
    object-fit: contain;
}

/* === Flip emoji button (transparent) === */
.letter-flip-emoji-btn {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    opacity: 0.7;
    color: rgba(255,255,255,0.8);
    transition: transform 0.2s, opacity 0.2s;
    animation: flipHint 2.5s ease-in-out infinite;
}
.letter-flip-emoji-btn:hover,
.letter-flip-emoji-btn:active {
    transform: scale(1.2);
    opacity: 1;
    animation: none;
}
@keyframes flipHint {
    0%, 70%, 100% { transform: rotateY(0deg); opacity: 0.7; }
    80% { transform: rotateY(180deg); opacity: 1; }
    90% { transform: rotateY(0deg); opacity: 0.7; }
}

/* === Buttons === */
.letter-top-btn {
    display: flex;
    justify-content: center;
    margin-bottom: 14px;
    animation: fadeIn 0.4s ease;
}

.letter-top-btn.hidden {
    display: none;
}

.letter-bottom-btn {
    display: flex;
    justify-content: center;
    margin-top: 14px;
    animation: fadeIn 0.4s ease;
}

.letter-bottom-btn.hidden {
    display: none;
}

.letter-envelope-scene.closing-fade {
    animation: fadeOutDown 0.6s ease forwards;
}

@keyframes fadeOutDown {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(30px); }
}

@media (max-width: 480px) {
    .envelope-wrapper {
        width: 300px;
        height: 190px;
    }

    /* Letter section: everything fits on screen, no scrolling at all */
    .letter-section {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        overflow: hidden;
        padding: 0;
    }

    .letter-envelope-scene {
        width: 96%;
        flex: 1;
        min-height: 0;
        padding: 8px 8px;
        box-sizing: border-box;
    }

    /* Equal spacing above and below letter */
    .letter-top-btn {
        margin-bottom: 8px;
    }
    .letter-flip-emoji-btn {
        font-size: 2.5rem;
    }

    .letter-bottom-btn {
        margin-top: 8px;
    }
    .letter-bottom-btn .enter-btn {
        padding: 8px 20px;
        font-size: 0.9rem;
    }

    /* Letter paper fills remaining space between buttons, no scroll */
    .letter-paper {
        flex: 1;
        min-height: 0;
        overflow: hidden;
        width: 100%;
    }

    .letter-paper .letter-flip-container {
        height: 100%;
    }
    .letter-paper .letter-flipper {
        height: 100%;
    }
    .letter-paper .letter-face {
        height: 100%;
    }

    /* Parchment: fill the available height */
    .about-letter.parchment {
        min-height: 0;
        height: 100%;
        overflow: hidden;
        padding: 10px 12px 6px;
    }

    .about-letter-title {
        font-size: 0.9rem;
        margin-bottom: 2px;
    }

    .about-letter-body {
        font-size: clamp(0.52rem, 1.35vh, 0.8rem);
        line-height: 1.45;
    }

    .about-letter-body p {
        margin-bottom: 0.2em;
    }

    .letter-footer-images {
        padding: 2px 0 0;
    }

    .letter-amlas-sig {
        width: clamp(65px, 24vw, 110px);
    }

    /* Back: picture centered */
    .letter-back-pic-wrapper {
        height: 100%;
        padding: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .letter-back-pic {
        max-width: 90%;
        max-height: 90%;
    }
}

.mood-container {
    text-align: center;
    padding: var(--spacing-xl);
    max-width: 600px;
    width: 90%;
}

.mood-title {
    font-size: clamp(1.5rem, 4vw, 2.2rem);
    font-weight: 700;
    color: var(--accent-primary);
    margin-bottom: var(--spacing-xs);
}

.mood-subtitle {
    color: rgba(255,255,255,0.6);
    margin-bottom: var(--spacing-xl);
    font-size: 1rem;
}

.mood-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.mood-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: var(--spacing-lg) var(--spacing-md);
    background: linear-gradient(145deg, rgba(155, 89, 182, 0.1), rgba(52, 73, 94, 0.2));
    border: 2px solid rgba(155, 89, 182, 0.2);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
    font-family: inherit;
    font-size: inherit;
}

.mood-card:hover {
    transform: translateY(-4px);
    border-color: #ffd700;
    box-shadow: 0 8px 25px rgba(255, 215, 0, 0.15);
}

.mood-card.selected {
    border-color: #ffd700;
    background: linear-gradient(145deg, rgba(255, 215, 0, 0.15), rgba(155, 89, 182, 0.2));
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.2);
}

.mood-emoji {
    font-size: 2.5rem;
}

.mood-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.mood-greeting {
    margin-top: var(--spacing-lg);
    animation: fadeIn 0.5s ease;
}

.mood-greeting-text {
    font-size: 1.2rem;
    color: rgba(255,255,255,0.9);
    margin-bottom: var(--spacing-lg);
    line-height: 1.6;
}

@media (max-width: 480px) {
    .mood-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ========================================
   LIVE CHAT SIDEBAR
   ======================================== */

.chat-toggle-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ffd700, #9b59b6);
    border: none;
    font-size: 1.7rem;
    cursor: pointer;
    z-index: 90; /* Sit behind modals */
    box-shadow: 0 4px 20px rgba(168, 85, 247, 0.45), 0 0 0 0 rgba(168, 85, 247, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: chat-pulse 3s ease-in-out infinite;
}

/* Hide chat bubble ONLY in Therapy tab to prevent overlap */
body[data-active-tab="salma-ai"] .chat-toggle-btn {
    display: none !important;
}

@keyframes chat-pulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(168, 85, 247, 0.45), 0 0 0 0 rgba(168, 85, 247, 0.3); }
    50% { box-shadow: 0 4px 20px rgba(168, 85, 247, 0.45), 0 0 0 10px rgba(168, 85, 247, 0); }
}

.chat-toggle-btn::after {
    content: 'Live Chat';
    position: absolute;
    bottom: calc(100% + 10px);
    right: 0;
    background: rgba(20, 16, 40, 0.95);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 8px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    border: 1px solid rgba(155, 89, 182, 0.3);
    font-family: inherit;
}

.chat-toggle-btn:hover::after {
    opacity: 1;
    transform: translateY(0);
}

.chat-toggle-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(168, 85, 247, 0.6);
    animation: none;
}

.chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #e74c3c;
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Lock body scroll when chat is open — mobile only, allow scroll on desktop */
@media (max-width: 768px) {
    body.chat-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
    }
}

.chat-sidebar {
    position: fixed;
    top: 0; right: -360px; bottom: 0;
    width: 350px;
    max-width: 100vw;
    background: rgba(13, 11, 30, 0.97);
    backdrop-filter: blur(20px);
    border-left: 1px solid rgba(155, 89, 182, 0.3);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-sidebar.open {
    right: 0;
}

.chat-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}

.chat-sidebar-header h3 {
    color: var(--accent-primary);
    font-weight: 700;
    font-size: 1.1rem;
}

.chat-close-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.6);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}

.chat-close-btn:hover {
    color: white;
    background: rgba(255,255,255,0.1);
}

#chat-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

#chat-body.hidden {
    display: none;
}

.chat-name-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 16px;
    padding: var(--spacing-lg);
    text-align: center;
}

.chat-name-prompt.hidden {
    display: none;
}

.chat-name-prompt p {
    color: rgba(255,255,255,0.8);
    font-size: 1.1rem;
    font-weight: 600;
}

.chat-name-input-area {
    display: flex;
    gap: 8px;
    width: 100%;
    max-width: 250px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.chat-bubble {
    max-width: 80%;
    padding: 8px 14px;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.4;
    animation: fadeIn 0.2s ease;
    word-break: break-word;
}

.chat-bubble.mine {
    align-self: flex-end;
    background: linear-gradient(135deg, rgba(142, 68, 173, 0.25), rgba(155, 89, 182, 0.15));
    border: 1px solid rgba(155, 89, 182, 0.35);
    border-bottom-right-radius: 4px;
}

.chat-bubble.theirs {
    align-self: flex-start;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.15), rgba(255, 215, 0, 0.08));
    border: 1px solid rgba(255, 215, 0, 0.25);
    border-bottom-left-radius: 4px;
}

.chat-bubble.reaction {
    padding: 4px 10px;
}

.chat-sender {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    color: rgba(255,255,255,0.5);
    margin-bottom: 2px;
}

.chat-text {
    color: rgba(255,255,255,0.9);
}

.chat-reaction-display {
    font-size: 1.5rem;
}

.chat-reactions {
    display: flex;
    gap: 6px;
    padding: 8px var(--spacing-md);
    overflow-x: auto;
    border-top: 1px solid rgba(255,255,255,0.05);
    flex-shrink: 0;
}

.chat-reaction-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.8);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
    font-family: inherit;
}

.chat-reaction-btn:hover {
    background: rgba(168, 85, 247, 0.15);
    border-color: rgba(168, 85, 247, 0.25);
}

.chat-typing-indicator {
    padding: 6px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.chat-typing-indicator.hidden { display: none; }
.chat-typing-name {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.5);
    font-weight: 500;
    white-space: nowrap;
}
.chat-typing-bubble {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}
.chat-typing-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: rgba(255,255,255,0.5);
    animation: typingBounce 1.4s ease-in-out infinite;
}
.chat-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

.chat-no-session {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 16px;
    color: rgba(255,255,255,0.5);
    font-size: 0.9rem;
    text-align: center;
    padding: 20px;
}
.chat-no-session.hidden { display: none; }
.chat-no-session p { margin: 0; }
.chat-connect-btn {
    background: linear-gradient(135deg, #ffd700, #ffec8b);
    border: none;
    color: #0d0b1e;
    padding: 10px 24px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
    min-height: 44px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.chat-connect-btn:hover { transform: scale(1.05); }

.chat-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: var(--spacing-md);
    border-top: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 20px;
    padding: 10px 16px;
    color: white;
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
}

.chat-input:focus {
    border-color: #ffd700;
}

.chat-send-btn {
    background: linear-gradient(135deg, #ffd700, #9b59b6);
    border: none;
    color: #0d0b1e;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 50%;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    transform: scale(1.1);
}

/* Voice Note Mic Button */
.chat-mic-btn {
    background: linear-gradient(135deg, var(--accent-secondary), #8e44ad);
    border: none;
    color: #fff;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 50%;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}
.chat-mic-btn:hover {
    transform: scale(1.1);
}
.chat-mic-btn.recording {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    animation: micPulse 1s ease infinite;
}
@keyframes micPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(231, 76, 60, 0); }
}

/* Recording overlay in input area */
.chat-recording-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    padding: 0 12px;
    color: #e74c3c;
    font-size: 0.85rem;
    font-weight: 600;
}
.chat-recording-bar .rec-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #e74c3c;
    animation: recBlink 1s ease infinite;
}
@keyframes recBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.2; }
}
.chat-recording-bar .rec-timer {
    font-variant-numeric: tabular-nums;
}
.chat-recording-bar .rec-cancel {
    margin-left: auto;
    background: none;
    border: none;
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    font-size: 0.8rem;
}
.chat-recording-bar .rec-cancel:hover { color: #fff; }

/* Voice note in chat bubble */
.chat-voice-note {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 180px;
}
.chat-voice-note .vn-play-btn {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}
.chat-voice-note .vn-waveform {
    flex: 1;
    height: 28px;
    display: flex;
    align-items: center;
    gap: 2px;
}
.chat-voice-note .vn-bar {
    width: 3px;
    background: currentColor;
    border-radius: 2px;
    opacity: 0.5;
    transition: opacity 0.1s;
}
.chat-voice-note .vn-bar.played { opacity: 1; }
.chat-voice-note .vn-duration {
    font-size: 0.7rem;
    opacity: 0.6;
    min-width: 30px;
    text-align: right;
}
.chat-voice-note .vn-speed-btn {
    background: rgba(255,255,255,0.12);
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 0.65rem;
    font-weight: 700;
    width: 30px;
    text-align: center;
    padding: 2px 0;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
    line-height: 1.2;
    transition: background 0.15s;
    flex-shrink: 0;
}
.chat-voice-note .vn-speed-btn:hover {
    background: rgba(255,255,255,0.2);
}
.chat-voice-note .vn-speed-btn.active {
    background: rgba(255,215,0,0.25);
    color: #a855f7;
}

@media (max-width: 480px) {
    .chat-sidebar {
        width: 100vw;
        right: -100vw;
    }
    .chat-toggle-btn {
        bottom: 16px;
        right: 16px;
        width: 48px;
        height: 48px;
        font-size: 1.2rem;
    }
}

/* ========================================
   QUIZ GAME
   ======================================== */

.quiz-area {
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.quiz-waiting {
    padding: var(--spacing-2xl) 0;
    color: rgba(255, 255, 255, 0.6);
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.quiz-waiting h2 {
    color: var(--accent-primary);
    font-size: clamp(1.2rem, 3vw, 1.6rem);
    margin-bottom: var(--spacing-sm);
}

/* Progress + timer row */
.quiz-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: clamp(8px, 1.5dvh, 16px);
}

.quiz-progress {
    color: rgba(255,255,255,0.5);
    font-size: clamp(0.7rem, 1.5dvh, 0.85rem);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
}

.quiz-timer-bar {
    flex: 1;
    height: 4px;
    background: rgba(255,255,255,0.08);
    border-radius: 3px;
    overflow: hidden;
}

.quiz-timer-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), #e74c3c);
    border-radius: 3px;
    width: 100%;
}

/* Question card — fills remaining space */
.quiz-question-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    animation: fadeIn 0.4s ease;
}

/* Question text */
.quiz-question-text {
    color: white;
    font-size: clamp(1rem, 2.5vw, 1.3rem);
    font-weight: 600;
    line-height: 1.4;
    padding: clamp(12px, 2dvh, 24px) clamp(8px, 2vw, 16px);
    background: rgba(25, 20, 50, 0.5);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(155, 89, 182, 0.2);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    margin-bottom: clamp(8px, 1.5dvh, 16px);
}

/* Options — 2x2 grid on all screens */
.quiz-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(6px, 1dvh, 12px);
    flex: 1;
    min-height: 0;
}

.quiz-option {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(8px, 1.2dvh, 16px) clamp(8px, 1.5vw, 16px);
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1.5px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.9);
    font-size: clamp(0.78rem, 1.6dvh, 0.95rem);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    text-align: center;
    overflow: hidden;
    word-break: break-word;
}

.quiz-option:hover:not(.disabled) {
    border-color: var(--accent-primary);
    background: rgba(168, 85, 247, 0.12);
    box-shadow: 0 4px 15px rgba(168, 85, 247, 0.15);
}

.quiz-option.selected {
    border-color: var(--accent-primary);
    background: rgba(168, 85, 247, 0.2);
    box-shadow: 0 0 15px rgba(168, 85, 247, 0.2);
}

.quiz-option.correct {
    border-color: var(--correct) !important;
    background: rgba(39, 174, 96, 0.25) !important;
    box-shadow: 0 0 12px rgba(39, 174, 96, 0.2) !important;
}

.quiz-option.wrong {
    border-color: #e74c3c !important;
    background: rgba(231, 76, 60, 0.25) !important;
    box-shadow: 0 0 12px rgba(231, 76, 60, 0.2) !important;
}

.quiz-option.disabled {
    pointer-events: none;
    opacity: 0.7;
}

/* Result replaces question text */
.quiz-question-text.quiz-result-flash {
    color: var(--accent-primary);
    font-size: clamp(1rem, 2.5dvh, 1.3rem) !important;
    animation: fadeIn 0.3s ease;
}

.quiz-final {
    padding: var(--spacing-xl) 0;
    animation: scaleIn 0.5s ease;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.quiz-final-title {
    color: var(--accent-primary);
    font-size: clamp(1.5rem, 4vw, 2.2rem);
    margin-bottom: var(--spacing-md);
}

.quiz-final-winner {
    font-size: clamp(1.1rem, 2.5vw, 1.5rem);
    color: white;
    margin-bottom: var(--spacing-xl);
}

.quiz-final-scores {
    display: flex;
    justify-content: center;
    gap: var(--spacing-2xl);
}

.quiz-final-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-sm);
    color: rgba(255,255,255,0.8);
    font-size: 1.1rem;
}

.quiz-score-big {
    font-size: clamp(2rem, 5dvh, 3rem);
    font-weight: 800;
    color: var(--accent-primary);
}

/* quiz-options is single column by default now */

/* ========================================
   MEDIA ROOM — Modern Redesign
   ======================================== */

.media-room {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--spacing-sm) 0;
    display: flex;
    flex-direction: column;
}

#media-connected:not(.hidden) {
    display: flex;
    flex-direction: column;
    gap: clamp(6px, 1.2dvh, 12px);
    overflow: visible;
    max-width: 100%;
}

/* --- Player Area --- */
.media-player-area {
    border-radius: 16px;
    overflow: hidden !important;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
    flex-grow: 0;
    position: relative;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    max-width: 100%;
    /* Smooth transitions between all player modes */
    transition: height 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                max-width 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                border-radius 0.3s ease,
                background 0.3s ease;
}

/* All content inside must fit, never expand the player */
.media-player-area > * {
    max-height: 100%;
    overflow: hidden;
}

.tiktok-embed-wrapper {
    overflow: hidden !important;
}

/* =============================================
   FIXED PLAYER SIZES — set per screen, NEVER changes
   height is !important so nothing can override it
   ============================================= */

/* ——— Desktop (>1024px) ——— */
.media-player-area                { height: 420px !important; }
.media-player-area.tiktok-mode    { height: 600px !important; max-width: 350px; background: #000; border-radius: 12px; }
.media-player-area.spotify-mode   { height: 352px !important; }

/* ——— Tablet (601–1024px) ——— */
@media (max-width: 1024px) {
    .media-player-area                { height: 360px !important; }
    .media-player-area.tiktok-mode    { height: 540px !important; max-width: 320px; }
    .media-player-area.spotify-mode   { height: 310px !important; }
}

/* ——— Large phone (431–600px) ——— */
@media (max-width: 600px) {
    .media-player-area                { height: 280px !important; border-radius: 12px; }
    .media-player-area.tiktok-mode    { height: min(600px, 75dvh) !important; max-width: 92vw; }
    .media-player-area.spotify-mode   { height: 260px !important; }
}

/* ——— Small phone (≤430px) ——— */
@media (max-width: 430px) {
    .media-player-area                { height: 240px !important; }
    .media-player-area.tiktok-mode    { height: min(570px, 73dvh) !important; max-width: 94vw; }
    .media-player-area.spotify-mode   { height: 220px !important; }
}

#yt-player-container,
#spotify-player-container {
    width: 100%;
    height: 100%;
}

.media-player-area iframe {
    width: 100% !important;
    height: 100% !important;
    border: none;
}

.media-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 16px;
    padding: 24px;
}

.media-empty-logos {
    display: flex;
    align-items: center;
    gap: 20px;
    opacity: 0.55;
}

.media-empty-text {
    color: rgba(255, 255, 255, 0.35);
    font-size: 0.9rem;
    margin: 0;
}

/* --- URL Input Row --- */
.media-input-row {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.media-url-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 10px 16px;
    color: #fff;
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease;
}

.media-url-input:focus {
    border-color: rgba(168, 85, 247, 0.45);
    box-shadow: 0 0 0 2px rgba(255, 215, 0, 0.08);
}

.media-url-input::placeholder {
    color: rgba(255, 255, 255, 0.25);
}

.media-add-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid rgba(168, 85, 247, 0.3);
    background: rgba(168, 85, 247, 0.15);
    color: #a855f7;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.media-add-btn:hover {
    background: rgba(168, 85, 247, 0.28);
    border-color: rgba(168, 85, 247, 0.5);
}

/* --- Transport Controls --- */
.media-transport {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(4px, 1vw, 12px);
    flex-shrink: 0;
}

.media-ctrl-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.2s ease;
}

.media-ctrl-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.25);
}

/* 10s skip buttons — arrow + "10" side by side */
.media-skip10-btn {
    gap: 3px;
    width: auto;
    padding: 0 12px;
    border-radius: 20px;
    border-color: rgba(168, 85, 247, 0.2);
    background: rgba(168, 85, 247, 0.08);
    color: rgba(200, 170, 255, 0.8);
}

.media-skip10-btn svg {
    flex-shrink: 0;
}

.media-skip10-btn:hover {
    background: rgba(168, 85, 247, 0.18);
    border-color: rgba(168, 85, 247, 0.4);
    color: #c8aaff;
}

.media-skip10-text {
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
}

.media-play-btn,
.media-pause-btn-new {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.media-play-btn {
    background: linear-gradient(135deg, #ffd700, #a855f7);
    color: #fff;
    box-shadow: 0 4px 16px rgba(255, 215, 0, 0.25), 0 4px 16px rgba(168, 85, 247, 0.2);
}

.media-play-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(255, 215, 0, 0.35), 0 6px 24px rgba(168, 85, 247, 0.3);
}

.media-pause-btn-new {
    background: rgba(255, 215, 0, 0.08);
    border: 1px solid rgba(255, 215, 0, 0.25);
    color: rgba(255, 220, 100, 0.85);
}

.media-pause-btn-new:hover {
    background: rgba(255, 215, 0, 0.18);
    color: #ffd700;
    border-color: rgba(255, 215, 0, 0.45);
}

/* --- Sync Row --- */
.media-sync-row {
    display: flex;
    justify-content: center;
    flex-shrink: 0;
}

.media-sync-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 18px;
    border-radius: 20px;
    border: 1px solid rgba(255, 215, 0, 0.18);
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.08), rgba(255, 215, 0, 0.06));
    color: rgba(255, 215, 0, 0.7);
    font-size: 0.8rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
}

.media-sync-btn:hover {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.15), rgba(255, 215, 0, 0.12));
    border-color: rgba(255, 215, 0, 0.35);
    color: #ffd700;
}

/* --- Queue Section --- */
.media-queue-section {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    max-width: 100%;
    overflow: hidden;
}

@media (max-width: 600px) {
    .media-queue-list {
        /* Show max 4 cards on phone */
        max-height: calc(4 * 56px + 3 * 4px);
    }
    .media-queue-scroll-wrapper {
        max-height: calc(4 * 56px + 3 * 4px);
    }
}

/* When TikTok is playing, show fewer queue cards to save space */
.media-player-area.tiktok-mode ~ .media-queue-section .media-queue-list {
    max-height: calc(3 * 56px + 2 * 4px);
}
.media-player-area.tiktok-mode ~ .media-queue-section .media-queue-scroll-wrapper {
    max-height: calc(3 * 56px + 2 * 4px);
}

.media-queue-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    flex-shrink: 0;
}

.media-queue-label {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin: 0;
}

.media-queue-count {
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.7rem;
}

.media-queue-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
    /* Show max 5 cards on desktop, scroll for the rest */
    max-height: calc(5 * 56px + 4 * 4px);
    padding: 2px;
    /* Always-visible purple scrollbar — never auto-hide */
    scrollbar-width: thin;
    scrollbar-color: rgba(155, 89, 182, 0.6) rgba(13, 11, 30, 0.3);
}

/* Desktop/Android: native custom scrollbar */
.media-queue-list::-webkit-scrollbar {
    width: 6px;
    display: block;
}

.media-queue-list::-webkit-scrollbar-track {
    background: rgba(13, 11, 30, 0.3);
    border-radius: 10px;
}

.media-queue-list::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(155, 89, 182, 0.7), rgba(100, 50, 150, 0.9));
    border-radius: 10px;
    min-height: 30px;
}

/* Scroll wrapper: list + custom scrollbar side by side */
.media-queue-scroll-wrapper {
    display: flex;
    position: relative;
    max-height: calc(5 * 56px + 4 * 4px);
}

.media-queue-scroll-wrapper .media-queue-list {
    flex: 1;
    min-width: 0;
}

/* Custom scrollbar track — hidden on desktop (native scrollbar works), shown on iOS */
.media-queue-scrollbar-track {
    display: none;
}

@supports (-webkit-touch-callout: none) {
    /* iOS Safari: hide native scrollbar by clipping it off */
    .media-queue-scroll-wrapper .media-queue-list {
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        -ms-overflow-style: none;
        padding-right: 10px;
        margin-right: -10px;
        clip-path: inset(0 10px 0 0);
    }
    .media-queue-list::-webkit-scrollbar {
        display: none;
        width: 0;
        height: 0;
    }
    .media-queue-scrollbar-track {
        display: block;
        width: 6px;
        background: rgba(13, 11, 30, 0.3);
        border-radius: 10px;
        margin-left: 4px;
        flex-shrink: 0;
        position: relative;
    }
    .media-queue-scrollbar-thumb {
        width: 100%;
        background: linear-gradient(180deg, rgba(155, 89, 182, 0.7), rgba(100, 50, 150, 0.9));
        border-radius: 10px;
        position: absolute;
        top: 0;
        min-height: 20px;
        transition: top 0.1s ease-out;
    }
    /* Hide custom track when queue doesn't overflow */
    .media-queue-scrollbar-track.hidden {
        display: none;
    }
}

.media-playlist-empty {
    color: rgba(255, 255, 255, 0.2);
    text-align: center;
    padding: var(--spacing-lg);
    font-size: 0.85rem;
}

.media-queue-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 10px;
    transition: all 0.2s ease;
    max-width: 100%;
    width: 100%;
    overflow: hidden;
    box-sizing: border-box;
    min-height: 52px;
    flex-shrink: 0;
}

.media-queue-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
}

.media-queue-item.active {
    border-color: rgba(168, 85, 247, 0.3);
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.06), rgba(255, 215, 0, 0.03));
}

.media-queue-num {
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 18px;
    text-align: center;
}

.media-queue-thumb {
    width: 48px;
    height: 36px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
}

.media-queue-id,
.media-queue-title {
    flex: 1;
    min-width: 0;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.3;
}

.media-queue-remove {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.2);
    font-size: 0.85rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.media-queue-remove:hover {
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.15);
}

/* ========================================
   SALMA AI CHATBOT
   ======================================== */

.salma-ai-container {
    max-width: 600px;
    margin: 0 auto;
    padding: var(--spacing-md) 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    min-height: 0;
}

.salma-face-wrap {
    text-align: center;
    margin-bottom: var(--spacing-lg);
}

.salma-ai-label {
    font-weight: 700;
    font-size: 1.1rem;
    margin-top: var(--spacing-sm);
    background: linear-gradient(135deg, var(--accent-secondary), var(--accent-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* CSS 3D Animated Face */
.salma-face {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    background: linear-gradient(145deg, #ffd89b, #f8b4b4);
    margin: 0 auto;
    position: relative;
    animation: faceBob 3s ease-in-out infinite;
    box-shadow: 0 8px 30px rgba(248, 180, 180, 0.3);
}

.face-inner {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
}

/* Eyes */
.face-eyes {
    display: flex;
    justify-content: center;
    gap: 30px;
    padding-top: 50px;
}

.face-eye {
    width: 22px;
    height: 22px;
    background: white;
    border-radius: 50%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.face-pupil {
    width: 10px;
    height: 10px;
    background: #2c3e50;
    border-radius: 50%;
    transition: transform 0.3s ease;
}

/* Mouth */
.face-mouth {
    width: 30px;
    height: 15px;
    border-bottom: 3px solid #c0392b;
    border-radius: 0 0 50% 50%;
    margin: 18px auto 0;
    transition: all 0.4s ease;
}

/* Blush */
.face-blush {
    width: 22px;
    height: 12px;
    background: rgba(255, 130, 130, 0.5);
    border-radius: 50%;
    position: absolute;
    top: 85px;
}

.face-blush.left { left: 18px; }
.face-blush.right { right: 18px; }

/* Expression Classes */
.face-happy .face-mouth {
    width: 35px;
    height: 18px;
    border-bottom: 3px solid #c0392b;
    border-radius: 0 0 50% 50%;
}

.face-thinking .face-mouth {
    width: 16px;
    height: 16px;
    border: 3px solid #c0392b;
    border-radius: 50%;
    background: none;
}

.face-thinking .face-pupil {
    transform: translate(3px, -2px);
}

.face-concerned .face-mouth {
    width: 25px;
    height: 12px;
    border-bottom: none;
    border-top: 3px solid #c0392b;
    border-radius: 50% 50% 0 0;
}

.face-concerned .face-blush {
    opacity: 0.3;
}

.face-laughing .face-mouth {
    width: 40px;
    height: 22px;
    border-bottom: 3px solid #c0392b;
    border-radius: 0 0 50% 50%;
    background: rgba(0,0,0,0.1);
}

.face-laughing .face-eye {
    height: 6px;
    border-radius: 0 0 50% 50%;
    overflow: hidden;
}

.face-laughing .face-pupil {
    display: none;
}

/* Blink Animation */
.salma-face.blink .face-eye {
    height: 3px;
    transition: height 0.1s ease;
}

.salma-face.blink .face-pupil {
    display: none;
}

/* Idle Bobbing */
@keyframes faceBob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

/* AI Chat */
.salma-ai-chat {
    width: 100%;
    flex: 1;
    min-height: 0;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(155, 89, 182, 0.2);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.salma-ai-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.ai-chat-bubble {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

.ai-chat-bubble.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.ai-chat-bubble.salma {
    align-self: flex-start;
}

.ai-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
}

.ai-bubble-content {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.5;
    word-break: break-word;
}

.ai-chat-bubble.salma .ai-bubble-content {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.15), rgba(255, 215, 0, 0.08));
    border: 1px solid rgba(255, 215, 0, 0.25);
    color: rgba(255,255,255,0.9);
    border-bottom-left-radius: 4px;
}

.ai-chat-bubble.user .ai-bubble-content {
    background: linear-gradient(135deg, rgba(142, 68, 173, 0.25), rgba(155, 89, 182, 0.15));
    border: 1px solid rgba(155, 89, 182, 0.35);
    color: rgba(255,255,255,0.9);
    border-bottom-right-radius: 4px;
}

/* Typing dots */
.typing-dots span {
    animation: typingBounce 1.4s infinite;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-secondary);
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

.salma-ai-input-area {
    display: flex;
    gap: 8px;
    padding: var(--spacing-md);
    border-top: 1px solid rgba(255,255,255,0.1);
}

.salma-ai-input {
    flex: 1;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 20px;
    padding: 10px 16px;
    color: white;
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
}

.salma-ai-input:focus {
    border-color: var(--accent-secondary);
}

/* ========================================
   NAV TAB UPDATES (5 tabs responsive)
   ======================================== */

@media (max-width: 600px) {
    .content-nav {
        gap: 2px;
    }
    .nav-tab {
        padding: 8px 10px;
        min-width: 0;
    }
    .nav-label {
        font-size: 0.65rem;
    }
    .nav-icon {
        font-size: 1.1rem;
    }
}

/* ========================================
   SESSION OVERLAY
   ======================================== */
.session-overlay {
    position: fixed;
    inset: 0;
    z-index: 2500;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

.session-overlay.hidden {
    display: none;
}

.session-overlay-content {
    max-width: 680px;
    width: 92%;
    max-height: 96vh;
    max-height: 96dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
    padding: clamp(var(--spacing-md), 3dvh, var(--spacing-xl));
    display: flex;
    flex-direction: column;
}

@media (min-width: 768px) {
    .session-overlay-content {
        padding: var(--spacing-xl) var(--spacing-xxl);
    }
    .session-overlay-content .role-avatar {
        width: 80px;
        height: 80px;
    }
    .session-overlay-content .role-card {
        padding: 24px 28px;
        gap: 12px;
    }
    .session-overlay-content .role-name {
        font-size: 1.15rem;
    }
    .session-overlay-content .lobby-subtitle {
        font-size: 1.15rem;
    }
}

.shared-lobby {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.session-overlay-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    color: rgba(255,255,255,0.5);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    z-index: 10;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.session-overlay-close:hover {
    color: white;
    background: rgba(255,255,255,0.1);
}

/* ========================================
   SESSION STATUS BUTTON (Header)
   ======================================== */
.session-status-btn {
    display: grid;
    grid-template-columns: 8px 1fr;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 20px;
    padding: 6px 10px 6px 16px;
    color: rgba(255,255,255,0.8);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 36px;
    width: 110px;
    box-sizing: border-box;
    margin-left: 8px;
}

.session-status-btn .session-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.session-status-btn #session-status-text {
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-status-btn:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.2);
}

.session-dot.online {
    background: #2ecc71;
    box-shadow: 0 0 6px rgba(46, 204, 113, 0.5);
}

.session-dot.waiting {
    background: #f39c12;
    box-shadow: 0 0 6px rgba(243, 156, 18, 0.5);
    animation: pulse-dot 1.5s infinite;
}

.session-dot.offline {
    background: rgba(255,255,255,0.3);
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}


/* ========================================
   MEDIA / GAMES NO-SESSION PROMPTS
   ======================================== */
.media-session-prompt,
.games-no-session {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-height: 0;
    gap: var(--spacing-md);
    text-align: center;
    padding: var(--spacing-lg);
}

.games-no-session p {
    color: rgba(255,255,255,0.5);
    font-size: 1rem;
    max-width: 300px;
}

/* --- Media No-Session Redesign (blurred preview + overlay) --- */
.media-no-session-redesign {
    position: relative;
    text-align: center;
    padding: var(--spacing-lg);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-width: 1400px;
    margin: 0 auto;
}

.media-no-session-redesign.hidden { display: none; }

.media-no-session-title {
    font-size: clamp(1.2rem, 3.5dvh, 2rem);
    font-weight: 800;
    margin: 0 0 clamp(6px, 1.5dvh, var(--spacing-lg));
    background: linear-gradient(135deg, var(--accent-secondary), var(--accent-primary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.media-no-session-subtitle {
    color: rgba(255, 255, 255, 0.5);
    font-size: clamp(0.85rem, 2dvh, 1rem);
    margin: 0 0 clamp(8px, 2dvh, 16px);
}

.media-preview-grid {
    display: flex;
    gap: clamp(8px, 1.5vw, 16px);
    justify-content: center;
    flex-wrap: wrap;
}

.media-preview-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: clamp(90px, 20vw, 130px);
    padding: clamp(16px, 3dvh, 28px) 12px;
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
}

.media-preview-name {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.8rem;
    font-weight: 500;
}

.media-card-locked {
    pointer-events: none;
    opacity: 0.35;
    filter: grayscale(0.4) brightness(0.6);
}

.media-connect-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(8px, 1.5dvh, var(--spacing-md));
    margin-top: clamp(var(--spacing-md), 2dvh, var(--spacing-xl));
    padding: clamp(var(--spacing-sm), 2dvh, var(--spacing-lg));
    background: rgba(25, 20, 50, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(155, 89, 182, 0.15);
    border-radius: var(--radius-lg);
}

.media-lock-icon {
    font-size: clamp(1.5rem, 4dvh, 2.5rem);
}

.media-connect-overlay p {
    color: rgba(255, 255, 255, 0.5);
    font-size: clamp(0.85rem, 2dvh, 1rem);
    margin: 0;
}

.media-session-prompt.hidden,
.games-no-session.hidden,
.games-no-session-redesign.hidden {
    display: none;
}

/* Games no-session redesign — dimmed cards with connect overlay */
.games-no-session-redesign {
    position: relative;
    text-align: center;
    padding: var(--spacing-lg);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-width: min(97%, 800px);
    margin: 0 auto;
}

.games-no-session-subtitle {
    color: rgba(255, 255, 255, 0.5);
    font-size: clamp(0.85rem, 2dvh, 1rem);
    margin-bottom: clamp(6px, 1.5dvh, var(--spacing-lg));
}

.games-preview-grid {
    position: relative;
}

.game-card-locked {
    pointer-events: none;
    opacity: 0.35;
    filter: grayscale(0.4) brightness(0.6);
    cursor: default;
}

.games-connect-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(8px, 1.5dvh, var(--spacing-md));
    margin-top: clamp(var(--spacing-md), 2dvh, var(--spacing-xl));
    padding: clamp(var(--spacing-sm), 2dvh, var(--spacing-lg));
    background: rgba(25, 20, 50, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(155, 89, 182, 0.15);
    border-radius: var(--radius-lg);
}

.games-lock-icon {
    font-size: clamp(1.5rem, 4dvh, 2.5rem);
}

.games-connect-overlay p {
    color: rgba(255, 255, 255, 0.5);
    font-size: clamp(0.85rem, 2dvh, 1rem);
}

/* Old media playback controls removed — now using .media-transport */

/* ========================================
   GALLERY HEADER — fit session btn
   ======================================== */
/* header layout handled above */

/* ========================================
   FAB (Floating Action Button)
   ======================================== */
.fab-container {
    position: fixed;
    bottom: 40px;
    right: 24px;
    z-index: 1000;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    transition: none;
}

.fab-container.fab-snapping {
    transition: left 0.3s ease, right 0.3s ease, top 0.3s ease, bottom 0.3s ease;
}

/* Actions positioned absolutely so FAB button never moves */
.fab-actions {
    position: absolute;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-end;
}

/* Default: right side, actions open upward */
.fab-actions {
    bottom: calc(100% + 12px);
    right: 0;
}

/* When near top, actions open downward */
.fab-container.fab-top .fab-actions {
    bottom: auto;
    top: calc(100% + 12px);
}

/* Right side: label then icon (default) */
.fab-action {
    flex-direction: row;
}

/* Left side: flip to icon then label, align left */
.fab-container.fab-left .fab-actions {
    align-items: flex-start;
    right: auto;
    left: 0;
}

.fab-container.fab-left .fab-action {
    flex-direction: row-reverse;
}

.fab-container.fab-dragging .fab-main {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(251, 191, 36, 0.5), 0 6px 28px rgba(168, 85, 247, 0.6);
    cursor: grabbing;
}

.fab-container.hidden {
    display: none;
}

.fab-main {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #c084fc, #fbbf24, #a855f7);
    color: #fff;
    font-size: 1.4rem;
    cursor: pointer;
    box-shadow: 0 4px 24px rgba(251, 191, 36, 0.35), 0 4px 20px rgba(168, 85, 247, 0.4);
    transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.fab-main:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(251, 191, 36, 0.45), 0 6px 28px rgba(168, 85, 247, 0.5);
}

.fab-main:active {
    transform: scale(0.95);
}

.fab-icon {
    transition: transform 0.3s ease;
    display: inline-block;
}

.fab-container.open .fab-icon {
    transform: rotate(45deg);
}

.fab-container.open .fab-main {
    background: linear-gradient(135deg, #c0392b, #e74c3c);
    box-shadow: 0 4px 20px rgba(231, 76, 60, 0.4);
}

.fab-actions.hidden {
    display: none;
}

.fab-action {
    display: flex;
    align-items: center;
    gap: 10px;
    border: none;
    background: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    animation: fabPopIn 0.25s ease-out both;
}

.fab-action:nth-child(1) { animation-delay: 0.05s; }
.fab-action:nth-child(2) { animation-delay: 0.1s; }
.fab-action:nth-child(3) { animation-delay: 0.15s; }
.fab-action:nth-child(4) { animation-delay: 0.2s; }
.fab-action:nth-child(5) { animation-delay: 0.25s; }

.fab-action-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(25, 20, 50, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(155, 89, 182, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.fab-action:hover .fab-action-icon {
    transform: scale(1.1);
    border-color: var(--accent-primary);
}

.fab-action-label {
    padding: 4px 12px;
    background: rgba(25, 20, 50, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 8px;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(155, 89, 182, 0.15);
    max-width: 60vw;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fab-action {
    position: relative;
}

.fab-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #e74c3c;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.5);
}

.fab-chat-badge.hidden {
    display: none;
}

/* Badge on the outer FAB main button */
.fab-main-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 10px;
    background: #e74c3c;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.5);
    pointer-events: none;
    animation: fabBadgePulse 2s ease-in-out infinite;
}

.fab-main-badge.hidden {
    display: none;
}

@keyframes fabBadgePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

@keyframes fabPopIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* FAB backdrop when open */
.fab-backdrop {
    position: fixed;
    inset: 0;
    z-index: 999;
    background: rgba(0, 0, 0, 0.3);
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (max-width: 600px) {
    .fab-container {
        bottom: 32px;
        right: 16px;
    }
    .fab-main {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
    .fab-action-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
}

/* ========================================
   MOBILE FIXES — touch targets, sizing
   ======================================== */
@media (max-width: 600px) {
    .session-status-btn {
        padding: 5px 10px;
        font-size: 0.7rem;
        min-height: 32px;
        width: 95px;
    }

    .header-left,
    .header-right {
        gap: 2px;
        min-width: 60px;
    }

    .header-icon-btn {
        font-size: 1.1rem;
        padding: 3px 5px;
    }

    .media-input-row {
        gap: 6px;
    }

    .media-url-input {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    .media-ctrl-btn {
        width: 38px;
        height: 38px;
    }

    .media-skip10-btn {
        height: 38px;
        padding: 0 12px;
    }

    .media-skip10-btn .media-skip10-text {
        display: none;
    }

    .media-play-btn,
    .media-pause-btn-new {
        width: 48px;
        height: 48px;
    }

    .lobby-cards {
        flex-direction: row;
        align-items: stretch;
        justify-content: center;
        gap: 8px; /* Extra compression */
    }

    .lobby-card {
        width: 50%;
        max-width: none;
        padding: 12px 8px; /* Compress */
    }

    .lobby-card-icon {
        font-size: 1.8rem;
        margin-bottom: 5px;
    }

    .lobby-card h3 {
        margin-bottom: 4px;
        font-size: 0.95rem;
    }

    .lobby-card p {
        margin-bottom: 10px;
        font-size: 0.75rem;
    }

    .role-cards {
        flex-direction: row;
        gap: 8px;
        justify-content: center;
    }

    .role-card {
        width: 50%;
        padding: 12px 8px;
        gap: 6px;
    }
    
    .role-avatar {
        width: 48px;
        height: 48px;
    }
    
    .role-name {
        font-size: 0.9rem;
    }

    .custom-name-input {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    .session-overlay-content {
        width: 98%;
        padding: clamp(10px, 2dvh, 16px);
        max-height: 98vh;
        max-height: 98dvh;
    }

    #shared-session-options .lobby-subtitle,
    #role-selection-view .lobby-subtitle {
        margin-bottom: 10px;
        font-size: 1rem;
    }

    .salma-ai-container {
        padding: var(--spacing-xs) 0;
        height: 100%;
        gap: 5px;
    }

    .salma-face {
        width: clamp(50px, 10dvh, 80px);
        height: clamp(50px, 10dvh, 80px);
    }
    
    .salma-ai-label {
        font-size: 0.9rem;
        margin-top: 5px;
    }
    
    .salma-face-wrap {
        margin-bottom: var(--spacing-sm);
    }
    
    .salma-ai-messages {
        padding: 10px;
    }
    
    .salma-ai-input-area {
        padding: 8px;
    }

    .salma-face .face-eyes {
        gap: clamp(12px, 2dvh, 20px);
        padding-top: clamp(15px, 2.5dvh, 35px);
    }

    .salma-face .face-eye {
        width: 16px;
        height: 16px;
    }

    .salma-face .face-pupil {
        width: 6px;
        height: 6px;
    }

    .salma-face .face-mouth {
        margin-top: 10px;
    }

    .salma-face .face-blush {
        top: 55px;
        width: 14px;
        height: 8px;
    }

    .salma-face .face-blush.left { left: 10px; }
    .salma-face .face-blush.right { right: 10px; }
}

/* Ensure all interactive elements have minimum touch target */
.ttt-btn,
.chat-reaction-btn,
.media-queue-remove,
.role-card,
.game-pick-card,
.session-status-btn,
.chat-send-btn {
    min-height: 44px;
}

#yt-player-container iframe {
    border-radius: var(--radius-lg);
}

.tiktok-embed-wrapper {
    width: 100%;
    height: 100%;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
}

.tiktok-embed-wrapper iframe {
    width: 100% !important;
    height: 100% !important;
    border: none !important;
    border-radius: 12px;
}

.tiktok-embed-wrapper:fullscreen,
.tiktok-embed-wrapper:-webkit-full-screen {
    background: #000;
}

.tiktok-embed-wrapper:fullscreen iframe,
.tiktok-embed-wrapper:-webkit-full-screen iframe {
    height: 100vh !important;
    max-width: 100vw;
    border-radius: 0;
}

/* Player area fullscreen (fallback for YouTube) */
.media-player-area:fullscreen,
.media-player-area:-webkit-full-screen {
    background: #000;
}

.media-player-area:fullscreen iframe,
.media-player-area:-webkit-full-screen iframe {
    width: 100vw !important;
    height: 100vh !important;
    border-radius: 0 !important;
}

/* ========================================
   CUSTOM NAME INPUT IN ROLE CARD
   ======================================== */
.role-card-custom {
    cursor: pointer;
}

.custom-name-input {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(155, 89, 182, 0.3);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    text-align: center;
    outline: none;
    width: 100%;
    max-width: 160px;
}

.custom-name-input:focus {
    border-color: #ffd700;
}

.custom-name-input::placeholder {
    color: rgba(255,255,255,0.35);
    font-size: 0.85rem;
}

/* ========================================
   CHAT REACTION BUTTONS — consistent sizing
   ======================================== */
.chat-reactions {
    display: flex;
    gap: 6px;
    padding: 8px var(--spacing-md);
    overflow-x: auto;
    border-top: 1px solid rgba(255,255,255,0.05);
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
}

.chat-reaction-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.8);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
    font-family: inherit;
    min-height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========================================
   GAME TURN TIMER BAR
   ======================================== */
.game-timer-bar {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    margin: 8px 0;
}

.game-timer-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 3px;
    transition: width 15s linear;
}

/* ========================================
   MOBILE LAYOUT FIXES — prevent overlapping
   ======================================== */
@media (max-width: 480px) {
    .gallery-header-modern {
        padding: var(--spacing-md) var(--spacing-xs);
    }

    .gallery-header-modern .logo-modern {
        font-size: clamp(1.2rem, 5vw, 1.6rem);
    }

    .gallery-header-modern .session-status-btn {
        font-size: 0.6rem;
        padding: 3px 8px;
        width: 82px;
        gap: 4px;
    }

    .gallery-header-modern .logout-btn {
        font-size: 0.9rem;
        padding: 3px 6px;
    }

    .header-left,
    .header-right {
        min-width: 50px;
    }

    .content-nav {
        min-width: 0;
        width: 95%;
        padding: 3px;
    }

    .nav-tab {
        padding: 6px 6px;
        gap: 3px;
        flex-direction: column;
    }

    .nav-label {
        font-size: 0.55rem;
    }

    .nav-icon {
        font-size: 1rem;
    }

    /* Game scoreboards */
    .score-card {
        padding: var(--spacing-sm);
    }

    .score-avatar {
        width: 35px;
        height: 35px;
    }

    .score-name {
        font-size: 0.75rem;
    }

    .score-vs {
        font-size: 0.9rem;
        padding: 0 var(--spacing-xs);
    }

    /* Game picker cards */
    .game-pick-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-sm);
    }

    .game-pick-card {
        padding: var(--spacing-sm);
    }

    /* Chat sidebar */
    .chat-sidebar {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Session overlay */
    .session-overlay-content {
        width: 98%;
        padding: var(--spacing-sm);
    }

    .role-cards {
        flex-direction: row !important;
        align-items: stretch !important;
        justify-content: center !important;
        gap: 8px !important;
    }

    .role-card {
        width: 48% !important;
        padding: 10px !important;
    }

    /* TTT grid */
    .ttt-cell {
        width: 70px;
        height: 70px;
    }

    /* CF board */
    .cf-cell {
        width: 36px;
        height: 36px;
    }

    /* RPS */
    .rps-battle-layout {
        gap: var(--spacing-sm);
    }

    .rps-choice-btn {
        padding: var(--spacing-sm);
    }

    .rps-emoji {
        font-size: 1.8rem;
    }
}

/* ========================================
   MEDIA QUEUE TYPE LABELS
   ======================================== */
.media-queue-type {
    display: block;
    font-size: 0.7rem;
    color: rgba(255,255,255,0.35);
    margin-top: 2px;
}

.media-queue-spotify-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    background: rgba(30, 215, 96, 0.1);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

#spotify-player-container iframe {
    border-radius: var(--radius-lg);
}

/* ========================================
   ABOUT TAB
   ======================================== */
/* Header Icon Buttons (mood, letter) */
.header-icon-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: transform 0.2s, filter 0.2s;
    filter: grayscale(0.3);
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.header-icon-btn:hover {
    transform: scale(1.2);
    filter: grayscale(0);
}

.letter-icon-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3em;
}

.letter-mood-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.67em;
    line-height: 1;
    pointer-events: none;
}

/* About Overlay */
.about-overlay {
    position: fixed;
    inset: 0;
    z-index: 1500;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
    overflow-y: auto;
    padding: 20px;
}

.about-overlay.hidden {
    display: none;
}

.about-overlay-content {
    position: relative;
    max-width: 650px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.about-close-btn {
    position: fixed;
    top: 16px;
    right: 20px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1.8rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1501;
    transition: background 0.2s;
}

.about-close-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.about-container {
    max-width: 650px;
    margin: 0 auto;
    padding: var(--spacing-xl) var(--spacing-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-xl);
}

/* Parchment / Tea-Stained Paper */
.about-letter.parchment {
    width: 100%;
    position: relative;
    background: #f4e4c1;
    background-image:
        linear-gradient(to bottom, rgba(139, 90, 43, 0.06) 1px, transparent 1px);
    background-size: 100% 2em;
    border: none;
    border-radius: 2px;
    padding: clamp(16px, 4vh, 45px) clamp(16px, 3vw, 40px) clamp(10px, 2vh, 20px);
    min-height: 0;
    display: flex;
    flex-direction: column;
    box-shadow:
        0 0 15px rgba(0, 0, 0, 0.3),
        inset 0 0 40px rgba(139, 90, 43, 0.15),
        inset 0 0 80px rgba(139, 90, 43, 0.08);
    overflow: hidden;
    transform: rotate(-0.5deg);
}

/* Rough torn edges */
.about-letter.parchment::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(135deg, transparent 0.6em, #f4e4c1 0.6em),
        linear-gradient(225deg, transparent 0.6em, #f4e4c1 0.6em),
        linear-gradient(315deg, transparent 0.6em, #f4e4c1 0.6em),
        linear-gradient(45deg, transparent 0.6em, #f4e4c1 0.6em);
    pointer-events: none;
    font-size: unset;
    padding: 0;
    top: 0;
    left: 0;
    transform: none;
}

/* Burn / dark edges */
.about-letter.parchment::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 2px;
    box-shadow:
        inset 0 0 60px rgba(101, 60, 20, 0.25),
        inset 0 0 120px rgba(80, 40, 10, 0.1);
    pointer-events: none;
}

/* Coffee / tea stain spots */
.parchment-stain {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    z-index: 1;
}

.parchment-stain.stain-1 {
    width: 120px;
    height: 110px;
    top: 15%;
    right: 8%;
    background: radial-gradient(ellipse, rgba(139, 90, 43, 0.12) 0%, rgba(139, 90, 43, 0.06) 40%, transparent 70%);
    transform: rotate(15deg);
}

.parchment-stain.stain-2 {
    width: 90px;
    height: 85px;
    bottom: 20%;
    left: 5%;
    background: radial-gradient(ellipse, rgba(120, 70, 30, 0.1) 0%, rgba(120, 70, 30, 0.04) 50%, transparent 70%);
    transform: rotate(-25deg);
}

.parchment-stain.stain-3 {
    width: 70px;
    height: 70px;
    top: 60%;
    right: 20%;
    background: radial-gradient(circle, rgba(101, 60, 20, 0.08) 0%, transparent 60%);
    border: 2px solid rgba(139, 90, 43, 0.06);
}

.about-letter-title {
    text-align: center;
    font-family: 'Special Elite', 'Courier New', monospace;
    font-size: clamp(0.9rem, 2.5vh, 1.8rem);
    font-weight: 400;
    color: #000000;
    background: none;
    -webkit-background-clip: unset;
    -webkit-text-fill-color: unset;
    margin-bottom: clamp(0.3em, 1.2vh, 1.2em);
    position: relative;
    z-index: 2;
}

.about-letter-body {
    font-family: 'Special Elite', 'Courier New', monospace;
    color: #000000;
    font-size: clamp(0.7rem, 1.7vh, 1.1rem);
    line-height: clamp(1.4em, 2.5vh, 2.2em);
    white-space: pre-wrap;
    position: relative;
    z-index: 2;
    flex: 1;
}

.about-letter-body p {
    margin-bottom: clamp(0.3em, 1vh, 0.8em);
}

/* ========================================
   MOBILE FIXES — books, header, file names, admin cards
   ======================================== */

/* Book cards: smaller on mobile */
@media (max-width: 600px) {
    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr));
        gap: var(--spacing-sm);
    }
    .book-card .video-desc {
        display: none;
    }
    .book-card .video-info {
        padding: 8px 10px;
    }
    .book-card .video-info h3 {
        font-size: 1rem;
    }
    .book-thumbnail {
        height: 430px;
    }
    .book-card .video-meta span {
        font-size: 0.65rem;
    }
}

/* Header: uniform size/alignment for all buttons (lock, connect, mood, letter) */
@media (max-width: 600px) {
    .logout-btn,
    .header-icon-btn {
        height: 32px;
        min-height: 32px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
        font-size: 1rem;
        padding: 0 6px;
    }
    .session-status-btn {
        height: 32px;
        min-height: 32px;
        display: grid;
        box-sizing: border-box;
        padding: 0 10px;
        font-size: 0.7rem;
        gap: 4px;
    }
    .header-left,
    .header-right {
        align-items: center;
        gap: 3px;
    }
}

.parchment-signature {
    font-family: 'Special Elite', 'Courier New', monospace;
    text-align: right;
    color: #000000;
    font-size: clamp(0.8rem, 1.5vh, 1.15rem);
    font-weight: 400;
    margin-top: clamp(0.5em, 1vh, 1.5em);
    font-style: italic;
    position: relative;
    z-index: 2;
}

.letter-footer-images {
    display: flex;
    justify-content: flex-end;
    padding: clamp(2px, 0.5vh, 16px) 0 clamp(2px, 0.5vh, 10px);
    position: relative;
    z-index: 2;
    flex-shrink: 0;
}

.letter-amlas-sig {
    width: clamp(80px, 20vw, 180px);
    height: auto;
}

@media (max-width: 600px) {
    .letter-amlas-sig {
        width: clamp(75px, 28vw, 130px);
    }
}

/* (duplicate letter flip styles removed — defined above) */

/* Mobile Viewport Height Fix for Modals */
@media (max-width: 768px) {
    .video-modal,
    .book-reader-modal,
    .modal-overlay,
    .session-overlay,
    #video-modal,
    #book-modal,
    #sfx-modal {
        height: 100dvh !important;
        max-height: 100dvh !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
    }

    /* Detail/show modals: slide up from bottom, content scrolls within */
    .detail-modal,
    .show-modal {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        overflow: hidden !important;
    }

    .detail-modal-content,
    .show-modal-content {
        max-height: calc(100dvh - 20px) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 24px) !important;
    }

    .session-overlay-content {
        max-height: 90dvh !important;
        height: auto !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }
}
