:root {
    --bg-color: #0b0f19;
    --primary-glow: #00f0ff;
    --secondary-glow: #ff003c;
    --text-color: #ffffff;
    --ui-bg: rgba(255, 255, 255, 0.05);
    --border-glow: rgba(0, 240, 255, 0.5);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-color);
    background-image: radial-gradient(circle at 50% 50%, #161f36 0%, var(--bg-color) 100%);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
}

#game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 800px;
    height: 100vh;
    padding: 10px;
}

#ui-header {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 600px;
    margin-bottom: 10px;
    z-index: 10;
}

.ui-element {
    background: var(--ui-bg);
    padding: 10px 20px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    backdrop-filter: blur(10px);
    font-size: 1.2rem;
    font-weight: 700;
    text-align: center;
}

.problem-panel {
    font-size: 1.8rem;
    font-weight: 900;
    color: var(--primary-glow);
    text-shadow: 0 0 10px var(--border-glow);
    border: 1px solid var(--border-glow);
}

#canvas-container {
    position: relative;
    width: 100%;
    max-width: 600px;
    aspect-ratio: 1/1;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 0 30px rgba(0, 240, 255, 0.15);
    border: 2px solid rgba(0, 240, 255, 0.2);
}

canvas {
    width: 100%;
    height: 100%;
    display: block;
    background-color: #050811; /* Darker than body */
}

/* OVERLAY PANTALLA INICIAL / GAME OVER */
#overlay-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(11, 15, 25, 0.85);
    backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 20;
    transition: opacity 0.3s;
}

#overlay-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

#overlay-title {
    font-size: 3.5rem;
    font-weight: 900;
    color: transparent;
    background-clip: text;
    -webkit-background-clip: text;
    background-image: linear-gradient(90deg, #00f0ff, #ff00ff);
    margin-bottom: 20px;
    text-shadow: 0 0 20px rgba(0, 240, 255, 0.5);
    text-align: center;
}

#overlay-message {
    font-size: 1.5rem;
    margin-bottom: 40px;
    color: #ffd700; /* Gold */
}

#overlay-btn {
    padding: 15px 40px;
    font-size: 1.5rem;
    font-weight: 900;
    cursor: pointer;
    background: transparent;
    color: #fff;
    border: 2px solid #00f0ff;
    border-radius: 30px;
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.5), inset 0 0 15px rgba(0, 240, 255, 0.2);
    text-transform: uppercase;
    transition: all 0.2s ease;
}

#overlay-btn:hover {
    background: #00f0ff;
    color: #000;
    box-shadow: 0 0 30px #00f0ff;
}

/* TABLE SELECTION GRID */
.table-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 20px;
    width: 80%;
    max-width: 400px;
}

.table-btn {
    padding: 10px 15px;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(0, 240, 255, 0.5);
    border-radius: 12px;
    backdrop-filter: blur(5px);
    transition: all 0.2s ease;
}

.table-btn:hover {
    background: rgba(0, 240, 255, 0.3);
    border-color: #00f0ff;
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.5);
    transform: scale(1.05);
}

.hidden {
    display: none !important;
}

/* TOUCH CONTROLS (D-PAD) */
#dpad-container {
    display: none; /* Hidden on large screens */
    flex-direction: column;
    align-items: center;
    margin-top: 20px;
    gap: 10px;
}

.dpad-row {
    display: flex;
    gap: 10px;
}

.dpad-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--ui-bg);
    border: 2px solid rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background 0.1s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.dpad-btn:active {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(0.95);
    border-color: var(--primary-glow);
    box-shadow: 0 0 15px var(--border-glow);
}

/* MEDIA QUERIES FOR MOBILE */
@media (max-width: 600px), (max-height: 800px) {
    #dpad-container {
        display: flex;
    }
    
    #game-container {
        justify-content: flex-start;
        padding-top: 10px;
    }

    #overlay-title {
        font-size: 2.5rem;
    }
    
    #overlay-message {
        font-size: 1.1rem;
        margin-bottom: 15px;
    }

    .table-grid {
        gap: 10px;
        width: 95%;
    }

    .table-btn {
        padding: 10px;
        font-size: 1rem;
        min-height: 48px; /* Minimum touch target size */
    }

    .ui-element {
        padding: 5px 10px;
        font-size: 0.9rem;
    }
    
    .problem-panel {
        font-size: 1.2rem;
    }
}
