/* ==========================================================================
   Çak Bir Beşlik - Premium Soft Dark Console Design System
   ========================================================================== */

:root {
    /* Fonts */
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;

    /* Color Palette - Premium Console Dark Theme */
    --bg-dark: #0f111a;
    --bg-gradient: radial-gradient(circle at 50% 30%, #1c1f30 0%, #0d0f17 100%);
    --bg-surface: rgba(23, 26, 42, 0.8);
    --bg-surface-solid: #171a2a;
    --bg-input: #0a0b10;
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #4b5563;

    /* Accent Colors (Premium Indigo / Violet) */
    --primary: #5f5af6;
    --primary-hover: #4f4ae0;
    --primary-shadow: #3b37c4;
    --primary-glow: rgba(95, 90, 246, 0.15);
    
    --secondary: #2d3142;
    --secondary-hover: #3f445c;
    --secondary-shadow: #1b1d28;

    /* Game State Colors (Tactile, Clear Colors) */
    --success: #10b981; /* Rich Emerald */
    --success-shadow: #059669;
    --present: #f59e0b; /* Rich Amber/Marigold */
    --present-shadow: #d97706;
    --absent: #374151; /* Dark Grey */

    --tile-empty: rgba(30, 41, 59, 0.4);
    --tile-border: rgba(99, 102, 241, 0.2);
    --tile-filled-border: rgba(99, 102, 241, 0.5);
    --tile-focus: #818cf8;

    /* Borders & Shadows */
    --border-color: rgba(99, 102, 241, 0.12);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 10px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.5);
}

/* ==========================================================================
   Base Styles & Reset
   ========================================================================== */

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

body {
    font-family: var(--font-body);
    background: var(--bg-dark);
    background-image: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   Header Styling (Console Navigation Bar)
   ========================================================================== */

.app-header {
    width: 100%;
    padding: 1.1rem 2rem;
    background: rgba(13, 15, 26, 0.85);
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.logo-icon {
    font-size: 1.6rem;
    filter: drop-shadow(0 2px 4px rgba(95, 90, 246, 0.3));
}

.logo-text {
    font-family: var(--font-heading);
    font-size: 1.45rem;
    font-weight: 800;
    letter-spacing: 1.5px;
    color: var(--text-primary);
    text-shadow: 0 2px 10px rgba(95, 90, 246, 0.1);
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 700;
    padding: 0.45rem 1rem;
    border-radius: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    transition: all 0.2s ease;
}

.nav-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(99, 102, 241, 0.3);
    transform: translateY(-1px);
}



/* ==========================================================================
   Layout Structures
   ========================================================================== */

.page-layout-wrapper {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 2rem;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem;
}

.app-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 900px;
}

