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

:root {
    --background: #07080d;
    --panel: rgba(15, 17, 27, 0.88);

    --white: #f4f4f7;
    --muted: #9297aa;

    --red: #ff4057;
    --red-dark: #8e1728;

    --gold: #ffd45c;
    --blue: #65b7ff;
    --green: #63e6a1;
}


html,
body {
    width: 100%;
    height: 100%;

    background: var(--background);

    color: var(--white);

    font-family:
        Arial,
        Helvetica,
        sans-serif;

    overflow: hidden;
}


button,
input {
    font: inherit;
}


/* ========================================
   GAME ROOT
======================================== */

#game {
    width: 100%;
    height: 100%;

    position: relative;

    overflow: hidden;

    background:
        radial-gradient(
            circle at 50% 45%,
            #202238 0%,
            #0d0f18 45%,
            #05060a 100%
        );
}


/* ========================================
   SCREENS
======================================== */

.screen {
    position: absolute;

    inset: 0;

    display: none;

    justify-content: center;
    align-items: center;

    overflow: hidden;
}

.screen.active {
    display: flex;
}


/* ========================================
   TITLE
======================================== */

/* V5 layout correction: title remains centered at full viewport size. */
#title-screen {
    display: flex;
    justify-content: center;
    align-items: center;
}
.title-content {
    margin: 0 auto;
}


#title-screen {

    position: relative;
    background:
        radial-gradient(
            circle at 50% 40%,
            rgba(255, 55, 80, 0.12),
            transparent 35%
        ),
        linear-gradient(
            135deg,
            #090a10,
            #111321
        );
}


.title-content {

    position: relative;
    z-index: 2;
    width: min(700px, 90%);

    text-align: center;

    animation:
        title-enter
        1s
        ease-out;
}


@keyframes title-enter {

    from {
        opacity: 0;
        transform: translateY(25px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }

}


.eyebrow {

    color: var(--muted);

    font-size: 11px;

    letter-spacing: 5px;

    margin-bottom: 20px;
}


.title-content h1 {

    font-size:
        clamp(70px, 15vw, 150px);

    line-height: 0.9;

    letter-spacing: 20px;

    margin-right: -20px;

    font-weight: 900;

    background:
        linear-gradient(
            180deg,
            #ffffff,
            #85899b
        );

    -webkit-background-clip: text;
    background-clip: text;

    color: transparent;

    text-shadow:
        0 0 60px rgba(255,255,255,0.08);
}


.title-subtitle {

    max-width: 500px;

    margin:
        35px
        auto
        40px;

    color: #aeb2c2;

    line-height: 1.7;

    font-size: 15px;
}


/* ========================================
   BUTTONS
======================================== */

.main-button {

    border: none;

    padding:
        14px
        32px;

    background: var(--white);

    color: #08090d;

    border-radius: 7px;

    font-weight: 800;

    font-size: 13px;

    letter-spacing: 2px;

    cursor: pointer;

    transition:
        transform .15s,
        background .15s,
        box-shadow .15s;
}


.main-button:hover {

    transform: translateY(-2px);

    box-shadow:
        0 8px 30px rgba(255,255,255,0.15);
}


.main-button:active {

    transform: scale(.97);
}


/* ========================================
   LANGUAGE
======================================== */

.language-buttons {

    display: flex;

    justify-content: center;

    gap: 8px;

    margin-top: 25px;
}


.language-button {

    border: 1px solid rgba(255,255,255,.15);

    background: transparent;

    color: #777c8e;

    padding:
        7px
        14px;

    border-radius: 5px;

    font-size: 11px;

    cursor: pointer;
}


.language-button.active {

    color: white;

    border-color:
        rgba(255,255,255,.5);

    background:
        rgba(255,255,255,.08);
}


.title-footer {

    position: absolute;

    bottom: 20px;

    width: 100%;

    text-align: center;

    color: #414555;

    font-size: 9px;

    letter-spacing: 3px;
}


/* ========================================
   GENERAL PANEL
======================================== */

.panel {

    width:
        min(520px, 90%);

    padding: 40px;

    text-align: center;

    background:
        var(--panel);

    border:
        1px solid
        rgba(255,255,255,.1);

    border-radius: 15px;

    box-shadow:
        0 30px 100px
        rgba(0,0,0,.45);

    backdrop-filter:
        blur(15px);
}


.panel h2 {

    font-size:
        clamp(25px, 5vw, 40px);

    margin-bottom: 20px;
}


.panel p {

    color: #9ea3b4;

    line-height: 1.7;
}


/* ========================================
   NAME SCREEN
======================================== */

#character-name {

    width: 100%;

    margin:
        30px
        0
        12px;

    padding: 14px 16px;

    border:
        1px solid
        rgba(255,255,255,.15);

    border-radius: 7px;

    background:
        rgba(0,0,0,.3);

    color: white;

    outline: none;

    text-align: center;
}


#character-name:focus {

    border-color:
        rgba(255,255,255,.5);

    box-shadow:
        0 0 20px
        rgba(255,255,255,.05);
}


.default-name {

    font-size: 12px;

    margin-bottom: 25px;
}


