:root {
    --bg-color: #050505;
    --panel-bg: #111117;
    --panel-bg-soft: #191922;
    --primary: #9d00ff;
    --secondary: #00f2ff;
    --danger: #ff3d82;
    --success: #4dff88;
    --text-main: #ffffff;
    --text-muted: #a9a9ba;
    --border: rgba(255, 255, 255, 0.1);
    --nav-height: 80px;
}

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

body {
    font-family: "Outfit", sans-serif;
    background:
        radial-gradient(circle at 20% 0%, rgba(157, 0, 255, 0.13) 0%, transparent 40%),
        radial-gradient(circle at 80% 20%, rgba(0, 242, 255, 0.08) 0%, transparent 45%),
        var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1,
h2,
h3 {
    font-family: "Space Grotesk", sans-serif;
}

.container {
    width: min(1280px, 100%);
    margin: 0 auto;
    padding: 0 2rem;
}

header {
    height: var(--nav-height);
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(5, 5, 5, 0.92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

nav {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.logo-link {
    text-decoration: none;
    color: inherit;
}

.logo {
    font-size: 1.45rem;
    font-weight: 800;
    letter-spacing: -0.04em;
}

.logo span {
    color: var(--primary);
}

.nav-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.live-indicator {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: var(--secondary);
    box-shadow: 0 0 10px var(--secondary);
    animation: pulse 1.3s infinite;
}

.header-actions,
.footer-links {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.btn {
    text-decoration: none;
    display: inline-block;
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.7rem 1.2rem;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    transition: 0.25s ease;
    cursor: pointer;
}

.btn-outline {
    background: rgba(255, 255, 255, 0.02);
}

.btn-compact {
    padding: 0.45rem 0.7rem;
    font-size: 0.8rem;
}

.btn:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
}

.play-main {
    flex: 1 0 auto;
    padding: 2rem 0 3rem;
}

.hero-grid {
    display: grid;
    grid-template-columns: 1.25fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.panel {
    background: linear-gradient(160deg, rgba(17, 17, 23, 0.98), rgba(12, 12, 18, 0.9));
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.2rem;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.75rem;
    color: var(--secondary);
    font-weight: 700;
    margin-bottom: 0.7rem;
}

h1 {
    font-size: clamp(1.7rem, 4vw, 2.6rem);
    margin-bottom: 0.7rem;
}

.hero-copy,
.muted,
.hero-note {
    color: var(--text-muted);
}

.hero-note {
    margin-top: 0.8rem;
    font-size: 0.86rem;
}

.control-panel {
    display: grid;
    gap: 0.65rem;
}

.control-row {
    display: grid;
    gap: 0.35rem;
}

label {
    font-size: 0.9rem;
    color: #d8d8e4;
}

select,
input[type="range"] {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-main);
    padding: 0.6rem 0.7rem;
}

select {
    display: none;
}

.custom-select {
    position: relative;
}

.custom-select-trigger {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-main);
    padding: 0.65rem 0.75rem;
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.65rem;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.custom-select.is-open .custom-select-trigger,
.custom-select-trigger:hover {
    border-color: rgba(157, 0, 255, 0.7);
    box-shadow: 0 0 0 3px rgba(157, 0, 255, 0.15);
}

.custom-select-caret {
    color: var(--secondary);
    font-size: 0.86rem;
}

.custom-select-menu {
    position: absolute;
    z-index: 35;
    top: calc(100% + 0.35rem);
    left: 0;
    right: 0;
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: linear-gradient(180deg, rgba(20, 20, 28, 0.98), rgba(12, 12, 18, 0.98));
    box-shadow: 0 18px 36px rgba(0, 0, 0, 0.48);
    padding: 0.3rem;
}

.custom-select-option {
    width: 100%;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: #e4e5f3;
    padding: 0.5rem 0.6rem;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.custom-select-option:hover {
    border-color: rgba(0, 242, 255, 0.45);
    background: rgba(0, 242, 255, 0.12);
}

.custom-select-option.is-selected {
    border-color: rgba(157, 0, 255, 0.7);
    background: rgba(157, 0, 255, 0.2);
    color: #ffffff;
}

.toggle-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem;
    margin-top: 0.35rem;
}

.toggle-row label {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.action-row {
    display: flex;
    gap: 0.65rem;
    margin-top: 0.35rem;
}

body.is-controls-hidden .hero-panel {
    display: none;
}

body.is-controls-hidden .control-panel > :not(.action-row) {
    display: none;
}

body.is-controls-hidden .control-panel {
    gap: 0;
}

.game-panel {
    display: grid;
    gap: 1rem;
}

.game-top {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
}

.game-top-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    flex-wrap: wrap;
}

.status-pill {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
    color: var(--secondary);
}

.drill-route-preview {
    margin-top: 0.55rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
    min-height: 30px;
}

.route-token {
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 0.36rem 0.46rem;
    background: rgba(255, 255, 255, 0.03);
    display: grid;
    place-items: center;
}

.route-separator {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: rgba(0, 242, 255, 0.75);
    box-shadow: 0 0 10px rgba(0, 242, 255, 0.4);
}

.timing-hud {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.55rem 0.65rem;
    min-width: 180px;
    display: grid;
    gap: 0.3rem;
    background: rgba(255, 255, 255, 0.02);
}

.timing-hud p {
    display: flex;
    justify-content: space-between;
    gap: 0.7rem;
    font-size: 0.82rem;
    color: #c8c9dc;
}

.timing-hud strong {
    color: #ffffff;
    font-family: "Space Grotesk", sans-serif;
}

.input-lane {
    min-height: 460px;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.4rem;
    position: relative;
    overflow: hidden;
    background:
        repeating-linear-gradient(0deg, rgba(157, 0, 255, 0.05) 0 2px, transparent 2px 26px),
        linear-gradient(180deg, rgba(12, 12, 18, 0.96), rgba(8, 8, 12, 0.98));
    box-shadow: inset 0 0 28px rgba(0, 0, 0, 0.4);
}

.note-highway {
    position: absolute;
    inset: 0.8rem;
}

.note-highway .muted {
    padding: 1rem;
}

.hit-line {
    position: absolute;
    left: 1.2rem;
    right: 1.2rem;
    bottom: 5.2rem;
    height: 3px;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(157, 0, 255, 0.9), rgba(0, 242, 255, 0.9));
    box-shadow: 0 0 16px rgba(0, 242, 255, 0.4);
}

.hit-line span {
    position: absolute;
    right: 0;
    top: -1.35rem;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    color: #b5b7ce;
}

.input-echo {
    position: absolute;
    left: 50%;
    bottom: 4.1rem;
    transform: translateX(-50%) scale(0.85);
    opacity: 0;
    pointer-events: none;
    min-width: 108px;
    min-height: 62px;
    padding: 0.3rem 0.5rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(16, 16, 22, 0.9);
    display: grid;
    place-items: center;
    z-index: 4;
    transition: transform 120ms ease, opacity 120ms ease, border-color 120ms ease;
}

.input-echo.is-visible {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

.input-echo.is-hit {
    border-color: rgba(77, 255, 136, 0.75);
    box-shadow: 0 0 18px rgba(77, 255, 136, 0.35);
}

.input-echo.is-miss {
    border-color: rgba(255, 61, 130, 0.75);
    box-shadow: 0 0 18px rgba(255, 61, 130, 0.32);
}

.input-token {
    min-width: 98px;
    text-align: center;
    border-radius: 8px;
    border: 1px solid var(--border);
    padding: 0.35rem 0.45rem;
    font-weight: 700;
    color: #d9daeb;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.01));
    display: grid;
    place-items: center;
    gap: 0.18rem;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    transition: opacity 120ms linear, filter 120ms linear;
    z-index: 2;
}

.token-stack {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
}

.token-icon {
    width: 34px;
    height: 34px;
    object-fit: contain;
    filter: drop-shadow(0 0 8px rgba(0, 242, 255, 0.22));
}

.token-raw {
    font-size: 0.73rem;
    color: #bfc1d8;
}

.input-token.is-done {
    border-color: rgba(77, 255, 136, 0.55);
    color: var(--success);
    filter: brightness(1.08);
}

.input-token.is-current {
    border-color: rgba(157, 0, 255, 0.75);
    box-shadow: 0 0 0 2px rgba(157, 0, 255, 0.2);
    color: #ffffff;
    animation: beatPulse 380ms ease-in-out infinite alternate;
}

.input-token.is-holding {
    border-color: rgba(0, 242, 255, 0.9);
    box-shadow: 0 0 0 2px rgba(0, 242, 255, 0.2), 0 0 20px rgba(0, 242, 255, 0.28);
    animation: holdPulse 440ms ease-in-out infinite alternate;
}

.input-token.is-locked {
    opacity: 0.65;
}

.input-token.is-past {
    opacity: 0.2;
}

.recovery-block {
    display: grid;
    gap: 0.45rem;
}

.recovery-label-row {
    display: flex;
    justify-content: space-between;
    color: #d8d8e4;
    font-size: 0.9rem;
}

.recovery-bar {
    height: 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    overflow: hidden;
    background: rgba(255, 255, 255, 0.04);
}

.recovery-progress {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    transition: width 120ms linear;
}

.hud-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(120px, 1fr));
    gap: 0.55rem;
}

.hud-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.65rem;
    background: rgba(255, 255, 255, 0.02);
}

.hud-card p {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.hud-card strong {
    font-size: 1.1rem;
}

.legend {
    font-size: 0.86rem;
}

.judgment-popup {
    position: absolute;
    left: 50%;
    top: 1rem;
    transform: translateX(-50%) scale(0.9);
    opacity: 0;
    pointer-events: none;
    font-family: "Space Grotesk", sans-serif;
    font-size: clamp(1.8rem, 6vw, 3.5rem);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    transition: 140ms ease;
    z-index: 6;
}

.judgment-popup.is-visible {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

.judgment-popup.perfect {
    color: var(--success);
    text-shadow: 0 0 30px rgba(77, 255, 136, 0.45);
}

.judgment-popup.great {
    color: var(--secondary);
    text-shadow: 0 0 24px rgba(0, 242, 255, 0.4);
}

.judgment-popup.good {
    color: #ffe066;
    text-shadow: 0 0 24px rgba(255, 224, 102, 0.35);
}

.judgment-popup.late,
.judgment-popup.miss {
    color: var(--danger);
    text-shadow: 0 0 24px rgba(255, 61, 130, 0.35);
}

.result-modal {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 20% 20%, rgba(157, 0, 255, 0.18) 0%, transparent 42%),
        radial-gradient(circle at 80% 70%, rgba(0, 242, 255, 0.14) 0%, transparent 45%),
        rgba(0, 0, 0, 0.72);
    display: grid;
    place-items: center;
    z-index: 140;
    padding: 1rem;
    backdrop-filter: blur(4px);
}

body.is-focus-mode .result-modal {
    z-index: 220;
}

.result-modal[hidden] {
    display: none;
}

.result-card {
    width: min(420px, 100%);
    border: 1px solid rgba(157, 0, 255, 0.42);
    border-radius: 16px;
    background:
        linear-gradient(155deg, rgba(20, 20, 28, 0.98), rgba(10, 10, 16, 0.96));
    box-shadow:
        0 20px 45px rgba(0, 0, 0, 0.45),
        0 0 26px rgba(157, 0, 255, 0.22);
    padding: 1.2rem;
    display: grid;
    gap: 0.8rem;
}

.result-eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.09em;
    font-size: 0.73rem;
    font-weight: 700;
    color: var(--secondary);
}

.result-card h2 {
    font-size: clamp(1.5rem, 4vw, 2rem);
    margin: 0;
}

#result-summary {
    color: #d5d7ea;
    line-height: 1.45;
    padding: 0.65rem 0.75rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.09);
    background: rgba(255, 255, 255, 0.03);
}

