:root {
    --bg: #05060f;
    --bg2: #0b0e22;
    --panel: #0e1230;
    --panel-edge: #1b2350;
    --cyan: #00e6ff;
    --magenta: #ff2ee6;
    --green: #3dff8a;
    --red: #ff3b52;
    --yellow: #ffe135;
    --text: #eaf2ff;
    --muted: #7c8bc4;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    background: radial-gradient(ellipse at 50% -10%, #131a44 0%, var(--bg) 55%);
    color: var(--text);
    font-family: 'Rajdhani', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

.stars {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.star {
    position: absolute;
    background: #cfe4ff;
    border-radius: 50%;
    animation: twinkle linear infinite;
}

@keyframes twinkle {

    0%,
    100% {
        opacity: .15;
    }

    50% {
        opacity: 1;
    }
}

.app {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

h1,
h2,
h3,
.disp {
    font-family: 'Orbitron', sans-serif;
    letter-spacing: .03em;
}

.screen {
    width: 100%;
    max-width: 720px;
    padding: 20px 16px 24px;
    display: none;
    flex-direction: column;
    align-items: center;
    flex: 1;
    transition: opacity .35s ease;
}

.screen.active {
    display: flex;
}

.screen.fading-out {
    opacity: 0;
}

.home {
    justify-content: center;
    text-align: center;
    gap: 18px;
    min-height: 100vh;
}

.home .eyebrow {
    color: var(--cyan);
    font-size: 12px;
    letter-spacing: .3em;
    text-transform: uppercase;
    font-weight: 700;
}

.home h1 {
    font-size: clamp(28px, 7vw, 52px);
    margin: 6px 0 0;
    color: #fff;
    text-shadow: 0 0 6px var(--cyan), 0 0 24px rgba(0, 230, 255, .6), 0 0 60px rgba(255, 46, 230, .35);
}

.home .cn-word {
    display: block;
    font-family: 'Noto Sans SC', sans-serif;
    font-weight: 900;
}

.home p.tag {
    color: var(--muted);
    font-size: 15px;
    margin: 2px 0 18px;
}

.ship-hero {
    width: 100px;
    height: 100px;
    filter: drop-shadow(0 0 14px var(--cyan));
    animation: float 3.2s ease-in-out infinite;
}

@keyframes float {

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

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

.btn {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: .07em;
    color: var(--bg);
    background: linear-gradient(135deg, var(--cyan), #63f2ff);
    border: none;
    border-radius: 10px;
    padding: 14px 30px;
    cursor: pointer;
    text-transform: uppercase;
    box-shadow: 0 0 0 1px rgba(0, 230, 255, .5) inset, 0 0 18px rgba(0, 230, 255, .55);
    transition: transform .15s ease, box-shadow .15s ease;
    -webkit-appearance: none;
    touch-action: manipulation;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 0 1px rgba(0, 230, 255, .7) inset, 0 0 28px rgba(0, 230, 255, .8);
}

.btn:active {
    transform: translateY(0);
}

.btn.ghost {
    background: transparent;
    color: var(--cyan);
    box-shadow: 0 0 0 1px rgba(0, 230, 255, .5) inset, 0 0 10px rgba(0, 230, 255, .25);
}

.btn.magenta {
    background: linear-gradient(135deg, var(--magenta), #ff7cf1);
    box-shadow: 0 0 0 1px rgba(255, 46, 230, .5) inset, 0 0 18px rgba(255, 46, 230, .55);
}

.btn.magenta:hover {
    box-shadow: 0 0 0 1px rgba(255, 46, 230, .7) inset, 0 0 28px rgba(255, 46, 230, .8);
}

.btn.small {
    padding: 10px 18px;
    font-size: 11px;
}

.btn:disabled {
    opacity: .4;
    cursor: not-allowed;
    transform: none;
}

.btn-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 10px;
}

.hub {
    gap: 20px;
    padding-top: 50px;
}

.hub h2 {
    font-size: 20px;
    color: #fff;
    text-align: center;
    margin: 0;
}

.hub .sub {
    color: var(--muted);
    text-align: center;
    margin: 0 0 6px;
    font-size: 13px;
}

.mode-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    width: 100%;
    max-width: 520px;
}

@media(min-width:560px) {
    .mode-grid {
        grid-template-columns: 1fr 1fr 1fr 1fr;
    }
}

.mode-card {
    background: linear-gradient(160deg, var(--panel), var(--bg2));
    border: 1px solid var(--panel-edge);
    border-radius: 14px;
    padding: 18px 12px;
    text-align: center;
    cursor: pointer;
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
    position: relative;
    overflow: hidden;
}

.mode-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 0%, rgba(0, 230, 255, .15), transparent 60%);
    opacity: 0;
    transition: opacity .2s;
}

.mode-card:hover {
    transform: translateY(-4px);
    border-color: var(--cyan);
    box-shadow: 0 8px 26px rgba(0, 230, 255, .2);
}

.mode-card:hover::before {
    opacity: 1;
}

.mode-card .icon {
    font-size: 26px;
    margin-bottom: 8px;
    display: block;
}

.mode-card .cn {
    font-family: 'Noto Sans SC', sans-serif;
    font-weight: 900;
    font-size: 16px;
    color: #fff;
    position: relative;
}

.mode-card .en {
    font-size: 10px;
    color: var(--muted);
    letter-spacing: .04em;
    margin-top: 4px;
    position: relative;
}

.mode-grid.stagger .mode-card {
    opacity: 0;
    transform: translateY(20px);
    animation: cardIn .5s ease forwards;
}

.mode-grid.stagger .mode-card:nth-child(1) {
    animation-delay: .05s;
}

.mode-grid.stagger .mode-card:nth-child(2) {
    animation-delay: .15s;
}

.mode-grid.stagger .mode-card:nth-child(3) {
    animation-delay: .25s;
}

.mode-grid.stagger .mode-card:nth-child(4) {
    animation-delay: .35s;
}

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

.lessons,
.glossary-topics {
    gap: 16px;
    padding-top: 50px;
}

.lessons h2,
.glossary-topics h2 {
    font-size: 20px;
    color: #fff;
    text-align: center;
    margin: 0;
}

.lessons .sub,
.glossary-topics .sub {
    color: var(--muted);
    text-align: center;
    margin: 0 0 6px;
    font-size: 13px;
}

.lesson-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 480px;
}

.lesson-card {
    background: linear-gradient(160deg, var(--panel), var(--bg2));
    border: 1px solid var(--panel-edge);
    border-radius: 12px;
    padding: 16px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: transform .15s ease, border-color .15s ease;
}

.lesson-card:hover {
    transform: translateX(4px);
    border-color: var(--magenta);
}

.lesson-card .title {
    font-family: 'Noto Sans SC', sans-serif;
    font-weight: 700;
    color: #fff;
    font-size: 16px;
}

.lesson-card .meta {
    font-size: 12px;
    color: var(--muted);
    margin-top: 3px;
}

.lesson-card .count {
    font-family: 'Orbitron', sans-serif;
    font-size: 12px;
    color: var(--cyan);
    white-space: nowrap;
    margin-left: 12px;
}

.mission {
    gap: 16px;
    padding-top: 60px;
    text-align: center;
}

.mission-badge {
    font-family: 'Orbitron', sans-serif;
    font-size: 11px;
    letter-spacing: .3em;
    color: var(--red);
    text-shadow: 0 0 8px var(--red);
}

.mission h2 {
    font-size: 20px;
    color: #fff;
    margin: 0;
}

.mission-text {
    max-width: 520px;
    font-size: 15px;
    line-height: 1.8;
    color: var(--muted);
    background: var(--panel);
    border: 1px solid var(--panel-edge);
    border-radius: 12px;
    padding: 18px 20px;
}

.mission-text strong {
    color: var(--yellow);
}

.glossary {
    gap: 18px;
    padding-top: 40px;
}

.glossary h2 {
    font-size: 20px;
    color: #fff;
    text-align: center;
    margin: 0;
}

.glossary .sub {
    color: var(--muted);
    text-align: center;
    margin: -10px 0 4px;
    font-size: 13px;
}

.glossary-content {
    width: 100%;
    max-width: 640px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.glossary-section h3 {
    font-size: 16px;
    color: var(--cyan);
    margin: 0 0 10px;
    font-family: 'Orbitron', sans-serif;
}

.glossary-section h3 .meta {
    color: var(--muted);
    font-size: 11px;
    font-family: 'Rajdhani', sans-serif;
    margin-left: 8px;
}

.glossary-table {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.g-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1.4fr 1.8fr;
    gap: 8px;
    padding: 9px 12px;
    background: var(--panel);
    border: 1px solid var(--panel-edge);
    border-radius: 8px;
    font-size: 13px;
    align-items: center;
}

.g-word {
    font-family: 'Noto Sans SC', sans-serif;
    font-weight: 700;
    color: #fff;
}

.g-pinyin {
    color: var(--cyan);
    font-family: 'Orbitron', sans-serif;
    font-size: 11px;
}

.g-en {
    color: var(--yellow);
}

.g-cn {
    color: var(--muted);
    font-family: 'Noto Sans SC', sans-serif;
    font-size: 12px;
}

@media(max-width:540px) {
    .g-row {
        grid-template-columns: 1fr 1fr;
        row-gap: 4px;
    }

    .g-en {
        grid-column: 1/3;
    }

    .g-cn {
        grid-column: 1/3;
    }
}

.quiz {
    gap: 16px;
    padding-top: 16px;
}

.hud {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'Orbitron', sans-serif;
    font-size: 11px;
    color: var(--muted);
    gap: 8px;
    flex-wrap: wrap;
}

.hud .mode-label {
    color: var(--magenta);
    text-transform: uppercase;
    letter-spacing: .08em;
}

.hud .score {
    color: var(--green);
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--panel-edge);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--cyan), var(--magenta));
    transition: width .3s ease;
}

