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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    /* Prevent double-tap zoom / scroll jank on mobile while interacting with the game */
    overscroll-behavior: none;
    /* Smooth transition during orientation change */
    transition: all 0.3s ease;
}

.container {
    max-width: 1200px;
    width: 100%;
    padding: 20px;
}

.game-header {
    text-align: center;
    margin-bottom: 20px;
}

.game-header h1 {
    font-size: 3em;
    text-shadow:
        0 0 10px rgba(255, 255, 255, 0.8),
        0 0 20px rgba(255, 0, 255, 0.6),
        0 0 30px rgba(0, 255, 255, 0.4);
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from {
        text-shadow:
            0 0 10px rgba(255, 255, 255, 0.8),
            0 0 20px rgba(255, 0, 255, 0.6),
            0 0 30px rgba(0, 255, 255, 0.4);
    }

    to {
        text-shadow:
            0 0 20px rgba(255, 255, 255, 1),
            0 0 30px rgba(255, 0, 255, 0.8),
            0 0 40px rgba(0, 255, 255, 0.6);
    }
}

#game-container {
    position: relative;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    overflow: visible;
    /* Prevent browser gestures inside the game area */
    touch-action: none;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: auto;
    background: linear-gradient(180deg, #1a0033 0%, #330066 50%, #4d0099 100%);
    border-radius: 10px;
    /* Prevent browser panning/zooming so touch controls feel like a real game */
    touch-action: none;
    position: relative;
    z-index: 1;
}

/* Tablet and larger phones */
@media (max-width: 768px) {
    .container {
        padding: 8px;
    }

    .game-header {
        margin-bottom: 8px;
    }

    .game-header h1 {
        font-size: 1.5em;
    }

    .controls {
        margin-top: 8px;
        padding: 8px;
    }

    .controls p {
        font-size: 0.85em;
    }

    .screen {
        width: calc(100% - 24px);
        max-width: 90%;
        padding: 20px 16px;
    }

    .screen h2 {
        font-size: 1.6em;
        margin-bottom: 10px;
        line-height: 1.1;
    }

    .screen p {
        font-size: 0.9em;
        margin: 6px 0;
        line-height: 1.4;
    }

    button {
        padding: 12px 32px;
        font-size: 1.05em;
        margin-top: 12px;
    }

    .pause-buttons button {
        padding: 10px 28px;
        font-size: 1em;
    }

    #pause-screen p {
        font-size: 1em;
    }

    .skin-selector {
        margin: 15px 0;
        padding: 12px;
    }

    .skin-selector label {
        font-size: 0.9em;
        margin-bottom: 8px;
    }

    .skin-btn {
        padding: 6px 12px;
        font-size: 0.9em;
        min-width: 45px;
    }

    .high-score-display {
        margin-top: 12px;
        font-size: 0.9em;
    }

    .score-panel {
        top: 8px;
        left: 8px;
        right: 8px;
        font-size: 0.9em;
    }

    .icon-btn {
        font-size: 0.9em;
        width: 32px;
        height: 32px;
    }

    .status-indicators {
        top: 60px;
        gap: 8px;
    }

    .indicator {
        padding: 3px 6px;
        font-size: 0.55em;
        border-radius: 8px;
        background: rgba(0, 0, 0, 0.6);
        max-width: 85%;
        animation: pulseMobile 1s ease-in-out infinite;
    }

    #multiplier,
    #invincible {
        border-width: 1px;
        text-shadow: 0 0 4px;
    }
}

/* Standard mobile phones (like iPhone 12 Pro, Pixel 5) */
@media (max-width: 430px) {
    .container {
        padding: 6px;
    }

    .game-header {
        margin-bottom: 6px;
    }

    .game-header h1 {
        font-size: 1.35em;
    }

    .screen {
        width: calc(100% - 20px);
        padding: 18px 14px;
    }

    .screen h2 {
        font-size: 1.4em;
        margin-bottom: 8px;
        line-height: 1.15;
    }

    .screen p {
        font-size: 0.85em;
        margin: 5px 0;
        line-height: 1.4;
    }

    button {
        padding: 11px 28px;
        font-size: 1em;
        margin-top: 10px;
    }

    .high-score-display {
        margin-top: 10px;
        font-size: 0.85em;
    }

    .score-panel {
        font-size: 0.85em;
        top: 6px;
        left: 6px;
        right: 6px;
    }

    .controls {
        padding: 6px;
        margin-top: 6px;
    }

    .controls p {
        font-size: 0.8em;
    }

    .skin-selector {
        margin: 12px 0;
        padding: 10px;
    }

    .skin-selector label {
        font-size: 0.85em;
        margin-bottom: 6px;
    }

    .skin-btn {
        padding: 5px 10px;
        font-size: 0.85em;
        min-width: 40px;
    }

    .status-indicators {
        top: 50px;
        gap: 5px;
    }

    .indicator {
        padding: 3px 6px;
        font-size: 0.55em;
        border-radius: 8px;
    }

    #multiplier,
    #invincible {
        border-width: 1px;
        text-shadow: 0 0 4px;
    }
}

