
/* ==========================================
   @layer features — games.css is the games feature monolith.
   Sits above @layer components so game chrome can decorate shared
   modals / toasts without fighting specificity.
   ========================================== */
@layer features {

/* Wordle/Hangman login splash + Success Popup CSS extracted to
   public/css/features/games-login-splash.css (Wave 6).
   That file ships everything between the earlier "WORDLE SECTION"
   and "SUCCESS POPUP" dividers: the `.wordle-*` container, the
   `.sfx-login-*` inputs/buttons, the `.game-board` / `.tile` / `.key` /
   `.keyboard-*` gate-puzzle geometry, the `.game-over-*` card, and the
   `.success-*` celebration. All animations
   (pop, flip, shake, fadeIn, scaleIn, bounce, pulse, confettiFall)
   and `.confetti*` were moved with them. */

/* TIC TAC TOE GAME STYLES extracted to
   public/css/features/games-tictactoe.css (Wave 6 CSS split).
   Score Display + vertical-card scoreboard + .score-card + .score-avatar
   + .score-info + .score-name + .score-value + .score-vs + .vs-round +
   .game-clock-shared extracted to public/css/features/games-scoreboard.css
   (Wave 6). */

/* Turn Indicator — unified all games */
.ttt-turn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    font-size: clamp(0.8rem, 1.8dvh, 1rem);
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: clamp(2px, 0.5dvh, 8px);
    flex-shrink: 0;
}

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

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

/* ── Game action toolbar (back + rematch) ── */
.game-actions,
.game-actions-left {
    position: absolute;
    top: 6px;
    display: flex;
    gap: 5px;
    z-index: 50;
}
.game-actions { right: 16px; }
.game-actions-left { left: 16px; }

.game-action-btn {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid rgba(var(--secondary-rgb),0.35);
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(var(--secondary-rgb),0.25), rgba(var(--primary-rgb),0.15));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: background 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease, filter 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}
.game-action-btn svg {
    width: 18px;
    height: 18px;
}
.game-action-btn:hover, .game-action-btn:active {
    color: var(--primary);
    border-color: rgba(var(--primary-rgb),0.5);
    background: rgba(var(--primary-rgb),0.12);
}
.game-action-btn:active {
    transform: scale(0.92);
}
/* .chess-vs-btn / .chess-resign-btn / .chess-draw-btn rules
   extracted to public/css/features/games-chess.css (Wave 6). */
/* Mobile */
/* breakpoint snap 600px -> 768px (Phase 7.6 ladder) */
@media (max-width: 768px) {
    .game-actions { top: 4px; right: 14px; gap: 4px; }
    .game-actions-left { top: 4px; left: 14px; }
}

/* .icy-canvas-wrap > .solo-pause-btn rules extracted to
   public/css/features/games-icytower.css (Wave 6). */

/* ── Solo pause overlay ── */
.solo-pause-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
}
.solo-pause-overlay.hidden { display: none; }
.solo-pause-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: rgba(10, 6, 24, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 1.5rem 2.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(var(--secondary-rgb),0.25);
    max-width: 280px;
    width: 90%;
}
.solo-pause-icon {
    color: rgba(255, 255, 255, 0.15);
    width: 36px;
    height: 36px;
}
.solo-pause-title {
    font-size: clamp(1.2rem, 3dvh, 1.6rem);
    font-weight: 800;
    color: var(--primary);
    letter-spacing: 0.05em;
    margin: 0;
}
.solo-pause-actions {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 0.5rem;
    min-width: 160px;
}
.solo-pause-actions .ttt-btn {
    width: 100%;
}

/* Solo game overlay buttons — Play/Play Again = golden white text, Home = purple smaller below */

/* Play / Play Again — golden with white text */
.icy-overlay .ttt-btn:not(.secondary),
.solo-pause-actions .ttt-btn:not(.secondary):not(.mixed) {
    color: #fff;
}