.default-name strong {

    color: var(--gold);
}


/* ========================================
   STORY
======================================== */

#story-screen {

    background:
        radial-gradient(
            circle at center,
            #151827,
            #05060a
        );
}


.story-container {

    width:
        min(750px, 88%);

    text-align: center;
}


.story-label {

    font-size: 11px;

    letter-spacing: 6px;

    color: #666b7e;

    margin-bottom: 40px;
}


.story-text-container {

    min-height: 230px;

    display: flex;

    justify-content: center;
    align-items: center;
}


.story-text {

    font-size:
        clamp(18px, 3vw, 28px);

    line-height: 1.7;

    color: #e6e7ed;

    animation:
        story-fade
        .6s
        ease;
}


@keyframes story-fade {

    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }

}


/* ========================================
   STAGE INTRO
======================================== */

#stage-intro-screen {

    background:
        radial-gradient(
            circle at 50% 40%,
            rgba(255,64,87,.12),
            transparent 40%
        );
}


.stage-intro {

    text-align: center;

    width:
        min(700px, 90%);
}


.stage-number {

    color: var(--red);

    letter-spacing: 5px;

    font-weight: bold;

    font-size: 13px;

    margin-bottom: 15px;
}


.stage-intro h2 {

    font-size:
        clamp(40px, 8vw, 75px);

    margin-bottom: 15px;
}


.stage-intro > p:not(.stage-number) {

    color: #9297aa;

    margin-bottom: 30px;
}


.stage-enemy-preview {

    width: 150px;
    height: 150px;

    margin:
        0
        auto
        30px;

    display: flex;

    justify-content: center;
    align-items: center;
}


/* ========================================
   SIMPLE ENEMY
======================================== */

.enemy-placeholder {

    position: relative;

    width: 100px;
    height: 100px;

    background:
        linear-gradient(
            145deg,
            #5b1724,
            #18070c
        );

    border-radius:
        45%
        45%
        40%
        40%;

    border:
        2px
        solid
        rgba(255,80,90,.4);

    box-shadow:
        0 0 35px
        rgba(255,40,60,.25);

    animation:
        enemy-idle
        2s
        ease-in-out
        infinite;
}


@keyframes enemy-idle {

    0%, 100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }

}


.enemy-placeholder::before,
.enemy-placeholder::after {

    content: "";

    position: absolute;

    top: -25px;

    width: 38px;
    height: 45px;

    background: #3c1019;

}


.enemy-placeholder::before {

    left: 2px;

    transform:
        rotate(-25deg)
        skewY(20deg);
}


.enemy-placeholder::after {

    right: 2px;

    transform:
        rotate(25deg)
        skewY(-20deg);
}


.devil-eye {

    position: absolute;

    top: 40px;

    width: 14px;
    height: 8px;

    background:
        #ff485e;

    box-shadow:
        0 0 12px
        #ff304b;

    border-radius: 50%;
}


.devil-eye.left {
    left: 25px;
}


.devil-eye.right {
    right: 25px;
}


/* ========================================
   BATTLE
======================================== */

#battle-screen {

    align-items: stretch;

    background:
        #07080d;
}


.battle-ui {

    position: absolute;

    top: 0;
    left: 0;

    width: 100%;

    padding: 15px;

    display: flex;

    justify-content: space-between;

    z-index: 20;
}


.player-status,
.enemy-status {

    width:
        min(300px, 32vw);

    padding: 12px;

    background:
        rgba(10,11,18,.85);

    border:
        1px
        solid
        rgba(255,255,255,.08);

    border-radius: 8px;

    backdrop-filter: blur(10px);
}


.enemy-status {

    text-align: right;
}


.ui-label {

    color: #73788a;

    font-size: 9px;

    letter-spacing: 2px;

    margin-bottom: 7px;
}


.enemy-name {

    font-weight: bold;

    font-size: 12px;

    margin-bottom: 8px;
}


.hp-wrapper {

    display: flex;

    align-items: center;

    gap: 8px;

    font-size: 10px;

    color: #aaa;
}


.hp-bar {

    height: 9px;

    flex: 1;

    background:
        #262936;

    border-radius: 20px;

    overflow: hidden;
}


.hp-fill {

    height: 100%;

    width: 100%;

    transition:
        width .25s ease;
}


.player-hp-fill {

    background:
        linear-gradient(
            90deg,
            #35d985,
            #8affbd
        );
}


.enemy-hp-fill {

    background:
        linear-gradient(
            90deg,
            #ff304c,
            #ff7888
        );
}


.battle-stats {

    display: flex;

    gap: 15px;

    margin-top: 8px;

    color: #72778a;

    font-size: 9px;
}


.battle-stats strong {

    color: white;

    margin-left: 3px;
}


/* ========================================
   BATTLE ARENA
======================================== */

#battle-arena {
    isolation: isolate;
    position: absolute;
    left: 50%;
    top: 90px;
    transform: translateX(-50%);
    width: min(600px, 72vw);
    height: calc(100% - 170px);
    overflow: hidden;
    border-left: 1px solid rgba(255,255,255,.07);
    border-right: 1px solid rgba(255,255,255,.07);
    background: linear-gradient(180deg, rgba(255,255,255,.015), rgba(255,255,255,.04));
}

