/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Montserrat', 'Arial', sans-serif;
}

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600;700&family=Playfair+Display:wght@700&display=swap');

body {
    overflow: hidden;
    color: white;
}

/* Fullscreen video background */
video {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover; 
    z-index: -1;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.1);
    z-index: 999;
    transition: opacity 1s ease-out;
}

.loading-screen video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.loading-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

/* Game Container */
.game-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
    padding: 20px;
    opacity: 0;
    transition: opacity 1s ease-in;
}

.game-container.show {
    opacity: 1;
}

/* Screens */
.screen {
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 15px;
    padding: 40px;
    text-align: center;
    width: 100%;
    max-width: 600px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.hidden {
    display: none !important;
}

/* Welcome Screen */
h1 {
    font-family: 'Playfair Display', serif;
    font-size: 52px;
    margin-bottom: 40px;
    background: linear-gradient(45deg, #ff9a9e, #67d3c2);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    letter-spacing: 2px;
}

h2 {
    font-family: 'Playfair Display', serif;
    font-size: 32px;
    margin-bottom: 30px;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.button-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
}

/* Buttons */
button {
    padding: 16px 32px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    border-radius: 50px;
    background: linear-gradient(45deg, #67d3c2, #7a88a7);
    color: white;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    letter-spacing: 1px;
}

button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    background: linear-gradient(45deg, #7ee8d7, #8998b7);
}

button:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

/* Room Code */
.code-display {
    font-size: 42px;
    font-weight: bold;
    background-color: rgba(255, 255, 255, 0.15);
    padding: 20px;
    border-radius: 12px;
    margin: 25px 0;
    letter-spacing: 8px;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.3);
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

#room-code-input {
    padding: 18px;
    font-size: 24px;
    width: 100%;
    margin-bottom: 25px;
    border-radius: 12px;
    border: none;
    text-align: center;
    letter-spacing: 8px;
    background-color: rgba(255, 255, 255, 0.9);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

#room-code-input:focus {
    outline: none;
    box-shadow: 0 4px 20px rgba(103, 211, 194, 0.5);
    transform: scale(1.02);
}

.error-message {
    color: #ff9a9e;
    margin-top: 15px;
    font-weight: bold;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Game Screen */
.game-header {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 25px;
    padding: 0 10px;
}

.player-info, .score-display {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.current-turn {
    font-size: 20px;
    padding: 10px 20px;
    background-color: #67d3c2;
    border-radius: 50px;
    margin-bottom: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    font-weight: bold;
    letter-spacing: 1px;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.score {
    font-size: 20px;
    margin: 5px 0;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    font-weight: bold;
}

/* Grid Container */
.grid-container {
    display: grid;
    grid-template-columns: repeat(5, 65px);
    grid-template-rows: repeat(5, 65px);
    gap: 0;
    position: relative;
    background-color: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: 15px;
    margin: 20px 0;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(5px);
}

/* Dots - Porcelain Look */
.dot {
    width: 14px;
    height: 14px;
    background: radial-gradient(circle at 30% 30%, white, #f0f0f0);
    border-radius: 50%;
    position: absolute;
    cursor: pointer;
    z-index: 3;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 
        inset -2px -2px 4px rgba(0, 0, 0, 0.1),
        inset 2px 2px 4px rgba(255, 255, 255, 0.8),
        0 0 10px rgba(255, 255, 255, 0.7);
}

.dot:hover {
    transform: scale(1.6);
    box-shadow: 
        inset -2px -2px 4px rgba(0, 0, 0, 0.1),
        inset 2px 2px 4px rgba(255, 255, 255, 0.8),
        0 0 15px rgba(103, 211, 194, 0.9);
}

.dot.selected {
    background: radial-gradient(circle at 30% 30%, #ffd1d1, #ff9a9e);
    transform: scale(1.6);
    box-shadow: 
        inset -2px -2px 4px rgba(0, 0, 0, 0.1),
        inset 2px 2px 4px rgba(255, 255, 255, 0.8),
        0 0 15px rgba(255, 154, 158, 0.9);
}

/* Lines */
.line {
    position: absolute;
    background-color: #4ecdc4;
    z-index: 2;
    transition: all 0.3s ease;
    box-shadow: 0 0 15px rgba(78, 205, 196, 0.8);
}

.line.horizontal {
    height: 6px;
    width: 51px;
    border-radius: 3px;
}

.line.vertical {
    width: 6px;
    height: 51px;
    border-radius: 3px;
}

.line.player-line {
    background-color: #4ecdc4;
    box-shadow: 0 0 15px rgba(78, 205, 196, 0.8);
}

.line.opponent-line {
    background-color: #ff6b6b;
    box-shadow: 0 0 15px rgba(255, 107, 107, 0.8);
}

/* Squares - 3D Style */
.square {
    position: absolute;
    z-index: 0;
    opacity: 0.65;
    border-radius: 8px;
    transition: all 0.3s ease;
    animation: squareAppear 0.5s ease-out;
    transform-style: preserve-3d;
    transform: perspective(800px) rotateX(15deg) rotateY(-15deg);
    box-sizing: border-box;
}

@keyframes squareAppear {
    from { transform: perspective(800px) rotateX(30deg) rotateY(-30deg) scale(0.5); opacity: 0; }
    to { transform: perspective(800px) rotateX(15deg) rotateY(-15deg) scale(1); opacity: 0.65; }
}

.square.player {
    background-color: #4ecdc4;
    box-shadow: 
        inset 0 0 20px rgba(0, 0, 0, 0.2), 
        0 0 15px rgba(78, 205, 196, 0.5),
        0 8px 15px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.square.opponent, .square.ai {
    background-color: #ff6b6b;
    box-shadow: 
        inset 0 0 20px rgba(0, 0, 0, 0.2), 
        0 0 15px rgba(255, 107, 107, 0.5),
        0 8px 15px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Game Over */
.final-score {
    font-size: 28px;
    margin: 25px 0;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    font-weight: bold;
}

.result-message {
    font-family: 'Playfair Display', serif;
    font-size: 38px;
    margin-bottom: 35px;
    font-weight: bold;
    background: linear-gradient(45deg, #ff9a9e, #67d3c2);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

/* Potential Lines (Shadows) */
.potential-line {
    position: absolute;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.potential-line.horizontal {
    height: 5px;
    width: 51px;
    background-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
    border-radius: 3px;
}

.potential-line.vertical {
    width: 5px;
    height: 51px;
    background-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
    border-radius: 3px;
}

.potential-line:hover {
    opacity: 0.7;
    box-shadow: 0 0 15px rgba(255, 255, 255, 1);
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .screen {
        padding: 25px;
        max-width: 90%;
    }
    
    h1 {
        font-size: 38px;
    }
    
    .grid-container {
        grid-template-columns: repeat(5, 50px);
        grid-template-rows: repeat(5, 50px);
        padding: 10px;
    }
    
    .line.horizontal {
        width: 36px;
    }
    
    .line.vertical {
        height: 36px;
    }
    
    .square {
        width: 50px;
        height: 50px;
    }
    
    .potential-line.horizontal {
        width: 36px;
    }
    
    .potential-line.vertical {
        height: 36px;
    }
    
    .game-content-wrapper {
        flex-direction: column;
        gap: 20px;
    }
    
    .hash-container {
        width: 80px;
        height: 80px;
    }
    
    .hash-symbol {
        width: 80px;
        height: 80px;
        font-size: 60px;
    }
}

@media (max-width: 480px) {
    .screen {
        padding: 15px;
    }
    
    h1 {
        font-size: 32px;
        margin-bottom: 30px;
    }
    
    h2 {
        font-size: 26px;
    }
    
    .grid-container {
        grid-template-columns: repeat(5, 40px);
        grid-template-rows: repeat(5, 40px);
        padding: 8px;
    }
    
    .line.horizontal {
        width: 26px;
        height: 5px;
    }
    
    .line.vertical {
        height: 26px;
        width: 5px;
    }
    
    .square {
        width: 40px;
        height: 40px;
    }
    
    .potential-line.horizontal {
        width: 26px;
    }
    
    .potential-line.vertical {
        height: 26px;
    }
    
    .game-header {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
    
    .player-info, .score-display {
        width: 100%;
        flex-direction: row;
        justify-content: space-between;
    }
    
    .current-turn {
        font-size: 16px;
        padding: 8px 16px;
    }
    
    .score {
        font-size: 16px;
    }
    
    button {
        padding: 12px 24px;
        font-size: 16px;
    }
}

/* Game content wrapper for layout */
.game-content-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 40px;
    margin-bottom: 20px;
}

/* 3D Hash Symbol */
.hash-container {
    perspective: 1000px;
    width: 100px;
    height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.hash-title {
    font-size: 18px;
    font-weight: bold;
    color: #ffffff;
    margin-bottom: 10px;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.6);
    text-align: center;
}

.hash-symbol {
    width: 100px;
    height: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 80px;
    font-weight: bold;
    color: #4ecdc4;
    text-shadow: 0 0 10px rgba(78, 205, 196, 0.8);
    transform-style: preserve-3d;
    animation: rotateHash 8s infinite linear;
}

@keyframes rotateHash {
    0% {
        transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg);
    }
    25% {
        transform: rotateX(90deg) rotateY(45deg) rotateZ(90deg);
    }
    50% {
        transform: rotateX(180deg) rotateY(90deg) rotateZ(180deg);
    }
    75% {
        transform: rotateX(270deg) rotateY(135deg) rotateZ(270deg);
    }
    100% {
        transform: rotateX(360deg) rotateY(180deg) rotateZ(360deg);
    }
}