.screen {
    display: none;
    width: 100%;
    max-width: 480px;
    animation: fadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.screen.active {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

#game-screen.screen.active {
    max-width: 100%;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   Premium Console Panels
   ========================================================================== */

.glass-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 1.25rem;
    padding: 2.25rem;
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
    width: 100%;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.panel-header {
    margin-bottom: 0.25rem;
}

.panel-header h2 {
    font-family: var(--font-heading);
    font-size: 1.85rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

.panel-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}

.text-center {
    text-align: center;
}

/* ==========================================================================
   Forms & Input Elements
   ========================================================================== */

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}

.form-group label {
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding-left: 0.15rem;
}

input[type="text"] {
    width: 100%;
    padding: 0.95rem 1.25rem;
    border-radius: 0.9rem;
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 1.05rem;
    font-weight: 600;
    font-family: var(--font-body);
    outline: none;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

input[type="text"]:focus {
    border-color: var(--primary);
    background: rgba(10, 11, 16, 0.8);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

input[type="text"]::placeholder {
    color: #4b5563;
}

/* ==========================================================================
   Tactile Console-Style Buttons
   ========================================================================== */

.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    padding: 0.95rem 1.75rem;
    border-radius: 0.9rem;
    border: none;
    font-size: 1rem;
    font-weight: 700;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
    user-select: none;
}

/* Primary Indigo 3D Button */
.primary-btn {
    background: var(--primary);
    color: white;
    box-shadow: 
        0 4px 0 var(--primary-shadow),
        0 8px 15px rgba(0, 0, 0, 0.3);
}

.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 
        0 5px 0 var(--primary-shadow),
        0 10px 18px rgba(0, 0, 0, 0.35);
}

.primary-btn:active {
    transform: translateY(3px);
    box-shadow: 
        0 1px 0 var(--primary-shadow),
        0 3px 5px rgba(0, 0, 0, 0.4);
}

/* Secondary Dark 3D Button */
.secondary-btn {
    background: var(--secondary);
    border: 1px solid rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
    box-shadow: 
        0 4px 0 var(--secondary-shadow),
        0 6px 12px rgba(0, 0, 0, 0.25);
}

.secondary-btn:hover {
    background: var(--secondary-hover);
    transform: translateY(-1px);
    box-shadow: 
        0 5px 0 var(--secondary-shadow),
        0 8px 15px rgba(0, 0, 0, 0.3);
}

.secondary-btn:active {
    transform: translateY(3px);
    box-shadow: 
        0 1px 0 var(--secondary-shadow),
        0 3px 6px rgba(0, 0, 0, 0.35);
}

/* Success Green 3D Button */
.success-btn {
    background: var(--success);
    color: white;
    width: 100%;
    box-shadow: 
        0 4px 0 var(--success-shadow),
        0 8px 15px rgba(0, 0, 0, 0.25);
}

.success-btn:hover:not([disabled]) {
    background: #0ea5e9; /* Sky Blue highlight on ready hover */
    box-shadow: 
        0 5px 0 #0284c7,
        0 10px 18px rgba(0, 0, 0, 0.3);
    transform: translateY(-1px);
}

.success-btn:active:not([disabled]) {
    transform: translateY(3px);
    box-shadow: 
        0 1px 0 #0284c7,
        0 3px 5px rgba(0, 0, 0, 0.35);
}

.success-btn[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
    background: #374151;
    box-shadow: none;
}

.btn-block {
    width: 100%;
}

/* Divider */
.divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin: 0.5rem 0;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-color);
}

.divider:not(:empty)::before { margin-right: 1.25rem; }
.divider:not(:empty)::after { margin-left: 1.25rem; }

/* Join Group */
.join-group {
    display: flex;
    gap: 0.75rem;
}

.join-group input {
    flex: 1.5;
    text-align: center;
    font-weight: 800;
    letter-spacing: 3px;
    text-transform: uppercase;
    font-family: var(--font-heading);
}

.join-group button {
    flex: 1;
}

/* ==========================================================================
   Lobby Feature Badges
   ========================================================================== */

.lobby-badge {
    background: rgba(95, 90, 246, 0.12);
    border: 1px solid rgba(95, 90, 246, 0.25);
    color: #a5b4fc;
    font-size: 0.72rem;
    font-weight: 800;
    padding: 0.3rem 0.85rem;
    border-radius: 6px;
    display: inline-block;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.lobby-features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.65rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 0.9rem;
    padding: 1.15rem;
}

.feature-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.4rem;
}

.feature-icon {
    font-size: 1.35rem;
}

.feature-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.feature-text strong {
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--text-primary);
}

.feature-text span {
    font-size: 0.65rem;
    color: var(--text-secondary);
    line-height: 1.3;
}

/* ==========================================================================
   Waiting Room Screen
   ========================================================================== */

.waiting-badge {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 800;
    padding: 0.3rem 0.85rem;
    border-radius: 6px;
    display: inline-block;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.highlight-code {
    color: var(--primary);
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 900;
    letter-spacing: 5px;
    display: block;
    margin-top: 0.5rem;
    text-shadow: 0 2px 10px rgba(95, 90, 246, 0.15);
}

.waiting-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.15rem;
    margin: 0.5rem 0;
}

