:root {
    --accent: #55ff9a;
    --accent-bright: #d8ffe8;
    --accent-rgb: 85, 255, 154;
    --surface: rgba(10, 15, 18, 0.9);
    --surface-strong: #10171b;
    --muted: #8d9b96;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: #050708;
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    padding: max(14px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    background:
        radial-gradient(circle at 50% 14%, rgba(var(--accent-rgb), 0.13), transparent 34%),
        linear-gradient(180deg, #080b0d 0%, #050708 100%);
    color: #f4f8f6;
    font-family: "Segoe UI", Arial, sans-serif;
    transition: background 0.8s ease;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: 0.28;
    background-image:
        linear-gradient(rgba(var(--accent-rgb), 0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(var(--accent-rgb), 0.025) 1px, transparent 1px);
    background-size: 32px 32px;
    mask-image: linear-gradient(to bottom, black, transparent 74%);
}

.game-container {
    position: relative;
    width: 100%;
    max-width: 430px;
    padding: 26px 20px 18px;
    overflow: hidden;
    text-align: center;
    background:
        linear-gradient(180deg, rgba(var(--accent-rgb), 0.045), transparent 32%),
        var(--surface);
    border: 1px solid rgba(var(--accent-rgb), 0.18);
    border-radius: 28px;
    box-shadow:
        0 28px 80px rgba(0, 0, 0, 0.48),
        inset 0 1px 0 rgba(255, 255, 255, 0.035),
        0 0 42px rgba(var(--accent-rgb), 0.04);
}

.game-container::before {
    content: "";
    position: absolute;
    top: 0;
    left: 18%;
    width: 64%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    box-shadow: 0 0 18px rgba(var(--accent-rgb), 0.7);
}

h1 {
    margin: 0 0 22px;
    color: var(--accent-bright);
    font-size: 40px;
    font-weight: 800;
    letter-spacing: 8px;
    line-height: 1;
    text-indent: 8px;
    text-shadow: 0 0 24px rgba(var(--accent-rgb), 0.38);
}

h1::after {
    content: "";
    display: block;
    width: 104px;
    height: 2px;
    margin: 13px auto 0;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.8);
}

h2 {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 3px;
}

#score {
    margin: 7px 0 11px;
    color: #f8fffb;
    font-size: 76px;
    font-variant-numeric: tabular-nums;
    font-weight: 750;
    line-height: 1;
    text-shadow:
        0 0 18px rgba(var(--accent-rgb), 0.22),
        0 5px 24px rgba(0, 0, 0, 0.45);
}

.timing-area {
    display: flex;
    justify-content: center;
    margin: 28px auto 25px;
}

.bar {
    position: relative;
    width: 350px;
    height: 32px;
    margin: 0 auto;
    overflow: hidden;
    background:
        radial-gradient(circle, rgba(255, 255, 255, 0.08) 0 2px, transparent 2.5px) 3px 50% / 18px 18px repeat-x,
        linear-gradient(180deg, #172127, #0d1317);
    border: 1px solid rgba(var(--accent-rgb), 0.17);
    border-radius: 16px;
    box-shadow:
        inset 0 2px 8px rgba(0, 0, 0, 0.72),
        0 0 0 4px rgba(255, 255, 255, 0.018),
        0 10px 28px rgba(0, 0, 0, 0.28);
}

#target {
    position: absolute;
    left: 135px;
    width: 80px;
    height: 100%;
    background:
        linear-gradient(90deg, rgba(var(--accent-rgb), 0.65), var(--accent), rgba(var(--accent-rgb), 0.72));
    border-inline: 1px solid var(--accent-bright);
    box-shadow:
        inset 0 0 10px rgba(255, 255, 255, 0.22),
        0 0 18px rgba(var(--accent-rgb), 0.72);
    transition: width 0.2s, background 0.35s, box-shadow 0.35s;
}

#marker {
    position: absolute;
    left: 0;
    width: 10px;
    height: 100%;
    background: #f8fffb;
    border-radius: 5px;
    box-shadow:
        0 0 6px #ffffff,
        0 0 14px rgba(var(--accent-rgb), 0.9),
        0 0 24px rgba(var(--accent-rgb), 0.48);
}

button {
    min-height: 48px;
    padding: 13px 28px;
    color: #041009;
    font: inherit;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 1.3px;
    text-transform: uppercase;
    cursor: pointer;
    background: linear-gradient(180deg, var(--accent-bright), var(--accent));
    border: 1px solid rgba(255, 255, 255, 0.48);
    border-radius: 14px;
    box-shadow:
        0 10px 24px rgba(var(--accent-rgb), 0.16),
        inset 0 1px 0 rgba(255, 255, 255, 0.54);
    transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.15s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

#tapButton {
    width: 100%;
    max-width: 326px;
}

