/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Fredoka', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    overflow: hidden;
    color: #333;
}

/* Screen System */
.screen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.screen.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Main Menu */
.menu-container {
    text-align: center;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
}

.game-title {
    margin-bottom: 2rem;
    position: relative;
}

.game-title h1 {
    font-size: 3rem;
    font-weight: 700;
    color: white;
    text-shadow: 4px 4px 0 rgba(0,0,0,0.2);
    margin-bottom: 0.5rem;
    animation: bounce 2s ease-in-out infinite;
}

.game-title .subtitle {
    font-size: 1rem;
    color: rgba(255,255,255,0.9);
    background: rgba(255,255,255,0.2);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    display: inline-block;
}

.emoji-float {
    font-size: 2.5rem;
    display: inline-block;
    animation: float 3s ease-in-out infinite;
}

.emoji-float.delay {
    animation-delay: 1.5s;
}

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

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

/* Menu Buttons */
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.menu-btn {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.2rem;
    font-weight: 600;
    padding: 1rem 2rem;
    border: none;
    border-radius: 50px;
    background: white;
    color: #667eea;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.menu-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.menu-btn:active {
    transform: translateY(0);
}

.menu-btn.play-btn {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    font-size: 1.4rem;
}

.back-btn {
    margin-top: 2rem;
    background: rgba(255,255,255,0.2);
    color: white;
}

.back-btn:hover {
    background: rgba(255,255,255,0.3);
}

.high-score-display {
    margin-top: 2rem;
    color: white;
    font-size: 1.1rem;
    background: rgba(255,255,255,0.1);
    padding: 1rem;
    border-radius: 15px;
}

/* Info Screens */
.info-container {
    background: white;
    border-radius: 25px;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.info-container h2 {
    font-size: 1.8rem;
    color: #667eea;
    margin-bottom: 1.5rem;
    text-align: center;
}

.info-content {
    text-align: left;
}

.info-section {
    margin-bottom: 1.5rem;
}

.info-section h3 {
    font-size: 1.2rem;
    color: #764ba2;
    margin-bottom: 0.5rem;
}

.info-section p, .info-section li {
    color: #666;
    line-height: 1.6;
}

.info-section ul {
    list-style: none;
    padding: 0;
}

.info-section li {
    padding: 0.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Controls Grid */
.controls-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.control-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: #f5f5f5;
    border-radius: 10px;
}

.key {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 0.3rem 0.6rem;
    border-radius: 5px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* NPC and Powerup Icons */
.npc-icon, .powerup-icon {
    font-size: 1.5rem;
}

/* Settings */
.settings-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: #f5f5f5;
    border-radius: 15px;
}

.setting-item label {
    font-weight: 600;
    color: #444;
}

.toggle-btn {
    font-family: 'Fredoka', sans-serif;
    font-weight: 600;
    padding: 0.5rem 1.5rem;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.toggle-btn.on {
    background: linear-gradient(135deg, #11998e, #38ef7d);
    color: white;
}

.toggle-btn.off {
    background: #ddd;
    color: #666;
}

#difficulty-select {
    font-family: 'Fredoka', sans-serif;
    font-size: 1rem;
    padding: 0.5rem 1rem;
    border: 2px solid #667eea;
    border-radius: 10px;
    background: white;
    color: #667eea;
    cursor: pointer;
}

/* Level Select */
.level-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
}

.level-card {
    position: relative;
    background: #f5f5f5;
    border-radius: 15px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0.5;
    pointer-events: none;
}

.level-card.unlocked {
    opacity: 1;
    pointer-events: auto;
}

.level-card.unlocked:hover {
    transform: translateX(5px);
    background: #e8e8e8;
}

.level-number {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
}

.level-name {
    font-size: 1.2rem;
    font-weight: 600;
    color: #333;
}

.level-stars {
    font-size: 1.2rem;
    color: #ffc107;
}

.level-desc {
    font-size: 0.9rem;
    color: #666;
}

.lock-overlay {
    position: absolute;
    right: 1rem;
    font-size: 1.5rem;
}

/* Game Screen */
#game-screen {
    background: #1a1a2e;
    flex-direction: column;
}

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

/* Game HUD */
.game-hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(0,0,0,0.5);
    z-index: 10;
}

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

.hud-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: white;
    font-weight: 600;
    background: rgba(255,255,255,0.1);
    padding: 0.5rem 1rem;
    border-radius: 25px;
}

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

.hud-center {
    flex: 1;
    display: flex;
    justify-content: center;
}

