* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    touch-action: none;
    overscroll-behavior: none;
}

#game-container {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background-color: #2d2d2d;
    background-image:
        linear-gradient(135deg, #555 12%, transparent 12%),
        linear-gradient(225deg, #555 12%, transparent 12%),
        linear-gradient(315deg, #555 12%, transparent 12%),
        linear-gradient(45deg, #555 12%, transparent 12%);
    background-size: 10px 10px;
    background-position: -5px 0, -5px 0, 0 0, 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#game-canvas {
    display: block;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    background: #87ceeb;
    max-width: 100%;
    max-height: 100%;
    box-shadow:
        0 0 0 6px #ffe060,
        0 0 0 12px #a03020;
}

#fullscreen-btn, #pause-btn, #mute-btn {
    position: absolute;
    top: env(safe-area-inset-top, 8px);
    margin: 8px;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.4);
    color: white;
    font-size: 16px;
    cursor: pointer;
    z-index: 100;
}

#fullscreen-btn {
    right: env(safe-area-inset-right, 8px);
    font-size: 20px;
}

#pause-btn {
    right: calc(env(safe-area-inset-right, 8px) + 56px);
    letter-spacing: -2px;
}

#mute-btn {
    right: calc(env(safe-area-inset-right, 8px) + 112px);
    font-size: 20px;
}

#mute-btn.muted {
    opacity: 0.5;
    text-decoration: line-through;
}

#fullscreen-btn:hover, #pause-btn:hover, #mute-btn:hover {
    background: rgba(0, 0, 0, 0.6);
}

#touch-controls {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 50;
}

#touch-controls.hidden {
    display: none;
}

.dpad, .actions {
    position: absolute;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
    display: flex;
    gap: 10px;
    pointer-events: none;
}

.dpad {
    left: calc(env(safe-area-inset-left, 0px) + 14px);
}

.actions {
    right: calc(env(safe-area-inset-right, 0px) + 14px);
}

.btn {
    pointer-events: auto;
    width: 64px;
    height: 64px;
    border: 2px solid rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.35);
    color: white;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
}

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

.btn-left::before { content: "\25C0"; font-size: 28px; }
.btn-right::before { content: "\25B6"; font-size: 28px; }

.btn-jump {
    width: 84px;
    height: 84px;
    font-size: 18px;
    letter-spacing: 2px;
    background: rgba(220, 40, 40, 0.55);
    border-color: rgba(255, 120, 120, 0.8);
    font-family: 'Courier New', 'Consolas', monospace;
    font-weight: bold;
    text-transform: uppercase;
}

#start-overlay {
    position: absolute;
    inset: 0;
    background: #87ceeb;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding:
        max(20px, env(safe-area-inset-top, 0px))
        max(20px, env(safe-area-inset-right, 0px))
        max(56px, calc(env(safe-area-inset-bottom, 0px) + 40px))
        max(20px, env(safe-area-inset-left, 0px));
    font-family: 'Courier New', 'Consolas', 'Monaco', monospace;
}

#start-overlay.hidden {
    display: none;
}

.start-card {
    background: transparent;
    border: none;
    box-shadow: none;
    max-width: none;
    width: 100%;
    height: 100%;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    text-align: center;
}

.screen-frame {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-height: 75vh;
    padding: 0;
    background: transparent;
    border: none;
}

@media (max-height: 520px) {
    .screen-frame { max-height: 50vh; }
    .welcome-image { max-height: 45vh; }
    .tagline { font-size: 13px; margin-bottom: 8px; }
    #start-btn { padding: 10px 36px; font-size: 16px; margin-bottom: 8px; }
    .controls-hint { font-size: 9px; margin-bottom: 6px; }
    .copyright { font-size: 8px; }
}

.welcome-image {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    max-width: min(832px, 95vw);
    max-height: 100%;
    width: auto;
    height: auto;
    display: block;
}

.tagline {
    font-family: inherit;
    font-size: 16px;
    font-weight: bold;
    color: #1a3a5a;
    text-align: center;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin: -4px 0 12px;
    text-shadow: 2px 2px 0 rgba(255, 255, 255, 0.35);
}

#start-btn {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding: 14px 48px;
    font-size: 20px;
    font-weight: bold;
    letter-spacing: 6px;
    background: #ffb840;
    color: #3a1a08;
    border: 3px solid #3a1a08;
    border-radius: 0;
    cursor: pointer;
    margin-bottom: 14px;
    font-family: inherit;
    text-transform: uppercase;
    box-shadow: 0 5px 0 #3a1a08;
    line-height: 1.2;
}

#start-btn:hover {
    background: #ffcc60;
}

#start-btn:active {
    transform: translateY(5px);
    box-shadow: none;
}

.controls-hint {
    font-size: 12px;
    line-height: 1.6;
    color: #1a3a5a;
    text-align: center;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 12px;
    font-weight: bold;
}

.copyright {
    font-size: 10px;
    text-align: center;
    color: #2a4a6a;
    letter-spacing: 2px;
    text-transform: uppercase;
    padding-top: 6px;
    margin-bottom: 0;
}