.lanes {

    position: absolute;

    inset: 0;

    display: flex;
}


.lane {

    position: relative;

    width: 25%;

    height: 100%;

    border-right:
        1px
        solid
        rgba(255,255,255,.055);
}


.lane:last-child {

    border-right: none;
}


.lane-key {

    position: absolute;

    bottom: 15px;

    left: 50%;

    transform:
        translateX(-50%);

    width: 50px;
    height: 50px;

    border:
        2px
        solid
        rgba(255,255,255,.2);

    border-radius: 50%;

    display: flex;

    justify-content: center;
    align-items: center;

    color: #777b8c;

    font-weight: bold;

    background:
        rgba(255,255,255,.035);
}


#hit-line {

    position: absolute;

    left: 0;

    bottom: 40px;

    width: 100%;

    height: 2px;

    background:
        rgba(255,255,255,.6);

    box-shadow:
        0 0 12px
        rgba(255,255,255,.4);

    z-index: 10;
}


#battle-message {

    position: absolute;

    left: 50%;
    top: 35%;

    transform:
        translate(-50%, -50%);

    color:
        rgba(255,255,255,.25);

    letter-spacing: 6px;

    font-size: 22px;

    z-index: 5;
}


#judgement {

    position: absolute;

    left: 50%;
    top: 45%;

    transform:
        translate(-50%, -50%);

    font-size: 38px;

    font-weight: 900;

    opacity: 0;

    z-index: 30;

    pointer-events: none;
}


#judgement.show {

    animation:
        judgement-pop
        .45s
        ease-out;
}


@keyframes judgement-pop {

    0% {
        opacity: 0;

        transform:
            translate(-50%, -50%)
            scale(.4);
    }

    25% {
        opacity: 1;

        transform:
            translate(-50%, -50%)
            scale(1.25);
    }

    100% {
        opacity: 0;

        transform:
            translate(-50%, -50%)
            scale(1);
    }

}


/* ========================================
   MOBILE
======================================== */

#mobile-controls {

    position: absolute;

    bottom: 15px;

    left: 50%;

    transform:
        translateX(-50%);

    display: none;

    gap: 8px;

    z-index: 30;
}


#mobile-controls button {

    width: 60px;
    height: 60px;

    border:
        2px
        solid
        rgba(255,255,255,.2);

    border-radius: 50%;

    background:
        rgba(255,255,255,.07);

    color: white;

    font-weight: bold;

    touch-action: manipulation;
}


#mobile-controls button:active {

    transform: scale(.9);

    background:
        rgba(255,255,255,.2);
}


/* ========================================
   MOBILE LAYOUT
======================================== */

@media (max-width: 700px) {

    .title-content h1 {

        letter-spacing: 10px;

        margin-right: -10px;
    }


    .title-subtitle {

        font-size: 13px;

        margin-top: 25px;
    }


    .panel {

        padding: 25px;
    }


    .battle-ui {

        padding: 8px;
    }


    .player-status,
    .enemy-status {

        width: 46%;

        padding: 8px;
    }


    .enemy-name {

        font-size: 9px;
    }


    .battle-stats {

        gap: 7px;

        font-size: 8px;
    }


    #battle-arena {

        top: 90px;

        width: 94vw;

        height:
            calc(100% - 175px);
    }


    #mobile-controls {

        display: flex;
    }


    .lane-key {

        bottom: 12px;

        width: 45px;
        height: 45px;

        font-size: 13px;
    }


    #hit-line {

        bottom: 34px;
    }

}

/* ========================================
   RHYTHM NOTES
======================================== */

/* ========================================
   RHYTHM NOTES
======================================== */

.rhythm-note {

    position: absolute;

    top: 0;
    left: 0;

    width: 44px;
    height: 44px;

    margin: 0;

    border-radius: 50%;

    transform: translateX(0);

    background: #ffffff;

    border:
        3px solid
        rgba(255,255,255,.9);

    box-shadow:
        0 0 12px
        rgba(255,255,255,.9),

        0 0 30px
        rgba(100,130,255,.7);

    z-index: 15;

    pointer-events: none;

    will-change:
        transform;
}

/* Q */

.lane:nth-child(1) .rhythm-note {

    background:
        radial-gradient(
            circle at 35% 30%,
            #ffffff,
            #ff4057 45%,
            #a5001b
        );

    box-shadow:
        0 0 12px #ff4057,
        0 0 30px rgba(255,40,70,.7);
}


/* W */

.lane:nth-child(2) .rhythm-note {

    background:
        radial-gradient(
            circle at 35% 30%,
            #ffffff,
            #ffd84d 45%,
            #a96b00
        );

    box-shadow:
        0 0 12px #ffd84d,
        0 0 30px rgba(255,200,50,.7);
}


/* E */

.lane:nth-child(3) .rhythm-note {

    background:
        radial-gradient(
            circle at 35% 30%,
            #ffffff,
            #4ce49a 45%,
            #087342
        );

    box-shadow:
        0 0 12px #4ce49a,
        0 0 30px rgba(50,230,150,.7);
}


