:root {
    --primary: #39c5bb;
    /* Miku Teal */
    --secondary: #e0509e;
    /* Luka Pink */
    --accent: #f5d72b;
    /* Rin/Len Yellow */
    --accent2: #a0a0ff;
    /* Kaito Blue */
    --bg: #0a0a0a;
    --text: #fff;
    --font-main: 'Exo 2', sans-serif;
    --glass: rgba(20, 20, 20, 0.6);
    --glass-border: rgba(255, 255, 255, 0.1);
}

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

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font-main);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

#app {
    position: relative;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, #1a1a1a 0%, #000 100%);
}

/* Subtle grid overlay */
#background-fx {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(rgba(57, 197, 187, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(57, 197, 187, 0.03) 1px, transparent 1px);
    background-size: 60px 60px;
    z-index: 0;
    pointer-events: none;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 5;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.4);
    pointer-events: auto;
    transition: opacity 0.5s ease;
    backdrop-filter: blur(2px);
}

.screen.active {
    display: flex;
}

/* --- Main Menu Styling --- */

#start-screen {
    background: radial-gradient(circle, rgba(0, 0, 0, 0.2) 0%, rgba(0, 0, 0, 0.8) 100%);
}

.title {
    font-size: 7rem;
    font-weight: 900;
    color: #fff;
    text-shadow:
        0 0 10px var(--primary),
        0 0 40px var(--primary),
        0 0 80px var(--primary);
    margin-bottom: 0;
    letter-spacing: 15px;
    text-transform: uppercase;
    animation: titleEntry 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    opacity: 0;
    transform: translateY(-50px);
}

.subtitle {
    font-size: 1.2rem;
    color: var(--primary);
    margin-bottom: 80px;
    letter-spacing: 8px;
    text-transform: uppercase;
    font-weight: 700;
    opacity: 0;
    animation: fadeInUp 0.8s ease-out 0.5s forwards;
}

.upload-container {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    opacity: 0;
    animation: fadeInUp 0.8s ease-out 0.8s forwards;
}

input[type="file"] {
    display: none;
}

/* Premium Button Style */
.btn-premium {
    position: relative;
    padding: 18px 60px;
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 3px;
    transition: all 0.3s ease;
    overflow: hidden;
    font-family: var(--font-main);
    backdrop-filter: blur(5px);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

.btn-premium::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: 0.5s;
}

.btn-premium:hover::before {
    left: 100%;
}

.btn-premium:hover {
    background: rgba(57, 197, 187, 0.2);
    border-color: var(--primary);
    box-shadow: 0 0 20px rgba(57, 197, 187, 0.4);
    transform: translateY(-2px);
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
}

.custom-file-upload {
    /* Inherit basic button props but can be specific */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Specific overrides for buttons generated in JS */
#play-btn {
    background: var(--primary);
    color: #000;
    border: none;
    box-shadow: 0 0 20px rgba(57, 197, 187, 0.3);
}

#play-btn:hover {
    background: #fff;
    box-shadow: 0 0 40px rgba(57, 197, 187, 0.6);
    transform: scale(1.05);
}

#status-text {
    margin-top: 30px;
    font-family: monospace;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.9rem;
    height: 20px;
    letter-spacing: 1px;
    opacity: 0;
    animation: fadeInUp 0.8s ease-out 1s forwards;
}

/* --- Game UI --- */

#game-ui {
    background: transparent;
    pointer-events: none;
    justify-content: space-between;
    padding: 40px;
    backdrop-filter: none;
}

.hud-top {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.score-container,
.combo-container {
    display: flex;
    flex-direction: column;
}

.score-container {
    align-items: flex-start;
}

.combo-container {
    align-items: flex-end;
}

.label {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.6);
    letter-spacing: 3px;
    margin-bottom: 5px;
    font-weight: 700;
}

#score {
    font-size: 3rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 0 15px var(--primary);
    font-variant-numeric: tabular-nums;
    font-family: 'Exo 2', sans-serif;
}

#combo {
    font-size: 5rem;
    font-weight: 900;
    color: var(--secondary);
    text-shadow: 0 0 25px rgba(224, 80, 158, 0.6);
    line-height: 1;
}

#combo.pulse {
    animation: comboPulse 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes comboPulse {
    0% {
        transform: scale(1.3);
    }

    100% {
        transform: scale(1);
    }
}

#feedback-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 4rem;
    font-weight: 900;
    font-style: italic;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
    opacity: 0;
    z-index: 20;
    pointer-events: none;
}

/* Key Guide */
.key-guide {
    display: flex;
    gap: 30px;
    margin-bottom: 40px;
}

.key-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0.4;
    transition: all 0.1s;
}

.key-item.active {
    opacity: 1;
    transform: translateY(4px);
}

.key-symbol {
    font-size: 2rem;
    margin-bottom: 10px;
    text-shadow: 0 0 15px currentColor;
}

.key-letter {
    font-size: 1rem;
    font-weight: 700;
    border: 1px solid rgba(255, 255, 255, 0.3);
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(5px);
}

.key-item.active .key-letter {
    background: #fff;
    color: #000;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
    border-color: #fff;
}

.key-primary {
    color: var(--primary);
}

.key-secondary {
    color: var(--secondary);
}

.key-accent {
    color: var(--accent);
}

.key-accent2 {
    color: var(--accent2);
}

/* --- Results Screen --- */

#results-screen h2 {
    font-size: 5rem;
    color: #fff;
    margin-bottom: 50px;
    text-transform: uppercase;
    letter-spacing: 10px;
    text-shadow: 0 0 30px var(--primary);
    animation: fadeInUp 0.8s ease-out forwards;
}

.result-stat {
    font-size: 2.5rem;
    margin: 10px 0;
    display: flex;
    gap: 30px;
    opacity: 0;
    animation: fadeInUp 0.8s ease-out 0.3s forwards;
}

.result-stat span {
    font-weight: 700;
    color: var(--primary);
    text-shadow: 0 0 15px var(--primary);
}

#restart-btn {
    margin-top: 60px;
    opacity: 0;
    animation: fadeInUp 0.8s ease-out 0.6s forwards;
}

/* --- Animations --- */

@keyframes titleEntry {
    0% {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
        filter: blur(10px);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

@keyframes fadeInUp {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}