.status-text {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.players-list-wrapper {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 0.9rem;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.player-bubble {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.8rem 1.15rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 0.65rem;
    animation: popIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.player-avatar {
    font-size: 1.2rem;
}

.player-name-text {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.player-host-tag {
    font-size: 0.65rem;
    font-weight: 800;
    color: var(--primary);
    border: 1px solid var(--primary);
    background: rgba(95, 90, 246, 0.06);
    padding: 0.15rem 0.5rem;
    border-radius: 5px;
    margin-left: auto;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.info-message {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
    background: rgba(95, 90, 246, 0.04);
    padding: 0.85rem 1.15rem;
    border-radius: 0.75rem;
    border: 1px solid rgba(95, 90, 246, 0.15);
}

/* ==========================================================================
   QR Code Sharing Container
   ========================================================================== */

.qr-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.65rem;
    margin: 1rem 0;
}

.qr-help-text {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.4;
}

.qr-code-wrapper {
    background: white;
    padding: 0.85rem;
    border-radius: 0.9rem;
    box-shadow: var(--shadow-lg);
    display: inline-block;
    transition: transform 0.2s ease;
}

.qr-code-wrapper:hover {
    transform: scale(1.03);
}

.qr-code-wrapper img {
    display: block;
    width: 130px;
    height: 130px;
}

/* ==========================================================================
   Game Screen Layouts
   ========================================================================== */

/* Desktop / Mobile Visibility Utilities */
.desktop-only {
    display: none !important;
}

.mobile-only {
    display: flex !important;
}

.game-dashboard {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    align-items: center;
}

@media (min-width: 900px) {
    .desktop-only {
        display: flex !important;
    }
    
    .mobile-only {
        display: none !important;
    }

    .game-dashboard {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        align-items: flex-start;
        width: 100%;
        gap: 2rem;
    }
}

/* Opponent Mini Boards */
.opponents-wrapper {
    display: flex;
    flex-direction: row;
    gap: 1.15rem;
    justify-content: center;
    flex-wrap: nowrap;
    width: 100%;
    overflow-x: auto;
    padding: 0.5rem 0;
    -webkit-overflow-scrolling: touch;
}

.opponents-wrapper::-webkit-scrollbar {
    height: 5px;
}

.opponents-wrapper::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 4px;
}

.opponents-wrapper::-webkit-scrollbar-thumb {
    background: var(--tile-border);
    border-radius: 4px;
}

@media (min-width: 900px) {
    .opponents-wrapper {
        display: flex;
        flex-direction: column;
        gap: 1rem;
        width: auto;
        max-width: 180px;
        overflow-x: visible;
        padding: 0;
    }

    .opponents-wrapper.left-side {
        grid-column: 1;
        justify-self: end;
    }

    .opponents-wrapper.right-side {
        grid-column: 3;
        justify-self: start;
    }

    .board-wrapper {
        grid-column: 2;
        justify-self: center;
    }
}

.opponent-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.65rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    padding: 0.75rem 0.85rem;
    border-radius: 0.9rem;
    box-shadow: var(--shadow-md);
    min-width: 140px;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.opponent-card:hover {
    transform: translateY(-2px);
    border-color: rgba(99, 102, 241, 0.4);
}

.opponent-header {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 0.4rem;
    margin-bottom: 0.15rem;
}

.opp-name {
    color: var(--text-primary);
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 75px;
}

.opp-score-badge {
    background: rgba(95, 90, 246, 0.15);
    border: 1px solid rgba(95, 90, 246, 0.3);
    color: #a5b4fc;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 0.15rem 0.5rem;
    border-radius: 100px;
    white-space: nowrap;
}

/* Main Playing Board */
.board-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.15rem;
}

.board-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.board-badge {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 0.4rem 1.15rem;
    border-radius: 100px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
}

/* ==========================================================================
   High-Tactile Game Board Grid & 3D Checked Tiles
   ========================================================================== */

.board {
    display: grid;
    grid-template-rows: repeat(6, 1fr);
    gap: 7px;
}

.board.mini {
    gap: 3.5px;
}

.row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 7px;
}

.board.mini .row {
    gap: 3.5px;
}

/* Dynamic Game Board Tiles */
.tile {
    width: 52px;
    height: 52px;
    border: 2px solid var(--tile-border);
    background: var(--tile-empty);
    border-radius: 0.65rem;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: var(--font-heading);
    font-size: 1.7rem;
    font-weight: 900;
    color: white;
    text-transform: uppercase;
    user-select: none;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.25);
    transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Mini grids */
.board.mini .tile {
    width: 14px;
    height: 14px;
    font-size: 0;
    border-width: 1.5px;
    border-radius: 0.15rem;
    box-shadow: none;
}

/* Active unverified input tile */
.tile.filled {
    border-color: var(--tile-filled-border);
    box-shadow: 
        inset 0 2px 4px rgba(0, 0, 0, 0.25),
        0 0 10px rgba(99, 102, 241, 0.15);
    animation: popLetter 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.2) forwards;
}