.result-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    gap: 0.55rem;
}

.result-stat {
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 10px;
    padding: 0.55rem 0.6rem;
    background: rgba(255, 255, 255, 0.02);
}

.result-stat p {
    margin: 0;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #b6b9d0;
}

.result-stat strong {
    display: block;
    margin-top: 0.2rem;
    font-size: 1.25rem;
    line-height: 1.15;
    color: #ffffff;
    font-family: "Space Grotesk", sans-serif;
}

.result-btn {
    justify-self: end;
    border-color: rgba(157, 0, 255, 0.78);
    background: linear-gradient(90deg, rgba(157, 0, 255, 0.38), rgba(0, 242, 255, 0.3));
    box-shadow: 0 0 16px rgba(157, 0, 255, 0.25);
}

.result-btn:hover {
    border-color: rgba(0, 242, 255, 0.9);
    box-shadow: 0 0 20px rgba(0, 242, 255, 0.3);
}

.hotkey-card {
    width: min(560px, 100%);
}

.hotkey-list {
    display: grid;
    gap: 0.45rem;
    max-height: 52vh;
    overflow-y: auto;
    padding-right: 0.2rem;
}

.hotkey-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.7rem;
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.02);
    padding: 0.5rem 0.6rem;
}

.hotkey-row p {
    margin: 0;
    font-size: 0.84rem;
    color: #d7d9ea;
}