/* R */

.lane:nth-child(4) .rhythm-note {

    background:
        radial-gradient(
            circle at 35% 30%,
            #ffffff,
            #579fff 45%,
            #1748a5
        );

    box-shadow:
        0 0 12px #579fff,
        0 0 30px rgba(60,130,255,.7);
}

.lane-key.pressed {

    transform:
        translateX(-50%)
        scale(.82);

    background:
        rgba(255,255,255,.25);

    border-color:
        rgba(255,255,255,.8);

    box-shadow:
        0 0 20px
        rgba(255,255,255,.5);

}

.lane {
    position: relative;
    flex: 1;
    height: 100%;
}

/* ========================================
   LANE KEYS
======================================== */

.lane-key {

    position: absolute;

    left: 50%;
    bottom: 8px;

    transform:
        translateX(-50%);

    width: 64px;
    height: 54px;

    border-radius: 14px;

    border:
        2px solid
        rgba(255,255,255,.25);

    background:
        rgba(15,20,35,.85);

    color:
        white;

    font-family:
        inherit;

    font-size:
        22px;

    font-weight:
        800;

    cursor:
        pointer;

    z-index:
        30;

    transition:
        transform .08s ease,
        background .08s ease,
        box-shadow .08s ease;
}


.lane-key:hover {

    background:
        rgba(255,255,255,.12);

}


.lane-key.pressed {

    transform:
        translateX(-50%)
        scale(.82);

    background:
        rgba(255,255,255,.3);

    border-color:
        rgba(255,255,255,.9);

    box-shadow:
        0 0 20px
        rgba(255,255,255,.7);

}


/* Q */

.lane:nth-child(1) .lane-key {

    border-color:
        rgba(255,64,87,.55);

}


/* W */

.lane:nth-child(2) .lane-key {

    border-color:
        rgba(255,216,77,.55);

}


/* E */

.lane:nth-child(3) .lane-key {

    border-color:
        rgba(76,228,154,.55);

}


/* R */

.lane:nth-child(4) .lane-key {

    border-color:
        rgba(87,159,255,.55);

}



/* =====================================================
   ENDO STAGE 1 OVERRIDES — THREE LANES
===================================================== */
#battle-arena {
    position: absolute;
    left: 50%;
    top: 90px;
    transform: translateX(-50%);
    width: min(540px, 78vw);
    height: calc(100% - 170px);
    overflow: hidden;
    isolation: isolate;
}

.note-track {
    position: absolute;
    inset: 0;
    overflow: hidden;
    z-index: 12;
}

/* Three clean piano-tile lanes */
.note-track::before,
.note-track::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(255,255,255,.08);
    pointer-events: none;
    z-index: 3;
}
.note-track::before { left: 33.333%; }
.note-track::after  { left: 66.666%; }

.rhythm-note {
    position: absolute;
    left: 0;
    width: 30%;
    max-width: 112px;
    min-width: 64px;
    height: 62px;
    border-radius: 14px;
    transform: translate(-50%, -50%);
    z-index: 20;
    pointer-events: none;
    will-change: left, top, transform;
    transition: none;
}

.rhythm-note[data-lane="0"] { left: 16.6667%; }
.rhythm-note[data-lane="1"] { left: 50%; }
.rhythm-note[data-lane="2"] { left: 83.3333%; }

.rhythm-note::after {
    content: attr(data-key);
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 15px;
    font-weight: 900;
    letter-spacing: 1px;
    color: rgba(0,0,0,.72);
}

.rhythm-note[data-key="Q"] {
    background: radial-gradient(circle at 35% 30%, #fff, #ff4057 46%, #9c001d);
    box-shadow: 0 0 18px #ff4057, 0 0 45px rgba(255,50,75,.45);
}
.rhythm-note[data-key="W"] {
    background: radial-gradient(circle at 35% 30%, #fff, #ffd84d 46%, #a66b00);
    box-shadow: 0 0 18px #ffd84d, 0 0 45px rgba(255,205,50,.45);
}
.rhythm-note[data-key="E"] {
    background: radial-gradient(circle at 35% 30%, #fff, #4ce49a 46%, #087342);
    box-shadow: 0 0 18px #4ce49a, 0 0 45px rgba(50,230,150,.45);
}

#rhythm-pulse {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 22px;
    height: 22px;
    transform: translate(-50%, -50%) scale(.5);
    border: 1px solid rgba(255,255,255,.2);
    border-radius: 50%;
    opacity: 0;
    pointer-events: none;
    z-index: 2;
}
#rhythm-pulse.pulse { animation: beat-pulse .22s ease-out; }
@keyframes beat-pulse {
    0% { opacity: .85; transform: translate(-50%, -50%) scale(.7); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(7); }
}

#hit-line {
    position: absolute;
    left: 0;
    bottom: 42px;
    width: 100%;
    height: 3px;
    background: rgba(255,255,255,.82);
    box-shadow: 0 0 18px rgba(255,255,255,.35);
    z-index: 25;
}

/* The three desktop/mobile target buttons form the same three lanes. */
#mobile-controls {
    position: absolute;
    left: 50%;
    bottom: 15px;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    width: min(540px, 78vw);
    z-index: 30;
}

