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

body {
    background: #1a1a2e;
    color: #e0e0e0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 16px 16px 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.back-link {
    align-self: flex-start;
    color: #8888aa;
    text-decoration: none;
    font-size: 0.95rem;
    transition: color 0.2s;
    padding: 4px 0;
}

.back-link:hover {
    color: #bbbbdd;
}

.title {
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: 2px;
    margin: 8px 0 12px;
    background: linear-gradient(135deg, #f44336, #ff9800, #ffeb3b, #4caf50, #2196f3);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Difficulty bar */
.difficulty-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.diff-btn {
    padding: 6px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #aaaacc;
    background: #16162e;
    border: 2px solid #2a2a4a;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.diff-btn:hover {
    background: #1e1e40;
    color: #ccccee;
    border-color: #3a3a6a;
}

.diff-btn.active {
    background: linear-gradient(135deg, #2196f3, #4caf50);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 2px 12px rgba(33, 150, 243, 0.35);
}

/* HUD */
.hud {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 12px;
    width: 100%;
    max-width: 900px;
}

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

.hud-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #666680;
}

.hud-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: #ffffff;
    min-width: 60px;
    text-align: center;
}

.hearts {
    color: #f44336;
    letter-spacing: 3px;
}

/* Canvas */
.canvas-wrapper {
    position: relative;
    width: 95%;
    max-width: 900px;
    border: 2px solid #2a2a4a;
    border-radius: 8px;
    overflow: hidden;
    background: #0a0a2a;
    touch-action: none;
}

canvas {
    display: block;
    width: 100%;
    height: auto;
    touch-action: none;
}

/* Overlay */
.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(10, 10, 42, 0.85);
    z-index: 10;
    transition: opacity 0.3s;
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.overlay-content {
    text-align: center;
}

.overlay-message {
    font-size: 1.6rem;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 8px;
}

.overlay-subtext {
    font-size: 1.1rem;
    color: #aaaacc;
    margin-bottom: 20px;
}

.overlay-btn {
    padding: 12px 32px;
    font-size: 1.1rem;
    font-weight: 600;
    color: #ffffff;
    background: linear-gradient(135deg, #2196f3, #4caf50);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}

.overlay-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 20px rgba(33, 150, 243, 0.4);
}

/* Controls hint */
.controls-hint {
    margin-top: 12px;
    font-size: 0.85rem;
    color: #555570;
    text-align: center;
}

.mobile-hint {
    display: none;
}

/* How to Play */
.how-to-play {
    margin-top: 20px;
    width: 95%;
    max-width: 900px;
    background: #12122a;
    border: 1px solid #2a2a4a;
    border-radius: 8px;
    overflow: hidden;
}

.how-to-play summary {
    padding: 12px 18px;
    font-size: 1rem;
    font-weight: 600;
    color: #aaaacc;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s, color 0.2s;
}

.how-to-play summary::-webkit-details-marker {
    display: none;
}

.how-to-play summary::before {
    content: '\25B6';
    font-size: 0.7rem;
    transition: transform 0.2s;
}

.how-to-play[open] summary::before {
    transform: rotate(90deg);
}

.how-to-play summary:hover {
    background: #1a1a3a;
    color: #ccccee;
}

.how-to-play ul {
    padding: 4px 18px 16px 36px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.how-to-play li {
    font-size: 0.9rem;
    color: #9999bb;
    line-height: 1.5;
}

.how-to-play li strong {
    color: #ccccee;
}

/* Large desktop — let the game fill more of the screen */
@media (min-width: 1200px) {
    .container {
        max-width: 1200px;
    }

    .canvas-wrapper,
    .hud,
    .how-to-play {
        max-width: 1200px;
    }
}

/* Mobile */
@media (max-width: 600px) {
    .title {
        font-size: 1.6rem;
        margin: 4px 0 8px;
    }

    .hud {
        gap: 20px;
    }

    .hud-value {
        font-size: 1.15rem;
    }

    .overlay-message {
        font-size: 1.2rem;
    }

    .overlay-subtext {
        font-size: 0.95rem;
    }

    .container {
        padding: 10px 8px 20px;
    }

    .canvas-wrapper {
        width: 100%;
    }

    .how-to-play {
        width: 100%;
    }

    .diff-btn {
        padding: 6px 14px;
        font-size: 0.82rem;
    }
}

/* Touch arrow controls */
.touch-controls {
    display: none;
    margin-top: 14px;
}

.touch-row {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.touch-btn {
    width: 80px;
    height: 64px;
    font-size: 26px;
    border: none;
    border-radius: 12px;
    background: rgba(100, 180, 255, 0.15);
    color: #88bbff;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    transition: background 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.touch-btn-launch {
    font-size: 20px;
    background: rgba(100, 255, 180, 0.15);
    color: #88ffcc;
}

.touch-btn:active,
.touch-btn.pressed {
    background: rgba(100, 180, 255, 0.4);
}

.touch-btn-launch:active,
.touch-btn-launch.pressed {
    background: rgba(100, 255, 180, 0.4);
}

body.has-touch .touch-controls { display: block; }
body.has-touch .desktop-hint   { display: none; }
body.has-touch .mobile-hint    { display: inline; }

@media (pointer: fine) {
    .desktop-hint { display: inline; }
    .mobile-hint  { display: none; }
}
