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

body {
    background-color: transparent;
    color: white;
    font-family: 'Poppins', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

main {
    width: 100%;
    padding: 20px;
    display: flex;
    justify-content: center;
}

.game {
    width: 100%;
    max-width: 1100px; /* Made slightly bigger as requested */
}

/* Overall container */
.game-container {
    background-color: hsl(287.36deg 100% 37.39% / 16%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 40px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
    
    display: flex;
    flex-direction: row;
    gap: 30px;
    align-items: stretch;
}

/* Three main panels */
.panel-board {
    flex: 1 1 500px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.panel-divider {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Thick vertical line as requested */
.thick-line {
    background: rgba(255, 255, 255, 0.8);
    width: 6px;
    height: 90%;
    border-radius: 10px;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.4);
}

.panel-info {
    flex: 1 1 350px;
    display: flex;
    flex-direction: column;
    justify-content: space-between; /* Spreads content nicely to remove empty space */
}

/* Top Section (Title, Turn) */
.info-top {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.game-title {
    font-size: 3.2rem; /* Slightly larger */
    font-weight: 800;
    background: linear-gradient(135deg, #00f0ff, #b41aaa, #ff8bf3);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.1;
}

.turn-display {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 15px 20px;
    font-size: 1.25rem;
    font-weight: 600;
    text-align: center;
}

/* Scoreboard */
.scoreboard {
    background: rgba(0, 0, 44, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 20px 25px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 20px 0; /* Creates breathing room */
}

.score-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.player-name {
    font-size: 1.3rem; /* Names made bigger */
    color: rgba(255, 255, 255, 0.9);
    font-weight: 700;
}

/* Scores in squares */
.score-square {
    width: 45px;
    height: 45px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    font-weight: 800;
    color: #fff;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.3);
}

/* Controls */
.panel-controls {
    display: flex;
    flex-direction: column;
}

.actions {
    display: flex;
    gap: 15px;
}

.btn-action {
    flex: 1;
    padding: 14px 24px;
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, #b41aaa, #6d1ffc);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(109, 31, 252, 0.4);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(180, 26, 170, 0.6);
}

.btn-outline {
    background: transparent;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.25);
}
.btn-outline:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

/* Game Board - Made fluid */
.game-board {
    width: 100%;
    min-width: 320px;
    max-width: 500px;
    height: auto;
    aspect-ratio: 1 / 1;
    display: grid;
    grid-template-columns: 1fr 2% 1fr 2% 1fr;
    grid-template-rows: 1fr 2% 1fr 2% 1fr;
    position: relative;
}

.box { position: relative; cursor: pointer; }

#box1 { grid-row: 5; grid-column: 1; }
#box2 { grid-row: 5; grid-column: 3; }
#box3 { grid-row: 5; grid-column: 5; }
#box4 { grid-row: 3; grid-column: 1; }
#box5 { grid-row: 3; grid-column: 3; }
#box6 { grid-row: 3; grid-column: 5; }
#box7 { grid-row: 1; grid-column: 1; }
#box8 { grid-row: 1; grid-column: 3; }
#box9 { grid-row: 1; grid-column: 5; }

/* Grid Lines Glow */
#board-line1 { background: white; grid-column: 2; grid-row: 1/6; border-radius: 4px; box-shadow: 0 0 10px rgba(255,255,255,0.4); }
#board-line2 { background: white; grid-column: 4; grid-row: 1/6; border-radius: 4px; box-shadow: 0 0 10px rgba(255,255,255,0.4); }
#board-line3 { background: white; grid-column: 1/6; grid-row: 2; border-radius: 4px; box-shadow: 0 0 10px rgba(255,255,255,0.4); }
#board-line4 { background: white; grid-column: 1/6; grid-row: 4; border-radius: 4px; box-shadow: 0 0 10px rgba(255,255,255,0.4); }

/* X and O Pieces - Added static neon glowing effect */
.cross, .circle {
    position: relative;
    width: 100%;
    height: 100%;
}

.crossLine1 {
    height: 8px;
    width: 100%;
    background: #ff2a5f; /* Brighter neon red/pink */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
    z-index: 1;
    border-radius: 7px;
    box-shadow: 0 0 20px #ff2a5f, 0 0 10px #ff2a5f; /* Glowing effect */
}
.crossLine1BG {
    height: 12px;
    width: 105%;
    background: white;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
    z-index: 0;
    border-radius: 10px;
}
.crossLine2 {
    height: 12px;
    width: 100%;
    background: #ff2a5f;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translateX(-50%) translatey(-50%) rotate(135deg);
    border: 2px solid white;
    border-radius: 6px;
    box-shadow: 0 0 20px #ff2a5f, 0 0 10px #ff2a5f; /* Glowing effect */
}

.mainCircle, .backCircle {
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
.mainCircle {
    height: 70%;
    width: 70%;
    border: 6px solid #00f0ff; /* Neon cyan */
    z-index: 1;
    box-shadow: 0 0 20px #00f0ff, inset 0 0 15px #00f0ff; /* Inner/Outer Glowing effect */
}
.backCircle {
    height: 70%;
    width: 70%;
    border: 8px solid white;
    z-index: 0;
}

/* Win Line Glowing */
#winline {
    width: 8px;
    position: absolute;
    border: 2px solid white;
    border-radius: 8px;
    z-index: 2;
    box-shadow: 0 0 15px currentColor;
}
.vertical { top: 50%; left: 50%; transform: translate(-50%, -50%); height: 300%; }
.horizontal { top: 50%; left: 50%; transform: translate(-50%, -50%) rotate(90deg); height: 300%; }
.diagonal { top: 50%; left: 50%; transform: translate(-50%, -50%) rotate(45deg); height: 390%; }
.rdiagonal { top: 50%; left: 50%; transform: translate(-50%, -50%) rotate(135deg); height: 390%; }
.BGred { background: #ff2a5f; color: #ff2a5f; }
.BGcyan { background: #00f0ff; color: #00f0ff; }


/* Modal Overlay Container */
.form, .winner-message-bg {
    position: fixed;
    z-index: 50;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}

/* Original Popup Trick */
.popup-box {
    background-color: #00002c;
    padding: 30px;
    border: none;
    width: 90%;
    max-width: 420px;
    border-radius: 12px;
    color: white;
    position: relative;
    box-shadow: 0 20px 40px rgba(0,0,0,0.6);
}
.popup-box::before {
    content: "";
    position: absolute;
    background: linear-gradient(45deg, #b41aaa, #6d1ffc 50%, #0dd5aa);
    top: -5px;
    right: -5px;
    bottom: -5px;
    left: -5px;
    z-index: -1;
    border-radius: 14px;
    animation: myAnimation 3s ease-in-out infinite;
}

@keyframes myAnimation {
    0%, 100% {
        background-size: 200% 200%;
        background-position: 100% 0;
    }
    50% {
        background-size: 200% 200%;
        background-position: 0 100%;
    }
}

/* X button (perfect center & rotate) */
.form-cross {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.6);
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    transition: transform 0.4s ease, color 0.4s ease;
    border-radius: 50%;
    transform-origin: center center;
}
.form-cross:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(180deg);
}

/* Form Inner Contents */
.content h3 { font-size: 1.3rem; margin-bottom: 20px; text-align: center; }
.content label { font-size: 1.05rem; margin-bottom: 5px; display: block; color: rgba(255,255,255,0.85); }
.content input[type="text"] {
    width: 100%;
    background: rgba(0, 69, 97, 0.45);
    border: 1px solid rgba(0, 224, 224, 0.3);
    font-size: 1rem;
    color: white;
    padding: 10px 15px;
    border-radius: 10px;
    margin-bottom: 15px;
    outline: none;
}
.content input[type="text"]:focus { border-color: #00e0e0; }
.mt-20 { margin-top: 20px; }

/* Radio buttons styled */
.XorO { display: flex; gap: 15px; margin-bottom: 20px; }
.XorO label {
    flex: 1;
    font-size: 1.1rem;
    border: 2px solid rgba(0, 224, 224, 0.4);
    padding: 10px 15px;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}
.XorO label:hover { border-color: #00e0e0; background: rgba(0,224,224,0.1); }
.XorO input[type="radio"] { accent-color: #00e0e0; width: 18px; height: 18px; }

/* Modal Form Buttons */
.buttonCenter { display: flex; gap: 10px; }
.buttonCenter button { flex: 1; padding: 10px; border-radius: 8px; border: none; font-size: 1rem; font-weight: bold; cursor: pointer; }
.buttonCenter button:first-child { background: linear-gradient(135deg, #0dd5aa, #009292); color: white; }
.buttonCenter button:last-child { background: rgba(255, 255, 255, 0.1); color: white; }

.buttons-select { display: flex; gap: 15px; }
.buttons-select button { flex: 1; padding: 12px; border: none; border-radius: 10px; font-weight: bold; font-size: 1.1rem; cursor: pointer; }
.buttons-select .select-ai { background: linear-gradient(135deg, #0dd5aa, #009292); color: white; }
.buttons-select .select-friend { background: linear-gradient(135deg, #b41aaa, #6d1ffc); color: white; }

/* Winner Message Info */
.winner-title {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 15px;
    text-align: center;
    background: linear-gradient(135deg, #00f0ff, #ff8bf3);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.result-message { text-align: center; width: 100%; display: flex; justify-content: space-around; font-size: 1.2rem; font-weight: bold; background: rgba(255,255,255,0.05); padding: 15px; border-radius: 10px; margin-bottom: 20px; border: 1px solid rgba(255,255,255,0.1); }
.hidden { display: none !important; }
.flex-center { display: flex; align-items: center; justify-content: center; }

.mobile-info-top {
    display: none;
}

/* Vertical Stacking on Mobile */
@media screen and (max-width: 900px) {
    main {
        padding: 10px;
    }

    .game-container {
        flex-direction: column;
        padding: 15px 15px; /* Dramatically reduced padding */
        align-items: center;
        gap: 15px; /* Reduced container gap */
    }

    .desktop-info-top {
        display: none;
    }

    .mobile-info-top {
        display: flex;
        flex-direction: column;
        align-items: center; /* Centers Tic Tac Toe title & Turn display */
        width: 100%;
        max-width: 400px;
        gap: 8px; /* Reduced gap */
    }

    .mobile-info-top .game-title {
        font-size: 2.5rem; /* Slightly smaller for mobile fit */
        text-align: center;
        margin: 0;
    }

    .mobile-info-top .scoreboard {
        width: 100%;
        margin: 5px 0; /* Reduced from 20px */
        padding: 12px 15px; /* Reduced padding */
        gap: 10px; /* Tighter scores */
    }

    .mobile-info-top .turn-display {
        width: 100%;
        padding: 10px 15px;
    }

    .panel-divider {
        display: none;
    }

    .panel-info {
        flex: 0 0 auto; /* Prevents it from keeping the 350px desktop height */
        gap: 0; /* Not needed since top info is hidden */
        width: 100%;
        max-width: 400px;
    }
    
    .panel-board {
        width: 100%;
        max-width: 380px; /* Slightly smaller board on mobile to save vertical space */
    }
}