/* Home button — purple bg, white text, smaller */
.solo-home-btn,
.icy-overlay .ttt-btn.secondary,
.solo-pause-actions .ttt-btn.secondary {
    background: linear-gradient(135deg, var(--secondary-dark), var(--secondary-dark)) !important;
    color: #fff !important;
    box-shadow: 0 4px 15px rgba(var(--secondary-dark-rgb),0.35);
    border: none;
}
.solo-home-btn,
.icy-overlay .ttt-btn.secondary {
    transform: scale(0.8);
}
.solo-home-btn:hover,
.icy-overlay .ttt-btn.secondary:hover,
.solo-pause-actions .ttt-btn.secondary:hover {
    background: linear-gradient(135deg, var(--secondary-alt), var(--secondary-dark)) !important;
    box-shadow: 0 6px 20px rgba(var(--secondary-dark-rgb),0.5);
}

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

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

.ttt-btn.secondary {
    background: linear-gradient(135deg, var(--secondary-dark), var(--secondary));
    color: #fff;
    box-shadow: 0 4px 15px rgba(var(--secondary-dark-rgb),0.3);
    border: none;
}

.ttt-btn.secondary:hover {
    background: linear-gradient(135deg, var(--secondary), var(--secondary-soft));
    box-shadow: 0 6px 20px rgba(var(--secondary-dark-rgb),0.4);
    color: #fff;
}
.ttt-btn.mixed {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    box-shadow: 0 4px 15px rgba(200, 140, 50, 0.3);
    border: none;
}
.ttt-btn.mixed:hover {
    background: linear-gradient(135deg, var(--primary-light), var(--secondary-soft));
    box-shadow: 0 6px 20px rgba(200, 140, 50, 0.4);
}

.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-confetti extracted to games-tictactoe.css
   (Wave 6). Mobile-responsive block for .ttt-grid / .ttt-cell
   extracted alongside; .score-* mobile rules moved to
   games-scoreboard.css; .ttt-controls / .ttt-btn / .game-container /
   .game-picker mobile rules split back into the remaining block
   below (shared — used by every game). */

/* Mobile Responsive — shared pieces only (TTT grid/cell + scoreboard
   already extracted to their feature files). */
@media (max-width: 480px) {
    .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);
    }

}

/* ==========================================
   SESSION LOBBY STYLES
   (.ttt-lobby extracted to games-tictactoe.css — only the SHARED
    lobby chrome remains here, used by every game's invite lobby.)
   ========================================== */

.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(var(--secondary-rgb),0.2);
    transition: background var(--transition-normal), background-color var(--transition-normal), border-color var(--transition-normal), box-shadow var(--transition-normal), color var(--transition-normal), filter var(--transition-normal), opacity var(--transition-normal), transform 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(var(--secondary-rgb),0.3);
    border-radius: var(--radius-md);
    outline: none;
    transition: background var(--transition-fast), background-color var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast), color var(--transition-fast), filter var(--transition-fast), opacity var(--transition-fast), transform 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);
    text-transform: none;
}

.lobby-status {
    font-size: 0.9rem;
    padding: var(--spacing-sm);
    min-height: 24px;
    transition: background var(--transition-fast), background-color var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast), color var(--transition-fast), filter var(--transition-fast), opacity var(--transition-fast), transform var(--transition-fast);
}

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

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

/* .ttt-key-display extracted to games-tictactoe.css. The earlier
   .session-close-btn rule block (30x30 close icon for ttt-key-display)
   is superseded by the later .session-close-btn block (2670+) that
   ships the 10px/15px version used site-wide, so removing this earlier
   definition is safe — grep only finds the one referenced in the TTT
   session UI. */

.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;
    }
}

/* .ttt-connection-status + .ttt-cell.clickable extracted to
   games-tictactoe.css (Wave 6). */

