html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    color: rgba(255, 255, 255, 0.87);
    /* Àdìrẹ indigo resist-dye border backdrop for widescreen desktops */
    background-color: #0b132b;
    background-image:
        radial-gradient(circle at 25% 20%, rgba(69, 123, 157, 0.16) 0, rgba(69, 123, 157, 0.16) 14px, transparent 15px),
        radial-gradient(circle at 75% 70%, rgba(244, 162, 97, 0.10) 0, rgba(244, 162, 97, 0.10) 10px, transparent 11px),
        repeating-linear-gradient(45deg, rgba(29, 53, 87, 0.5) 0 24px, rgba(11, 19, 43, 0.5) 24px 48px);
    font-family: Arial, Helvetica, sans-serif;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

#app {
    position: relative;
    width: 100%;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action: none;
}

#game-container {
    width: 100%;
    height: 100%;
    touch-action: none;
}

#game-container canvas {
    touch-action: none;
}

#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    display: flex;
    flex-direction: column;
}

#hud button,
#hud a,
#hud input,
#hud [role="button"],
#hud .interactive {
    pointer-events: auto;
}

/* ---------------- HUD ---------------- */
.hud-top {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: min(100%, 540px);
    padding: 10px 14px 0;
    box-sizing: border-box;
}

.hud-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.hud-score { display: flex; flex-direction: column; }
.hud-label { font-size: 10px; letter-spacing: 2px; color: #a8b8d0; }
.hud-value { font-size: 24px; font-weight: bold; color: #ffd166; }

.hud-combo {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
}
.combo-count { font-size: 30px; font-weight: bold; color: #f8f9fa; line-height: 1; }
.combo-mult { font-size: 12px; letter-spacing: 1px; color: #e9c46a; }

.hud-buttons { display: flex; gap: 10px; }
.icon-btn {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    border: 1px solid rgba(241, 250, 238, 0.35);
    background: rgba(28, 37, 65, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.icon-btn:active { background: rgba(69, 123, 157, 0.6); }

.hud-phase-row {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 12px;
    letter-spacing: 2px;
}
.phase-name { color: #f4a261; font-weight: bold; }
.accuracy { color: #a8b8d0; }

.progress-track {
    margin-top: 5px;
    height: 6px;
    border-radius: 3px;
    background: rgba(29, 53, 87, 0.9);
    overflow: hidden;
}
.song-progress {
    font-size: 12px;
    letter-spacing: 0.08em;
    color: #ffd166;
    opacity: 0.85;
    font-variant-numeric: tabular-nums;
}

.progress-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, #e07a5f, #f4a261, #ffd166);
    transition: width 0.25s linear;
}

.combo-flare {
    position: absolute;
    top: 96px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 34px;
    font-weight: bold;
    color: #ffd166;
    text-shadow: 0 0 18px rgba(255, 209, 102, 0.8);
    animation: flare 0.4s ease-out;
    pointer-events: none;
}
@keyframes flare {
    0% { transform: translateX(-50%) scale(1.5); opacity: 1; }
    100% { transform: translateX(-50%) scale(1); opacity: 0.85; }
}

/* ---------------- Touch lanes ---------------- */
/* Hide touch zones on desktop pointers so they never cover the strike line */
@media (hover: hover) and (pointer: fine) {
    .touch-lanes {
        display: none;
    }
}

/* Warm HUD glow once the city awakens (city-awakens event) */
#hud.city-awake .hud-top {
    box-shadow: 0 0 24px rgba(255, 209, 102, 0.35);
}

.touch-lanes {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: min(100%, 540px);
    height: 120px;
    display: flex;
    gap: 8px;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
    box-sizing: border-box;
}

.lane-btn {
    flex: 1;
    min-height: 96px;
    border-radius: 16px;
    border: 2px solid rgba(248, 249, 250, 0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    font-family: inherit;
    transition: transform 0.05s;
}
.lane-btn:active { transform: scale(0.96); }
.lane-low { background: rgba(224, 122, 95, 0.35); }
.lane-mid { background: rgba(244, 162, 97, 0.35); }
.lane-high { background: rgba(248, 249, 250, 0.22); }
.lane-name { font-size: 18px; font-weight: bold; letter-spacing: 2px; color: #f8f9fa; }
.lane-key { font-size: 11px; color: rgba(248, 249, 250, 0.7); }

/* ---------------- Overlays ---------------- */
.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px;
    box-sizing: border-box;
    background: rgba(11, 19, 43, 0.82);
    backdrop-filter: blur(3px);
    pointer-events: auto;
    z-index: 50;
}

.menu-overlay { gap: 10px; }
.drum-emblem { filter: drop-shadow(0 0 24px rgba(244, 162, 97, 0.45)); }
.game-title {
    margin: 6px 0 0;
    font-size: 56px;
    letter-spacing: 8px;
    color: #ffd166;
    text-shadow: 0 0 30px rgba(255, 209, 102, 0.5);
}
.game-subtitle {
    margin: 0;
    font-size: 20px;
    letter-spacing: 5px;
    color: #f1faee;
    font-weight: normal;
}
.tagline {
    margin: 8px 0;
    max-width: 400px;
    font-size: 14px;
    line-height: 1.5;
    color: #a8b8d0;
}
.mechanics-card {
    max-width: 420px;
    background: rgba(29, 53, 87, 0.55);
    border: 1px solid rgba(69, 123, 157, 0.5);
    border-radius: 14px;
    padding: 12px 18px;
    font-size: 13px;
    line-height: 1.55;
    color: #dce6f2;
}
.mechanics-card p { margin: 6px 0; }

.primary-btn {
    margin-top: 14px;
    min-height: 64px;
    padding: 0 44px;
    font-size: 20px;
    font-weight: bold;
    letter-spacing: 3px;
    color: #0b132b;
    background: linear-gradient(180deg, #ffd166, #f4a261);
    border: none;
    border-radius: 32px;
    cursor: pointer;
    box-shadow: 0 0 28px rgba(255, 209, 102, 0.45);
    font-family: inherit;
}
.primary-btn:active { transform: scale(0.97); }

.secondary-btn {
    margin-top: 12px;
    min-height: 48px;
    padding: 0 28px;
    font-size: 14px;
    letter-spacing: 2px;
    color: #f1faee;
    background: transparent;
    border: 1px solid rgba(241, 250, 238, 0.5);
    border-radius: 24px;
    cursor: pointer;
    font-family: inherit;
}
.secondary-btn:active { background: rgba(69, 123, 157, 0.4); }

/* Countdown */
.countdown-overlay { background: rgba(11, 19, 43, 0.35); pointer-events: none; }
.countdown-text {
    font-size: 52px;
    font-weight: bold;
    letter-spacing: 6px;
    color: #ffd166;
    text-shadow: 0 0 30px rgba(255, 209, 102, 0.7);
    animation: pulse 1s ease-in-out infinite;
}
.countdown-sub { font-size: 15px; color: #dce6f2; letter-spacing: 2px; margin-top: 8px; }
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

/* Pause */
.pause-title { font-size: 42px; letter-spacing: 8px; color: #f8f9fa; margin: 0 0 6px; }
.pause-sub { color: #a8b8d0; margin: 0 0 18px; font-size: 14px; }

/* Results */
.results-overlay { gap: 8px; }
.rank-badge {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 64px;
    font-weight: bold;
    color: #0b132b;
    background: radial-gradient(circle, #ffd166, #f4a261);
    box-shadow: 0 0 40px rgba(255, 209, 102, 0.6);
}
.rank-badge.rank-D { background: radial-gradient(circle, #8fa3bf, #457b9d); color: #f1faee; }
.rank-badge.rank-C { background: radial-gradient(circle, #a8dadc, #457b9d); color: #0b132b; }
.rank-epithet { margin: 10px 0 0; font-size: 20px; color: #e9c46a; font-style: italic; font-weight: normal; }
.final-score { font-size: 46px; font-weight: bold; color: #f8f9fa; margin: 4px 0; }

.results-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    gap: 8px;
    margin: 8px 0 4px;
    width: min(100%, 340px);
}
.result-cell {
    background: rgba(29, 53, 87, 0.6);
    border: 1px solid rgba(69, 123, 157, 0.4);
    border-radius: 10px;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.rc-label { font-size: 10px; letter-spacing: 2px; color: #a8b8d0; }
.rc-value { font-size: 22px; font-weight: bold; color: #f8f9fa; }
.result-cell.perfect .rc-value { color: #ffd166; }
.result-cell.good .rc-value { color: #f1faee; }
.result-cell.miss .rc-value { color: #e07a5f; }

.restart-hint { font-size: 12px; color: #a8b8d0; margin: 6px 0 0; }