#mobile-controls button {
    flex: 1;
    height: 62px;
    border: 2px solid rgba(255,255,255,.22);
    border-radius: 14px;
    background: rgba(15,20,35,.88);
    color: rgba(255,255,255,.88);
    font-size: 22px;
    font-weight: 800;
    touch-action: manipulation;
    position: relative;
    overflow: hidden;
}

#mobile-controls button[data-key="Q"] { border-color: rgba(255,64,87,.7); }
#mobile-controls button[data-key="W"] { border-color: rgba(255,216,77,.7); }
#mobile-controls button[data-key="E"] { border-color: rgba(76,228,154,.7); }
#mobile-controls button.pressed { transform: scale(.96); background: rgba(255,255,255,.18); }

@media (min-width: 701px) {
    #mobile-controls button::after {
        content: none;
    }
}

@media (max-width: 700px) {
    #battle-arena { width: 94vw; height: calc(100% - 175px); }
    #mobile-controls { width: 94vw; }
    #mobile-controls button { height: 68px; }
    #mobile-controls button { color: transparent; font-size: 0; }
    .rhythm-note { height: 56px; min-width: 58px; }
    .rhythm-note::after { display: none; }
}



/* =====================================================
   POLISH UPDATE
===================================================== */

#scene-transition {
    position: fixed;
    inset: 0;
    background: #05060a;
    opacity: 0;
    pointer-events: none;
    z-index: 1000;
}

#scene-transition.flash {
    animation: scene-flash .36s ease;
}

@keyframes scene-flash {
    0% { opacity: 0; }
    35% { opacity: .96; }
    100% { opacity: 0; }
}

.screen {
    transition: opacity .18s ease;
}

.battle-ui {
    padding: 18px 22px;
}

.player-status,
.enemy-status {
    width: min(380px, 38vw);
    padding: 16px 18px;
}

.ui-label {
    font-size: 11px;
}

.player-status #player-name-ui {
    font-size: 18px;
    font-weight: 900;
    letter-spacing: .5px;
}

.enemy-name {
    font-size: 18px;
    letter-spacing: .8px;
}

.hp-bar {
    height: 14px;
}

#player-hp-text,
#enemy-hp-text {
    font-size: 12px;
    font-weight: 800;
}

.battle-stats {
    font-size: 11px;
}

#judgement {
    font-size: clamp(44px, 7vw, 74px);
    letter-spacing: 2px;
    text-shadow: 0 8px 35px rgba(0,0,0,.5);
}

#note-track {
    position: absolute;
    inset: 0;
    display: flex;
    z-index: 15;
}

.note-lane {
    position: relative;
    flex: 1;
    border-right: 1px solid rgba(255,255,255,.055);
}

.note-lane:last-child { border-right: 0; }

.rhythm-note {
    left: 50%;
    width: 56px;
    height: 56px;
    margin-left: -28px;
    border-radius: 14px;
    transform: none;
}

.rhythm-note::after {
    content: attr(data-key);
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: rgba(10,10,14,.72);
    font-size: 22px;
    font-weight: 1000;
}

#hit-line {
    height: 4px;
    box-shadow: 0 0 22px rgba(255,255,255,.6);
}

.screen-shake {
    animation: screen-shake .42s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes screen-shake {
    0%,100% { transform: translate3d(0,0,0); }
    15% { transform: translate3d(-10px,5px,0) rotate(-.3deg); }
    30% { transform: translate3d(12px,-6px,0) rotate(.35deg); }
    45% { transform: translate3d(-8px,4px,0) rotate(-.2deg); }
    60% { transform: translate3d(6px,-3px,0) rotate(.15deg); }
}

@media (max-width: 700px) {
    .battle-ui { padding: 8px; }
    .player-status, .enemy-status { width: 47%; padding: 10px; }
    .player-status #player-name-ui, .enemy-name { font-size: 12px; }
    .hp-bar { height: 11px; }
    #player-hp-text, #enemy-hp-text { font-size: 9px; }
    .battle-stats { font-size: 9px; gap: 10px; }
    .rhythm-note { width: 48px; height: 48px; margin-left: -24px; border-radius: 12px; }
    .rhythm-note::after { font-size: 17px; }
}

/* Per-lane note colors now that each note lives inside its own lane */
.note-lane:nth-child(1) .rhythm-note {
    background: radial-gradient(circle at 35% 30%, #ffffff, #ff4057 45%, #a5001b);
    box-shadow: 0 0 12px #ff4057, 0 0 30px rgba(255,40,70,.7);
}
.note-lane:nth-child(2) .rhythm-note {
    background: radial-gradient(circle at 35% 30%, #ffffff, #ffd84d 45%, #a96b00);
    box-shadow: 0 0 12px #ffd84d, 0 0 30px rgba(255,200,50,.7);
}
.note-lane:nth-child(3) .rhythm-note {
    background: radial-gradient(circle at 35% 30%, #ffffff, #4ce49a 45%, #087342);
    box-shadow: 0 0 12px #4ce49a, 0 0 30px rgba(50,230,150,.7);
}

.note-lane:nth-child(1) { background: linear-gradient(180deg, transparent, rgba(255,64,87,.018)); }
.note-lane:nth-child(2) { background: linear-gradient(180deg, transparent, rgba(255,216,77,.012)); }
.note-lane:nth-child(3) { background: linear-gradient(180deg, transparent, rgba(76,228,154,.018)); }

#mobile-controls {
    display: flex;
    position: absolute;
    z-index: 40;
    left: 50%;
    bottom: 10px;
    transform: translateX(-50%);
    width: min(540px, 78vw);
    gap: 8px;
}

#mobile-controls button {
    flex: 1;
    min-width: 0;
    width: auto;
    height: 68px;
    border-radius: 16px;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform .08s ease, background .08s ease, box-shadow .08s ease, filter .08s ease;
}

#mobile-controls button.pressed {
    transform: translateY(6px) scale(.985);
    background: rgba(255,255,255,.20);
    box-shadow: inset 0 5px 12px rgba(0,0,0,.35), 0 0 22px rgba(255,255,255,.16);
    filter: brightness(1.12);
}

@media (max-width: 700px) {
    #mobile-controls {
        width: 94vw;
        bottom: 10px;
    }
    #mobile-controls button {
        flex: 1;
        min-width: 0;
        width: auto;
        max-width: none;
        height: 68px;
        border-radius: 16px;
        color: rgba(255,255,255,.92);
        font-size: 22px;
    }
}