@media (hover: hover) {
    button:hover {
        filter: brightness(1.07);
        transform: translateY(-2px);
        box-shadow:
            0 13px 30px rgba(var(--accent-rgb), 0.24),
            inset 0 1px 0 rgba(255, 255, 255, 0.62);
    }
}

button:active {
    filter: brightness(0.94);
    transform: translateY(1px) scale(0.995);
}

button:focus {
    outline: none;
}

button:focus-visible {
    outline: 2px solid var(--accent-bright);
    outline-offset: 3px;
}

button:disabled {
    cursor: default;
    filter: saturate(0.45);
    opacity: 0.52;
    transform: none;
}

#continuePanel {
    width: 100%;
    max-width: 350px;
    margin: 19px auto 0;
    padding: 15px;
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 89, 89, 0.2);
    border-radius: 18px;
    box-shadow: inset 0 0 24px rgba(255, 45, 45, 0.025);
}

#continuePanel[hidden] {
    display: none;
}

#continuePanel > p:first-child {
    margin: 0 0 13px;
    color: #ff8e8e;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 3px;
}

#continuePanel button {
    display: block;
    width: 100%;
    margin: 9px 0;
    padding: 11px 18px;
    font-size: 13px;
}

#endRunButton {
    color: #c2ccc8;
    background: #171e21;
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: none;
}

#continueStatus {
    min-height: 1.2em;
    margin: 11px 0 0;
    color: var(--muted);
    font-size: 12px;
}

#audioControls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
    max-width: 326px;
    margin: 27px auto 0;
}

#audioControls button {
    min-width: 0;
    padding: 11px 8px;
    color: #c9d7d1;
    font-size: 12px;
    letter-spacing: 0.35px;
    text-transform: none;
    background: linear-gradient(180deg, #182126, #11181c);
    border-color: rgba(var(--accent-rgb), 0.12);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

#privacyButton {
    min-height: 32px;
    margin-top: 14px;
    padding: 7px 14px;
    color: #77847f;
    font-size: 10px;
    font-weight: 650;
    letter-spacing: 1px;
    background: transparent;
    border: 1px solid #293337;
    border-radius: 10px;
    box-shadow: none;
}

#controlHint {
    margin: 13px 0 0;
    color: #68736f;
    font-size: 10px;
    font-weight: 650;
    letter-spacing: 1.8px;
}

.touch-hint {
    display: none;
}

.shake {
    animation: shake 0.3s;
}

.break {
    background: #ff3f52 !important;
    border-color: #ffd6da !important;
    box-shadow:
        inset 0 0 9px rgba(255, 255, 255, 0.5),
        0 0 12px #ff3045,
        0 0 30px rgba(255, 32, 52, 0.8) !important;
    animation: breakEffect 0.45s ease-out forwards;
}

.gold-mode {
    --accent: #ffd34e;
    --accent-bright: #fff4b0;
    --accent-rgb: 255, 211, 78;
}

.mythic-mode {
    --accent: #b77cff;
    --accent-bright: #f0ddff;
    --accent-rgb: 183, 124, 255;
}

.gold-mode #score,
.mythic-mode #score {
    color: var(--accent-bright);
    text-shadow:
        0 0 15px rgba(var(--accent-rgb), 0.82),
        0 0 38px rgba(var(--accent-rgb), 0.35);
}

.flash {
    animation: flashHit 0.15s;
}

@keyframes shake {
    0% { transform: translateX(0); }
    15% { transform: translateX(-10px); }
    30% { transform: translateX(10px); }
    45% { transform: translateX(-7px); }
    60% { transform: translateX(7px); }
    75% { transform: translateX(-3px); }
    100% { transform: translateX(0); }
}

@keyframes breakEffect {
    0% { transform: scale(1); opacity: 1; filter: brightness(1); }
    20% { transform: scale(1.12); filter: brightness(2); }
    48% { transform: scale(0.92); }
    75% { transform: scale(1.18); opacity: 0.78; }
    100% { transform: scale(0); opacity: 0; }
}

@keyframes flashHit {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.75); }
}

@media (hover: none), (pointer: coarse) {
    .touch-hint {
        display: inline;
    }

    .keyboard-hint {
        display: none;
    }
}

@media (max-width: 430px) {
    body {
        padding-inline: max(8px, env(safe-area-inset-left));
    }

    .game-container {
        padding: 23px 14px 16px;
        border-radius: 24px;
    }
}

@media (max-width: 374px) {
    .bar {
        transform: scaleX(calc((100vw - 36px) / 350));
    }

    h1 {
        font-size: 35px;
    }

    #score {
        font-size: 68px;
    }
}

@media (max-height: 690px) {
    .game-container {
        padding-block: 18px 13px;
    }

    h1 {
        margin-bottom: 16px;
        font-size: 34px;
    }

    #score {
        font-size: 62px;
    }

    .timing-area {
        margin-block: 20px;
    }

    #audioControls {
        margin-top: 20px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