/* Smaller phones (like iPhone SE, smaller Android) */
@media (max-width: 375px) {
    .game-header h1 {
        font-size: 1.25em;
    }

    .screen {
        width: calc(100% - 16px);
        padding: 16px 12px;
    }

    .screen h2 {
        font-size: 1.3em;
        margin-bottom: 8px;
        line-height: 1.15;
    }

    .screen p {
        font-size: 0.82em;
        margin: 4px 0;
        line-height: 1.45;
    }

    button {
        padding: 10px 24px;
        font-size: 0.95em;
        margin-top: 8px;
    }

    .high-score-display {
        margin-top: 8px;
        font-size: 0.8em;
    }

    .score-panel {
        font-size: 0.82em;
        top: 5px;
        left: 5px;
        right: 5px;
    }

    .controls p {
        font-size: 0.78em;
    }

    .status-indicators {
        top: 45px;
        gap: 4px;
    }

    .indicator {
        padding: 2px 5px;
        font-size: 0.5em;
        border-radius: 6px;
        background: rgba(0, 0, 0, 0.55);
        max-width: 80%;
        animation: pulseMobile 1s ease-in-out infinite;
    }

    #multiplier,
    #invincible {
        border-width: 1px;
        text-shadow: 0 0 3px;
    }
}

/* Very small devices */
@media (max-width: 320px) {
    .game-header h1 {
        font-size: 1.1em;
    }

    .screen {
        width: calc(100% - 12px);
        padding: 14px 10px;
    }

    .screen h2 {
        font-size: 1.2em;
        margin-bottom: 6px;
    }

    .screen p {
        font-size: 0.78em;
        margin: 3px 0;
        line-height: 1.45;
    }

    button {
        padding: 9px 20px;
        font-size: 0.9em;
        margin-top: 6px;
    }

    .high-score-display {
        margin-top: 6px;
        font-size: 0.75em;
    }

    .score-panel {
        font-size: 0.78em;
    }

    .controls p {
        font-size: 0.75em;
    }

    .status-indicators {
        top: 40px;
        gap: 4px;
    }

    .indicator {
        padding: 2px 5px;
        font-size: 0.55em;
        border-radius: 6px;
    }

    #multiplier,
    #invincible {
        border-width: 1px;
        text-shadow: 0 0 3px;
    }
}

/* Landscape mobile devices - maximize vertical space */
@media (max-height: 600px) and (orientation: landscape) {
    .container {
        padding: 5px;
    }

    .game-header {
        margin-bottom: 3px;
    }

    .game-header h1 {
        font-size: 1.2em;
    }

    .controls {
        margin-top: 3px;
        padding: 5px;
    }

    .controls p {
        font-size: 0.75em;
    }

    .screen {
        padding: 12px 15px;
        max-height: 85vh;
        overflow-y: auto;
        /* Make modal more compact in landscape */
        max-width: 450px;
    }

    .screen h2 {
        font-size: 1.3em;
        margin-bottom: 6px;
        line-height: 1.1;
    }

    .screen p {
        font-size: 0.75em;
        margin: 3px 0;
        line-height: 1.3;
    }

    button {
        margin-top: 8px;
        padding: 8px 24px;
        font-size: 0.9em;
    }

    .high-score-display {
        margin-top: 6px;
        font-size: 0.75em;
    }

    .score-panel {
        top: 5px;
        left: 5px;
        right: 5px;
        font-size: 0.8em;
    }

    .status-indicators {
        top: 35px;
        gap: 5px;
    }

    .indicator {
        padding: 4px 8px;
        font-size: 0.75em;
        border-radius: 10px;
    }

    #multiplier,
    #invincible {
        border-width: 1px;
        text-shadow: 0 0 5px;
    }

    .icon-btn {
        width: 28px;
        height: 28px;
        font-size: 0.8em;
    }
}