/* 3D Flipping Colors on checked tiles */
.tile.flip {
    animation: flipTile 0.5s ease forwards;
}

.tile.correct {
    background-color: var(--success) !important;
    border-color: var(--success) !important;
    color: white !important;
    box-shadow: 
        inset 0 2px 0 rgba(255, 255, 255, 0.2),
        0 3px 0 var(--success-shadow),
        0 5px 10px rgba(16, 185, 129, 0.15);
}

.tile.present {
    background-color: var(--present) !important;
    border-color: var(--present) !important;
    color: white !important;
    box-shadow: 
        inset 0 2px 0 rgba(255, 255, 255, 0.2),
        0 3px 0 var(--present-shadow),
        0 5px 10px rgba(245, 158, 11, 0.15);
}

.tile.absent {
    background-color: var(--absent) !important;
    border-color: var(--absent) !important;
    color: #94a3b8 !important;
    box-shadow: none;
}

/* ==========================================================================
   Clicky Console-Style Keyboard Keypads
   ========================================================================== */

.keyboard-wrapper {
    width: 100%;
    max-width: 550px;
    margin: 1.5rem auto 0 auto;
}

.keyboard {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 6px;
    width: 100%;
}

.key {
    flex: 1;
    background: #1e2235;
    border: none;
    border-radius: 0.65rem;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 1.1rem;
    font-weight: 800;
    height: 52px;
    cursor: pointer;
    text-transform: uppercase;
    display: flex;
    justify-content: center;
    align-items: center;
    /* Physical 3D clicky button styling */
    box-shadow: 
        0 3px 0 #0d0f19,
        0 4px 6px rgba(0, 0, 0, 0.3);
    transition: background-color 0.1s, transform 0.05s, box-shadow 0.05s;
    user-select: none;
    touch-action: manipulation;
}

.key:hover:not([disabled]) {
    background: #2b2f4a;
}

.key:active:not([disabled]) {
    transform: translateY(3px);
    box-shadow: 
        0 0 0 #0d0f19,
        0 1px 3px rgba(0, 0, 0, 0.4);
}

.key.action-key {
    flex: 1.6;
    font-size: 0.8rem;
    background: #2d3142;
    box-shadow: 
        0 3px 0 #1b1d28,
        0 4px 6px rgba(0, 0, 0, 0.3);
}

.key.action-key:hover {
    background: #3c4157;
}

.key.action-key:active {
    transform: translateY(3px);
    box-shadow: 
        0 0 0 #1b1d28,
        0 1px 3px rgba(0, 0, 0, 0.4);
}

.key.correct {
    background-color: var(--success) !important;
    box-shadow: 
        0 3px 0 var(--success-shadow),
        0 4px 6px rgba(0,0,0,0.25);
}

.key.present {
    background-color: var(--present) !important;
    box-shadow: 
        0 3px 0 var(--present-shadow),
        0 4px 6px rgba(0,0,0,0.25);
}

.key.absent {
    background-color: #08090f !important;
    opacity: 0.35;
    box-shadow: none;
}

/* ==========================================================================
   Emoji Reaction Pill Bar
   ========================================================================== */

.emoji-bar-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin: 1.25rem auto 0 auto;
    padding: 0.45rem 1.25rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 100px;
    width: fit-content;
    box-shadow: var(--shadow-md);
}