/* CLEAR TIMING GUIDE */
#hit-line {
    height: 12px;
    bottom: 38px;
    background: transparent;
    box-shadow: none;
    z-index: 25;
}
#hit-line .timing-zone {
    position: absolute;
    top: 2px;
    height: 8px;
    border-radius: 999px;
    pointer-events: none;
}
#hit-line .good-zone {
    left: 18%; right: 18%;
    background: rgba(255,255,255,.16);
}
#hit-line .excellent-zone {
    left: 31%; right: 31%;
    background: rgba(255,255,255,.28);
}
#hit-line .perfect-zone {
    left: 44%; right: 44%;
    background: rgba(255,255,255,.78);
    box-shadow: 0 0 16px rgba(255,255,255,.78);
}
#hit-line .hit-line-core {
    position: absolute;
    left: 50%;
    top: -3px;
    width: 3px;
    height: 18px;
    transform: translateX(-50%);
    background: #ffffff;
    box-shadow: 0 0 10px rgba(255,255,255,.95);
}
@media (max-width: 700px) {
    #hit-line { bottom: 32px; }
}


/* V5 BUTTON PRESS FEEDBACK */
#mobile-controls button {
    appearance: none;
    -webkit-appearance: none;
    box-shadow: inset 0 -5px 0 rgba(0,0,0,.28), 0 7px 0 rgba(0,0,0,.18);
}
#mobile-controls button.pressed {
    transform: translateY(6px) scale(.985);
    box-shadow: inset 0 4px 10px rgba(0,0,0,.42), 0 1px 0 rgba(0,0,0,.14);
}


/* =====================================================
   V6 — PIANO TILES TARGET LINE
===================================================== */
#battle-arena {
    bottom: 10px;
    height: calc(100% - 110px);
}

.note-track {
    inset: 0 0 68px 0;
}

#hit-line {
    left: 0;
    right: 0;
    bottom: 68px;
    width: 100%;
    height: 10px;
    background: transparent;
    box-shadow: none;
    z-index: 35;
    pointer-events: none;
}

#hit-line .timing-zone {
    top: 1px;
    height: 8px;
    border-radius: 999px;
}

#hit-line .good-zone {
    left: 0;
    right: 0;
    background: rgba(255,255,255,.11);
}

#hit-line .excellent-zone {
    left: 0;
    right: 0;
    background: rgba(255,255,255,.18);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.13);
}

#hit-line .perfect-zone {
    left: 0;
    right: 0;
    background: rgba(255,255,255,.30);
    box-shadow: 0 0 16px rgba(255,255,255,.34);
}

#hit-line .hit-line-core {
    left: 0;
    right: 0;
    top: 2px;
    width: 100%;
    height: 3px;
    transform: none;
    background: #fff;
    box-shadow: 0 0 14px rgba(255,255,255,.95);
}

#mobile-controls {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 68px;
    gap: 0;
    padding: 0;
    z-index: 40;
}

#mobile-controls button {
    height: 68px;
    border-radius: 0;
    border-width: 1px;
    border-top-color: rgba(255,255,255,.50);
    box-shadow: inset 0 -6px 0 rgba(0,0,0,.30), 0 6px 0 rgba(0,0,0,.18);
    transition: transform .07s ease, background .07s ease, box-shadow .07s ease, filter .07s ease;
}

#mobile-controls button.pressed {
    transform: translateY(6px);
    box-shadow: inset 0 5px 12px rgba(0,0,0,.42), 0 0 0 rgba(0,0,0,0);
}