.powerup-slot {
    background: rgba(255,255,255,0.1);
    border: 2px dashed rgba(255,255,255,0.3);
    padding: 0.5rem 1.5rem;
    border-radius: 25px;
    color: white;
    min-width: 150px;
    text-align: center;
}

.powerup-slot.has-powerup {
    background: rgba(255,215,0,0.3);
    border: 2px solid gold;
}

.powerup-empty {
    color: rgba(255,255,255,0.5);
    font-size: 0.9rem;
}

.hud-btn {
    font-size: 1.5rem;
    background: rgba(255,255,255,0.2);
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.hud-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.1);
}

/* Game Canvas */
#game-canvas {
    display: block;
    margin: auto;
    image-rendering: pixelated;
}

/* Mobile Controls */
.mobile-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: none;
    justify-content: space-between;
    align-items: flex-end;
    padding: 1rem;
    z-index: 20;
}

.mobile-controls.show {
    display: flex;
}

.d-pad {
    position: relative;
    width: 140px;
    height: 140px;
}

.d-btn {
    position: absolute;
    width: 50px;
    height: 50px;
    background: rgba(255,255,255,0.3);
    border: none;
    border-radius: 10px;
    font-size: 1.5rem;
    color: white;
    cursor: pointer;
    transition: all 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.d-btn.up { top: 0; left: 50%; transform: translateX(-50%); }
.d-btn.down { bottom: 0; left: 50%; transform: translateX(-50%); }
.d-btn.left { left: 0; top: 50%; transform: translateY(-50%); }
.d-btn.right { right: 0; top: 50%; transform: translateY(-50%); }

.action-buttons {
    display: flex;
    gap: 1rem;
}

.action-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: none;
    font-family: 'Fredoka', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.1s ease;
}

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

.use-btn {
    background: linear-gradient(135deg, #f093fb, #f5576c);
    color: white;
}

/* Detection Bar */
.detection-bar {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 30px;
    background: rgba(0,0,0,0.7);
    border-radius: 15px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 30;
}

.detection-bar.hidden {
    display: none;
}

.detection-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: linear-gradient(90deg, #ff6b6b, #ff0000);
    transition: width 0.1s linear;
}

.detection-bar span {
    position: relative;
    z-index: 1;
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
}

/* Overlays */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.overlay.hidden {
    display: none;
}

.overlay-content {
    background: white;
    border-radius: 25px;
    padding: 2rem;
    text-align: center;
    max-width: 400px;
    width: 90%;
    animation: popIn 0.3s ease;
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.overlay-content h2 {
    font-size: 1.8rem;
    color: #667eea;
    margin-bottom: 1.5rem;
}

.pause-buttons, .complete-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

/* Caught Screen */
.caught-content {
    background: linear-gradient(135deg, #ff9a9e, #fecfef);
}

.caught-content h2 {
    color: #ff4757;
}

.caught-emoji {
    font-size: 4rem;
    margin-bottom: 1rem;
}

#caught-message {
    color: #666;
    margin-bottom: 1.5rem;
}

/* Level Complete */
.complete-content {
    background: linear-gradient(135deg, #a8edea, #fed6e3);
}

.complete-content h2 {
    color: #00b894;
}

.complete-emoji {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.stats-display {
    margin-bottom: 1.5rem;
}

.stat {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(0,0,0,0.1);
}

.stat-label {
    color: #666;
}

.stat-value {
    font-weight: 700;
    color: #333;
}

.stars-display {
    font-size: 2.5rem;
    margin-top: 1rem;
}

.final-stats {
    margin: 1.5rem 0;
    padding: 1rem;
    background: rgba(255,255,255,0.5);
    border-radius: 15px;
}

/* Responsive */
@media (max-width: 600px) {
    .game-title h1 {
        font-size: 2.2rem;
    }

    .menu-btn {
        font-size: 1rem;
        padding: 0.8rem 1.5rem;
    }

    .info-container {
        padding: 1.5rem;
    }

    .controls-grid {
        grid-template-columns: 1fr;
    }

    .game-hud {
        padding: 0.5rem;
        flex-wrap: wrap;
    }

    .hud-item {
        padding: 0.3rem 0.6rem;
        font-size: 0.9rem;
    }

    .powerup-slot {
        min-width: 120px;
        font-size: 0.9rem;
    }
}

/* Touch device detection */
@media (pointer: coarse) {
    .mobile-controls {
        display: flex;
    }
}

/* Scrollbar styling */
.info-container::-webkit-scrollbar {
    width: 8px;
}

.info-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.info-container::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 10px;
}

.info-container::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}
