:root {
    --bg-dark: #0b0f19;
    --card-bg: rgba(22, 27, 46, 0.85);
    --card-border: rgba(255, 255, 255, 0.12);
    --accent-gold: #ffd15c;
    --accent-gold-glow: rgba(255, 209, 92, 0.45);
    --accent-blue: #4facfe;
    --accent-pink: #f7729f;
    --text-main: #f0f4fc;
    --text-muted: #9baec8;
    --danger: #ff5b6b;
    --success: #3dd598;
    --font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: radial-gradient(circle at 50% 20%, #171b38 0%, #0c1023 60%, #060812 100%);
    font-family: var(--font-family);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
}

.game-container {
    position: relative;
    width: 100%;
    max-width: 900px;
    height: 100%;
    max-height: 650px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
}

/* Header HUD */
.hud-bar {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 8px 18px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 10;
    gap: 10px;
    margin-bottom: 8px;
}

.hud-group {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.hud-pill {
    display: flex;
    align-items: center;
    gap: 7px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.3px;
    transition: transform 0.15s ease, background 0.15s ease;
}

.hud-pill.highlight {
    transform: scale(1.1);
    background: rgba(255, 209, 92, 0.25);
    border-color: var(--accent-gold);
}

.hud-pill .icon {
    font-size: 18px;
    filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.5));
}

.score-value {
    color: var(--accent-gold);
    font-size: 18px;
    font-weight: 800;
}

.lives-container {
    display: flex;
    gap: 4px;
    align-items: center;
}

.heart {
    font-size: 18px;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s;
    filter: drop-shadow(0 0 4px rgba(255, 91, 107, 0.6));
}

.heart.lost {
    opacity: 0.25;
    filter: grayscale(100%);
    transform: scale(0.8);
}

.heart.shake {
    animation: heartShake 0.4s ease;
}

@keyframes heartShake {
    0%, 100% { transform: scale(1); }
    20% { transform: scale(1.3) rotate(-15deg); }
    50% { transform: scale(0.9) rotate(15deg); }
    80% { transform: scale(1.1) rotate(-5deg); }
}

.hud-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-icon {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-main);
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    outline: none;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.18);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn-icon:active {
    transform: translateY(1px);
}

/* Canvas Area */
.canvas-wrapper {
    position: relative;
    width: 100%;
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(255, 255, 255, 0.1);
    background: #060914;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    cursor: grab;
}

#gameCanvas:active {
    cursor: grabbing;
}

/* Modal Overlays */
.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(6, 9, 20, 0.82);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 20;
    padding: 20px;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: linear-gradient(145deg, rgba(28, 35, 62, 0.95), rgba(16, 21, 38, 0.95));
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 24px;
    padding: 32px 36px;
    max-width: 460px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7), 0 0 30px rgba(79, 172, 254, 0.2);
    transform: translateY(20px) scale(0.95);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.active .modal-card {
    transform: translateY(0) scale(1);
}

.modal-title {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #ffd15c 0%, #ff8c42 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 0.5px;
}

.modal-card.game-over .modal-title {
    background: linear-gradient(135deg, #ff7675 0%, #e84393 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.modal-desc {
    color: var(--text-muted);
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 24px;
}

.instructions-box {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 14px;
    padding: 14px 18px;
    margin-bottom: 24px;
    text-align: left;
    font-size: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.instruction-item {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-main);
}

.instruction-item .icon {
    font-size: 18px;
}

.score-summary {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 24px;
}

.summary-card {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 14px 22px;
    min-width: 120px;
}

.summary-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.summary-value {
    font-size: 32px;
    font-weight: 800;
    color: var(--accent-gold);
}

.new-record-badge {
    display: inline-block;
    background: linear-gradient(90deg, #ff9f43, #ee5253);
    color: white;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 12px;
    margin-bottom: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    animation: pulseGlow 1.5s infinite;
}

@keyframes pulseGlow {
    0%, 100% { transform: scale(1); box-shadow: 0 0 10px rgba(238, 82, 83, 0.5); }
    50% { transform: scale(1.05); box-shadow: 0 0 18px rgba(255, 159, 67, 0.8); }
}

.btn-primary {
    background: linear-gradient(135deg, #ffc439 0%, #ff7e40 100%);
    color: #1e1302;
    border: none;
    font-size: 17px;
    font-weight: 700;
    padding: 14px 36px;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(255, 134, 64, 0.4);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    outline: none;
}

.btn-primary:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 10px 25px rgba(255, 134, 64, 0.6);
}

.btn-primary:active {
    transform: translateY(1px) scale(0.98);
}

/* Key hints below */
.keys-hint {
    margin-top: 14px;
    font-size: 12px;
    color: var(--text-muted);
}

.key-badge {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    padding: 2px 6px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 11px;
    color: #fff;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .game-container {
        padding: 6px;
    }
    .hud-bar {
        padding: 8px 12px;
    }
    .hud-pill {
        padding: 4px 10px;
        font-size: 13px;
    }
    .modal-card {
        padding: 24px 20px;
    }
    .modal-title {
        font-size: 22px;
    }
    .summary-value {
        font-size: 26px;
    }
}
