:root {
    --text: #ffffff;  
    --accent: #3f5a78; /* Changed from purple to blue */
}

body {
    margin: 0;
    /* Exact same dark level as your TTT, just a dark blue hue instead of purple */
    background: #101622; 
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100dvh;
    overflow: hidden;
    font-family: Arial, sans-serif; 
}

#main-container {
    container-type: size;
    position: relative; 
    width: 100vw; 
    height: 100vh;
    max-width: 177.78vh;
    max-height: 56.25vw; 
    aspect-ratio: 16 / 9;
    background: transparent; 
    overflow: hidden;
}

.screen {
    position: absolute; 
    width: 100%; 
    height: 100%; 
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.hidden { display: none !important; }

.game-title {
    font-size: 6cqw;
    font-family: "Fredoka", 'Arial Black', sans-serif;
    font-weight: 900;
    margin-bottom: 5cqh;
    letter-spacing: 0.5cqw;
    
    color: #ffffff; 
    text-shadow: 0 0.5cqw 1.5cqw rgba(0,0,0,0.8); 
    text-transform: uppercase;
}

.menu-row {
    display: flex;
    justify-content: center;
    width: 75cqw;
    gap: 4cqw;
}

.menu-section {
    text-align: center;
    padding: 4cqh 3cqw;
    width: 45%; 
    
    background: rgba(255, 255, 255, 0.06); 
    border: 1px solid rgba(255, 255, 255, 0.1); 
    border-radius: 1.5cqw;
    box-shadow: 0 1cqw 3cqw rgba(0, 0, 0, 0.8); 
    backdrop-filter: blur(10px);
}

.section-heading {
    font-family: Arial, sans-serif;
    font-size: 2.5cqw;
    margin-bottom: 3cqh;
    color: #ffffff;
    text-shadow: 0 0.2cqw 0.5cqw rgba(0,0,0,0.8);
    text-transform: uppercase;
}

/* Changed from Purple to Blue Gradient */
.btn {
    display: block;
    width: 100%; 
    padding: 2cqh 0;
    margin: 1.5cqh auto;
    font-size: 1.5cqw;
    font-weight: bold;
    text-transform: uppercase;
    border: none;
    border-radius: 1cqw;
    color: white; 
    background: linear-gradient(45deg, #1e5cff, #4da6ff); 
    box-shadow: 0 0.5cqw 1.5cqw rgba(0,0,0,0.6); 
    cursor: pointer;
    transition: 0.2s ease; 
}

.btn:hover {
    transform: scale(1.05);
    background: linear-gradient(45deg, #336eff, #80bfff); 
}

/* Invite Button using Cyan */
.invite-btn {
    background: linear-gradient(45deg, #0096c7, #33cfff) !important;
}
.invite-btn:hover {
    background: linear-gradient(45deg, #00b4d8, #90e0ef) !important;
}

.top-bar {
    position: absolute;
    top: 4cqh; 
    right: 4cqw;
    display: flex;
    align-items: center;
    z-index: 50;
}

#status { 
    font-size: 2.5cqw; 
    font-weight: bold; 
    color: #ffffff; 
    text-shadow: 0 0.2cqw 0.5cqw rgba(0,0,0,0.8);
    margin-left: 2cqw;
}

.controls {
    display: flex;
    gap: 1cqw; 
}

.icon-btn {
    background: rgba(255, 255, 255, 0.15); 
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: white; 
    cursor: pointer; 
    backdrop-filter: blur(5px); 
    transition: 0.2s;
    display: flex; justify-content: center; align-items: center;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.3); 
    transform: scale(1.1); 
}

.round-btn {
    width: 5cqh; 
    height: 5cqh;
    padding: 1cqh; 
}

.round-btn svg { width: 100%; height: 100%; fill: #ffffff; }

.game-layout {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4cqw; 
    width: 100%;
    margin-top: 0;
}

.player-profile {
    width: 14cqw;
    background: rgba(255, 255, 255, 0.06); 
    border: 1px solid rgba(255, 255, 255, 0.05); 
    backdrop-filter: blur(10px);
    border-radius: 0.5cqw;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 3cqh 0;
    box-shadow: 0 0.5cqw 2cqw rgba(0,0,0,0.8);
    transition: all 0.3s ease;
}

.player-profile h3 {
    font-size: 1.8cqw;
    font-weight: normal; 
    margin: 1cqh 0;
    color: #e0e0e0;
    text-shadow: none;
}

.player-profile p { 
    font-size: 1.2cqw; 
    color: #aaaaaa; 
    font-weight: normal; 
}

.avatar {
    width: 6cqw; height: 6cqw;
    border-radius: 50%;
    margin-bottom: 1cqh;
    box-shadow: inset 0 0.5cqw 0 rgba(255,255,255,0.3), 0 0.5cqw 1cqw rgba(0, 0, 0, 0.6); 
}

.p1-color { background: linear-gradient(135deg, #33cfff, #0077b6); border: 0.2cqw solid #005f8f; }
.p2-color { background: linear-gradient(135deg, #ffeb3b, #f57f17); border: 0.2cqw solid #c46200; }

.board-wrapper {
    aspect-ratio: 1 / 1 !important;
    flex-shrink: 0 !important; 
    height: 90cqh;  
    width: auto; 
    border-radius: 1cqw;
    position: relative;
    
    background:  rgba(255, 255, 255, 0.06); 
    border: 1px solid rgba(255, 255, 255, 0.05);
    
    box-shadow: 0 0.5cqw 2cqw rgba(0,0,0,0.8);
}

#game-board { width: 100%; height: 100%; position: relative; }

.square {
    position: absolute;
    box-sizing: border-box;
    border: 0.15cqh solid #6d768b; 
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    border-radius: 0.5cqw;
}

.outer { width: 90%; height: 90%; }
.middle { width: 60%; height: 60%; }
.inner { width: 30%; height: 30%; }

.line { position: absolute; background-color: rgba(109, 118, 139, 0.588); pointer-events: none; }

.vertical-top { width: 0.3cqh; height: 30%; top: 5%; left: 50%; transform: translateX(-50%); }
.vertical-bottom { width: 0.3cqh; height: 30%; bottom: 5%; left: 50%; transform: translateX(-50%); }
.horizontal-left { height: 0.3cqh; width: 30%; left: 5%; top: 50%; transform: translateY(-50%); }
.horizontal-right { height: 0.3cqh; width: 30%; right: 5%; top: 50%; transform: translateY(-50%); }

/* Spots & Coins */
.spot {
    position: absolute;
    width: 3cqh; height: 3cqh;
    background-color: #6d768b; 
    border: 1px solid #6d768b;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    display: flex; justify-content: center; align-items: center;
    cursor: pointer; z-index: 10;
    box-sizing: border-box; 
    transition: 0.2s;
}
.spot:hover { 
    background-color: #ffffff; 
} 

.coin {
    position: absolute;
    width: 7cqh; height: 7cqh;
    border-radius: 50%; z-index: 20; box-sizing: border-box; 
    transition: transform 0.2s cubic-bezier(0.5, 0, 0.5, 1.2), box-shadow 0.2s;
}

.coin.drop-in {
    animation: dropFromFront 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes dropFromFront {
    0% { transform: scale(3); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.coin:hover {
    transform: scale(1.1) translateY(-0.5cqh); 
    filter: brightness(1.1);
    cursor: grab;
}

.coin.white {
    background: linear-gradient(135deg, #33cfff, #0077b6); 
    border: 0.3cqh solid #005f8f; 
    box-shadow: inset 0 0.4cqh 0 rgba(255,255,255,0.4), 0 0.5cqh 1cqh rgba(0, 0, 0, 0.5); 
}
.coin.black {
    background: linear-gradient(135deg, #ffeb3b, #f57f17); 
    border: 0.3cqh solid #c46200; 
    box-shadow: inset 0 0.4cqh 0 rgba(255,255,255,0.5), 0 0.5cqh 1cqh rgba(0, 0, 0, 0.5); 
}
.coin.selected {
    transform: scale(1.1) translateY(-0.5cqh);
    box-shadow: inset 0 0.4cqh 0 rgba(255,255,255,0.5), 0 0 2cqh 0.5cqh rgba(255, 255, 255, 0.6);
}

/* --- POPUP MODALS --- */
.modal {
    position: fixed; /* 'fixed' ensures it covers the absolute entire screen */
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(15, 15, 18, 0.6); /* Reduced from 0.85 to 0.6 for a lighter background */
    display: flex; justify-content: center; align-items: center;
    z-index: 1000; /* Bumped up to ensure it sits above everything */
}

.modal-box {
    background: #333438; 
    border: 2px solid #1f1f22;
    padding: 5cqh 4cqw;
    border-radius: 1cqw; text-align: center;
    box-shadow: 0 1.5cqw 3cqw rgba(0,0,0,0.5);
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    min-width: 40cqw; /* Make it wider to fit the buttons */
}

/* Make buttons sit in a horizontal row */
.btn-group {
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 2cqw;
    margin-top: 3cqh;
    width: 100%;
}

.btn-group .btn {
    flex: 1; /* This forces all buttons to be exactly the same size! */
    margin: 0; 
    padding: 1.5cqh 1cqw;
    text-align: center;
}

/* Allow the win message to split onto two lines nicely */
#win-message {
    white-space: pre-line; 
    line-height: 1.5;
}

@keyframes popIn {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.name-input {
    display: block; width: 100%; padding: 2cqh; margin: 2cqh 0;
    background: rgba(255,255,255,0.1); border: 1px solid rgba(255, 255, 255, 0.2);
    color: white; font-size: 1.5cqw; border-radius: 0.5cqw; text-align: center;
}
.name-input:focus { outline: none; border-color: var(--accent); }


/* =========================================================
   PORTRAIT MODE (FOR MOBILE PHONES) 
   ========================================================= */
@media screen and (orientation: portrait) {
    #main-container { 
        aspect-ratio: auto !important; 
        max-height: 100dvh !important; 
        max-width: 100vw !important;
    }

    .game-title { font-size: 8cqw !important; margin-top: 10cqh; margin-bottom: 2cqh !important; }
    
    .menu-row { flex-direction: column !important; width: 85cqw !important; gap: 2cqh !important;}
    .menu-section { width: 100% !important; padding: 4cqw !important; }
    .section-heading { font-size: 6cqw !important; margin-bottom: 1.5cqh !important; }
    .btn { font-size: 4cqw !important; padding: 1.5cqh !important; margin: 1cqh auto !important; }

    .top-bar { top: 2cqh !important; right: 4cqw !important; left: auto !important; }
    .round-btn { width: 6cqw !important; height: 6cqw !important; padding: 1.5cqw !important; }

    .game-layout {
        flex-direction: column !important;
        height: auto !important; 
        gap: 3cqh !important; 
        margin-top: 0 !important; 
    }

    .board-wrapper {
        width: 95cqw !important;
        max-width: 67cqh !important; 
        height: auto !important;
        aspect-ratio: 1 / 1 !important;
        flex-shrink: 0 !important;
    }

    .square { 
        border-width: 0.15cqw !important; 
        box-shadow: 0 0 0 0.15cqw rgba(255, 255, 255, 0.15) !important;
        box-sizing: border-box !important;
    }
    .vertical-top, .vertical-bottom, .horizontal-left, .horizontal-right {
        width: 0.3cqw !important; height: 30% !important;
    }
    .horizontal-left, .horizontal-right { height: 0.3cqw !important; width: 30% !important; }
    
    .spot { width: 4cqw !important; height: 4cqw !important; border-width: 0.3cqw !important; box-sizing: border-box !important;}
    .coin { width: 8cqw !important; height: 8cqw !important; }

    .player-profile {
        width: 90cqw !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        padding: 1.5cqh 4cqw !important;
        aspect-ratio: auto !important;
    }
    .avatar { width: 8cqw !important; height: 8cqw !important; margin: 0 !important; box-shadow: inset 0 1cqw 0 rgba(255,255,255,0.3), 0 1cqw 2cqw rgba(0, 0, 0, 0.6) !important;}
    
    .player-profile h3 { font-size: 4.5cqw !important; margin: 0 !important; font-weight: normal !important; }
    .player-profile p { font-size: 3.5cqw !important; margin: 0 !important; font-weight: normal !important; }

    .modal-box { width: 85cqw !important; padding: 4cqh 5cqw !important; }
    .name-input { font-size: 4cqw !important; }
}