/* Tris — Tema neon blu/rosa su sfondo scuro */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background: #0a0a1a;
    font-family: 'Segoe UI', Tahoma, sans-serif;
    overflow: hidden;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

#gameContainer {
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Schermate overlay */
.screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 26, 0.95);
    z-index: 10;
    padding: 20px;
    text-align: center;
}

.screen h1 {
    color: #00ccff;
    font-size: 2.5rem;
    text-shadow: 0 0 20px #00ccff;
    margin-bottom: 10px;
}

.screen h2 {
    color: #fff;
    font-size: 1.8rem;
    margin-bottom: 10px;
}

.screen p {
    color: rgba(255,255,255,0.7);
    font-size: 1rem;
    margin-bottom: 24px;
}

.game-btn {
    padding: 14px 40px;
    font-size: 1.1rem;
    font-weight: 700;
    border: 2px solid #00ccff;
    background: transparent;
    color: #00ccff;
    border-radius: 30px;
    cursor: pointer;
    margin: 6px;
    transition: all 0.3s;
    min-width: 180px;
}

.game-btn:hover, .game-btn:active {
    background: #00ccff;
    color: #0a0a1a;
    box-shadow: 0 0 20px rgba(0, 204, 255, 0.5);
}

.game-btn.secondary {
    border-color: rgba(255,255,255,0.3);
    color: rgba(255,255,255,0.6);
}

.game-btn.secondary:hover {
    background: rgba(255,255,255,0.1);
    color: white;
    border-color: white;
    box-shadow: none;
}

.game-btn.small {
    padding: 10px 28px;
    font-size: 0.95rem;
    min-width: 140px;
}

.controls-hint {
    margin-top: 20px;
    color: rgba(255,255,255,0.4);
    font-size: 0.8rem;
}

/* Area di gioco */
#gameArea {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    position: relative;
}

/* HUD punteggio */
#hud {
    display: flex;
    justify-content: center;
    gap: 30px;
}

.hud-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hud-label {
    color: rgba(255,255,255,0.5);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.score-x {
    color: #00ccff;
    font-size: 1.5rem;
    font-weight: 700;
    text-shadow: 0 0 10px rgba(0,204,255,0.5);
}

.score-o {
    color: #ff3366;
    font-size: 1.5rem;
    font-weight: 700;
    text-shadow: 0 0 10px rgba(255,51,102,0.5);
}

.score-draw {
    color: rgba(255,255,255,0.6);
    font-size: 1.5rem;
    font-weight: 700;
}

/* Turno */
#turnIndicator {
    color: rgba(255,255,255,0.8);
    font-size: 1rem;
    font-weight: 600;
    min-height: 24px;
}

/* Griglia */
#grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    width: min(80vw, 300px);
    height: min(80vw, 300px);
    position: relative;
}

.cell {
    background: rgba(255,255,255,0.03);
    border: 2px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: min(15vw, 56px);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    aspect-ratio: 1;
}

.cell:hover:not(.taken) {
    background: rgba(0, 204, 255, 0.08);
    border-color: rgba(0, 204, 255, 0.3);
}

.cell:active:not(.taken) {
    transform: scale(0.95);
}

.cell.taken {
    cursor: default;
}

.cell.x {
    color: #00ccff;
    text-shadow: 0 0 15px rgba(0,204,255,0.6);
    animation: cellPop 0.25s ease-out;
}

.cell.o {
    color: #ff3366;
    text-shadow: 0 0 15px rgba(255,51,102,0.6);
    animation: cellPop 0.25s ease-out;
}

.cell.win-cell {
    background: rgba(255, 215, 0, 0.1);
    border-color: rgba(255, 215, 0, 0.5);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.2);
}

@keyframes cellPop {
    0% { transform: scale(0.3); opacity: 0; }
    60% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

/* Linea vincente */
#winLine {
    position: absolute;
    top: 0;
    left: 0;
    width: min(80vw, 300px);
    height: min(80vw, 300px);
    pointer-events: none;
    z-index: 5;
}

#winLineEl {
    stroke: #FFD700;
    stroke-width: 4;
    stroke-linecap: round;
    filter: drop-shadow(0 0 8px rgba(255,215,0,0.8));
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    animation: drawLine 0.4s ease forwards;
}

@keyframes drawLine {
    to { stroke-dashoffset: 0; }
}

/* Risultato round */
#roundResult {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
}

#resultText {
    font-size: 1.3rem;
    font-weight: 700;
}

#resultText.win {
    color: #FFD700;
    text-shadow: 0 0 15px rgba(255,215,0,0.5);
}

#resultText.lose {
    color: #ff3366;
}

#resultText.draw {
    color: rgba(255,255,255,0.6);
}

/* Bottone nuova partita */
#btnNewGame {
    margin-top: 4px;
}

.hidden { display: none !important; }

/* Responsive */
@media (max-width: 360px) {
    .screen h1 { font-size: 2rem; }
    #hud { gap: 20px; }
    .cell { font-size: 12vw; border-radius: 8px; }
}