@media (max-width: 700px) {
    #battle-arena {
        width: 94vw;
        top: 90px;
        bottom: 10px;
        height: calc(100% - 180px);
    }
    .note-track { inset: 0 0 68px 0; }
    #hit-line { bottom: 68px; }
    #mobile-controls { height: 68px; }
    #mobile-controls button { height: 68px; }
}

/* =====================================================
   V7 — RESTORE TRUE FULL-SCREEN TITLE
===================================================== */
#title-screen {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 50% 40%, rgba(255,55,80,.12), transparent 35%),
        linear-gradient(135deg, #090a10, #111321);
}

#title-screen.active {
    display: flex;
}

.title-content {
    position: relative;
    z-index: 2;
    width: min(700px, 90%);
    margin: 0 auto;
    text-align: center;
}

.title-footer {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 20px;
    z-index: 2;
}

@media (max-width: 700px) {
    .title-content h1 {
        font-size: clamp(65px, 18vw, 110px);
    }
}

/* =====================================================
   V8 — CENTER PIANO-TILE TARGETS WITH THE ARENA
===================================================== */
#mobile-controls {
    left: 50%;
    right: auto;
    bottom: 10px;
    width: min(540px, 78vw);
    height: 68px;
    padding: 0;
    margin: 0;
    transform: translateX(-50%);
    display: flex;
    gap: 0;
    z-index: 40;
    overflow: hidden;
}

#mobile-controls button {
    flex: 1 1 0;
    min-width: 0;
    width: 33.3333%;
    max-width: none;
    height: 68px;
    margin: 0;
    border-radius: 0;
}

/* Keep the target line and piano buttons on the same x-span. */
#battle-arena {
    left: 50%;
    transform: translateX(-50%);
    width: min(540px, 78vw);
}

@media (max-width: 700px) {
    #mobile-controls {
        left: 50%;
        right: auto;
        width: 94vw;
        transform: translateX(-50%);
    }

    #battle-arena {
        width: 94vw;
    }
}


/* =====================================================
   V9 — TRUE LANE-CENTERED NOTES
   Notes use the exact center of each note lane and align
   visually with the center of the three target buttons.
===================================================== */
.note-track {
    display: flex;
    width: 100%;
    height: 100%;
    left: 0;
    right: 0;
}

.note-lane {
    position: relative;
    flex: 1 1 33.3333%;
    min-width: 0;
    height: 100%;
    overflow: visible;
}

.note-lane .rhythm-note {
    position: absolute;
    left: 50% !important;
    right: auto !important;
    margin-left: 0 !important;
    transform: translateX(-50%) !important;
    width: min(86%, 132px);
    min-width: 64px;
    max-width: none;
    height: 56px;
    box-sizing: border-box;
}

@media (max-width: 700px) {
    .note-lane .rhythm-note {
        width: min(88%, 120px);
        min-width: 52px;
        height: 48px;
    }
}


/* =====================================================
   STAGE 2 VISUAL VARIATION
===================================================== */
#enemy-preview[data-stage="2"] .enemy-placeholder {
    background: linear-gradient(145deg, #35185b, #09040f);
    border-color: rgba(167, 104, 255, .55);
    box-shadow: 0 0 42px rgba(145, 74, 255, .32);
}

#enemy-placeholder[data-stage="2"]::before,
#enemy-placeholder[data-stage="2"]::after {
    background: #241037;
}

#enemy-placeholder[data-stage="2"] .devil-eye {
    background: #c76cff;
    box-shadow: 0 0 14px #a83cff;
}


/* =====================================================
   STAGE 3 VISUAL VARIATION
===================================================== */
#enemy-preview[data-stage="3"] .enemy-placeholder {
    width: 118px;
    height: 118px;
    background: linear-gradient(145deg, #39215c, #0b0712);
    border-color: rgba(202, 128, 255, .6);
    box-shadow: 0 0 55px rgba(177, 94, 255, .38);
    border-radius: 18% 18% 42% 42%;
}

#enemy-placeholder[data-stage="3"]::before,
#enemy-placeholder[data-stage="3"]::after {
    width: 28px;
    height: 60px;
    top: -36px;
    background: #251234;
}

#enemy-placeholder[data-stage="3"]::before {
    left: 12px;
    transform: rotate(-12deg) skewY(12deg);
}

#enemy-placeholder[data-stage="3"]::after {
    right: 12px;
    transform: rotate(12deg) skewY(-12deg);
}

#enemy-placeholder[data-stage="3"] .devil-eye {
    top: 47px;
    width: 18px;
    height: 6px;
    background: #d58cff;
    box-shadow: 0 0 18px #b248ff;
}

#enemy-placeholder[data-stage="3"] .devil-eye.left { left: 27px; }
#enemy-placeholder[data-stage="3"] .devil-eye.right { right: 27px; }

#battle-screen[data-stage="3"] {
    background: radial-gradient(circle at 50% 35%, rgba(139, 72, 200, .09), #07080d 58%);
}


