:root {
    --primary-color: #00d2ff;
    /* Schtroumpf Blue */
    --accent-color: #ffd700;
    /* Star Gold */
    --text-color: #ffffff;
    --bg-color: #333;
}

* {
    box-sizing: border-box;
    user-select: none;
    touch-action: none;
    /* Prevent default touch actions like scrolling */
}

body,
html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #000;
    font-family: 'Fredoka One', cursive, sans-serif;
}

button,
input,
select,
textarea {
    font-family: 'Fredoka One', cursive, sans-serif;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* Maintain aspect ratio if we enforce one, currently responsive */
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    /* Let clicks pass through to canvas principally, enable for buttons */
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.7);
    color: var(--text-color);
    pointer-events: auto;
    transition: opacity 0.3s;
    z-index: 100;
    /* Ensure screens are above other UI elements */
}

.hidden {
    opacity: 0;
    pointer-events: none !important;
}

.active {
    opacity: 1;
    pointer-events: auto;
}

h1 {
    font-size: 4rem;
    color: var(--primary-color);
    text-shadow: 3px 3px 0px #000;
    margin-bottom: 20px;
    text-align: center;
}

p {
    font-size: 1.5rem;
    margin-bottom: 30px;
}

#progress-container {
    position: absolute;
    bottom: 20px;
    left: 10%;
    width: 80%;
    height: 30px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 15px;
    display: flex;
    align-items: center;
    padding: 0 10px;
    border: 2px solid white;
}

#azrael-icon {
    font-size: 24px;
    position: absolute;
    left: -10px;
    /* Chasing from behind */
    animation: bounce 1s infinite alternate;
}

#progress-bar {
    width: 100%;
    height: 10px;
    background: #555;
    border-radius: 5px;
    position: relative;
    margin: 0 10px;
}

#player-progress-icon {
    position: absolute;
    top: -15px;
    left: 0%;
    /* Dynamic */
    font-size: 24px;
    transition: left 0.5s linear;
}

#goal-icon {
    font-size: 24px;
}

@keyframes bounce {
    from {
        transform: translateY(0);
    }

    to {
        transform: translateY(-5px);
    }
}

.btn-primary {
    padding: 15px 40px;
    font-size: 2rem;
    font-family: inherit;
    background-color: var(--primary-color);
    color: white;
    border: 4px solid white;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 5px 0 #0099cc;
    transition: transform 0.1s, box-shadow 0.1s;
}

.btn-primary:active {
    transform: translateY(4px);
    box-shadow: 0 1px 0 #0099cc;
}

#hud {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    gap: 20px;
    font-size: 2rem;
    color: white;
    text-shadow: 2px 2px 0 #000;
}

.bubble {
    position: absolute;
    /* Positioned by JS */
    background: white;
    color: black;
    padding: 15px 25px;
    border-radius: 30px;
    font-size: 2.5rem;
    border: 4px solid black;
    transform: translate(-50%, -150%);
    /* Center horizontally, move up */
}

.bubble::after {
    content: '';
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 15px 15px 0;
    border-style: solid;
    border-color: black transparent transparent transparent;
}

/* Ensure inner bubble tail matches white bg */
.bubble::before {
    content: '';
    position: absolute;
    bottom: -9px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 12px 12px 0;
    border-style: solid;
    border-color: white transparent transparent transparent;
    z-index: 1;
}

#gargamel-screen h2 {
    color: #ff4444;
    font-size: 3rem;
}

/* Math Overlay & Keyboard */
#math-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: auto;
    /* Allow clicks on keyboard */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    /* Keyboard at bottom */
    padding-bottom: 50px;
}

.keyboard {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    background: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.key-btn {
    width: 80px;
    height: 80px;
    background: #00d2ff;
    color: white;
    font-size: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 15px;
    cursor: pointer;
    box-shadow: 0 4px 0 #0099cc;
    transition: transform 0.1s;
}

.key-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #0099cc;
}

/* Specific style for OK button */
.key-btn:last-child {
    background: #4CAF50;
    box-shadow: 0 4px 0 #388E3C;
}

.key-btn:last-child:active {
    box-shadow: 0 0 0 #388E3C;
}

/* Virtual Game Controls */
#virtual-controls {
    position: absolute;
    bottom: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    pointer-events: auto;
}

.control-btn {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.5);
    border: 3px solid white;
    border-radius: 50%;
    font-size: 2.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    touch-action: manipulation;
}

.control-btn:active {
    background: rgba(255, 255, 255, 0.8);
    transform: scale(0.95);
}

/* Profile & Menu Styles */
.profile-grid {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 30px;
}

.profile-card {
    background: white;
    color: black;
    border-radius: 15px;
    padding: 20px;
    width: 200px;
    cursor: pointer;
    transition: transform 0.2s;
    border: 4px solid var(--primary-color);
}

.profile-card:hover {
    transform: scale(1.1);
}

/* Modal */
.modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
    pointer-events: auto;
    /* Fix: Override parent's pointer-events: none */
}

.modal-content {
    background: white;
    padding: 20px;
    border-radius: 15px;
    text-align: center;
    border: 4px solid #2c3e50;
}

.modal-content input {
    font-size: 24px;
    padding: 10px;
    border-radius: 10px;
    border: 2px solid #ccc;
    margin-bottom: 20px;
    width: 200px;
    text-align: center;
}

.profile-card .avatar {
    font-size: 3rem;
    text-align: center;
    margin-bottom: 10px;
}

.profile-card .name {
    font-weight: bold;
    font-size: 1.5rem;
    text-align: center;
}

.profile-card .score {
    font-size: 1rem;
    color: #666;
    text-align: center;
}

.btn-secondary {
    padding: 10px 20px;
    font-size: 1.2rem;
    font-family: inherit;
    background-color: white;
    color: var(--primary-color);
    border: 3px solid var(--primary-color);
    border-radius: 30px;
    cursor: pointer;
    margin-top: 10px;
}