:root {
    --glow-color: #00ffff;
    color-scheme: only light;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #1a1a1a;
    overflow: hidden;
}

.bg-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    background-color: #1a1a1a;
}

.bg-image {
    width: 100%;
    height: 100%;
    background-image: url('./bg.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    filter: blur(10px);
    transform: scale(1.1);
    opacity: 0.8;
}

.bg-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
}

/* Keyboard Layout */
.keyboard-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 900px;
    padding: 20px;
    z-index: 10;
}

#game-area {
    position: relative;
    width: 100%;
    height: clamp(320px, 50vh, 520px);
    margin-bottom: 16px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    background: rgba(8, 10, 18, 0.28);
    box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.18);
}

.word-stream {
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    margin-bottom: 20px;
    padding: 10px 24px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    font-family: monospace;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.stream-word {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    white-space: nowrap;
}

.previous-word,
.next-word {
    flex: 1;
    color: rgba(255, 255, 255, 0.4);
    font-size: 24px;
}

.current-word {
    display: flex;
    flex: 2;
    justify-content: center;
    align-items: center;
    flex-wrap: nowrap;
    color: #fff;
    font-size: clamp(16px, 4vw, 36px);
    font-weight: 800;
    text-shadow: 0 0 12px rgba(255, 255, 255, 0.32);
}

.char {
    display: inline-block;
    margin: 0 clamp(0px, 0.4vw, 3px);
    color: rgba(255, 255, 255, 0.68);
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.18);
}

.char.correct {
    color: #8dffcf;
    text-decoration: line-through;
    text-shadow: 0 0 10px rgba(76, 255, 180, 0.8);
}

.char.missed {
    color: #ff8a8a;
    text-decoration: line-through;
    text-shadow: 0 0 10px rgba(255, 80, 80, 0.7);
}

.start-button {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 3;
    padding: 13px 24px;
    transform: translate(-50%, -50%);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 0 24px var(--glow-color);
    color: #15151a;
    font: inherit;
    font-size: 17px;
    font-weight: 800;
    cursor: pointer;
}

.start-button:hover {
    background: #fff;
    box-shadow: 0 0 32px var(--glow-color);
}

.start-button:focus-visible {
    outline: 3px solid var(--glow-color);
    outline-offset: 4px;
}

.start-button[hidden] {
    display: none;
}

.judgment-line {
    position: absolute;
    right: 0;
    bottom: 54px;
    left: 0;
    height: 2px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 0 8px #fff, 0 0 18px var(--glow-color);
}

.judgment-line.pulse {
    animation: beat-pulse 180ms ease-out;
}

.note {
    position: absolute;
    top: 0;
    left: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, 0.9);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 0 12px var(--glow-color), inset 0 0 10px rgba(255, 255, 255, 0.7);
    color: #15151a;
    font-size: 18px;
    font-weight: 700;
    text-shadow: none;
    pointer-events: none;
}

.note.hit {
    animation: note-hit 160ms ease-out forwards;
}

.judgment-feedback {
    position: absolute;
    right: 0;
    bottom: 76px;
    left: 0;
    color: #fff;
    font-size: clamp(22px, 4vw, 34px);
    font-weight: 800;
    letter-spacing: 3px;
    text-align: center;
    text-shadow: 0 0 10px var(--glow-color), 0 0 22px var(--glow-color);
    pointer-events: none;
}

.judgment-feedback.show {
    animation: feedback-float 700ms ease-out forwards;
}

.game-hud {
    position: fixed;
    top: 30px;
    left: 30px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 130px;
    padding: 16px 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.game-hud span {
    color: #fff;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 8px var(--glow-color);
}

.keyboard {
    display: flex;
    flex-direction: column;
    gap: clamp(8px, 1.5vw, 16px);
    width: 100%;
}

.key-row {
    display: flex;
    justify-content: center;
    gap: clamp(6px, 1vw, 12px);
}

/* Individual Keys */
.key {
    width: clamp(40px, 5vw, 64px);
    height: clamp(40px, 5vw, 64px);
    background-color: rgba(20, 20, 25, 0.85);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: clamp(16px, 2.5vw, 24px);
    font-weight: 600;
    color: #ffffff;
    box-shadow: 0 4px 6px rgba(0,0,0,0.4), inset 0 2px 4px rgba(255,255,255,0.05);
    transition: all 0.1s ease-out;
}

/* Active Key State (Pressed) */
.key.active {
    background-color: rgba(255, 255, 255, 0.15);
    border-color: var(--glow-color);
    box-shadow: 
        0 0 15px var(--glow-color), 
        0 0 30px var(--glow-color),
        inset 0 0 10px var(--glow-color);
    transform: scale(0.95);
    transition: all 0.05s ease-out;
    color: #ffffff;
    text-shadow: 0 0 8px var(--glow-color);
}

.key.note-glow {
    border-color: var(--glow-color);
    box-shadow:
        0 0 15px var(--glow-color),
        0 0 30px var(--glow-color),
        inset 0 0 10px var(--glow-color);
    text-shadow: 0 0 8px var(--glow-color);
}

@keyframes note-hit {
    to {
        opacity: 0;
        transform: scale(1.7);
        filter: brightness(2);
    }
}

@keyframes beat-pulse {
    0% {
        opacity: 1;
        height: 4px;
        box-shadow: 0 0 12px #fff, 0 0 28px var(--glow-color);
    }
    100% {
        opacity: 0.75;
        height: 2px;
    }
}

@keyframes feedback-float {
    0% {
        opacity: 1;
        transform: translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateY(-28px);
    }
}

/* Glassmorphism Settings Panel */
.settings-panel {
    position: fixed;
    top: 30px;
    right: 30px;
    padding: 20px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
    z-index: 100;
}

.settings-label {
    color: white;
    font-family: sans-serif;
    font-size: 14px;
    letter-spacing: 1px;
}

.color-options {
    display: flex;
    gap: 10px;
}

.color-button {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: transform 0.1s;
}

.color-button:hover {
    transform: scale(1.2);
}

@media (max-width: 650px) {
    .game-hud {
        top: 12px;
        left: 12px;
        min-width: 105px;
        padding: 10px 12px;
        font-size: 13px;
    }

    .settings-panel {
        top: 12px;
        right: 12px;
        padding: 12px;
    }

    .color-options {
        gap: 6px;
    }

    .color-button {
        width: 24px;
        height: 24px;
    }
}