/* ============================================
   LOOP'S ADVENTURE - PLATFORM GAME STYLES
   ============================================ */

/* ============================================
   CSS VARIABLES
   ============================================ */
:root {
    --bg-dark: #0d1b2a;
    --bg-medium: #1b263b;
    --bg-light: #243447;
    --text-primary: #e0e7ff;
    --text-secondary: #a3b8cc;
    --accent-green: #4a7c59;
    --accent-moss: #6b8f71;
    --accent-lavender: #9381ff;
    --accent-cyan: #7ec8e3;
    --accent-yellow: #ffd166;
    --accent-orange: #ef8354;
    --accent-red: #ff6b6b;
    --accent-pink: #fd79a8;
    --health-green: #55efc4;
    --health-red: #ff4757;
}

/* ============================================
   RESET & BASE
   ============================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Press Start 2P', monospace;
    background: var(--bg-dark);
    color: var(--text-primary);
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* ============================================
   GAME CONTAINER
   ============================================ */
#game-container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

/* ============================================
   GAME SCREENS
   ============================================ */
.game-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
}

.game-screen.active {
    display: flex;
}

.overlay-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.3s ease;
}

.overlay-screen.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ============================================
   MAIN MENU
   ============================================ */
.menu-content, .overlay-content {
    text-align: center;
    padding: 2rem;
}

.game-title {
    font-size: clamp(1.5rem, 6vw, 3rem);
    color: var(--accent-yellow);
    text-shadow: 
        4px 4px 0 var(--accent-orange),
        0 0 30px rgba(255, 209, 102, 0.5);
    margin-bottom: 1rem;
    animation: titlePulse 2s ease-in-out infinite;
}

@keyframes titlePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.menu-loop {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto;
    animation: menuFloat 3s ease-in-out infinite;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.5));
}

.menu-loop-frame {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
    opacity: 0;
}

.menu-loop-frame.frame-1 { animation: menuFrame1 1.2s steps(1) infinite; }
.menu-loop-frame.frame-2 { animation: menuFrame2 1.2s steps(1) infinite; }
.menu-loop-frame.frame-3 { animation: menuFrame3 1.2s steps(1) infinite; }
.menu-loop-frame.frame-4 { animation: menuFrame4 1.2s steps(1) infinite; }

@keyframes menuFrame1 {
    0%, 100% { opacity: 1; }
    25%, 99.9% { opacity: 0; }
}
@keyframes menuFrame2 {
    0%, 24.9% { opacity: 0; }
    25%, 49.9% { opacity: 1; }
    50%, 100% { opacity: 0; }
}
@keyframes menuFrame3 {
    0%, 49.9% { opacity: 0; }
    50%, 74.9% { opacity: 1; }
    75%, 100% { opacity: 0; }
}
@keyframes menuFrame4 {
    0%, 74.9% { opacity: 0; }
    75%, 99.9% { opacity: 1; }
    100% { opacity: 0; }
}

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

.menu-subtitle {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
    margin-bottom: 2rem;
}

.game-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.7rem;
    padding: 1rem 2rem;
    background: linear-gradient(180deg, var(--accent-lavender) 0%, #7b6bcc 100%);
    border: 4px solid #5a4a99;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5);
    box-shadow: 
        0 4px 0 #4a3a88,
        0 8px 15px rgba(0, 0, 0, 0.3);
    min-width: 200px;
}

.game-btn:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 6px 0 #4a3a88,
        0 12px 20px rgba(0, 0, 0, 0.4);
}

.game-btn:active {
    transform: translateY(2px);
    box-shadow: 
        0 2px 0 #4a3a88,
        0 4px 10px rgba(0, 0, 0, 0.3);
}

.game-btn.secondary {
    background: linear-gradient(180deg, #636e72 0%, #4a5568 100%);
    border-color: #3d4852;
    box-shadow: 
        0 4px 0 #2d3748,
        0 8px 15px rgba(0, 0, 0, 0.3);
}

.menu-info {
    font-size: 0.5rem;
    color: var(--text-secondary);
    line-height: 2;
}

/* ============================================
   CONTROLS SCREEN
   ============================================ */
.screen-title {
    font-size: 1.2rem;
    color: var(--accent-cyan);
    margin-bottom: 2rem;
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
    max-width: 500px;
}

.control-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.key {
    background: var(--bg-light);
    padding: 0.5rem 0.8rem;
    border-radius: 4px;
    border: 2px solid var(--accent-lavender);
    font-size: 0.5rem;
    min-width: 60px;
    text-align: center;
}

.action {
    font-size: 0.5rem;
    color: var(--text-secondary);
}

/* ============================================
   CHARACTER SELECT
   ============================================ */
.character-grid {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 2rem;
}

.char-option {
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.4);
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.char-option:hover, .char-option.selected {
    border-color: var(--accent-yellow);
    box-shadow: 0 0 20px rgba(255, 209, 102, 0.3);
    transform: translateY(-5px);
}

.char-sprite {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 auto 0.5rem;
}

.char-sprite-frame {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
    opacity: 0;
}

.char-sprite-frame.frame-1 { animation: menuFrame1 1.2s steps(1) infinite; }
.char-sprite-frame.frame-2 { animation: menuFrame2 1.2s steps(1) infinite; }
.char-sprite-frame.frame-3 { animation: menuFrame3 1.2s steps(1) infinite; }
.char-sprite-frame.frame-4 { animation: menuFrame4 1.2s steps(1) infinite; }

.char-name {
    font-size: 0.7rem;
    color: var(--accent-yellow);
    margin-bottom: 0.3rem;
}

.char-desc {
    font-size: 0.4rem;
    color: var(--text-secondary);
}

/* ============================================
   GAME AREA
   ============================================ */
#game-area {
    flex-direction: column;
}

