* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    font-family: 'Orbitron', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    min-height: 100vh;
    padding: 0;
    margin: 0;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 20px;
    animation: fadeInDown 1s ease;
}

header h1 {
    font-size: 2.5em;
    font-weight: 900;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
    margin-bottom: 10px;
    word-break: break-word;
}

.tagline {
    font-size: 1em;
    opacity: 0.9;
    word-break: break-word;
}

/* Game Wrapper */
.game-wrapper {
    position: relative;
    margin: 0 auto;
    width: 100%;
    max-width: 800px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    overflow: hidden;
    background: #000;
    aspect-ratio: 800 / 600;
    animation: fadeIn 1s ease;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Buttons on Canvas */
.fullscreen-btn,
.sound-btn {
    position: absolute;
    top: 8px;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    z-index: 100;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    touch-action: manipulation;
}

.fullscreen-btn {
    right: 8px;
}

.sound-btn {
    right: 55px;
}

.fullscreen-btn:hover,
.sound-btn:hover,
.fullscreen-btn:active,
.sound-btn:active {
    background: rgba(0, 0, 0, 0.9);
    border-color: rgba(255, 215, 0, 0.8);
}

.fullscreen-icon,
.sound-icon {
    fill: white;
    display: block;
    width: 20px;
    height: 20px;
}

/* Controls Overlay */
.controls-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: opacity 0.3s ease;
    padding: 20px;
}

.controls-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.controls-content {
    text-align: center;
    padding: 30px;
    max-width: 400px;
}

.controls-content h2 {
    font-size: 2em;
    margin-bottom: 25px;
    color: #ffd700;
    word-break: break-word;
}

.control-item {
    margin: 15px 0;
    font-size: 1em;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.key {
    display: inline-block;
    background: linear-gradient(145deg, #667eea, #764ba2);
    padding: 8px 15px;
    margin: 0 3px;
    border-radius: 5px;
    font-weight: bold;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
    min-width: 40px;
}

.description {
    display: block;
    margin-top: 8px;
    color: #ccc;
    font-size: 0.9em;
}

.desk-controls {
    display: flex;
}

.mobile-controls-only {
    display: block;
}

/* Mobile Controls */
.mobile-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 10px 15px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    z-index: 50;
    touch-action: manipulation;
}

.mobile-controls.hidden {
    display: none;
}

.lane-button,
.jump-button {
    flex: 1;
    max-width: 80px;
    padding: 12px 8px;
    font-size: 0.9em;
    font-weight: bold;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: 'Orbitron', sans-serif;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.jump-button {
    background: linear-gradient(145deg, #f093fb, #f5576c);
    border-color: rgba(255, 255, 255, 0.5);
    flex: 1.2;
    max-width: 100px;
}

.lane-button:active,
.jump-button:active {
    transform: scale(0.9);
    background: rgba(255, 255, 255, 0.2);
}

.lane-emoji,
.jump-emoji {
    font-size: 1.5em;
    line-height: 1;
}

.lane-text,
.jump-text {
    font-size: 0.7em;
    opacity: 0.8;
    line-height: 1;
}

/* Stats Panel */
.stats-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin: 20px 0;
    animation: fadeInUp 1s ease;
}

.stat-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.stat-label {
    display: block;
    font-size: 0.8em;
    opacity: 0.8;
    margin-bottom: 5px;
}

.stat-value {
    display: block;
    font-size: 1.5em;
    font-weight: bold;
    color: #ffd700;
}

/* Instructions */
.instructions {
    margin: 30px 0;
    animation: fadeInUp 1s ease 0.3s both;
}

.instructions h3 {
    text-align: center;
    font-size: 1.8em;
    margin-bottom: 25px;
    word-break: break-word;
}

.instruction-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 15px;
}

.instruction-card {
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 10px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.instruction-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.instruction-card h4 {
    font-size: 1.2em;
    margin-bottom: 10px;
    color: #ffd700;
    word-break: break-word;
}

.instruction-card p {
    line-height: 1.5;
    opacity: 0.9;
    font-size: 0.95em;
}

/* Footer */
footer {
    text-align: center;
    margin-top: 30px;
    padding: 15px;
    opacity: 0.7;
    animation: fadeIn 2s ease;
}

.shortcuts {
    margin-top: 8px;
    font-size: 0.85em;
    opacity: 0.8;
}

.shortcuts strong {
    color: #FFD700;
    padding: 2px 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

/* Pause Overlay */
.pause-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    transition: opacity 0.3s ease;
}

.pause-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.pause-content {
    text-align: center;
    padding: 30px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    max-width: 90%;
}

.pause-content h2 {
    font-size: 2.5em;
    margin-bottom: 15px;
    color: #FFD700;
    word-break: break-word;
}

.pause-content p {
    font-size: 1.2em;
    color: #FFFFFF;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile Specific Styles */
@media (max-width: 768px) {
    .container {
        padding: 0 !important;
    }
    
    header {
        display: none;
    }
    
    .stats-panel {
        display: none;
    }
    
    .instructions {
        display: none;
    }
    
    footer {
        display: none;
    }
    
    .game-wrapper {
        border-radius: 0;
        aspect-ratio: auto;
        height: 100vh;
        max-height: 100vh;
    }
    
    .mobile-controls {
        display: flex !important;
        padding: 8px 10px;
        background: linear-gradient(transparent, rgba(0, 0, 0, 0.9));
    }
    
    .lane-button,
    .jump-button {
        padding: 10px 5px;
        max-width: 60px;
        font-size: 0.8em;
    }
    
    .controls-content {
        padding: 20px;
    }
    
    .controls-content h2 {
        font-size: 1.5em;
    }
    
    .pause-content {
        padding: 20px;
    }
    
    .pause-content h2 {
        font-size: 1.8em;
    }
    
    .fullscreen-btn,
    .sound-btn {
        padding: 6px;
        top: 5px;
    }
    
    .fullscreen-btn {
        right: 5px;
    }
    
    .sound-btn {
        right: 45px;
    }
}

/* Desktop - hide mobile controls */
@media (min-width: 769px) {
    .mobile-controls {
        display: none !important;
    }
}

/* Landscape mobile optimization */
@media (max-height: 500px) and (orientation: landscape) {
    .mobile-controls {
        padding: 5px 8px;
    }
    
    .lane-button,
    .jump-button {
        padding: 6px 4px;
        max-width: 50px;
        font-size: 0.7em;
    }
    
    .lane-emoji,
    .jump-emoji {
        font-size: 1em;
    }
    
    .controls-overlay {
        padding: 10px;
    }
    
    .controls-content h2 {
        font-size: 1.3em;
    }
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    .game-wrapper {
        height: -webkit-fill-available;
    }
    
    #gameCanvas {
        height: -webkit-fill-available;
    }
}

/* Prevent overscroll on mobile */
html, body {
    overscroll-behavior: none;
    overscroll-behavior-x: contain;
    overscroll-behavior-y: contain;
}