.card {
    width: 100%;
    background: linear-gradient(160deg, var(--panel), var(--bg2));
    border: 1px solid var(--panel-edge);
    border-radius: 16px;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.prompt-label {
    font-size: 11px;
    letter-spacing: .18em;
    color: var(--muted);
    text-transform: uppercase;
    font-family: 'Orbitron', sans-serif;
    text-align: center;
}

.prompt-main {
    font-family: 'Noto Sans SC', sans-serif;
    font-weight: 900;
    font-size: clamp(22px, 6vw, 32px);
    text-align: center;
    color: #fff;
    line-height: 1.5;
}

.prompt-pinyin {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(20px, 5vw, 26px);
    color: var(--cyan);
    text-shadow: 0 0 12px rgba(0, 230, 255, .6);
    text-align: center;
}

.prompt-en {
    color: var(--yellow);
    font-weight: 600;
    font-size: 16px;
    text-align: center;
}

.prompt-cn {
    font-family: 'Noto Sans SC', sans-serif;
    color: var(--muted);
    font-size: 14px;
    text-align: center;
}

.blank {
    color: var(--cyan);
}

input[type=text] {
    width: 100%;
    max-width: 320px;
    background: #050716;
    border: 1px solid var(--panel-edge);
    border-radius: 10px;
    padding: 12px 14px;
    color: #fff;
    font-family: 'Noto Sans SC', sans-serif;
    font-size: 19px;
    text-align: center;
    outline: none;
    transition: border-color .15s;
}

input[type=text]:focus {
    border-color: var(--cyan);
    box-shadow: 0 0 10px rgba(0, 230, 255, .4);
}

canvas.draw-canvas {
    background: #fff;
    border-radius: 10px;
    touch-action: none;
    cursor: crosshair;
    box-shadow: 0 0 22px rgba(0, 230, 255, .25);
    width: 100%;
    max-width: 300px;
    height: auto;
    aspect-ratio: 300/220;
}

.canvas-tools {
    display: flex;
    gap: 10px;
}

.feedback-msg {
    font-size: 13px;
    text-align: center;
    min-height: 20px;
    color: var(--muted);
    padding: 0 8px;
}

.feedback-msg.ok {
    color: var(--green);
}

.feedback-msg.bad {
    color: var(--red);
}

.action-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
}

