@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

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

body {
    font-family: 'Press Start 2P', monospace;
    background: #5c94fc;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    color: #fff;
    user-select: none;
}

.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 960px;
    padding: 20px;
}

.screen.active {
    display: flex;
}

/* ===== Start Screen ===== */
.title-block {
    text-align: center;
    margin-bottom: 30px;
}

.game-title {
    font-size: 48px;
    color: #e52521;
    text-shadow: 4px 4px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000;
    letter-spacing: 4px;
    animation: bounce 1.5s ease-in-out infinite;
}

.game-subtitle {
    font-size: 28px;
    color: #fbd000;
    text-shadow: 3px 3px 0 #000;
    margin-top: 10px;
    letter-spacing: 8px;
}

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

.menu {
    background: rgba(0, 0, 0, 0.7);
    border: 4px solid #fff;
    border-radius: 12px;
    padding: 30px 40px;
    text-align: center;
    margin-bottom: 20px;
}

.menu h3 {
    font-size: 16px;
    margin-bottom: 20px;
    color: #fbd000;
}

.difficulty-buttons {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
}

.diff-btn {
    font-family: inherit;
    background: #333;
    border: 3px solid #555;
    border-radius: 8px;
    padding: 15px 20px;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-width: 130px;
}

.diff-btn:hover {
    border-color: #fbd000;
    transform: translateY(-3px);
}

.diff-btn.selected {
    border-color: #fbd000;
    background: #4a4a00;
    box-shadow: 0 0 15px rgba(251, 208, 0, 0.5);
}

.diff-icon {
    font-size: 28px;
}

.diff-name {
    font-size: 12px;
    color: #fff;
}

.diff-desc {
    font-size: 8px;
    color: #aaa;
    line-height: 1.5;
}

.primary-btn {
    font-family: inherit;
    font-size: 14px;
    background: #e52521;
    color: #fff;
    border: 3px solid #fff;
    border-radius: 8px;
    padding: 15px 40px;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
}

.primary-btn:hover:not(:disabled) {
    background: #ff3b30;
    transform: scale(1.05);
}

.primary-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.secondary-btn {
    font-family: inherit;
    font-size: 12px;
    background: #333;
    color: #fff;
    border: 3px solid #777;
    border-radius: 8px;
    padding: 12px 30px;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 15px;
}

.secondary-btn:hover {
    border-color: #fff;
}

.instructions {
    text-align: center;
    font-size: 9px;
    line-height: 2;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5);
}

/* ===== Game Screen ===== */
#game-screen {
    padding: 0;
    justify-content: flex-start;
}

.hud {
    display: flex;
    justify-content: space-around;
    width: 960px;
    background: #000;
    padding: 10px 0;
    border-bottom: 3px solid #fff;
}

.hud-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.hud-label {
    font-size: 9px;
    color: #fbd000;
}

.hud-value {
    font-size: 14px;
    color: #fff;
}

#game-canvas {
    display: block;
    background: #5c94fc;
    image-rendering: pixelated;
    border: 3px solid #000;
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10;
}

.overlay.active {
    display: flex;
}

#overlay-content {
    background: rgba(0, 0, 0, 0.85);
    border: 4px solid #fbd000;
    border-radius: 12px;
    padding: 30px 50px;
    text-align: center;
    font-size: 18px;
    color: #fff;
}

#overlay-content h2 {
    font-size: 24px;
    color: #fbd000;
    margin-bottom: 15px;
}

#overlay-content p {
    font-size: 12px;
    margin-bottom: 10px;
}

.overlay-btn {
    font-family: inherit;
    font-size: 14px;
    background: #e52521;
    color: #fff;
    border: 3px solid #fff;
    border-radius: 8px;
    padding: 15px 35px;
    cursor: pointer;
    margin-top: 15px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: background 0.15s, transform 0.1s;
}

.overlay-btn:active {
    background: #ff3b30;
    transform: scale(0.95);
}

/* ===== End Screens ===== */
.end-title {
    font-size: 40px;
    margin-bottom: 30px;
    text-shadow: 4px 4px 0 #000;
}

.gameover {
    color: #e52521;
}

.victory {
    color: #fbd000;
    animation: bounce 1s ease-in-out infinite;
}

.end-score {
    font-size: 14px;
    margin-bottom: 20px;
    color: #fff;
}

.end-score span {
    color: #fbd000;
}

#gameover-screen, #victory-screen {
    background: #5c94fc;
    min-height: 100vh;
}

/* ===== Touch Controls ===== */
.touch-controls {
    display: none;
    width: 100%;
    max-width: 960px;
    height: 90px;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px;
    background: #000;
    border-top: 3px solid #fff;
    pointer-events: none;
}

.touch-left,
.touch-right {
    display: flex;
    gap: 12px;
    pointer-events: none;
}

.touch-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.6);
    background: rgba(40, 40, 40, 0.8);
    color: #fff;
    font-size: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
    user-select: none;
    transition: background 0.1s, transform 0.1s;
}

.touch-btn:active,
.touch-btn.active {
    background: rgba(229, 37, 33, 0.7);
    transform: scale(0.92);
}

.jump-btn {
    width: 72px;
    height: 72px;
    background: rgba(229, 37, 33, 0.5);
    border-color: rgba(255, 255, 255, 0.7);
    font-size: 30px;
}

.jump-btn:active,
.jump-btn.active {
    background: rgba(229, 37, 33, 0.9);
}

/* Show touch controls only on touch devices */
@media (hover: none) and (pointer: coarse) {
    .touch-controls {
        display: flex;
    }
}

/* ===== Responsive Canvas ===== */
#game-screen {
    position: relative;
    width: 100%;
    max-width: 960px;
}

#game-canvas {
    width: 100%;
    height: auto;
    max-width: 960px;
}

.hud {
    width: 100%;
    max-width: 960px;
}

/* Scale down on small screens */
@media (max-width: 600px) {
    .game-title { font-size: 28px; }
    .game-subtitle { font-size: 18px; }
    .difficulty-buttons { flex-direction: column; gap: 10px; }
    .diff-btn { min-width: 200px; }
    .hud-label { font-size: 7px; }
    .hud-value { font-size: 11px; }
    .menu { padding: 20px; }
    .menu h3 { font-size: 12px; }
    .end-title { font-size: 28px; }
}