/* 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: background 0.3s ease, background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease, color 0.3s ease, filter 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
    color: var(--text-primary);
    font-family: 'Outfit', sans-serif;
}

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

.role-card.selected {
    border-color: var(--accent-primary);
    background: rgba(var(--secondary-alt-rgb),0.12);
    box-shadow: 0 0 20px rgba(var(--secondary-alt-rgb),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;
}

/* .score-you-badge extracted to games-scoreboard.css (Wave 6).
   .ttt-container / .ttt-grid / .ttt-cell + their mobile @media block
   extracted to games-tictactoe.css (Wave 6). Only the shared lobby
   (.role-card, .role-avatar) + non-TTT (.hangman-game-area,
   .wordle-container) mobile rules remain here. */

/* Mobile Centering Fix — shared pieces only */
@media (max-width: 480px) {
    .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) extracted to
   games-tictactoe.css (Wave 6). */

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

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

.lobby-subtitle {
    font-size: clamp(0.65rem, 1.5dvh, 1rem);
    color: var(--text-secondary);
    margin-bottom: clamp(2px, 0.5dvh, 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(var(--secondary-rgb),0.1), rgba(52, 73, 94, 0.25));
    border: 2px solid rgba(var(--secondary-rgb),0.25);
    border-radius: var(--radius-md);
    flex: 1;
    min-width: 130px;
    min-height: 180px;
    justify-content: center;
    cursor: pointer;
    transition: background 0.3s ease, background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease, color 0.3s ease, filter 0.3s ease, opacity 0.3s ease, transform 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(var(--secondary-rgb),0.6);
    box-shadow: 0 8px 25px rgba(var(--secondary-rgb),0.2);
}

.role-card.selected {
    border-color: var(--secondary-alt);
    background: linear-gradient(145deg, rgba(var(--secondary-alt-rgb),0.1), rgba(var(--secondary-rgb),0.2));
    box-shadow: 0 0 20px rgba(var(--secondary-alt-rgb),0.15);
}

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

.role-card.selected .role-avatar {
    border-color: var(--secondary-alt);
}

.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(var(--secondary-rgb),0.1), rgba(52, 73, 94, 0.2));
    border: 1px solid rgba(var(--secondary-rgb),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(var(--secondary-rgb),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: var(--secondary-alt);
}

.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: clamp(4px, 1dvh, var(--spacing-lg));
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: visible;
}

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

/* Game mode toggle — segmented pill control */
.game-mode-toggle {
    position: relative;
    display: inline-flex;
    background: rgba(25, 20, 50, 0.6);
    border: 1px solid rgba(var(--secondary-rgb),0.2);
    border-radius: 12px;
    padding: 3px;
    margin-bottom: clamp(4px, 1dvh, 12px);
    gap: 0;
}
.game-mode-btn {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    border: none;
    border-radius: 10px;
    background: none;
    color: rgba(255,255,255,0.5);
    font-family: inherit;
    font-size: clamp(0.65rem, 1.4dvh, 0.85rem);
    font-weight: 600;
    cursor: pointer;
    transition: color 0.3s;
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
}
.game-mode-btn.active { color: #fff; }
.game-mode-btn svg { flex-shrink: 0; }
.game-mode-label {
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 15ch;
}
.game-mode-indicator {
    position: absolute;
    top: 3px;
    left: 3px;
    height: calc(100% - 6px);
    width: calc(50% - 3px);
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(var(--secondary-rgb),0.5), rgba(var(--primary-rgb),0.25));
    border: 1px solid rgba(var(--secondary-rgb),0.35);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}
.game-mode-toggle[data-mode="ai"] .game-mode-indicator {
    transform: translateX(100%);
}

.game-picker-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: clamp(6px, 1.2dvh, var(--spacing-md));
    width: 100%;
    max-width: 750px;
    margin: 0 auto;
}

.game-pick-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: clamp(3px, 0.8dvh, 10px);
    padding: clamp(8px, 1.5dvh, 20px) clamp(6px, 1.5vw, 16px);
    background: rgba(25, 20, 50, 0.45);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(var(--primary-rgb),0.15);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: background 0.3s ease, background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease, color 0.3s ease, filter 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
    overflow: visible;
}

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