/* =====================================================
   STAGE 4 — HIGH DEVIL VISUALS
===================================================== */
#enemy-preview[data-stage="4"] .enemy-placeholder,
#enemy-placeholder[data-stage="4"] {
    background: linear-gradient(145deg, #6b1220, #130308);
    border-color: rgba(255, 74, 98, .72);
    box-shadow: 0 0 52px rgba(255, 43, 70, .42);
}
#enemy-preview[data-stage="4"] .enemy-placeholder::before,
#enemy-preview[data-stage="4"] .enemy-placeholder::after,
#enemy-placeholder[data-stage="4"]::before,
#enemy-placeholder[data-stage="4"]::after {
    background: #410813;
}
#enemy-preview[data-stage="4"] .devil-eye,
#enemy-placeholder[data-stage="4"] .devil-eye {
    background: #ffbd55;
    box-shadow: 0 0 16px #ff5a3d;
}
#battle-screen[data-stage="4"] #battle-background {
    background: radial-gradient(circle at 50% 40%, rgba(255, 48, 70, .11), transparent 48%);
}

/* =====================================================
   STAGE 4 — HIGH DEVIL VISUALS
===================================================== */
#enemy-preview[data-stage="4"] .enemy-placeholder,
#enemy-placeholder[data-stage="4"] {
    background: linear-gradient(145deg, #6b1220, #130308);
    border-color: rgba(255, 74, 98, .72);
    box-shadow: 0 0 52px rgba(255, 43, 70, .42);
}
#enemy-preview[data-stage="4"] .enemy-placeholder::before,
#enemy-preview[data-stage="4"] .enemy-placeholder::after,
#enemy-placeholder[data-stage="4"]::before,
#enemy-placeholder[data-stage="4"]::after {
    background: #410813;
}
#enemy-preview[data-stage="4"] .devil-eye,
#enemy-placeholder[data-stage="4"] .devil-eye {
    background: #ffbd55;
    box-shadow: 0 0 16px #ff5a3d;
}
#battle-screen[data-stage="4"] #battle-background {
    background: radial-gradient(circle at 50% 40%, rgba(255, 48, 70, .11), transparent 48%);
}


/* V15 - Piano Tiles style target: the thick hit line sits directly on top of the Q/W/E keys. */
#hit-line {
    bottom: 78px;
    height: 10px;
    background: #ffffff;
    border-radius: 999px;
    box-shadow: 0 0 12px rgba(255,255,255,.9), 0 0 28px rgba(255,255,255,.35);
    z-index: 45;
    overflow: hidden;
}

#hit-line::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(255,255,255,.55), rgba(255,255,255,1), rgba(255,255,255,.55));
    opacity: .9;
}

#hit-line .timing-zone,
#hit-line .hit-line-core {
    display: none;
}

#mobile-controls {
    bottom: 8px;
    height: 70px;
    gap: 8px;
}

#mobile-controls button {
    height: 70px;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 -6px 0 rgba(0,0,0,.28), 0 7px 0 rgba(0,0,0,.18);
}

#mobile-controls button::before {
    content: "";
    position: absolute;
    left: 8%;
    right: 8%;
    top: 0;
    height: 4px;
    border-radius: 999px;
    background: rgba(255,255,255,.65);
    box-shadow: 0 0 10px rgba(255,255,255,.28);
}

#mobile-controls button.pressed {
    transform: translateY(6px) scale(.985);
}

@media (max-width: 700px) {
    #hit-line { bottom: 78px; }
    #mobile-controls { bottom: 8px; height: 70px; }
    #mobile-controls button { height: 70px; }
}


/* V17 - wrong-lane feedback */
#judgement { text-shadow: 0 0 18px currentColor; }


/* V29 - Ending / epilogue without image asset */
#ending-screen {
    align-items: stretch;
    justify-content: center;
    background:
        radial-gradient(circle at 50% 35%, rgba(255,64,87,.10), transparent 34%),
        linear-gradient(145deg, #08090f, #121423 55%, #07080d);
    overflow: hidden;
}

.ending-content {
    position: relative;
    z-index: 2;
    width: min(820px, 88vw);
    min-height: 100%;
    margin: 0 auto;
    padding: clamp(44px, 8vh, 92px) 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.ending-content h2 {
    font-size: clamp(32px, 5vw, 64px);
    line-height: 1.05;
    letter-spacing: 2px;
    margin-bottom: 18px;
    max-width: 760px;
}

.ending-divider {
    width: 100%;
    height: 1px;
    background: rgba(255,255,255,.25);
    margin: 0 0 28px;
}

.ending-text {
    max-width: 760px;
    color: #d8dae2;
    font-size: clamp(14px, 1.35vw, 18px);
    line-height: 1.8;
    margin-bottom: 20px;
}

.ending-warning {
    color: #ff9cab;
}

.ending-quote {
    color: #f4f4f7;
    font-style: italic;
    margin-top: 8px;
    margin-bottom: 38px;
}

#play-again-button {
    align-self: flex-start;
}

@media (max-width: 700px) {
    .ending-content {
        width: 88vw;
        padding: 36px 0;
    }

    .ending-content h2 {
        font-size: clamp(28px, 9vw, 42px);
    }

    .ending-text {
        font-size: 14px;
        line-height: 1.7;
    }
}
