/* ===========================================
   MODERN GLASS CYBER UI (2025)
   Téma: Deep Space & Neon Glass
=========================================== */

:root {
    /* Paletta */
    --bg-dark: #030508;
    --bg-panel: rgba(13, 18, 30, 0.65);
    --primary: #00f2ff;   /* Cyan */
    --secondary: #7000ff; /* Violet */
    --accent: #ff0055;    /* Magenta */
    --text-main: #ffffff;
    --text-muted: #94a3b8;
    
    /* Effektek */
    --glass-border: 1px solid rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --backdrop-blur: blur(16px);
    --neon-glow: 0 0 10px rgba(0, 242, 255, 0.5);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    /* Dinamikus, mély háttér */
    background: radial-gradient(circle at 10% 20%, #1a0b2e 0%, #000000 40%, #02101f 90%);
    background-attachment: fixed;
    font-family: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden; 
}

/* ===========================================
   LAYOUT & CONTAINER
=========================================== */

.main-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); 
    gap: 2rem;
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

@media (max-width: 900px) {
    .main-layout {
        grid-template-columns: minmax(0, 100%);
        padding: 1rem;
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
    }
}

/* ===========================================
   GLASS PANELS (Lobby & Game Area)
=========================================== */

.lobby,
.game-area {
    background: var(--bg-panel);
    backdrop-filter: var(--backdrop-blur);
    -webkit-backdrop-filter: var(--backdrop-blur);
    border: var(--glass-border);
    border-radius: 24px;
    padding: 1.5rem;
    box-shadow: var(--glass-shadow);
    min-width: 0; 
    width: 100%;
    max-width: 100%;
    
    /* Hogy a footer alulra kerüljön, ha kevés a tartalom */
    display: flex;
    flex-direction: column;
}

/* Ha van üres hely, a tartalom nyúljon, így a footer lent marad */
.game-area > .board-container {
    flex-grow: 1; 
}

/* ===========================================
   HEADER / TOPBAR (Kép + Login alatta)
=========================================== */

.topbar {
    display: flex;
    flex-direction: column; /* EGYMÁS ALÁ */
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    gap: 15px;
}

.logo-container {
    width: 100%;
    text-align: center;
}

/* HEADER KÉP STÍLUS */
.game-logo {
    width: 100%;
    height: auto;
    max-height: 150px; /* Hogy ne legyen túl magas asztali nézetben */
    object-fit: contain; /* Vagy 'cover', ha teljesen ki akarod tölteni */
    border-radius: 12px;
    box-shadow: 0 0 20px rgba(0, 242, 255, 0.15);
    display: block;
}

.user-info-bar {
    width: 100%;
    display: flex;
    justify-content: space-between; /* Két szélre: név és kilépés gomb */
    align-items: center;
    font-size: 0.9rem;
    color: var(--text-muted);
    background: rgba(0,0,0,0.2); /* Kicsit sötétebb sáv a login infónak */
    padding: 8px 15px;
    border-radius: 8px;
}

.user-info strong {
    color: var(--primary);
}

/* ===========================================
   BUTTONS
=========================================== */

.btn {
    background: linear-gradient(135deg, rgba(0, 242, 255, 0.1), rgba(112, 0, 255, 0.1));
    border: 1px solid rgba(0, 242, 255, 0.3);
    color: var(--primary);
    padding: 0.6rem 1.2rem;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
    box-shadow: 0 0 0 transparent;
    white-space: nowrap;
}

.btn:hover {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-color: transparent;
    color: #000;
    box-shadow: 0 0 20px rgba(0, 242, 255, 0.4);
    transform: translateY(-2px);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
}

.btn-secondary {
    border-color: rgba(255,255,255,0.2);
    color: var(--text-muted);
    background: transparent;
}
.btn-secondary:hover {
    background: rgba(255,255,255,0.1);
    color: white;
    box-shadow: none;
}

/* SELECT */
select {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 0.6rem;
    border-radius: 10px;
    outline: none;
    cursor: pointer;
    max-width: 100%;
}

/* ===========================================
   LOBBY ITEMS & CARDS
=========================================== */

.lobby-block h3 {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 1rem;
    border-left: 3px solid var(--secondary);
    padding-left: 10px;
}

.game-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 1rem;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.game-card:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-3px);
}

.game-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
    gap: 5px;
}

.game-card-title {
    font-weight: 700;
    color: white;
}

.game-card-status {
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
}

