:root {
    --bg-1: #07111f;
    --bg-2: #1b2435;
    --bg-3: #0f1728;
    --accent-1: #32f6d2;
    --accent-2: #ffb347;
    --accent-3: #ff5f7a;
    --ink: #ecf2ff;
    --ink-dim: #9bb0d7;
    --card: rgba(13, 21, 37, 0.74);
    --card-border: rgba(141, 177, 235, 0.24);
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: radial-gradient(1200px 700px at 15% 10%, #1d2b44 0%, transparent 58%),
        radial-gradient(900px 700px at 85% 85%, #282a4a 0%, transparent 60%),
        linear-gradient(160deg, var(--bg-1), var(--bg-2) 45%, var(--bg-3));
    color: var(--ink);
    font-family: 'Chakra Petch', sans-serif;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

#app {
    width: 100%;
    height: 100%;
    max-width: 520px;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04), 0 20px 70px rgba(5, 12, 24, 0.55);
}

.screen {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.screen.active {
    display: flex;
}

.overlay {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(6, 10, 18, 0.78);
    z-index: 100;
    backdrop-filter: blur(7px);
}

.overlay.active {
    display: flex;
}

.game-logo {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 3rem;
    letter-spacing: 0.18em;
    font-weight: 400;
    text-shadow: 0 0 20px rgba(50, 246, 210, 0.4);
}

.game-logo span {
    color: var(--accent-2);
    text-shadow: 0 0 28px rgba(255, 179, 71, 0.45);
}

.game-logo.large {
    font-size: 4rem;
}

#screen-loading,
#screen-menu,
#screen-results {
    align-items: center;
    justify-content: center;
}

#screen-loading {
    background: radial-gradient(circle at 30% 30%, rgba(255, 179, 71, 0.18), transparent 38%),
        radial-gradient(circle at 70% 70%, rgba(50, 246, 210, 0.14), transparent 40%);
}

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

.loading-bar-container {
    width: 280px;
    height: 10px;
    margin: 28px auto 14px;
    border-radius: 999px;
    background: rgba(20, 33, 56, 0.75);
    border: 1px solid rgba(160, 200, 255, 0.2);
    overflow: hidden;
}

.loading-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-1), var(--accent-2), var(--accent-3));
    transition: width 0.2s linear;
}

.loading-text {
    color: var(--ink-dim);
    font-size: 0.8rem;
    letter-spacing: 0.08em;
}

#screen-menu {
    background: linear-gradient(145deg, rgba(19, 32, 54, 0.86), rgba(11, 19, 32, 0.9));
}