#game-canvas {
    display: block;
    background: #1a1a2e;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* ============================================
   HUD
   ============================================ */
#game-hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.7) 0%, transparent 100%);
    z-index: 50;
}

.hud-left, .hud-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.hud-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.level-text {
    font-size: 0.6rem;
    color: var(--accent-yellow);
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.8);
}

.hud-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.hud-icon {
    font-size: 1.2rem;
}

.hud-value {
    font-size: 0.7rem;
    min-width: 40px;
}

.health-item {
    gap: 0.3rem;
}

.health-sprite {
    height: 32px;
    width: auto;
    image-rendering: pixelated;
    filter: drop-shadow(2px 2px 2px rgba(0, 0, 0, 0.5));
}

.health-text {
    font-size: 0.5rem;
    min-width: 30px;
}

.hud-btn {
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 0.5rem;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.hud-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-lavender);
}

/* ============================================
   MOBILE CONTROLS
   ============================================ */
#mobile-controls {
    display: none;
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    justify-content: space-between;
    z-index: 60;
}

@media (max-width: 768px), (pointer: coarse) {
    #mobile-controls {
        display: flex;
    }
}

.mobile-left, .mobile-right {
    display: flex;
    gap: 10px;
}

.mobile-btn {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.2);
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    font-size: 1.5rem;
    color: white;
    cursor: pointer;
    transition: all 0.1s ease;
    -webkit-tap-highlight-color: transparent;
}

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

.mobile-btn.jump {
    background: rgba(85, 239, 196, 0.3);
    border-color: rgba(85, 239, 196, 0.6);
}

.mobile-btn.attack {
    background: rgba(255, 107, 107, 0.3);
    border-color: rgba(255, 107, 107, 0.6);
}

/* ============================================
   OVERLAY SCREENS
   ============================================ */
.overlay-content h2 {
    font-size: 1.5rem;
    margin-bottom: 2rem;
    color: var(--accent-yellow);
}

.game-over-title {
    color: var(--accent-red) !important;
    animation: gameOverShake 0.5s ease;
}

@keyframes gameOverShake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-10px); }
    40%, 80% { transform: translateX(10px); }
}

.victory-title {
    color: var(--accent-yellow) !important;
    animation: victoryBounce 0.5s ease;
}

@keyframes victoryBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.final-stats, .level-stats {
    margin-bottom: 2rem;
    font-size: 0.6rem;
    line-height: 2;
}

.stat-star {
    font-size: 2rem;
    margin-bottom: 1rem;
    animation: starSpin 1s ease;
}

@keyframes starSpin {
    from { transform: rotateY(0deg); }
    to { transform: rotateY(360deg); }
}

.overlay-content .game-btn {
    margin-bottom: 0.5rem;
}

/* ============================================
   DIALOG BOX
   ============================================ */
.dialog {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 600px;
    background: rgba(0, 0, 0, 0.9);
    border: 4px solid var(--accent-lavender);
    border-radius: 12px;
    padding: 1.5rem;
    display: none;
    z-index: 80;
    animation: dialogSlide 0.3s ease;
}

.dialog.active {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

@keyframes dialogSlide {
    from {
        transform: translateX(-50%) translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

.dialog-portrait {
    font-size: 3rem;
    background: var(--bg-light);
    padding: 0.5rem;
    border-radius: 8px;
    border: 2px solid var(--accent-cyan);
}

.dialog-content {
    flex: 1;
}

.dialog-name {
    font-size: 0.7rem;
    color: var(--accent-yellow);
    margin-bottom: 0.5rem;
}

.dialog-text {
    font-size: 0.5rem;
    line-height: 1.8;
    color: var(--text-primary);
}

.dialog-prompt {
    position: absolute;
    bottom: 8px;
    right: 15px;
    font-size: 0.4rem;
    color: var(--text-secondary);
    animation: promptBlink 1s ease-in-out infinite;
}

@keyframes promptBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ============================================
   FLOATING MESSAGES
   ============================================ */
#floating-messages {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 70;
}

.float-msg {
    position: absolute;
    font-size: 0.8rem;
    font-family: 'Press Start 2P', monospace;
    animation: floatUp 1.5s ease-out forwards;
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.8);
    pointer-events: none;
}

.float-msg.heal {
    color: var(--health-green);
}

.float-msg.damage {
    color: var(--health-red);
}

.float-msg.score {
    color: var(--accent-yellow);
}

.float-msg.gem {
    color: var(--accent-cyan);
}

@keyframes floatUp {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-50px) scale(1.2);
    }
}

/* ============================================
   LOADING ANIMATION
   ============================================ */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.loading-dots {
    display: flex;
    gap: 0.5rem;
}

.loading-dot {
    width: 12px;
    height: 12px;
    background: var(--accent-lavender);
    border-radius: 50%;
    animation: loadingBounce 1s ease-in-out infinite;
}

.loading-dot:nth-child(2) { animation-delay: 0.2s; }
.loading-dot:nth-child(3) { animation-delay: 0.4s; }

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

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 600px) {
    .game-title {
        font-size: 1.5rem;
    }
    
    .menu-loop {
        font-size: 4rem;
    }
    
    .game-btn {
        font-size: 0.6rem;
        padding: 0.8rem 1.5rem;
        min-width: 160px;
    }
    
    .controls-grid {
        grid-template-columns: 1fr;
    }
    
    #game-hud {
        padding: 8px 12px;
    }
    
    .health-sprite {
        height: 24px;
    }
    
    .hud-value {
        font-size: 0.5rem;
    }
    
    .level-text {
        font-size: 0.5rem;
    }
    
    .mobile-btn {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
}

/* ============================================
   SCROLLBAR
   ============================================ */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--accent-lavender);
    border-radius: 4px;
}