/* ---------- warp transition (home -> hub) ---------- */
.warp-overlay {
    position: fixed;
    inset: 0;
    z-index: 90;
    background: #000;
    opacity: 0;
    visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.warp-overlay.playing {
    visibility: visible;
    animation: warpBgPulse 1.7s ease forwards;
}

@keyframes warpBgPulse {
    0% {
        opacity: 0;
    }

    30% {
        opacity: 1;
    }

    78% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

.warp-ship {
    width: 110px;
    height: 110px;
    filter: drop-shadow(0 0 18px var(--cyan));
    opacity: 1;
}

.warp-overlay.playing .warp-ship {
    animation: warpShipFly .85s cubic-bezier(.4, 0, 1, 1) forwards;
}

@keyframes warpShipFly {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    100% {
        transform: scale(10);
        opacity: 0;
    }
}

/* ---------- docking sequence (hub -> content) ---------- */
.dock-overlay {
    position: fixed;
    inset: 0;
    z-index: 85;
    background: #000;
    opacity: 0;
    visibility: hidden;
    overflow: hidden;
    perspective: 900px;
    pointer-events: none;
}

.dock-overlay.playing {
    visibility: visible;
    opacity: 1;
}

.dock-scene {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.station {
    width: 220px;
    height: 130px;
    position: relative;
    transform: scale(.05);
    opacity: 0;
    transform-style: preserve-3d;
}

.dock-overlay.approach .station {
    animation: stationApproach 1s cubic-bezier(.3, .6, .3, 1) forwards;
}

@keyframes stationApproach {
    0% {
        transform: scale(.05) rotateY(-10deg);
        opacity: 0;
    }

    55% {
        opacity: 1;
    }

    100% {
        transform: scale(1.6) rotateY(0deg);
        opacity: 1;
    }
}

.station-body {
    position: absolute;
    inset: 0;
    background: linear-gradient(160deg, #e8edf5, #aab4c6);
    border-radius: 14px;
    box-shadow: 0 0 40px rgba(0, 230, 255, .35), inset 0 0 30px rgba(0, 0, 0, .25);
}

.station-body::before {
    content: '';
    position: absolute;
    inset: 10px;
    border-radius: 8px;
    background-image: repeating-linear-gradient(90deg, rgba(20, 30, 60, .5) 0 6px, transparent 6px 26px),
        repeating-linear-gradient(0deg, rgba(20, 30, 60, .4) 0 4px, transparent 4px 22px);
}

.station-wing {
    position: absolute;
    top: 50%;
    width: 64px;
    height: 14px;
    background: linear-gradient(90deg, #7c8bc4, #c8d2e8);
    transform: translateY(-50%);
}

.station-wing.left {
    left: -64px;
    border-radius: 6px 0 0 6px;
}

.station-wing.right {
    right: -64px;
    border-radius: 0 6px 6px 0;
}

.station-lights {
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle, var(--cyan) 2px, transparent 3px);
    background-size: 26px 26px;
    opacity: .7;
    animation: lightsBlink 1.5s linear infinite;
}

@keyframes lightsBlink {

    0%,
    100% {
        opacity: .4;
    }

    50% {
        opacity: .9;
    }
}

.dock-doors {
    position: absolute;
    inset: 0;
    display: flex;
}

.door {
    flex: 1;
    background: linear-gradient(180deg, #cfd6e6, #8b93ab);
    position: relative;
    box-shadow: inset 0 0 40px rgba(0, 0, 0, .4);
}

.door::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: repeating-linear-gradient(0deg, rgba(0, 0, 0, .15) 0 3px, transparent 3px 30px);
}

.door-left {
    transform: translateX(-100%);
}

.door-right {
    transform: translateX(100%);
}

.dock-overlay.seal .door-left {
    animation: doorCloseL .5s ease forwards;
}

.dock-overlay.seal .door-right {
    animation: doorCloseR .5s ease forwards;
}

@keyframes doorCloseL {
    to {
        transform: translateX(0);
    }
}

@keyframes doorCloseR {
    to {
        transform: translateX(0);
    }
}

.dock-interior {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    background: radial-gradient(circle at 50% 40%, #16224a, #04050d 75%);
    gap: 10px;
}

.dock-overlay.interior .dock-interior {
    animation: interiorFade .4s ease forwards;
}

@keyframes interiorFade {
    to {
        opacity: 1;
    }
}

.interior-particles {
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle, var(--cyan) 1.5px, transparent 2px);
    background-size: 40px 40px;
    animation: particlesDrift 3s linear infinite;
    opacity: .5;
}

@keyframes particlesDrift {
    from {
        background-position: 0 0;
    }

    to {
        background-position: 200px 100px;
    }
}

.interior-text {
    font-family: 'Orbitron', sans-serif;
    color: var(--cyan);
    letter-spacing: .1em;
    font-size: 14px;
    text-shadow: 0 0 10px var(--cyan);
    z-index: 2;
    text-align: center;
}

/* ---------- mission result cutscene ---------- */
.cutscene-overlay {
    position: fixed;
    inset: 0;
    z-index: 95;
    background: #000;
    opacity: 0;
    visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    pointer-events: none;
}

.cutscene-overlay.playing {
    visibility: visible;
    animation: cutFade .3s ease forwards;
}

@keyframes cutFade {
    to {
        opacity: 1;
    }
}

.cutscene-victory,
.cutscene-fail {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.cutscene-overlay.victory .cutscene-victory {
    display: flex;
}

.cutscene-overlay.fail .cutscene-fail {
    display: flex;
}

.panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.cutscene-overlay.warscene .panel {
    display: none;
}

.switch-row {
    display: flex;
    gap: 14px;
}

.switch {
    width: 26px;
    height: 52px;
    border-radius: 6px;
    background: #222c50;
    border: 2px solid var(--red);
    position: relative;
    box-shadow: 0 0 10px rgba(255, 59, 82, .6);
}

.switch::after {
    content: '';
    position: absolute;
    left: 3px;
    right: 3px;
    top: 3px;
    height: 18px;
    background: var(--red);
    border-radius: 4px;
    box-shadow: 0 0 8px var(--red);
    transition: transform .3s ease, background .3s ease, box-shadow .3s ease;
}

.switch.off {
    border-color: #3a4568;
    box-shadow: none;
}

.switch.off::after {
    transform: translateY(26px);
    background: #3a4568;
    box-shadow: none;
}

.cutscene-caption {
    font-family: 'Orbitron', sans-serif;
    color: var(--cyan);
    text-align: center;
    font-size: 14px;
    letter-spacing: .08em;
    text-shadow: 0 0 10px var(--cyan);
}

.cutscene-caption.big {
    font-size: 22px;
    color: var(--green);
    text-shadow: 0 0 14px var(--green);
}

.fail-text {
    color: var(--red) !important;
    text-shadow: 0 0 16px var(--red) !important;
    font-size: 26px !important;
}

.war-scene {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    opacity: 0;
}

.cutscene-overlay.victory.warscene .war-scene {
    display: flex;
    animation: fadeInScene .5s ease forwards;
}

@keyframes fadeInScene {
    to {
        opacity: 1;
    }
}

.silhouettes {
    display: flex;
    gap: 30px;
    align-items: flex-end;
}

.robot {
    width: 40px;
    height: 70px;
    background: linear-gradient(180deg, #8892b0, #454f73);
    border-radius: 8px 8px 4px 4px;
    position: relative;
    box-shadow: 0 0 14px var(--red);
    transition: box-shadow .6s ease, filter .6s ease;
}

.robot::after {
    content: '';
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--red);
    box-shadow: 0 0 8px var(--red);
    transition: background .6s ease, box-shadow .6s ease;
}

.cutscene-overlay.victory.poweroff .robot {
    box-shadow: none;
    filter: grayscale(1) brightness(.5);
}

.cutscene-overlay.victory.poweroff .robot::after {
    background: #333;
    box-shadow: none;
}

.human {
    width: 26px;
    height: 70px;
    background: linear-gradient(180deg, #00e6ff, #0a4a66);
    border-radius: 12px 12px 4px 4px;
}

.earth {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #3dff8a, #0a3d62 60%, #041c33);
    position: relative;
    box-shadow: 0 0 40px rgba(61, 255, 138, .4);
}

.cutscene-overlay.fail.exploding .earth {
    animation: earthShake .6s ease-in-out, earthBlow .5s ease-in .6s forwards;
}

@keyframes earthShake {

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

    25% {
        transform: translate(-4px, 2px);
    }

    50% {
        transform: translate(4px, -2px);
    }

    75% {
        transform: translate(-3px, 3px);
    }
}

@keyframes earthBlow {
    to {
        transform: scale(2.4);
        opacity: 0;
        box-shadow: 0 0 120px rgba(255, 59, 82, .8);
    }
}

.frag {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 14px;
    height: 14px;
    background: var(--red);
    opacity: 0;
    border-radius: 3px;
}

.cutscene-overlay.fail.exploding .frag {
    animation: fragFly .8s ease-out 1.05s forwards;
}

@keyframes fragFly {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    100% {
        opacity: 0;
        transform: translate(calc(-50% + var(--fx)), calc(-50% + var(--fy))) scale(.2);
    }
}

/* ---------- in-quiz battle overlay (correct/wrong/skip) ---------- */
.battle-overlay {
    position: fixed;
    inset: 0;
    z-index: 80;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    overflow: hidden;
    background: transparent;
}

.battle-overlay.playing {
    opacity: 1;
    visibility: visible;
}

.ov-ship {
    position: absolute;
    width: min(18vw, 90px);
    height: min(18vw, 90px);
    left: 50%;
    bottom: 6%;
    transform: translateX(-50%);
    filter: drop-shadow(0 0 16px var(--cyan));
}

.ov-laser {
    position: absolute;
    bottom: 16%;
    width: 6px;
    height: 14vh;
    background: var(--cyan);
    border-radius: 3px;
    opacity: 0;
    box-shadow: 0 0 12px var(--cyan);
}

.ov-laser:nth-child(2) {
    left: calc(50% - 5vw);
}

.ov-laser:nth-child(3) {
    left: 50%;
}

.ov-laser:nth-child(4) {
    left: calc(50% + 5vw);
}

.ov-enemy {
    position: absolute;
    top: 8%;
    width: min(10vw, 60px);
    height: min(10vw, 60px);
    opacity: 0;
}

.ov-enemy:nth-of-type(1) {
    left: 18%;
}

.ov-enemy:nth-of-type(2) {
    left: 47%;
}

.ov-enemy:nth-of-type(3) {
    left: 74%;
}

.ov-wall {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 55%;
    opacity: 0;
    background: repeating-linear-gradient(45deg, var(--red), var(--red) 14px, #7a0016 14px, #7a0016 28px);
}

.ov-wall-left {
    left: -60%;
}

.ov-wall-right {
    right: -60%;
}

.ov-chaser {
    position: absolute;
    bottom: 10%;
    width: min(9vw, 54px);
    height: min(9vw, 54px);
    opacity: 0;
}

.ov-chaser:nth-of-type(1) {
    left: -15%;
}

.ov-chaser:nth-of-type(2) {
    left: -25%;
}

.battle-overlay.correct .ov-laser {
    animation: ovLaserUp .5s ease-in forwards;
}

.battle-overlay.correct .ov-laser:nth-child(3) {
    animation-delay: .07s;
}

.battle-overlay.correct .ov-laser:nth-child(4) {
    animation-delay: .14s;
}

.battle-overlay.correct .ov-enemy {
    animation: ovEnemyHit .5s ease-in forwards;
    animation-delay: .5s;
}

.battle-overlay.correct .ov-ship {
    animation: ovShipKick .8s ease-in-out;
}

@keyframes ovLaserUp {
    0% {
        opacity: 1;
        bottom: 16%;
    }

    100% {
        opacity: 1;
        bottom: 90%;
    }
}

@keyframes ovEnemyHit {
    0% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }

    60% {
        opacity: 1;
        transform: scale(1.7) rotate(30deg);
    }

    100% {
        opacity: 0;
        transform: scale(.2) rotate(70deg);
    }
}

@keyframes ovShipKick {

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

    30% {
        transform: translateX(-50%) translateY(-14px);
    }
}

.battle-overlay.wrong .ov-wall-left {
    animation: ovWallInL .5s ease-out forwards;
}

.battle-overlay.wrong .ov-wall-right {
    animation: ovWallInR .5s ease-out forwards;
}

.battle-overlay.wrong .ov-ship {
    animation: ovShipShake .55s ease-in-out .4s;
}

@keyframes ovWallInL {
    0% {
        opacity: 1;
        left: -60%;
    }

    100% {
        opacity: 1;
        left: -2%;
    }
}

@keyframes ovWallInR {
    0% {
        opacity: 1;
        right: -60%;
    }

    100% {
        opacity: 1;
        right: -2%;
    }
}

@keyframes ovShipShake {

    0%,
    100% {
        transform: translateX(-50%);
    }

    20% {
        transform: translateX(-62%);
    }

    40% {
        transform: translateX(-38%);
    }

    60% {
        transform: translateX(-58%);
    }

    80% {
        transform: translateX(-42%);
    }
}

.battle-overlay.skip .ov-ship {
    animation: ovShipFlee 1.1s linear forwards;
}

.battle-overlay.skip .ov-chaser {
    opacity: 1;
    animation: ovChaserGo 1.1s linear forwards;
}

.battle-overlay.skip .ov-chaser:nth-of-type(2) {
    animation-delay: .08s;
}

@keyframes ovShipFlee {
    0% {
        left: 0%;
        bottom: 8%;
        opacity: 1;
    }

    100% {
        left: 96%;
        bottom: 55%;
        opacity: 1;
    }
}

@keyframes ovChaserGo {
    0% {
        left: -15%;
        bottom: 10%;
        opacity: 1;
    }

    100% {
        left: 100%;
        bottom: 50%;
        opacity: 1;
    }
}

.flash {
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    z-index: 60;
}

.flash.play-green {
    background: var(--green);
    animation: flashPulse .9s ease-out;
}

.flash.play-red {
    background: var(--red);
    animation: flashPulse .9s ease-out;
}

.flash.play-yellow {
    background: var(--yellow);
    animation: flashPulse 1.2s ease-out;
}

@keyframes flashPulse {
    0% {
        opacity: 0;
    }

    18% {
        opacity: .42;
    }

    100% {
        opacity: 0;
    }
}

.summary {
    gap: 16px;
    padding-top: 36px;
}

.stat-grid {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    justify-content: center;
}

.stat {
    background: var(--panel);
    border: 1px solid var(--panel-edge);
    border-radius: 12px;
    padding: 14px 20px;
    text-align: center;
    min-width: 100px;
}

.stat .num {
    font-family: 'Orbitron', sans-serif;
    font-size: 24px;
    color: var(--cyan);
}

.stat .lbl {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .07em;
}

.skip-list {
    width: 100%;
    max-width: 520px;
    background: var(--panel);
    border: 1px solid var(--panel-edge);
    border-radius: 12px;
    padding: 14px 18px;
}

.skip-list h3 {
    margin: 0 0 10px;
    font-size: 13px;
    color: var(--yellow);
}

.skip-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px dashed var(--panel-edge);
    font-family: 'Noto Sans SC', sans-serif;
    font-size: 13px;
    gap: 8px;
}

.skip-row:last-child {
    border-bottom: none;
}

.skip-row .py {
    color: var(--muted);
    font-family: 'Rajdhani', sans-serif;
}

.score-badge {
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    color: #0a0f1e;
    background: var(--cyan);
    border-radius: 20px;
    padding: 4px 14px;
    display: inline-block;
}

footer.hint {
    color: var(--muted);
    font-size: 11px;
    margin-top: auto;
    padding: 14px;
    text-align: center;
}

@media(max-width:420px) {
    .screen {
        padding: 16px 12px 20px;
    }

    .card {
        padding: 20px 14px;
    }

    .btn {
        padding: 12px 22px;
        font-size: 13px;
    }
}

@media(min-width:900px) {
    .screen {
        max-width: 820px;
    }

    .card {
        padding: 32px 30px;
    }
}
