body {
    margin: 0; padding: 0;
    /* Uzay / Nebula Arka Planı */
    background-color: #050510;
    background-image: 
        radial-gradient(circle at 50% 50%, #1b0029 0%, #000005 100%),
        radial-gradient(white, rgba(255,255,255,.2) 2px, transparent 3px),
        radial-gradient(white, rgba(255,255,255,.1) 1px, transparent 2px);
    background-size: 100% 100%, 550px 550px, 350px 350px;
    background-position: 0 0, 0 0, 0 0;
    color: #fff;
    font-family: 'Press Start 2P', cursive;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    min-height: 100vh; overflow: hidden;
    user-select: none; touch-action: manipulation;
}

.back-link {
    position: absolute; top: 20px; left: 20px;
    color: #777; text-decoration: none; font-family: 'Roboto', sans-serif; 
    font-weight: bold; font-size: 0.8rem; z-index: 200; transition: color 0.3s;
}
.back-link:hover { color: #00f3ff; }

/* HEADER - Biraz küçülttük ki yer kaplamasın */
.game-header { text-align: center; margin-bottom: 15px; z-index: 10; margin-top: 0; }
h1 { font-size: 1.5rem; margin-bottom: 8px; color: #fff; text-shadow: 0 0 15px rgba(0, 243, 255, 0.5); }
.highlight { color: #00f3ff; text-shadow: 0 0 15px #00f3ff; }

.status-bar { 
    font-family: 'Roboto', sans-serif; font-size: 1rem; 
    background: rgba(17, 17, 17, 0.8); padding: 6px 20px; 
    border-radius: 20px; border: 1px solid #333; display: inline-block;
    backdrop-filter: blur(5px);
}
.turn-x { color: #00f3ff; text-shadow: 0 0 10px #00f3ff; font-weight: bold;}
.turn-o { color: #ff0055; text-shadow: 0 0 10px #ff0055; font-weight: bold;}

/* OYUN KONTEYNERİ */
.game-container-row {
    display: flex; align-items: center; justify-content: center; gap: 25px;
    width: 100%; height: auto; position: relative; z-index: 5;
    /* Marginleri kaldırdık, Flexbox ortalayacak */
    margin-top: 0; margin-bottom: 0;
}

/* OYUNCU PANELLERİ - Biraz daha kompakt */
.player-panel {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: rgba(20, 20, 30, 0.6);
    border: 2px solid #333; border-radius: 12px;
    padding: 15px; width: 110px; /* Genişlik kısıldı */
    transition: all 0.3s;
    backdrop-filter: blur(5px);
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

.panel-title { font-size: 0.6rem; color: #aaa; margin-bottom: 8px; font-family: 'Roboto'; font-weight: bold; }
.panel-score { font-size: 1.8rem; margin-bottom: 8px; }
.panel-icon { font-size: 1.8rem; opacity: 0.3; }

.p1-panel { border-color: #00f3ff; }
.p1-panel .panel-score { color: #00f3ff; text-shadow: 0 0 15px #00f3ff; }
.p2-panel { border-color: #ff0055; }
.p2-panel .panel-score { color: #ff0055; text-shadow: 0 0 15px #ff0055; }

/* Aktif Oyuncu Efekti */
.turn-active-x .p1-panel { transform: scale(1.1); box-shadow: 0 0 30px rgba(0, 243, 255, 0.4); background: rgba(0, 243, 255, 0.1); }
.turn-active-o .p2-panel { transform: scale(1.1); box-shadow: 0 0 30px rgba(255, 0, 85, 0.4); background: rgba(255, 0, 85, 0.1); }

/* ANA TAHTA (DÜZELTİLEN KISIM) */
.main-board {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
    /* ESKİSİ: 90vmin (Ekranın %90'ı) -> Çok büyüktü.
       YENİSİ: 75vmin (Ekranın %75'i) -> Tam istediğin "zoom out" etkisi.
       Bu sayede her çözünürlükte (Laptop, 4K Monitör) ekranın ortasında ferah durur.
    */
    width: 75vmin; height: 75vmin; 
    max-width: 600px; max-height: 600px; 
    padding: 10px; 
    background: rgba(10, 10, 20, 0.6);
    border-radius: 15px;
    box-shadow: 0 0 60px rgba(0, 243, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* KÜÇÜK TAHTALAR */
.sub-board {
    display: grid; 
    grid-template-columns: repeat(3, 1fr); 
    grid-template-rows: repeat(3, 1fr);
    gap: 2px;
    background: #181818;
    border: 2px solid #333;
    border-radius: 6px;
    transition: all 0.3s;
    position: relative;
    aspect-ratio: 1 / 1;
}

.sub-board.active {
    border-color: #ffd700;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
    background: #2a2a2a;
    z-index: 10;
    transform: scale(1.02);
}

.sub-board.won-x { background: rgba(0, 243, 255, 0.15); border-color: #00f3ff; }
.sub-board.won-o { background: rgba(255, 0, 85, 0.15); border-color: #ff0055; }
.sub-board.draw { background: rgba(100, 100, 100, 0.15); border-color: #666; opacity: 0.6; }

.sub-board::after {
    content: attr(data-winner);
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 5rem; z-index: 5;
    text-shadow: 0 0 20px currentColor;
    display: none; pointer-events: none; font-weight: bold;
}
@media (max-width: 600px) { .sub-board::after { font-size: 3rem; } }

.sub-board.won-x::after { display: block; color: #00f3ff; }
.sub-board.won-o::after { display: block; color: #ff0055; }
.sub-board.draw::after { display: block; content: "-"; color: #888; font-size: 6rem; line-height: 0.5;}

/* HÜCRELER */
.cell {
    background: rgba(255,255,255,0.03);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; cursor: pointer;
    transition: background 0.2s; width: 100%; height: 100%;
}
@media (max-width: 600px) { .cell { font-size: 0.9rem; } }

.active .cell:not(.x):not(.o):hover { background: rgba(255, 215, 0, 0.15); cursor: pointer; }
.sub-board:not(.active) .cell { cursor: default; opacity: 0.7; }

.cell.x { color: #00f3ff; text-shadow: 0 0 8px #00f3ff; }
.cell.o { color: #ff0055; text-shadow: 0 0 8px #ff0055; }

/* ----- MOBİL VE TABLET DÜZENİ (KORUNDU) ----- */
@media (max-width: 900px) {
    .game-header { margin-top: 60px; margin-bottom: 10px; }
    h1 { font-size: 1.4rem; }

    /* Grid Yapısı ile sağlam yerleşim */
    .game-container-row {
        display: grid;
        grid-template-columns: 1fr 1fr; 
        grid-template-rows: auto auto; 
        gap: 15px;
        width: 96%;
        margin-top: 10px; margin-bottom: 20px;
    }
    
    /* Paneller üstte */
    .player-panel {
        position: static;
        width: 100%; 
        flex-direction: row; 
        padding: 8px 15px;
        height: auto;
        justify-content: space-between;
        box-sizing: border-box;
    }
    
    .panel-title { font-size: 0.6rem; margin: 0; }
    .panel-score { font-size: 1.2rem; margin: 0; }
    .panel-icon { font-size: 1.2rem; }

    .p1-panel { grid-row: 1; grid-column: 1; }
    .p2-panel { grid-row: 1; grid-column: 2; }

    .turn-active-x .p1-panel, .turn-active-o .p2-panel { transform: scale(1.02); }

    /* Oyun Tahtası: Mobilde büyük kalmalı */
    .main-board {
        grid-row: 2;
        grid-column: 1 / span 2; 
        width: 92vw; /* Ekran genişliğine göre ayarla */
        height: 92vw; /* Kare olsun */
        /* Masaüstündeki vmin ayarını eziyoruz, mobilde genişlik önemlidir */
        max-width: none;
        max-height: none;
        justify-self: center;
    }
}

/* --- OVERLAYS ve KONTROLLER --- */
.top-controls { position: absolute; top: 20px; right: 20px; z-index: 200; display: flex; gap: 10px; }
.icon-btn {
    background: rgba(0, 0, 0, 0.5); border: 1px solid #555; color: #aaa;
    width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
    font-size: 1.2rem; display: flex; align-items: center; justify-content: center;
    transition: 0.3s; box-shadow: none; padding: 0; backdrop-filter: blur(4px);
}
.icon-btn:hover { border-color: #ffd700; color: #ffd700; box-shadow: 0 0 10px #ffd700; background: rgba(0,0,0,0.8); }

.overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(5, 5, 10, 0.96); 
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    z-index: 100; backdrop-filter: blur(8px);
}
.overlay h1 { font-size: 2.5rem; color: #00f3ff; margin-bottom: 20px; text-align: center; text-shadow: 0 0 20px #00f3ff; }
.overlay h2 { font-size: 2rem; color: #ffd700; margin-bottom: 20px; text-shadow: 0 0 30px #ffd700; text-align: center; }

.btn-group { display: flex; flex-direction: column; gap: 15px; width: 250px; }
button {
    background: rgba(0, 243, 255, 0.05); color: #fff; border: 2px solid #00f3ff;
    padding: 18px; font-family: 'Press Start 2P'; font-size: 0.8rem; cursor: pointer;
    border-radius: 8px; box-shadow: 0 0 15px rgba(0, 243, 255, 0.1); transition: 0.2s;
    text-transform: uppercase; letter-spacing: 1px;
}
button:hover { background: #00f3ff; color: #000; box-shadow: 0 0 30px #00f3ff; transform: scale(1.05); }
.close-btn { border-color: #ff0055; width: auto; padding: 10px 40px; background: rgba(255, 0, 85, 0.05);}
.close-btn:hover { background: #ff0055; color: #fff; box-shadow: 0 0 20px #ff0055; }

.rules-preview { text-align: center; font-family: 'Roboto'; color: #aaa; margin-bottom: 30px; font-size: 0.9rem; line-height: 1.6; }
.rules-content {
    background: rgba(20, 20, 20, 0.9); padding: 20px; border-radius: 10px; border: 1px solid #333;
    max-width: 500px; width: 90%; margin-bottom: 20px; box-shadow: 0 0 30px rgba(0,0,0,0.5);
}
.rule-item { display: flex; align-items: flex-start; gap: 15px; margin-bottom: 15px; text-align: left; }
.rule-item i { font-size: 1.2rem; color: #00f3ff; width: 25px; text-align: center; margin-top: 2px;}
.rule-item p { font-family: 'Roboto'; font-size: 0.85rem; color: #ddd; line-height: 1.4; margin: 0; }
.rule-item strong { color: #fff; }

.blink { animation: blink 2s infinite; }
@keyframes blink { 50% { opacity: 0.5; } }

#effects-canvas { position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }