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

body {
    font-family: 'Courier New', monospace;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #fff;
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* Loading Screen */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-content {
    text-align: center;
    padding: 20px;
}

.loading-content h1 {
    font-size: 2em;
    margin-bottom: 20px;
    text-shadow: 0 0 10px #ff6b6b;
}

.loading-spinner {
    font-size: 3em;
    animation: spin 2s linear infinite;
    margin: 20px 0;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#loading-text {
    margin: 10px 0;
    font-size: 1em;
    color: #ffd93d;
}

.loading-bar {
    width: 300px;
    max-width: 90vw;
    height: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
    margin: 20px auto;
}

#loading-progress {
    height: 100%;
    background: linear-gradient(90deg, #ff6b6b, #ffd93d);
    width: 0%;
    transition: width 0.3s ease;
}

/* Menu Screens */
#start-screen, #pause-menu, #game-over-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.menu-content {
    text-align: center;
    padding: 20px;
    max-width: 500px;
    width: 90%;
}

.pixel-title {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 0 0 20px #ff6b6b, 4px 4px 0 #000;
    letter-spacing: 2px;
}

.subtitle {
    font-size: 1.2em;
    color: #ffd93d;
    margin-bottom: 30px;
}

.difficulty-selector {
    margin: 30px 0;
}

.difficulty-selector h3 {
    margin-bottom: 15px;
    color: #6bcfff;
}

.difficulty-btn {
    padding: 12px 24px;
    margin: 0 5px;
    font-size: 1em;
    font-family: 'Courier New', monospace;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 2px solid #fff;
    cursor: pointer;
    transition: all 0.3s;
}

.difficulty-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.difficulty-btn.active {
    background: #ff6b6b;
    border-color: #ff6b6b;
    box-shadow: 0 0 20px #ff6b6b;
}

.play-btn {
    padding: 20px 60px;
    font-size: 1.5em;
    font-family: 'Courier New', monospace;
    background: linear-gradient(135deg, #ff6b6b, #ff4757);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
    transition: all 0.3s;
    margin: 20px 0;
}

.play-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.6);
}

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

.menu-btn {
    padding: 15px 40px;
    font-size: 1.1em;
    font-family: 'Courier New', monospace;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 2px solid #fff;
    cursor: pointer;
    margin: 10px;
    transition: all 0.3s;
}

.menu-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.menu-btn.secondary {
    background: transparent;
    border-color: #888;
    color: #888;
}

.controls-info, .high-score {
    margin-top: 30px;
    font-size: 0.9em;
    color: #aaa;
}

.settings {
    margin: 20px 0;
    font-size: 1em;
}

.settings label {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

/* Game Container */
#game-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* HUD */
#hud-top {
    background: rgba(0, 0, 0, 0.8);
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #ffd93d;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

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

.score-display {
    font-size: 1.2em;
}

.label {
    color: #ffd93d;
    margin-right: 5px;
}

#score-value {
    color: #fff;
    font-weight: bold;
}

#stars-display {
    font-size: 1.3em;
    color: #ffd93d;
    text-shadow: 0 0 5px #ffd93d;
}

#lives-display {
    font-size: 1.3em;
}

.next-star {
    font-size: 0.9em;
}

#next-star-value {
    color: #6bcfff;
}

#pause-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: none;
    font-size: 1.5em;
    padding: 5px 15px;
    cursor: pointer;
    transition: background 0.3s;
}

#pause-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Canvas */
#game-canvas {
    flex: 1;
    background: #000;
    display: block;
    touch-action: none;
}

/* Touch Controls */
#touch-controls {
    background: rgba(0, 0, 0, 0.6);
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 2px solid #ffd93d;
    flex-shrink: 0;
    min-height: 120px;
}

#dpad-zone {
    position: relative;
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.05);
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
}

.dpad-directions {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.dpad-arrow {
    position: absolute;
    color: rgba(255, 255, 255, 0.3);
    font-size: 1.5em;
}

.dpad-arrow.up { top: 5px; left: 50%; transform: translateX(-50%); }
.dpad-arrow.right { right: 5px; top: 50%; transform: translateY(-50%); }
.dpad-arrow.down { bottom: 5px; left: 50%; transform: translateX(-50%); }
.dpad-arrow.left { left: 5px; top: 50%; transform: translateY(-50%); }

#dpad-stick {
    position: absolute;
    width: 50px;
    height: 50px;
    background: radial-gradient(circle, #ff6b6b, #ff4757);
    border: 2px solid #fff;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.1s ease;
    box-shadow: 0 0 10px rgba(255, 107, 107, 0.5);
}

#action-buttons {
    display: flex;
    gap: 15px;
}

.action-btn {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: radial-gradient(circle, #6bcfff, #4facfe);
    border: 3px solid #fff;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(107, 207, 255, 0.4);
    transition: all 0.1s;
    overflow: hidden;
}

.action-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 10px rgba(107, 207, 255, 0.6);
}

.btn-icon {
    font-size: 2em;
}

.btn-label {
    font-size: 0.7em;
    font-family: 'Courier New', monospace;
    color: #fff;
}

.cooldown-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: rgba(0, 0, 0, 0.6);
    transition: height 0.1s linear;
}

.action-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Game Over Screen */
.final-score {
    margin: 30px 0;
}

.score-label {
    font-size: 1.2em;
    color: #ffd93d;
}

.score-number {
    font-size: 3em;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 20px #ff6b6b;
}

#final-stars {
    font-size: 2em;
    margin: 10px 0;
    color: #ffd93d;
}

.stats {
    margin: 20px 0;
    font-size: 1em;
    color: #aaa;
}

.stats p {
    margin: 5px 0;
}

.stats span {
    color: #6bcfff;
    font-weight: bold;
}

/* Footer */
#berry-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.8);
    padding: 10px;
    text-align: center;
    font-size: 0.9em;
    z-index: 5;
    display: none;
}

#berry-footer a {
    color: #ff6b6b;
    text-decoration: none;
}

#berry-footer a:hover {
    text-decoration: underline;
}

/* Desktop adjustments */
@media (min-width: 768px) {
    #touch-controls {
        display: none;
    }
    
    .controls-info {
        display: block;
    }
    
    #berry-footer {
        display: block;
    }
}

/* Landscape mobile */
@media (max-width: 768px) and (orientation: landscape) {
    #hud-top {
        padding: 5px 10px;
        font-size: 0.9em;
    }
    
    #touch-controls {
        padding: 10px;
        min-height: 100px;
    }
    
    #dpad-zone {
        width: 100px;
        height: 100px;
    }
    
    .action-btn {
        width: 70px;
        height: 70px;
    }
}