.game-icon-styled {
    display: flex;
    align-items: center;
    justify-content: center;
    width: clamp(42px, 7dvh, 72px);
    height: clamp(42px, 7dvh, 72px);
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(var(--secondary-rgb),0.25), rgba(var(--primary-rgb),0.15));
    border: 1.5px solid rgba(var(--secondary-rgb),0.35);
    color: var(--secondary-soft);
    filter: drop-shadow(0 2px 8px rgba(var(--secondary-rgb),0.3));
    transition: background 0.3s ease, background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease, color 0.3s ease, filter 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
    flex-shrink: 0;
}

.game-icon-styled svg {
    width: clamp(22px, 4dvh, 36px);
    height: clamp(22px, 4dvh, 36px);
}

.game-pick-card:hover .game-icon-styled {
    color: var(--primary);
    border-color: rgba(var(--primary-rgb),0.45);
    background: linear-gradient(135deg, rgba(var(--primary-rgb),0.18), rgba(var(--secondary-rgb),0.15));
    filter: drop-shadow(0 0 10px rgba(var(--primary-rgb),0.35)) drop-shadow(0 3px 8px rgba(var(--primary-rgb),0.2));
}

.game-pick-name {
    font-size: clamp(0.6rem, 1.4dvh, 0.9rem);
    font-weight: 700;
    text-align: center;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.2;
    max-width: 100%;
    display: block;
}

.game-live-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    background: var(--primary);
    color: var(--secondary-dark);
    font-size: 0.55rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    animation: live-pulse 1.5s ease-in-out infinite;
    z-index: 5;
    pointer-events: none;
}

@keyframes live-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Non-blocking disconnect banner (replaces freeze overlay) */
.game-disconnect-banner {
    position: absolute;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    background: rgba(var(--primary-rgb),0.12);
    border: 1px solid rgba(var(--primary-rgb),0.3);
    border-radius: 8px;
    padding: 6px 16px;
    color: var(--primary);
    font-size: 0.75rem;
    font-family: 'Outfit', sans-serif;
    pointer-events: none;
    animation: fadeIn 0.3s ease;
    white-space: nowrap;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    gap: 6px;
}

.game-disconnect-banner .countdown {
    font-weight: 700;
    color: #e74c3c;
}

.game-pick-card:hover {
    transform: translateY(-4px);
    border-color: rgba(var(--primary-rgb),0.4);
    box-shadow: 0 6px 20px rgba(var(--primary-rgb),0.15), 0 0 30px rgba(var(--primary-rgb),0.06);
    background: rgba(var(--primary-rgb),0.05);
}

/* Primary SVG fills brighten on card hover; secondary stays subtle.
   Uses var(--primary-light) so the brighten effect follows the active theme —
   gold → bright gold (default), green → bright green (matrix), etc. */
.game-pick-card:hover .game-icon-styled svg [fill="var(--primary)"],
.game-pick-card:hover .game-icon-styled svg [fill="rgba(var(--primary-rgb),0.15)"] {
    fill: var(--primary-light);
    transition: fill 0.3s ease;
}
.game-pick-card:hover .game-icon-styled svg [stroke="var(--primary)"] {
    stroke: var(--primary-light);
    transition: stroke 0.3s ease;
}

.game-pick-desc {
    font-size: clamp(0.45rem, 1dvh, 0.8rem);
    /* Phase 8.5 contrast */
    color: var(--text-muted);
}

/* Mode indicator dots — colored circles under game name */
.game-mode-dots {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.mode-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.mode-dot.mode-solo {
    background: var(--secondary-dark);
    box-shadow: 0 0 4px rgba(var(--secondary-dark-rgb),0.4);
}
.mode-dot.mode-solo.mode-off {
    background: transparent;
    border: 1px solid rgba(var(--secondary-dark-rgb),0.25);
    box-shadow: none;
}

.mode-dot.mode-duo {
    background: var(--primary);
    box-shadow: 0 0 4px rgba(var(--primary-rgb),0.4);
}
.mode-dot.mode-duo.mode-off {
    background: transparent;
    border: 1px solid rgba(var(--primary-rgb),0.25);
    box-shadow: none;
}

/* Game legend */
.game-legend {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: clamp(12px, 2vw, 20px);
    padding: clamp(4px, 0.8dvh, 8px) 0;
}

.game-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: clamp(0.55rem, 1.2dvh, 0.75rem);
    color: rgba(255, 255, 255, 0.5);
    font-family: 'Outfit', sans-serif;
}

