:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --secondary: #10b981;
    --accent: #f59e0b;
    --danger: #ef4444;
    --bg-main: #f8fafc;
    --card-bg: rgba(255, 255, 255, 0.8);
    --text-main: #1e293b;
    --text-muted: #64748b;
    --radius-lg: 24px;
    --radius-md: 16px;
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --font-head: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: #0f172a;
    font-family: var(--font-body);
    color: var(--text-main);
    overflow: hidden;
    height: 100dvh;
    width: 100vw;
    display: flex;
    justify-content: center;
}

#game-container {
    width: 100%;
    max-width: 500px;
    height: 100%;
    background-color: var(--bg-main);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none !important;
    flex-direction: column;
    z-index: 10;
    padding: 20px;
}

.screen.active {
    display: flex !important;
    animation: fadeIn 0.4s ease-out;
}

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

/* Splash Screen */
#screen-splash {
    background: radial-gradient(circle at top right, #6366f1, #4f46e5);
    justify-content: center;
    align-items: center;
    text-align: center;
    color: white;
}

.pixel-title {
    font-family: var(--font-head);
    font-weight: 800;
    font-size: 3rem;
    letter-spacing: -2px;
    margin-bottom: 5px;
}

.pixel-title .go {
    color: var(--accent);
    background: white;
    padding: 0 10px;
    border-radius: 12px;
    margin-left: 5px;
}

.subtitle {
    font-size: 1rem;
    opacity: 0.9;
    margin-bottom: 40px;
}

.starter-preview {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    padding: 40px;
    backdrop-filter: blur(10px);
    margin-bottom: 40px;
    box-shadow: var(--shadow-lg);
}

.starter-preview img {
    width: 180px;
    filter: drop-shadow(0 10px 20px rgba(0,0,0,0.2));
}

.bounce {
    animation: bounce 2s infinite ease-in-out;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

.btn-retro {
    background: white;
    color: var(--primary-dark);
    border: none;
    border-radius: 20px;
    padding: 16px 40px;
    font-family: var(--font-head);
    font-weight: 800;
    font-size: 1.2rem;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-retro:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-lg);
}

.btn-retro:active {
    transform: scale(0.95);
}

/* World Screen */
#screen-world {
    background-color: #f1f5f9;
    padding: 0;
}

.game-header {
    background: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e2e8f0;
    box-shadow: var(--shadow-sm);
}

.player-info {
    display: flex;
    flex-direction: column;
}

#player-lvl {
    font-family: var(--font-head);
    font-weight: 800;
    color: var(--primary);
    font-size: 0.9rem;
}

#player-name {
    font-size: 1.1rem;
    font-weight: 700;
}

.world-selector {
    flex: 1;
    padding: 20px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    overflow-y: auto;
}

.world-card {
    background: white;
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
    border: 1px solid transparent;
}

.world-card:not(.locked):hover {
    transform: translateX(5px);
    border-color: var(--primary-light);
    box-shadow: var(--shadow-md);
}

.world-card.locked {
    opacity: 0.6;
    background: #e2e8f0;
}

.world-icon {
    font-size: 2.5rem;
    background: #f8fafc;
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
}

.world-info h3 {
    font-family: var(--font-head);
    font-size: 1.2rem;
    margin-bottom: 4px;
}

.world-info p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.bottom-nav {
    background: white;
    display: flex;
    justify-content: space-around;
    padding: 15px;
    border-top: 1px solid #e2e8f0;
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.05);
}

.btn-icon {
    background: #f8fafc;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 14px;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.4);
}

/* Battle Screen */
#screen-battle {
    padding: 0;
    background: #e0f2fe;
}

.battle-bg {
    flex: 1;
    position: relative;
    background: linear-gradient(180deg, #e0f2fe 0%, #ffffff 100%);
    overflow: hidden;
}

.box-retro {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    border-radius: 16px;
    padding: 12px;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.enemy-status {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 200px;
}

.player-status {
    position: absolute;
    bottom: 40px;
    right: 20px;
    width: 200px;
}

.name-bar {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-weight: 700;
    font-size: 0.9rem;
}

.hp-bar-bg {
    height: 10px;
    background: #e2e8f0;
    border-radius: 5px;
    overflow: hidden;
}

.hp-fill {
    height: 100%;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.hp-fill.green { background: linear-gradient(90deg, #10b981, #34d399); }
.hp-fill.yellow { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.hp-fill.red { background: linear-gradient(90deg, #ef4444, #f87171); }

.enemy-sprite-container, .player-sprite-container {
    position: absolute;
    transition: all 0.3s;
}

.enemy-sprite-container { top: 15%; right: 10%; }
.player-sprite-container { bottom: 15%; left: 10%; }

#enemy-sprite, #player-sprite {
    width: clamp(100px, 30vw, 160px);
    filter: drop-shadow(0 20px 30px rgba(0,0,0,0.15));
    mix-blend-mode: multiply; /* Helps blend white backgrounds into the UI */
}

.battle-ui {
    background: white;
    padding: 24px;
    border-radius: 32px 32px 0 0;
    box-shadow: 0 -10px 25px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.dialog-box {
    background: #f8fafc;
    border-radius: 16px;
    padding: 16px;
    min-height: 70px;
    display: flex;
    align-items: center;
    border: 1px solid #e2e8f0;
}

.dialog-box p {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-main);
    line-height: 1.4;
}

.action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.action-grid .btn-retro {
    padding: 14px;
    font-size: 1rem;
    border-radius: 16px;
}

#btn-attack { background: var(--primary); color: white; }
#btn-capture { background: var(--secondary); color: white; }
#btn-flee { 
    grid-column: span 2; 
    background: #f1f5f9; 
    color: var(--text-muted); 
    font-size: 0.9rem;
    padding: 10px;
}

.math-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
    animation: slideUp 0.3s ease-out;
}

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

.problem-display {
    font-family: var(--font-head);
    font-size: 2.2rem;
    font-weight: 800;
    text-align: center;
    color: var(--primary-dark);
}

.answer-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.btn-ans {
    padding: 18px;
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 1.3rem;
    border: 2px solid #e2e8f0;
    background: white;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-ans:hover {
    border-color: var(--primary);
    background: #f5f3ff;
    transform: translateY(-2px);
}

/* Overlays */
.overlay {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(12px);
}

.evo-content h2 {
    font-family: var(--font-head);
    font-size: 1.8rem;
    margin-bottom: 30px;
}

.hidden { display: none !important; }

/* Responsive Adjustments */
@media (max-width: 380px) {
    .pixel-title { font-size: 2.2rem; }
    .starter-preview { padding: 20px; }
    .starter-preview img { width: 120px; }
    .problem-display { font-size: 1.8rem; }
    .btn-ans { padding: 12px; font-size: 1.1rem; }
}

@media (max-height: 650px) {
    .starter-preview { margin-bottom: 20px; }
    .battle-bg { min-height: 180px; }
    .battle-ui { padding: 16px; }
    .dialog-box { min-height: 50px; }
}