.status-waiting { background: rgba(255, 200, 0, 0.15); color: #ffcc00; border: 1px solid rgba(255, 200, 0, 0.3); }
.status-running { background: rgba(0, 242, 255, 0.15); color: #00f2ff; border: 1px solid rgba(0, 242, 255, 0.3); }
.status-finished { background: rgba(255, 0, 85, 0.15); color: #ff0055; border: 1px solid rgba(255, 0, 85, 0.3); }

.game-card-body {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.game-card-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.game-card-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: rgba(255,255,255,0.05);
}
.game-card-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    transition: width 0.5s ease;
}

.lobby-item {
    padding: 0.8rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
}
.lobby-item:last-child { border-bottom: none; }
.lobby-item small { color: var(--text-muted); }

/* --- TOPLISTA IGAZÍTÁS --- */
.top-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.9rem;
    display: table; 
}

.top-table th {
    text-align: center; /* A statisztika fejlécek középre */
    color: var(--text-muted);
    font-weight: 500;
    padding: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

/* Az első oszlop (Név) fejléc legyen balra */
.top-table th:first-child {
    text-align: left;
}

.top-table td {
    padding: 10px;
    background: rgba(255,255,255,0.02);
    text-align: center; /* A statisztika adatok középre */
}

/* Az első oszlop (Név) tartalom legyen balra */
.top-table td:first-child {
    text-align: left;
}

.top-table tr:first-child td:first-child { border-top-left-radius: 10px; }
.top-table tr:first-child td:last-child { border-top-right-radius: 10px; }
.top-table tr:last-child td:first-child { border-bottom-left-radius: 10px; }
.top-table tr:last-child td:last-child { border-bottom-right-radius: 10px; }

/* ===========================================
   GAME AREA & BOARD
=========================================== */

.game-info {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 16px;
    padding: 1rem;
    margin-bottom: 1rem;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.05);
    max-width: 100%;
}

.game-info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 5px;
}

.timer-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.4);
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.timer-box.my-turn-timer {
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(0, 242, 255, 0.2);
}

.timer-digits {
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.4rem;
    font-weight: bold;
    color: white;
}
.timer-digits.danger {
    color: var(--accent);
    text-shadow: 0 0 10px var(--accent);
}

.game-players-line {
    display: flex;
    justify-content: center;
    gap: 2rem;
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0.5rem 0;
    flex-wrap: wrap; /* Nevek törhetnek */
}

.player-x { color: var(--primary); text-shadow: 0 0 10px rgba(0, 242, 255, 0.4); }
.player-o { color: var(--accent); text-shadow: 0 0 10px rgba(255, 0, 85, 0.4); }

.active-turn {
    text-decoration: underline;
    text-underline-offset: 4px;
}

/* --- GAME FOOTER --- */
.game-footer {
    margin-top: auto; /* Automatikusan az aljára tolja */
    padding-top: 1rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    opacity: 0.7;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    width: 100%;
}

/* --- EMPTY STATE (Amikor nincs játék) --- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
    position: relative;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    filter: drop-shadow(0 0 15px var(--primary));
    animation: floatIcon 3s ease-in-out infinite;
}

.empty-state h2 {
    color: var(--primary);
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

@keyframes floatIcon {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.pulse-ring {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 200px; height: 200px;
    border: 1px solid var(--primary);
    border-radius: 50%;
    opacity: 0;
    animation: pulseRing 3s infinite;
    z-index: -1;
}

@keyframes pulseRing {
    0% { width: 100px; height: 100px; opacity: 0.5; }
    100% { width: 300px; height: 300px; opacity: 0; }
}

/* --- MOBIL OPTIMALIZÁCIÓ (JAVÍTVA: NÉGYZET ALAKÚ CELLÁK) --- */

.board-container {
    display: block;       
    width: 100%;          
    max-width: 100%;      
    overflow-x: auto;     
    -webkit-overflow-scrolling: touch; 
    padding: 1rem;
    background: radial-gradient(circle, rgba(0, 242, 255, 0.03) 0%, transparent 70%);
    border-radius: 12px;
    /* Flex itemként */
    flex-grow: 1; 
    margin-bottom: 1rem;
    min-height: 300px; 
}

.board {
    display: table;       
    border-collapse: collapse;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    border-radius: 8px;
    background: rgba(0,0,0,0.4);
    
    /* FIX: A min-width: 600px helyett max-content-et használunk. 
       Így a tábla szélessége = oszlopok száma * cella szélesség.
       10x10-nél nem nyúlik meg, 20x20-nál viszont kilóg (görgethető). */
    margin: 0 auto;       
    width: max-content;     
}