.menu-bg {
    position: absolute;
    inset: 0;
    background-image: linear-gradient(rgba(134, 169, 223, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(134, 169, 223, 0.05) 1px, transparent 1px);
    background-size: 22px 22px;
    opacity: 0.5;
    animation: drift 12s linear infinite;
}

@keyframes drift {
    from { transform: translateY(0); }
    to { transform: translateY(22px); }
}

.menu-content {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 30px 20px;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 44px;
}

.menu-stats {
    margin-top: 30px;
    display: flex;
    gap: 28px;
    justify-content: center;
    color: var(--ink-dim);
    font-size: 0.8rem;
}

.stat span {
    color: var(--accent-1);
    font-weight: 700;
}

.btn {
    font-family: 'Chakra Petch', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    border-radius: 14px;
    padding: 14px 28px;
    min-width: 220px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    color: #08243c;
    background: linear-gradient(135deg, var(--accent-1), #92ffe9);
    box-shadow: 0 8px 24px rgba(50, 246, 210, 0.25);
}

.btn-secondary {
    color: var(--ink);
    background: var(--card);
    border-color: var(--card-border);
}

.btn-danger {
    color: #ffd5dd;
    background: rgba(141, 18, 44, 0.45);
    border-color: rgba(255, 121, 146, 0.42);
}

.screen-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: rgba(9, 15, 27, 0.82);
    border-bottom: 1px solid rgba(130, 171, 238, 0.2);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 20;
}

.screen-header h2 {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.35rem;
    letter-spacing: 0.12em;
    font-weight: 400;
}

.btn-back {
    background: transparent;
    color: var(--ink);
    border: 1px solid rgba(154, 193, 255, 0.35);
    border-radius: 10px;
    padding: 4px 10px;
    font-size: 1rem;
}

.header-stars {
    color: var(--accent-2);
}

.artist-grid,
.song-list,
.difficulty-list,
.instrument-list,
.catalogue-list,
.settings-list {
    padding: 14px;
    display: grid;
    gap: 12px;
}

.artist-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.song-list,
.difficulty-list,
.instrument-list,
.catalogue-list,
.settings-list {
    grid-template-columns: 1fr;
}

.artist-card,
.song-card,
.difficulty-card,
.catalogue-card {
    background: linear-gradient(130deg, rgba(14, 24, 42, 0.82), rgba(10, 17, 31, 0.88));
    border: 1px solid var(--card-border);
    border-radius: 16px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.artist-card {
    text-align: center;
    padding: 12px;
    position: relative;
    cursor: pointer;
    overflow: hidden;
}

.artist-avatar {
    width: 66px;
    height: 66px;
    border-radius: 14px;
    margin: 0 auto 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
}

.artist-cover {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 12px;
    object-fit: cover;
    margin: 0 auto 10px;
    display: block;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}

.artist-card:hover .artist-cover {
    transform: translateY(-2px) scale(1.01);
    transition: transform 120ms ease;
}

.artist-name { font-size: 0.8rem; font-weight: 700; }
.artist-songs-count { color: var(--ink-dim); font-size: 0.65rem; margin-top: 3px; }
.artist-card.locked { opacity: 0.48; }
.artist-lock-overlay {
    position: absolute;
    inset: 0;
    border-radius: 16px;
    background: rgba(4, 8, 14, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.song-card,
.difficulty-card,
.catalogue-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
}

.song-info,
.difficulty-info,
.catalogue-info { flex: 1; min-width: 0; }
.song-title,
.difficulty-name,
.catalogue-name { font-size: 0.86rem; font-weight: 700; }
.song-duration,
.difficulty-desc,
.catalogue-desc,
.song-best-score { color: var(--ink-dim); font-size: 0.66rem; margin-top: 3px; }
.song-best-stars,
.difficulty-stars .song-best-stars { color: var(--accent-2); }

.difficulty-badge,
.instrument-badge,
.catalogue-avatar {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.instrument-badge { background: rgba(50, 246, 210, 0.14); font-size: 1.5rem; }

.catalogue-unlocked-badge { color: var(--accent-1); font-size: 0.68rem; }
.catalogue-cost { color: var(--accent-2); font-weight: 700; }

.btn-unlock {
    margin-top: 6px;
    border: 0;
    border-radius: 8px;
    padding: 6px 12px;
    color: #081d31;
    background: linear-gradient(120deg, var(--accent-1), #9fffe5);
    font-weight: 700;
    font-family: 'Chakra Petch', sans-serif;
}

#screen-game {
    background: radial-gradient(700px 420px at 50% 0%, rgba(61, 88, 133, 0.35), rgba(7, 12, 24, 0.95));
}

#game-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.game-hud {
    position: absolute;
    inset: 0 0 auto 0;
    z-index: 24;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 10px;
    pointer-events: none;
}

.game-hud > * { pointer-events: auto; }

.score {
    font-family: 'Bebas Neue', sans-serif;
    letter-spacing: 0.08em;
    font-size: 2rem;
    line-height: 1;
}

.combo {
    color: var(--accent-2);
    font-weight: 700;
    font-size: 0.8rem;
    min-height: 1.2em;
}

.note-count {
    color: var(--ink-dim);
}

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

.song-progress-bar,
.overdrive-meter {
    width: 150px;
    height: 6px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(32, 47, 74, 0.75);
    border: 1px solid rgba(147, 184, 242, 0.2);
}

.song-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #81a9ff, #5dffdf);
}

.overdrive-wrap {
    text-align: center;
}

.overdrive-label {
    color: var(--ink-dim);
    font-size: 0.55rem;
    letter-spacing: 0.12em;
    margin-bottom: 2px;
}

.overdrive-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #59d7ff, #ffe48a, #ff9d6a);
}

.hud-right {
    display: flex;
    gap: 6px;
}

.btn-pause,
.btn-activate {
    border-radius: 10px;
    border: 1px solid rgba(147, 184, 242, 0.35);
    color: var(--ink);
    background: rgba(11, 21, 37, 0.78);
    padding: 8px 10px;
    font-weight: 700;
}

.btn-activate.ready {
    border-color: rgba(255, 215, 120, 0.9);
    box-shadow: 0 0 16px rgba(255, 215, 120, 0.4);
}

.btn-activate.active {
    background: linear-gradient(135deg, rgba(255, 205, 116, 0.9), rgba(255, 131, 82, 0.95));
    color: #29120c;
    border-color: rgba(255, 234, 193, 0.9);
}

.singer-container {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: 44%;
    opacity: 0.58;
    pointer-events: none;
}

.hit-feedback {
    position: absolute;
    left: 50%;
    bottom: 20%;
    transform: translateX(-50%);
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    opacity: 0;
}

.hit-feedback.show {
    animation: hitPop 0.35s ease-out forwards;
}

@keyframes hitPop {
    0% { opacity: 1; transform: translateX(-50%) scale(1.18); }
    100% { opacity: 0; transform: translateX(-50%) scale(0.86) translateY(-18px); }
}

.hit-perfect { color: #ffe48a; }
.hit-great { color: #5dffdf; }
.hit-good { color: #9fc2ff; }
.hit-miss { color: #ff8098; }

.results-content {
    width: 100%;
    padding: 20px;
    text-align: center;
}

.results-content h2 {
    font-family: 'Bebas Neue', sans-serif;
    letter-spacing: 0.12em;
    font-weight: 400;
    font-size: 2rem;
}

.results-grade {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 6rem;
    line-height: 0.9;
    color: #fff;
    text-shadow: 0 0 30px rgba(93, 255, 223, 0.5);
}

.results-stars {
    color: var(--accent-2);
    letter-spacing: 0.2em;
    font-size: 1.7rem;
    margin: 8px 0 18px;
}

.results-stats {
    max-width: 320px;
    margin: 0 auto 16px;
}

.result-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(124, 160, 220, 0.24);
}

.results-unlock {
    background: rgba(255, 192, 102, 0.14);
    border: 1px solid rgba(255, 192, 102, 0.34);
    border-radius: 10px;
    max-width: 320px;
    margin: 0 auto 16px;
    padding: 10px;
}

.results-buttons {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
}

.setting-item {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    padding: 12px;
}

.setting-item label {
    display: block;
    margin-bottom: 8px;
    color: var(--ink-dim);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
}

.setting-item input[type='range'] {
    width: 100%;
    accent-color: var(--accent-1);
}

.setting-hint {
    margin-top: 6px;
    font-size: 0.62rem;
    color: var(--ink-dim);
}

.calibration-content {
    padding: 22px 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.calibration-instructions {
    text-align: center;
    color: var(--ink-dim);
    font-size: 0.78rem;
}

.calibration-pulse {
    width: 82px;
    height: 82px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(93, 255, 223, 0.6), rgba(93, 255, 223, 0.06));
    box-shadow: 0 0 0 0 rgba(93, 255, 223, 0.3);
}

.calibration-pulse.pulse {
    animation: calPulse 0.36s ease-out;
}

@keyframes calPulse {
    0% { transform: scale(0.86); box-shadow: 0 0 0 0 rgba(93, 255, 223, 0.42); }
    100% { transform: scale(1.08); box-shadow: 0 0 0 22px rgba(93, 255, 223, 0); }
}

.calibration-readout {
    font-size: 0.9rem;
    color: var(--accent-2);
}

.overlay-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.overlay-content h2 {
    font-family: 'Bebas Neue', sans-serif;
    letter-spacing: 0.12em;
    font-weight: 400;
    font-size: 2rem;
}

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(156, 194, 255, 0.42); border-radius: 999px; }

@media (max-width: 430px) {
    .game-logo.large { font-size: 3.5rem; }
    .score { font-size: 1.7rem; }
    .song-progress-bar, .overdrive-meter { width: 126px; }
    .btn { min-width: 190px; }
}