/* Partner-only games dimmed when partner offline */
.game-pick-card.needs-partner {
    opacity: 0.35;
    filter: grayscale(0.4);
    cursor: not-allowed;
    pointer-events: none;
}

.game-pick-card.needs-partner:hover {
    transform: none;
    border-color: rgba(var(--secondary-rgb),0.2);
    box-shadow: none;
    background: rgba(25, 20, 50, 0.45);
}

/* ========================================
   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: 600px;
    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, var(--secondary), #e74c3c);
    background-clip: text; -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* .game-back-btn — inherits from .game-action-btn (no extra overrides) */

/* Battleship (Ocean Theme) CSS extracted to
   public/css/features/games-battleship.css (Wave 6).
   Note: Battleship is NOT an active game (no games/battleship.js)
   but the CSS is kept in its own file for historical / rewrite
   purposes. The mobile-responsive @media block for .bs-* rules
   stays below because it sits inside the shared MOBILE RESPONSIVE
   GAMES block alongside .cf- / .rockpaper- rules. */

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

/* breakpoint snap 600px -> 768px (Phase 7.6 ladder) */
@media (max-width: 768px) {
    .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(3, 1fr);
        gap: clamp(5px, 1dvh, 10px);
    }

    .game-pick-card {
        padding: clamp(8px, 1.5dvh, 16px) clamp(4px, 1vw, 10px);
    }

    .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;
    }

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

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

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

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

    .rockpaperscissors-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(12px, 2.5dvh, 2rem);
    width: 100%;
    display: flex;
    justify-content: center;
}

.picker-controls .ttt-btn {
    font-size: clamp(0.65rem, 1.5dvh, 0.9rem);
    padding: clamp(6px, 1dvh, 10px) clamp(16px, 4vw, 32px);
    max-width: 240px;
    width: auto;
}

/* Phase 7.7: !important stripped — only rule targeting this ID; its
   1,0,0 specificity beats any class-level fight. */
#shared-waiting {
    max-width: 500px;
    width: 90%;
    margin: 2rem auto;
    left: auto;
    transform: none;
    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) */
#rockpaperscissors-controls {
    grid-template-columns: 1fr;
    place-items: center;
}

#rockpaperscissors-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: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: background 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), background-color 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), border-color 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), box-shadow 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), color 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), filter 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 4px 15px rgba(var(--primary-rgb),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(var(--primary-rgb),0.5);
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
}

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

.ttt-btn.purple-btn {
    background: linear-gradient(135deg, var(--secondary-dark), var(--secondary));
    color: #fff;
    box-shadow: 0 4px 15px rgba(var(--secondary-dark-rgb),0.3);
}

.ttt-btn.purple-btn:hover {
    background: linear-gradient(135deg, var(--secondary), var(--secondary-soft));
    box-shadow: 0 8px 25px rgba(var(--secondary-dark-rgb),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: var(--z-overlay);
    /* Long error messages (e.g. PiP DOMException with the full reason) used
       to get clipped because toast had no max-width and no wrap. Allow up to
       90vw wide and wrap on mobile. */
    max-width: min(90vw, 520px);
    line-height: 1.35;
    white-space: normal;
    word-break: break-word;
    text-align: center;
}

.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: background 0.2s, background-color 0.2s, border-color 0.2s, box-shadow 0.2s, color 0.2s, filter 0.2s, opacity 0.2s, transform 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);
}

/* =========================================
   INVITE NOTIFICATION (game invites, sync invites)
   ========================================= */
