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

:root {
    --bg-color: #87CEEB;
    --ground-color: #228B22;
    --ui-bg: rgba(255, 255, 255, 0.95);
    --text-color: #2d3436;
    --accent-color: #ff4757;
    --btn-shadow: #26af5c;
    --font-main: 'Fredoka', sans-serif;
}

body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-main);
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-color);
    transition: background-color 0.8s ease;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(45, 52, 54, 0.6);
    backdrop-filter: blur(3px);
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    text-align: center;
}

.hidden {
    display: none !important;
}

/* Animations */
@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}
.bounce {
    animation: bounce 2s infinite ease-in-out;
    font-size: 3.5rem;
    text-shadow: 4px 4px 0px #ff4757;
    margin-bottom: 2rem;
}

.level-up-msg {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 5rem;
    color: #f1c40f;
    text-shadow: 5px 5px 0px #d35400;
    font-weight: bold;
    z-index: 50;
    pointer-events: none;
    animation: levelUpPop 1.5s forwards;
}

@keyframes levelUpPop {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
    50% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
    100% { transform: translate(-50%, -100%) scale(1); opacity: 0; }
}

/* UI Elements */
#ui-layer {
    position: absolute;
    top: 15px;
    left: 15px;
    right: 15px;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    z-index: 10;
}

#equation-container {
    background: var(--ui-bg);
    color: var(--text-color);
    padding: 15px 25px;
    border-radius: 25px;
    font-size: 32px;
    font-weight: bold;
    box-shadow: 0 8px 0px rgba(0,0,0,0.1);
    border: 4px solid var(--accent-color);
}

#lives-container {
    margin-top: 10px;
    display: flex;
    gap: 5px;
}

.heart {
    width: 30px;
    height: 30px;
    background: #ff4757;
    position: relative;
    transform: rotate(-45deg);
    margin: 10px;
}
.heart:before, .heart:after {
    content: "";
    width: 30px;
    height: 30px;
    background: #ff4757;
    border-radius: 50%;
    position: absolute;
}
.heart:before { top: -15px; left: 0; }
.heart:after { left: 15px; top: 0; }

#stats-container {
    background: var(--ui-bg);
    color: var(--text-color);
    padding: 15px 20px;
    border-radius: 25px;
    box-shadow: 0 8px 0px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.hud-item {
    font-size: 1.2rem;
    font-weight: bold;
}

#player-display {
    color: #2ed573;
    font-weight: bold;
}

/* Avatar Selection */
.avatar-selection {
    margin-bottom: 1rem;
    width: 90%;
    max-width: 600px;
}

.avatar-grid {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 10px;
}

.avatar-option {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 4px solid transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 120px;
}

.avatar-option span {
    font-size: 1rem;
    font-weight: bold;
}

.avatar-option.selected {
    background: rgba(241, 196, 15, 0.1);
    border-color: #f1c40f;
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(241, 196, 15, 0.3);
}

.avatar-canvas {
    width: 80px;
    height: 80px;
}

/* Theme Selection */
.theme-selection {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 1rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 10px 20px;
    border-radius: 50px;
}

.theme-selection p { margin: 0; font-weight: bold; }

.btn-theme-small {
    padding: 8px 15px;
    font-size: 0.9rem;
    border-radius: 20px;
    margin: 0;
    box-shadow: none;
}

.btn-theme-small.sky { background: #3498db; color: white; opacity: 0.7; }
.btn-theme-small.underwater { background: #2980b9; color: white; opacity: 0.7; }
.btn-theme-small.desert { background: #e67e22; color: white; opacity: 0.7; }

.btn-theme-small.active {
    opacity: 1 !important;
    box-shadow: 0 4px 0px rgba(0,0,0,0.2);
    transform: scale(1.1);
}

.btn-play-large {
    background: #2ed573;
    color: white;
    font-size: 2.5rem;
    padding: 15px 60px;
    border-radius: 100px;
    box-shadow: 0 10px 0px #26af5c;
    margin: 1.5rem 0;
    transition: all 0.2s;
    animation: pulse 2s infinite;
}

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

.btn-play-large:active {
    transform: translateY(6px);
    box-shadow: 0 4px 0px #26af5c;
}

/* Form Elements */
.input-group {
    margin-bottom: 1rem;
}

input[type="text"] {
    padding: 15px 25px;
    font-size: 1.5rem;
    border-radius: 50px;
    border: 4px solid #2ed573;
    outline: none;
    font-family: var(--font-main);
    text-align: center;
}

/* Buttons */
button {
    padding: 15px 35px;
    font-size: 1.2rem;
    cursor: pointer;
    border: none;
    border-radius: 50px;
    font-family: var(--font-main);
    font-weight: bold;
    transition: all 0.1s;
    text-transform: uppercase;
}

.btn-main {
    background: #2ed573;
    color: white;
    box-shadow: 0 6px 0px var(--btn-shadow);
}

.btn-theme {
    margin: 10px;
    box-shadow: 0 6px 0px rgba(0,0,0,0.2);
    color: white;
}

.btn-theme.sky { background: #3498db; }
.btn-theme.underwater { background: #2980b9; }
.btn-theme.desert { background: #e67e22; }

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

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 2rem 0;
}

.stat-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 15px;
    font-size: 1.5rem;
}

/* Mobile Adjustments */
@media (max-width: 600px) {
    .bounce { font-size: 2.2rem; }
    #equation-container { font-size: 24px; padding: 10px 15px; }
    .stat-item { font-size: 1.2rem; }
    input[type="text"] { font-size: 1.2rem; width: 80%; }
    .level-up-msg { font-size: 3rem; }
}

/* Themes */
.theme-sky {
    --bg-color: #87CEEB;
    --ground-color: #2ed573;
    --ui-bg: rgba(255, 255, 255, 0.9);
    --text-color: #2d3436;
    --accent-color: #ff7675;
}

.theme-underwater {
    --bg-color: #0984e3;
    --ground-color: #fdcb6e;
    --ui-bg: rgba(255, 255, 255, 0.9);
    --text-color: #2d3436;
    --accent-color: #00cec9;
}

.theme-desert {
    --bg-color: #fab1a0;
    --ground-color: #e17055;
    --ui-bg: rgba(255, 255, 255, 0.9);
    --text-color: #2d3436;
    --accent-color: #d63031;
}