/* Very short landscape (like iPhone SE landscape) */
@media (max-height: 420px) and (orientation: landscape) {
    body {
        overflow-y: auto;
    }

    .game-header h1 {
        font-size: 1em;
    }

    .game-header {
        margin-bottom: 2px;
    }

    .controls {
        margin-top: 2px;
        padding: 3px;
    }

    .controls p {
        font-size: 0.7em;
    }

    .screen {
        padding: 10px 12px;
        max-height: 90vh;
        max-width: 400px;
    }

    .screen h2 {
        font-size: 1.1em;
        margin-bottom: 4px;
    }

    .screen p {
        font-size: 0.7em;
        margin: 2px 0;
        line-height: 1.25;
    }

    button {
        margin-top: 6px;
        padding: 6px 20px;
        font-size: 0.85em;
    }

    .high-score-display {
        margin-top: 4px;
        font-size: 0.7em;
    }

    .score-panel {
        font-size: 0.75em;
        top: 3px;
        left: 3px;
        right: 3px;
    }

    .status-indicators {
        top: 30px;
        gap: 4px;
    }

    .indicator {
        padding: 3px 6px;
        font-size: 0.7em;
        border-radius: 8px;
    }

    #multiplier,
    #invincible {
        border-width: 1px;
        text-shadow: 0 0 4px;
    }
}

#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

.score-panel {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    font-size: 1.3em;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    pointer-events: none;
}

.left-panel,
.right-panel {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.right-panel {
    align-items: flex-end;
}

.high-score {
    font-size: 0.8em;
    opacity: 0.8;
}

.icon-btn {
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 1.2em;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 0;
    padding: 0;
}

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

.status-indicators {
    position: absolute;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    pointer-events: none;
}

.indicator {
    background: rgba(0, 0, 0, 0.7);
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 1.2em;
    animation: pulse 1s ease-in-out infinite;
    white-space: nowrap;
    text-align: center;
    max-width: 90%;
}

.indicator.hidden {
    display: none;
}

#multiplier {
    color: #9400d3;
    text-shadow: 0 0 10px #9400d3;
    border: 2px solid #9400d3;
}

#invincible {
    color: #ffd700;
    text-shadow: 0 0 10px #ffd700;
    border: 2px solid #ffd700;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

@keyframes pulseMobile {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.02);
    }
}

.screen {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    background: rgba(0, 0, 0, 0.8);
    padding: 40px 60px;
    border-radius: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    pointer-events: auto !important;
    max-height: 90vh;
    overflow-y: auto;
    z-index: 200;
}

.screen.hidden {
    display: none;
}

.screen h2 {
    font-size: 2.5em;
    margin-bottom: 20px;
    text-shadow: 0 0 10px rgba(255, 0, 255, 0.8);
}

.screen p {
    font-size: 1.2em;
    margin: 10px 0;
}

.high-score-display {
    margin-top: 20px;
    font-size: 1em;
    opacity: 0.8;
}

.new-high-score {
    color: #ffd700;
    font-size: 1.3em;
    font-weight: bold;
    text-shadow: 0 0 10px #ffd700;
    animation: glow 1s ease-in-out infinite alternate;
}

.new-high-score.hidden {
    display: none;
}

button {
    margin-top: 20px;
    padding: 15px 40px;
    font-size: 1.3em;
    font-weight: bold;
    color: white;
    background: linear-gradient(135deg, #ff00ff 0%, #00ffff 100%);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(255, 0, 255, 0.4);
    pointer-events: auto !important;
    position: relative;
    z-index: 300;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(255, 0, 255, 0.6);
}

button:active {
    transform: translateY(0);
    background: linear-gradient(135deg, #cc00cc 0%, #00cccc 100%);
}

button:focus {
    outline: 3px solid rgba(255, 255, 255, 0.5);
}

/* Pause menu specific styles */
.pause-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
    align-items: center;
}

.pause-buttons button {
    width: 100%;
    max-width: 250px;
    margin-top: 0;
}

#pause-screen p {
    font-size: 1.1em;
    margin-bottom: 15px;
    color: #ffd700;
    font-weight: bold;
}

/* Skin selector styles */
.skin-selector {
    margin: 20px 0;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.skin-selector label {
    display: block;
    font-size: 1em;
    margin-bottom: 10px;
    color: #ffd700;
    font-weight: bold;
}

.skin-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    align-items: center;
}

.skin-btn {
    padding: 8px 16px;
    font-size: 1em;
    font-weight: bold;
    color: white;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 0;
    min-width: 50px;
    pointer-events: auto;
    position: relative;
    z-index: 10;
}

.skin-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.5);
}

.skin-btn.active {
    background: linear-gradient(135deg, #ff00ff 0%, #00ffff 100%);
    border-color: rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 15px rgba(255, 0, 255, 0.6);
    transform: scale(1.1);
}

.controls {
    text-align: center;
    margin-top: 20px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    max-width: 1000px;
    margin-left: auto;
    margin-right: auto;
}

.controls p {
    font-size: 1.1em;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}