.sfx-invite {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%) translateY(-120%);
    width: 90vw;
    max-width: 360px;
    background: linear-gradient(135deg, rgba(25, 20, 50, 0.95), rgba(15, 12, 30, 0.98));
    border: 1px solid rgba(var(--secondary-alt-rgb),0.4);
    border-radius: 16px;
    padding: 14px 16px;
    z-index: var(--z-critical);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 20px rgba(var(--secondary-alt-rgb),0.15);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.sfx-invite.show {
    transform: translateX(-50%) translateY(0);
}
.sfx-invite-body {
    display: flex;
    align-items: center;
    gap: 12px;
}
.sfx-invite-icon {
    font-size: 1.6rem;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(var(--secondary-alt-rgb),0.15);
    border-radius: 10px;
}
.sfx-invite-text {
    flex: 1;
    font-size: 0.85rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.4;
}
.sfx-invite-text strong {
    color: var(--primary);
    font-weight: 700;
}
.sfx-invite-actions {
    display: flex;
    gap: 8px;
}
.sfx-invite-btn {
    flex: 1;
    padding: 8px 0;
    border: none;
    border-radius: 10px;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.2s, background-color 0.2s, border-color 0.2s, box-shadow 0.2s, color 0.2s, filter 0.2s, opacity 0.2s, transform 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.sfx-invite-btn:active { transform: scale(0.97); }
.sfx-invite-btn.primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    box-shadow: 0 3px 10px rgba(var(--primary-rgb),0.3);
}
.sfx-invite-btn.secondary {
    background: linear-gradient(135deg, var(--secondary-dark), var(--secondary-dark));
    color: #fff;
    box-shadow: 0 3px 10px rgba(var(--secondary-dark-rgb),0.3);
}

/* =========================================
   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: var(--z-overlay);
    opacity: 1;
    transition: opacity 0.3s ease;
}

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

.modal .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;
}


/* =========================================
   MOBILE & SIZING REFINEMENTS (User Requested)
   (All .ttt-result-modal descendant overrides extracted to
    games-tictactoe.css — Wave 6.)
   ========================================= */

/* 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: background 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease, filter 0.2s ease, opacity 0.2s ease, transform 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,
.rockpaperscissors-arena,
.bs-container {
    position: relative;
}


/* =========================================
   USER FEEDBACK REFINEMENTS (Font Sizing)
   ========================================= */

/* Session-exit override chain removed in Phase 7.7 — every property the
   retrofitted "purple" override set was overridden again by the FINAL
   redesigned .session-exit-btn block lower in this file (line 4165+,
   "SESSION LEAVE BUTTON - REDESIGN (BOTTOM)"), so the entire purple
   override + its :hover pair were dead code carrying 8 !important rules. */

/* Phase 7.7: earlier .ttt-btn.text-sm block merged into the consolidated
   one lower in the file (around line 3633). Kept here as a comment
   marker so the "small text helper" intent is discoverable via grep. */


/* 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)
   Phase 7.7: !important stripped — same selector redefined at this
   source position already wins over earlier .ttt-controls blocks. */
.ttt-controls {
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: none;
    padding: 10px 0;
}

/* Restore solid buttons.
   Phase 7.7: !important stripped — .ttt-controls .ttt-btn (0,2,0) already
   wins over the base .ttt-btn (0,1,0); no .modal-buttons / .picker-controls
   / #rockpaperscissors-controls sibling fights these same background/color
   properties. */
.ttt-controls .ttt-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border: none;
    color: #0d0b1e;
    box-shadow: 0 4px 15px rgba(var(--primary-rgb),0.35);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.ttt-controls .ttt-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(var(--primary-rgb),0.5);
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
}

.ttt-controls .ttt-btn.purple-btn {
    background: linear-gradient(135deg, var(--secondary-dark), var(--secondary));
    color: #fff;
    box-shadow: 0 4px 15px rgba(var(--secondary-dark-rgb),0.3);
}