@media (max-width: 650px) {
    .board-container {
        padding: 0.5rem;
    }
}

.board .cell {
    width: 36px;
    height: 36px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    text-align: center;
    vertical-align: middle;
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
}

.board .cell:hover:not(:has(span)) {
    background: rgba(255, 255, 255, 0.08);
}

/* --- UTOLSÓ LÉPÉS KIEMELÉSE --- */
.cell.last-move::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border: 2px solid #fff;
    border-radius: 4px;
    box-shadow: 0 0 10px #fff, inset 0 0 10px #fff;
    animation: pulseLast 1.5s infinite;
    pointer-events: none; /* Hogy át lehessen rajta kattintani */
}

@keyframes pulseLast {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.95); }
    100% { opacity: 1; transform: scale(1); }
}

/* X és O stílus (JAVÍTVA) */
.cell-symbol {
    font-size: 22px;
    font-weight: bold;
    /* JAVÍTÁS: inline-block a sima block helyett, és line-height */
    display: inline-block; 
    line-height: 36px; /* A cella magasságához igazítva */
    width: 100%;
    height: 100%;
    animation: symbolPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.cell-symbol-x { 
    color: var(--primary); 
    filter: drop-shadow(0 0 4px var(--primary));
}
.cell-symbol-o { 
    color: var(--accent); 
    filter: drop-shadow(0 0 4px var(--accent));
}

@keyframes symbolPop {
    from { transform: scale(0); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* GYŐZTES SOR */
.board .win-cell {
    background: rgba(255, 255, 255, 0.15) !important;
    box-shadow: inset 0 0 15px rgba(255, 255, 255, 0.2);
}
.board .win-cell .cell-symbol {
    animation: winPulse 1s infinite alternate;
}

@keyframes winPulse {
    from { transform: scale(1); filter: drop-shadow(0 0 5px currentColor); }
    to { transform: scale(1.2); filter: drop-shadow(0 0 15px currentColor); }
}

/* ===========================================
   MODALS & OVERLAYS
=========================================== */

.modal-backdrop, .neon-modal-overlay, .vs-overlay {
    position: fixed;
    top: 0; 
    left: 0; 
    width: 100vw; 
    height: 100vh;
    background: rgba(3, 5, 8, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000; 
}

.neon-modal-content {
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 3rem;
    border-radius: 24px;
    box-shadow: 0 0 100px rgba(0,0,0,0.8);
    text-align: center;
    max-width: 450px;
    width: 90%;
    position: relative;
    z-index: 10001;
}

.neon-modal-content.win { border-top: 4px solid var(--primary); }
.neon-modal-content.loss { border-top: 4px solid var(--accent); }

.neon-modal-title {
    font-size: 2.5rem;
    font-weight: 900;
    margin-bottom: 1rem;
    background: linear-gradient(to right, #fff, #ccc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.win .neon-modal-title { background: linear-gradient(to right, var(--primary), #fff); -webkit-background-clip: text; }
.loss .neon-modal-title { background: linear-gradient(to right, var(--accent), #ff88aa); -webkit-background-clip: text; }

.neon-modal-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 2rem;
}

.neon-modal-btn {
    border: none;
    padding: 1rem 2rem;
    border-radius: 50px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    width: 100%;
}

.btn-restart {
    background: var(--primary);
    color: #000;
    box-shadow: 0 0 15px rgba(0, 242, 255, 0.3);
}
.btn-restart:hover {
    transform: scale(1.03);
    box-shadow: 0 0 25px rgba(0, 242, 255, 0.5);
}

.btn-close {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.btn-close:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}


/* VS Overlay */
.vs-overlay { z-index: 9999; }
.vs-container { font-size: 3rem; font-weight: 900; text-transform: uppercase; }
.vs-player.p1 { color: var(--primary); text-shadow: 0 0 30px var(--primary); }
.vs-player.p2 { color: var(--accent); text-shadow: 0 0 30px var(--accent); }
.vs-badge { font-family: 'Impact', sans-serif; font-style: italic; margin: 0 2rem; color: white; }

/* Login Modal */
.modal-dialog {
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border-radius: 20px;
}
.form-group input {
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
    color: white;
    padding: 12px;
    border-radius: 8px;
    transition: border-color 0.3s;
}
.form-group input:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 242, 255, 0.1);
}

/* Toast */
.neon-toast {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.1);
    border-left: 4px solid var(--primary);
    color: white;
    border-radius: 8px;
    padding: 16px 24px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.neon-toast.error { border-left-color: var(--accent); }