.hotkey-bind-btn {
    min-width: 120px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.hotkey-bind-btn.is-listening {
    border-color: rgba(0, 242, 255, 0.9);
    box-shadow: 0 0 18px rgba(0, 242, 255, 0.28);
}

.hotkey-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
}

body.is-focus-mode header,
body.is-focus-mode .hero-grid,
body.is-focus-mode footer {
    display: none;
}

body.is-focus-mode .play-main {
    padding: 0;
}

body.is-focus-mode .game-panel.container {
    width: 100%;
    max-width: none;
    position: fixed;
    inset: 0;
    border-radius: 0;
    border: none;
    margin: 0;
    z-index: 60;
    padding: 1rem 1.2rem;
    background: #050505;
    overflow: auto;
}

footer {
    border-top: 1px solid var(--border);
    padding: 1.35rem 0;
    margin-top: auto;
}

.footer-row {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.8rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.footer-row a {
    color: #d7b2ff;
    text-decoration: none;
}

@keyframes pulse {
    0% { opacity: 0.35; }
    50% { opacity: 1; }
    100% { opacity: 0.35; }
}

@keyframes beatPulse {
    from {
        transform: translateX(-50%) translateY(0);
    }
    to {
        transform: translateX(-50%) translateY(-2px);
    }
}

@keyframes holdPulse {
    0% {
        transform: translateX(-50%) scale(1);
        box-shadow: 0 0 0 2px rgba(0, 242, 255, 0.16), 0 0 14px rgba(0, 242, 255, 0.2);
        filter: brightness(1);
    }
    100% {
        transform: translateX(-50%) scale(1.05);
        box-shadow: 0 0 0 2px rgba(0, 242, 255, 0.35), 0 0 28px rgba(0, 242, 255, 0.45);
        filter: brightness(1.12);
    }
}

@media (max-width: 980px) {
    .hero-grid {
        grid-template-columns: 1fr;
    }

    .hud-grid {
        grid-template-columns: repeat(2, minmax(120px, 1fr));
    }

    .input-lane {
        min-height: 400px;
    }

    .nav-meta {
        display: none;
    }

    .game-top {
        flex-direction: column;
    }

    .game-top-actions {
        justify-content: flex-start;
        align-self: stretch;
    }
}

@media (max-width: 640px) {
    .container {
        padding: 0 1rem;
    }

    .header-actions {
        gap: 0.35rem;
    }

    .header-actions .btn {
        padding: 0.55rem 0.75rem;
    }

    .action-row {
        flex-wrap: wrap;
    }
}