.ttt-controls .ttt-btn.purple-btn:hover {
    background: linear-gradient(135deg, var(--secondary), var(--secondary-soft));
    box-shadow: 0 8px 25px rgba(var(--secondary-dark-rgb),0.4);
}

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

/* Force relative positioning on all game containers to capture the absolute exit button.
   Phase 7.7: !important stripped — no earlier rule sets `position` on any
   of these containers, so this plain rule already wins. */
.ttt-container,
.cf-container,
.rockpaperscissors-container,
.bs-container,
.game-inner-container {
    position: relative;
}

/* Second session-exit override chain also removed in Phase 7.7 — same
   reason as above: raspberry/wine background + top/right were all
   superseded by the FINAL .session-exit-btn block at line 4165+. */

/* Ensure RPS container has height/block formatting context if needed */
.rockpaperscissors-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:not(.therapy-send-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.
   Phase 7.7: consolidated from two blocks; !important stripped —
   source position already wins over earlier .ttt-btn / .ttt-controls
   .ttt-btn rules for all declared properties. */
.ttt-btn.text-sm {
    font-size: clamp(0.6rem, 2.2vw, 0.8rem);
    padding: 0.6rem 0.6rem;
    letter-spacing: -0.2px;
    line-height: 1.1;
    min-width: 0;
    white-space: normal;
    text-align: center;
}

/* Update general TTT buttons to be smaller too */
.ttt-btn:not(.therapy-send-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.
   Phase 7.7: !important stripped — last base-level .ttt-controls block,
   no later rule fights flex-wrap/gap/width at the same specificity. */
.ttt-controls {
    flex-wrap: nowrap;
    width: 100%;
    gap: 8px;
}

.ttt-controls .ttt-btn {
    flex: 1 1 auto;
}


/* =========================================
   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.
   Phase 7.7: !important stripped — no higher-specificity selector
   in the codebase targets this ID. */
#shared-copy-key {
    padding: 0;
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    background: rgba(255, 255, 255, 0.1);
    /* Subtle glass style */
    border: 1px solid rgba(255, 255, 255, 0.2);
}

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

/* 3. Text Alignment for Session Key.
   Phase 7.7: !important stripped — same selector redefined LATER
   than the base .session-key-box at line 1551, wins by source order. */
.session-key-box {
    align-items: center;
    gap: 12px;
}


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

/* breakpoint snap 600px -> 768px (Phase 7.6 ladder) */
/* Phase 7.7: !important stripped — later non-media-query
   .modal-buttons/.modal-buttons .ttt-btn blocks (lines 3747+) win by
   source order at the same specificity anyway. These media rules only
   take effect for properties not redeclared below. */
@media (max-width: 768px) {
    .modal-buttons {
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 10px;
    }

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

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

/* 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.
   Phase 7.7: !important stripped — same selector redefined LATER than
   the base .modal-buttons at line 3373, wins by source order. */
.modal-buttons {
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}

/* 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 extracted to games-tictactoe.css — Wave 6.) */


/* =========================================
   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: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 30px rgba(var(--primary-rgb),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: var(--primary);
    text-shadow: 0 0 30px rgba(var(--primary-rgb),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;
    }
}

/* RPS small countdown + rpsCountdownPulse keyframe extracted to
   public/css/features/games-rps.css (Wave 5 CSS split). */

/* #ttt-confirm-yes / #ttt-confirm-no extracted to
   games-tictactoe.css (Wave 6). */

/* Third session-exit override also dead — top/right/display/align-items/gap
   all overridden by the FINAL block lower in this file. Removed in Phase 7.7. */

/* =========================================
   SHARED GAME RESULT MODAL (Unified)
   ========================================= */

.game-result-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    pointer-events: auto;
    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(var(--secondary-alt-rgb),0.35);
    box-shadow: 0 0 40px rgba(var(--secondary-alt-rgb),0.15), 0 20px 60px rgba(0, 0, 0, 0.5);
    padding: 1.5rem;
    border-radius: 16px;
    pointer-events: auto !important;
    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: clamp(2.5rem, 8vw, 3.5rem);
    margin-bottom: 0.6rem;
    filter: drop-shadow(0 0 10px rgba(var(--secondary-alt-rgb),0.4));
    animation: bounceIn 0.8s;
}

.game-result-text {
    font-size: clamp(1.2rem, 5vw, 1.6rem);
    font-weight: 800;
    margin-bottom: 1.2rem;
    background: linear-gradient(135deg, var(--primary), #e67e22, var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 1px;
    line-height: 1.3;
    word-break: break-word;
}

.game-result-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 4px;
}

.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 reveal-state selectors + RPS-specific @keyframes fadeIn redefinition
   extracted to public/css/features/games-rps.css (Wave 5 CSS split). */

/* (Leave session button removed) */

/* ==========================================
   SESSION LEAVE BUTTON - REDESIGN (BOTTOM)
   Phase 7.7: !important stripped — all earlier .session-exit-btn
   overrides were removed in this same sprint (the "purple" and
   "raspberry" retrofit chains), so this block is now the only base
   definition apart from the initial .session-exit-btn rule at
   line ~3464 which has same specificity but is EARLIER in source.
   The only compound selector fighting this is .session-exit-btn.hidden
   (display: none !important — still needed, unchanged).
   ========================================== */
.session-exit-btn {
    position: relative;
    top: auto;
    right: auto;
    margin: 1.5rem auto 0 auto;
    padding: 0.5rem 1rem;
    border-radius: 0 0 10px 10px;
    /* Inverse pyramid hint */
    clip-path: polygon(0 0, 100% 0, 85% 100%, 15% 100%);
    /* Inverse Trapezoid */
    border: none;
    background: linear-gradient(180deg, rgba(231, 76, 60, 0.8), rgba(192, 57, 43, 0.9));
    color: #fff;
    font-family: 'Outfit', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    transition: background 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1), color 0.3s cubic-bezier(0.4, 0, 0.2, 1), filter 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
    width: fit-content;
    min-width: 120px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    letter-spacing: 1px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.session-exit-btn:hover {
    background: linear-gradient(180deg, rgba(231, 76, 60, 1), rgba(192, 57, 43, 1));
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.5);
    transform: translateY(-2px);
    padding-bottom: 0.8rem;
    /* Visual feedback */
}