.emoji-bar-title {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.emoji-btn-group {
    display: flex;
    gap: 0.4rem;
}

.emoji-reaction-btn {
    background: transparent;
    border: none;
    font-size: 1.35rem;
    cursor: pointer;
    padding: 0.15rem;
    transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    user-select: none;
    touch-action: manipulation;
}

.emoji-reaction-btn:hover {
    transform: scale(1.3) translateY(-2px);
}

.emoji-reaction-btn:active {
    transform: scale(0.95);
}

/* ==========================================================================
   Floating Reaction Alert Container
   ========================================================================== */

.reaction-container {
    position: fixed;
    top: 5.5rem;
    right: 1.5rem;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
    max-width: 260px;
}

.reaction-bubble {
    background: var(--bg-surface-solid);
    border: 1px solid var(--border-color);
    color: white;
    padding: 0.55rem 1.15rem;
    border-radius: 100px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 700;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    pointer-events: auto;
    animation: reactionIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards,
               reactionOut 0.3s ease forwards 4.7s;
}

.reaction-sender {
    color: #a5b4fc;
    font-weight: 800;
}

.reaction-emoji {
    font-size: 1.2rem;
}

@keyframes reactionIn {
    from { opacity: 0; transform: translateX(40px) scale(0.95); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes reactionOut {
    from { opacity: 1; transform: translateX(0) scale(1); }
    to { opacity: 0; transform: translateX(35px) scale(0.9); }
}

/* ==========================================================================
   Modals & Popups (Win / Loss UI Overlay)
   ========================================================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(13, 15, 26, 0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 1rem;
}

.modal-overlay.active {
    display: flex;
}

.modal-panel {
    max-width: 390px;
    align-items: center;
    text-align: center;
    box-shadow: var(--shadow-xl);
    animation: modalPopIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.modal-icon {
    font-size: 3.5rem;
    margin-bottom: 0.25rem;
}

.modal-title {
    font-family: var(--font-heading);
    font-size: 1.95rem;
    font-weight: 800;
    color: var(--text-primary);
}

.modal-message {
    color: var(--text-secondary);
    font-size: 0.98rem;
    line-height: 1.55;
    margin-bottom: 0.25rem;
}

/* Reset countdown in Modal */
.countdown-container {
    width: 100%;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.countdown-bar {
    width: 100%;
    height: 5px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
}

.countdown-progress {
    width: 100%;
    height: 100%;
    background: var(--primary);
    transition: width 1s linear;
}

/* Rules Modal Custom Layout */
.rules-panel {
    max-width: 460px !important;
}

.modal-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 0.5rem;
}

.modal-header-row h3 {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-primary);
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.85rem;
    cursor: pointer;
    line-height: 1;
    transition: color 0.15s;
}

.close-btn:hover {
    color: var(--text-primary);
}

.rules-content {
    text-align: left;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.rules-intro {
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

.rules-steps {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.step-item {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
}

.step-num {
    background: rgba(95, 90, 246, 0.1);
    border: 1px solid var(--border-color);
    color: var(--primary);
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 800;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.step-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.step-text strong {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-primary);
}

.step-text span {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.rules-divider {
    height: 1px;
    background: var(--border-color);
    width: 100%;
}

.rules-subtitle {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.rules-grid {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.rule-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    transition: background-color 0.15s ease;
}

.rule-card:hover {
    background: rgba(255, 255, 255, 0.03);
}

.rule-card-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.rule-card-text strong {
    font-size: 0.85rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: var(--text-primary);
}

.rule-card-text span {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.3;
}

.mini-tile {
    width: 34px !important;
    height: 34px !important;
    font-size: 1.05rem !important;
    border-radius: 0.45rem !important;
    border-width: 1.5px !important;
    flex-shrink: 0;
}

/* ==========================================================================
   Center Tactile Toast Notification Alerts
   ========================================================================== */

.toast-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 90%;
    max-width: 380px;
    pointer-events: none;
}

.toast {
    background: #1e2235;
    border: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    padding: 0.85rem 1.25rem 0.85rem 1rem;
    border-radius: 0.65rem;
    font-family: var(--font-body);
    font-size: 0.92rem;
    font-weight: 700;
    /* Clean shadow and border design */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    text-align: left;
    gap: 0.65rem;
    animation: toastIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards,
               toastOut 0.25s ease forwards 2.75s;
    pointer-events: auto;
}

.toast-icon {
    font-size: 1.15rem;
    flex-shrink: 0;
}

.toast.toast-error {
    border-left: 4px solid #ef4444;
    background: #241414;
    border-top-color: rgba(239, 68, 68, 0.12);
    border-right-color: rgba(239, 68, 68, 0.12);
    border-bottom-color: rgba(239, 68, 68, 0.12);
    box-shadow: 
        0 10px 30px rgba(0, 0, 0, 0.4),
        0 0 15px rgba(239, 68, 68, 0.1);
}

.toast.toast-warning {
    border-left: 4px solid #f59e0b;
    background: #281e12;
    border-top-color: rgba(245, 158, 11, 0.12);
    border-right-color: rgba(245, 158, 11, 0.12);
    border-bottom-color: rgba(245, 158, 11, 0.12);
    box-shadow: 
        0 10px 30px rgba(0, 0, 0, 0.4),
        0 0 15px rgba(245, 158, 11, 0.1);
}

.toast.toast-success {
    border-left: 4px solid #10b981;
    background: #13241b;
    border-top-color: rgba(16, 185, 129, 0.12);
    border-right-color: rgba(16, 185, 129, 0.12);
    border-bottom-color: rgba(16, 185, 129, 0.12);
    box-shadow: 
        0 10px 30px rgba(0, 0, 0, 0.4),
        0 0 15px rgba(16, 185, 129, 0.1);
}

/* ==========================================================================
   Animations & Keyframes
   ========================================================================== */

@keyframes popLetter {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

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

@keyframes modalPopIn {
    0% { transform: scale(0.94) translateY(18px); opacity: 0; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

@keyframes flipTile {
    0% { transform: rotateX(0deg); }
    45% {
        transform: rotateX(90deg);
        background-color: var(--tile-empty);
        border-color: var(--tile-border);
    }
    55% { transform: rotateX(90deg); }
    100% { transform: rotateX(0deg); }
}

@keyframes shakeRow {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

.shake {
    animation: shakeRow 0.5s cubic-bezier(.36, .07, .19, .97) both;
}

.nazar-pulse {
    animation: nazarPulse 2s infinite ease-in-out;
    display: inline-block;
}

@keyframes nazarPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(15px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to { opacity: 0; transform: translateY(-10px) scale(0.95); }
}

/* ==========================================================================
   Responsive Scaling (Mobile/Tablet Viewports)
   ========================================================================== */

@media (max-width: 500px) {
    .page-layout-wrapper {
        padding: 1rem 0.5rem;
        gap: 1rem;
    }

    .glass-panel {
        padding: 1.5rem;
        border-radius: 1rem;
    }

    .panel-header h2 {
        font-size: 1.5rem;
    }

    .lobby-badge {
        padding: 0.25rem 0.75rem;
    }

    .lobby-features {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        padding: 0.75rem;
    }

    .feature-item {
        flex-direction: row;
        align-items: center;
        text-align: left;
        gap: 0.75rem;
    }

    .join-group {
        flex-direction: column;
        gap: 0.5rem;
    }

    .join-group button {
        width: 100%;
    }

    /* Tiles scaling */
    .board {
        gap: 5px;
    }

    .row {
        gap: 5px;
    }

    .tile {
        width: 38px;
        height: 38px;
        font-size: 1.25rem;
        border-radius: 0.35rem;
    }

    .board.mini .tile {
        width: 10px;
        height: 10px;
        border-radius: 0.1rem;
    }

    .board.mini {
        gap: 2px;
    }

    .board.mini .row {
        gap: 2px;
    }

    .opponent-card {
        padding: 0.4rem 0.5rem;
        gap: 0.3rem;
        min-width: 110px;
    }

    .opponents-wrapper {
        gap: 0.75rem;
    }

    .game-dashboard {
        gap: 1.25rem;
    }

    .board-wrapper {
        gap: 0.75rem;
    }

    /* Keyboard scaling */
    .keyboard-wrapper {
        margin-top: 1rem;
    }

    .key {
        height: 42px;
        font-size: 0.88rem;
        border-radius: 0.45rem;
        box-shadow: 
            0 2px 0 #0d0f19,
            0 3px 5px rgba(0, 0, 0, 0.3);
    }

    .key:active:not([disabled]) {
        transform: translateY(2px);
        box-shadow: 
            0 0 0 #0d0f19,
            0 1px 2px rgba(0, 0, 0, 0.45);
    }

    .key.action-key {
        font-size: 0.65rem;
        box-shadow: 
            0 2px 0 #1b1d28,
            0 3px 5px rgba(0, 0, 0, 0.3);
    }

    .key.action-key:active {
        transform: translateY(2px);
        box-shadow: 
            0 0 0 #1b1d28,
            0 1px 2px rgba(0, 0, 0, 0.45);
    }

    /* Emoji bar scaling */
    .emoji-bar-wrapper {
        margin-top: 0.75rem;
        padding: 0.4rem 1rem;
    }

    .emoji-reaction-btn {
        font-size: 1.15rem;
    }
}

@media (max-width: 360px) {
    .board {
        gap: 4px;
    }

    .row {
        gap: 4px;
    }

    .tile {
        width: 32px;
        height: 32px;
        font-size: 1.1rem;
    }

    .key {
        height: 35px;
        font-size: 0.78rem;
    }

    .key.action-key {
        font-size: 0.52rem;
    }
}

/* ==========================================================================
   Ad Slots
   ========================================================================== */

.ad-container {
    width: 100%;
    margin-top: 1.25rem;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.01);
    border: 1px dashed var(--border-color);
    border-radius: 0.5rem;
    min-height: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.ad-container::before {
    content: "REKLAM";
    position: absolute;
    top: 2px;
    left: 6px;
    font-size: 0.6rem;
    font-weight: 700;
    color: #4b5563;
    letter-spacing: 0.5px;
}

.sidebar-ad {
    display: none;
    width: 160px;
    height: 600px;
    background: rgba(255, 255, 255, 0.01);
    border: 1px dashed var(--border-color);
    border-radius: 0.75rem;
    position: sticky;
    top: 80px;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.sidebar-ad::before {
    content: "REKLAM";
    position: absolute;
    top: 4px;
    font-size: 0.6rem;
    font-weight: 700;
    color: #4b5563;
    letter-spacing: 0.5px;
}

.mobile-bottom-ad {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 480px;
    height: 100px;
    margin: 1.25rem auto;
    background: rgba(255, 255, 255, 0.01);
    border: 1px dashed var(--border-color);
    border-radius: 0.75rem;
    position: relative;
    overflow: hidden;
}

.mobile-bottom-ad::before {
    content: "REKLAM";
    position: absolute;
    top: 4px;
    left: 8px;
    font-size: 0.6rem;
    font-weight: 700;
    color: #4b5563;
    letter-spacing: 0.5px;
}

@media (min-width: 1200px) {
    .page-layout-wrapper {
        max-width: 100%;
        padding-left: 2.5rem;
        padding-right: 2.5rem;
    }

    .sidebar-ad {
        display: flex;
        position: fixed;
        top: 100px;
        z-index: 40;
    }

    .sidebar-ad.left-ad {
        left: 2rem;
    }

    .sidebar-ad.right-ad {
        right: 2rem;
    }

    .mobile-bottom-ad {
        display: none;
    }
}

.cookie-prefs-link {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    transition: color 0.2s ease, transform 0.2s ease;
    display: inline-block;
    padding: 0.25rem 0.5rem;
}
.cookie-prefs-link:hover {
    color: var(--text-primary);
    transform: translateY(-1px);
}

.game-dashboard.single-player-grid {
    display: block !important;
    width: 100% !important;
}

.game-dashboard.single-player-grid .board-wrapper {
    margin: 0 auto !important;
    width: fit-content !important;
}

.game-dashboard.single-player-grid .opponents-wrapper {
    display: none !important;
}