/* ==========================================
   SalmasFlix — Games · Tic Tac Toe
   Extracted from games.css in Phase 7.9 (2026-04-24, Wave 6).
   Originally spread across lines 668-1278, 1598-1663, and
   1665-1727 of the monolith ("TIC TAC TOE GAME STYLES",
   "TTT SESSION LOBBY STYLES", "TIC TAC TOE BASE STYLES (Fix)").

   TTT-specific geometry + session-lobby chrome for the turn-based
   X vs O grid. Selectors in here are only ever referenced by
   `public/js/games/tictactoe.js` (verified via grep).

   Kept in shared games.css (NOT extracted here):
   - `.ttt-btn` / `.ttt-btn.secondary` / `.ttt-btn.mixed` / `.ttt-btn.danger`
     — the primary button system used by EVERY game
   - `.ttt-controls` — shared game-controls bar used by TTT, CF, RPS, BS
   - `.ttt-turn` — turn indicator chip, also used by Memory Match
   - `.ttt-result-modal` .modal-* selectors — shared result-modal chrome
     redefined in mobile/refinement sections of games.css
   - `.ttt-container` position/flex declarations bundled with
     multi-selector rules (`.ttt-container, .cf-container, ...`)

   Theme tokens: colors driven by `var(--primary)`, `var(--secondary)`,
   `rgba(var(--primary-rgb), X)`, etc. — NO hardcoded hex accent values.
   ========================================== */

@layer features {


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

.ttt-container {
    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;
}

/* 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(var(--secondary-rgb),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(var(--secondary-alt-rgb),0.1);
}

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

.ttt-piece {
    width: clamp(40px, 8dvh, 56px);
    height: clamp(40px, 8dvh, 56px);
    background-size: 130%;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 50%;
    border: 2px solid rgba(var(--secondary-rgb),0.4);
    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;
    }
}

/* 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: var(--z-modal);
    padding: var(--spacing-md);
    animation: fadeIn 0.2s ease;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.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(var(--secondary-alt-rgb),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(var(--secondary-alt-rgb),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(var(--secondary-alt-rgb),0.6);
    box-shadow: 0 0 20px rgba(var(--secondary-alt-rgb),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, var(--primary), var(--primary-light));
    color: #fff;
    box-shadow: 0 4px 15px rgba(var(--primary-rgb),0.35);
}
.ttt-result-modal .ttt-btn:hover {
    box-shadow: 0 6px 20px rgba(var(--primary-rgb),0.5);
}
.ttt-result-modal .ttt-btn.secondary {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    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: #fff;
}
.ttt-result-modal .purple-btn {
    background: linear-gradient(135deg, var(--secondary-dark), var(--secondary-dark));
    color: #fff;
    box-shadow: 0 4px 15px rgba(var(--secondary-dark-rgb),0.35);
}

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

/* Mobile Responsive — TTT grid only (score-* rules live in
   games-scoreboard.css; .ttt-btn / .ttt-controls / .game-picker /
   .game-container rules stay in games.css). */
@media (max-width: 480px) {
    .ttt-grid {
        max-width: 280px;
        gap: 4px;
        padding: 6px;
    }

    .ttt-cell {
        padding: 4px;
    }
}


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

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

/* 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(var(--secondary-alt-rgb),0.25);
    margin-bottom: var(--spacing-lg);
    position: relative;
}

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

/* 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(var(--secondary-alt-rgb),0.15);
    transform: scale(1.05);
}


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

.ttt-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-height: 0;
}

.ttt-grid {
    width: 100%;
}

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

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

/* TIC TAC TOE BASE STYLES (Fix) — second, more-aggressive redefinition
   from the monolith's "TIC TAC TOE BASE STYLES (Fix)" section. */
.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: 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;
    /* 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: var(--secondary-alt);
}

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


/* ==========================================
   TTT CONFIRM MODAL BUTTONS
   Moved from games.css CONFIRM MODAL BUTTONS block
   (Phase 7.7 note: ID specificity trumps .ttt-btn class rules).
   ========================================== */

#ttt-confirm-yes {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 0 15px rgba(var(--primary-rgb),0.4);
    border: 2px solid rgba(255, 255, 255, 0.2);
    font-weight: 800;
}

#ttt-confirm-no {
    background: linear-gradient(135deg, var(--secondary-dark), var(--secondary));
    color: white;
    box-shadow: 0 0 15px rgba(var(--secondary-dark-rgb),0.4);
}


/* Third redefinition of `.ttt-result-content` from the STRICTER MODAL
   BUTTON SIZING block (wins by source order over the earlier one). */
.ttt-result-content {
    width: 90vw;
    max-width: 380px;
    padding: 2rem 2.5rem;
}


/* ==========================================
   RESULT MODAL OVERRIDES — descendant selectors of .ttt-result-modal
   Moved from the monolith's OVERRIDES + MOBILE & SIZING REFINEMENTS
   blocks. All rules descend from .ttt-result-modal so they stay with
   the TTT result-modal chrome even though their inner targets
   (.role-prompt, .role-avatar, .role-name, .modal-content, .modal-title,
   .modal-text, .modal-buttons) are shared primitives.
   ========================================== */

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

/* 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);
}


} /* end @layer features */