.session-exit-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(231, 76, 60, 0.3);
}

/* Mobile adjustments */
/* breakpoint snap 600px -> 768px (Phase 7.6 ladder) */
@media (max-width: 768px) {
    .session-exit-btn {
        margin-top: 1rem;
        font-size: 0.75rem;
        padding: 0.5rem 1.5rem;
        width: 140px;
    }

    /* Reset game title margins */
    .game-title,
    .ttt-title {
        margin-top: 0;
        display: block;
    }
}

/* Ensure absolute positioning works relative to the container */
.game-inner-container,
.ttt-container,
.cf-container,
.rockpaperscissors-container,
.bs-container,
.quiz-container {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    justify-content: flex-start;
    padding-top: 52px;
}


/* ========================================
   GAME TURN TIMER BAR
   ======================================== */
/* Unified turn timer — all games */
.game-timer-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: clamp(4px, 0.8dvh, 8px) 0;
    flex-shrink: 0;
}

.game-timer-bar {
    flex: 1;
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    overflow: hidden;
}

.game-timer-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, var(--secondary-alt), var(--primary));
    border-radius: 2px;
    transition: width 15s linear;
}

.game-timer-text {
    font-family: 'Outfit', monospace;
    font-size: clamp(0.7rem, 1.5dvh, 0.85rem);
    font-weight: 700;
    color: rgba(255, 255, 255, 0.5);
    min-width: 32px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* RPS battle layout block + H&S block extracted to
   public/css/features/games-rps.css + games-hideandseek.css
   (Wave 5 CSS split). Shared multi-selector rules referencing
   .rockpaperscissors-arena / .rockpaperscissors-container remain
   in this file because they bind styles to multiple games at once. */


} /* end @layer features */
