@import url("https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Rajdhani:wght@500;600;700&display=swap");

:root {
    --bg: #05080b;
    --panel: rgba(6, 11, 16, 0.84);
    --panel-strong: rgba(4, 8, 12, 0.94);
    --line: rgba(137, 164, 185, 0.3);
    --line-bright: rgba(167, 202, 227, 0.55);
    --text: #d8e4ec;
    --muted: #8b9aa5;
    --danger: #f23d3d;
    --danger-dark: #7b1517;
    --ammo: #d89d34;
    --accent: #87bce7;
    --green: #74d86b;
    --shadow: rgba(0, 0, 0, 0.7);
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    background:
        radial-gradient(
            circle at 50% 35%,
            rgba(28, 45, 56, 0.22),
            transparent 42%
        ),
        linear-gradient(135deg, #020406 0%, #071017 50%, #030507 100%);
    color: var(--text);
    font-family: "Rajdhani", system-ui, sans-serif;
    user-select: none;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 20;
    background:
        repeating-linear-gradient(
            0deg,
            rgba(255, 255, 255, 0.018) 0,
            rgba(255, 255, 255, 0.018) 1px,
            transparent 1px,
            transparent 4px
        ),
        radial-gradient(
            circle at 50% 50%,
            transparent 52%,
            rgba(0, 0, 0, 0.45) 100%
        );
    mix-blend-mode: screen;
    opacity: 0.55;
}

body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 21;
    box-shadow: inset 0 0 90px rgba(0, 0, 0, 0.92);
}

#game-shell {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background: #030609;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: auto;
    cursor: crosshair;
    background: #05080a;
}

#hud {
    position: absolute;
    inset: 0;
    z-index: 5;
    pointer-events: none;
}

.hud-panel {
    border: 1px solid var(--line);
    background:
        linear-gradient(180deg, rgba(13, 22, 30, 0.9), rgba(4, 8, 12, 0.78)),
        radial-gradient(
            circle at 20% 0%,
            rgba(97, 147, 174, 0.14),
            transparent 40%
        );
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.9),
        0 18px 35px rgba(0, 0, 0, 0.42),
        inset 0 0 28px rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(7px);
}

.hud-status {
    position: absolute;
    left: clamp(18px, 3vw, 46px);
    bottom: clamp(18px, 3vw, 42px);
    width: 270px;
    padding: 17px 18px 16px;
}

.stat {
    margin-bottom: 15px;
}

.stat:last-child {
    margin-bottom: 0;
}

.stat-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.stat-label,
.screen-kicker {
    display: block;
    color: #b9c5ce;
    font-family: "Share Tech Mono", monospace;
    font-size: 15px;
    letter-spacing: 0.08em;
    text-shadow: 0 0 12px rgba(136, 199, 235, 0.18);
}

.stat-value {
    color: #e9f1f6;
    font-family: "Share Tech Mono", monospace;
    font-size: 18px;
}

.bar {
    position: relative;
    height: 10px;
    margin-top: 7px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(0, 0, 0, 0.58);
}

.bar span {
    display: block;
    width: 100%;
    height: 100%;
    transition: width 160ms ease-out;
}

.bar-health span {
    background:
        linear-gradient(90deg, #b91519, #ff3d3d 70%, #ff7a64),
        linear-gradient(180deg, rgba(255, 255, 255, 0.22), transparent);
    box-shadow: 0 0 16px rgba(255, 47, 47, 0.35);
}

.bar-ammo span {
    background:
        linear-gradient(90deg, #9a681c, #d89d34 75%, #f7c360),
        linear-gradient(180deg, rgba(255, 255, 255, 0.22), transparent);
    box-shadow: 0 0 16px rgba(216, 157, 52, 0.32);
}

.stat-level,
.stat-lives,
.stat-timer,
.stat-score {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 12px;
}

.stat-lives .stat-value {
    color: #ff6b6b;
    text-shadow: 0 0 12px rgba(242, 61, 61, 0.32);
}

.stat-timer .stat-value {
    color: #87bce7;
    text-shadow: 0 0 12px rgba(135, 188, 231, 0.36);
}

.stat-score .stat-value {
    color: #f7c360;
    text-shadow: 0 0 12px rgba(247, 195, 96, 0.34);
}

.narrator-card {
    position: absolute;
    left: 50%;
    bottom: clamp(18px, 3vw, 42px);
    transform: translateX(-50%);
    width: clamp(360px, 42vw, 560px);
    min-height: 48px;
    display: grid;
    grid-template-columns: 54px 1fr;
    align-items: center;
    gap: 6px;
    padding: 9px 15px 9px 11px;
    opacity: 0.9;
}

.narrator-title {
    color: var(--accent);
    font-family: "Share Tech Mono", monospace;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.13em;
    margin-bottom: 2px;
    text-shadow: 0 0 12px rgba(135, 188, 231, 0.5);
    transition:
        color 220ms ease,
        text-shadow 220ms ease;
}

#narrator-text {
    margin: 0;
    color: #eef4f8;
    font-family: "Share Tech Mono", monospace;
    font-size: clamp(12px, 1vw, 15px);
    line-height: 1.28;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.85);
}

.narrator-card[data-voice="monster"] {
    border-color: rgba(220, 70, 90, 0.55);
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.9),
        0 18px 35px rgba(0, 0, 0, 0.42),
        inset 0 0 28px rgba(120, 12, 24, 0.5);
    animation: monsterPulse 2.6s ease-in-out infinite;
}

.narrator-card[data-voice="monster"] .narrator-title {
    color: #ff6a72;
    text-shadow:
        0 0 10px rgba(242, 61, 61, 0.85),
        0 0 22px rgba(160, 14, 24, 0.55);
    letter-spacing: 0.18em;
}

.narrator-card[data-voice="monster"] #narrator-text {
    color: #ffe1e1;
    font-style: italic;
    text-shadow:
        0 0 9px rgba(180, 18, 28, 0.35),
        0 2px 4px rgba(0, 0, 0, 0.9);
}

.narrator-card[data-voice="monster"] .voice-icon span {
    background: linear-gradient(180deg, #ffd0d3, #c83b46);
}

@keyframes monsterPulse {
    0%,
    100% {
        box-shadow:
            0 0 0 1px rgba(0, 0, 0, 0.9),
            0 18px 35px rgba(0, 0, 0, 0.42),
            inset 0 0 28px rgba(120, 12, 24, 0.45);
    }

    50% {
        box-shadow:
            0 0 0 1px rgba(0, 0, 0, 0.9),
            0 18px 38px rgba(120, 0, 18, 0.35),
            inset 0 0 38px rgba(180, 18, 28, 0.65);
    }
}

.voice-icon {
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--accent);
    filter: drop-shadow(0 0 12px rgba(114, 179, 221, 0.32));
}

.voice-icon::before,
.voice-icon::after {
    content: "";
    width: 12px;
    height: 2px;
    background: rgba(135, 188, 231, 0.5);
}

.voice-icon span {
    display: block;
    width: 3px;
    border-radius: 3px;
    background: linear-gradient(180deg, #c7eaff, #6ba6cf);
    animation: voicePulse 900ms ease-in-out infinite alternate;
}

.voice-icon span:nth-child(1) {
    height: 18px;
    animation-delay: -300ms;
}

.voice-icon span:nth-child(2) {
    height: 34px;
    animation-delay: -120ms;
}

.voice-icon span:nth-child(3) {
    height: 48px;
}

.voice-icon span:nth-child(4) {
    height: 31px;
    animation-delay: -230ms;
}

.voice-icon span:nth-child(5) {
    height: 22px;
    animation-delay: -420ms;
}

@keyframes voicePulse {
    from {
        opacity: 0.38;
        transform: scaleY(0.55);
    }

    to {
        opacity: 1;
        transform: scaleY(1);
    }
}

#minimap {
    position: absolute;
    top: clamp(18px, 2.5vw, 34px);
    right: clamp(18px, 2.5vw, 34px);
    width: 150px;
    height: 118px;
    opacity: 0.82;
    border: 2px solid rgba(154, 178, 194, 0.28);
    background: rgba(2, 5, 8, 0.68);
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.95),
        0 14px 28px rgba(0, 0, 0, 0.36),
        inset 0 0 18px rgba(0, 0, 0, 0.85);
}


.screen {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(
            circle at 50% 45%,
            rgba(21, 39, 52, 0.55),
            rgba(0, 0, 0, 0.88) 70%
        ),
        repeating-linear-gradient(
            90deg,
            rgba(255, 255, 255, 0.025) 0,
            rgba(255, 255, 255, 0.025) 1px,
            transparent 1px,
            transparent 7px
        );
    pointer-events: auto;
}

.screen-visible {
    display: flex;
}

.screen-card {
    width: min(720px, calc(100vw - 40px));
    border: 1px solid var(--line-bright);
    background:
        linear-gradient(180deg, rgba(9, 15, 22, 0.96), rgba(4, 7, 11, 0.92)),
        radial-gradient(
            circle at 50% 0%,
            rgba(95, 152, 185, 0.15),
            transparent 45%
        );
    box-shadow:
        0 0 0 1px #000,
        0 30px 70px rgba(0, 0, 0, 0.75),
        inset 0 0 50px rgba(0, 0, 0, 0.58);
    padding: clamp(28px, 5vw, 52px);
    text-align: center;
}

.screen-card.compact {
    width: min(520px, calc(100vw - 40px));
}

.screen-kicker {
    color: var(--accent);
    margin-bottom: 8px;
}

.screen-kicker.danger {
    color: var(--danger);
}

h1,
h2 {
    margin: 0;
    color: #f0f6fa;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    line-height: 0.95;
    text-shadow:
        0 0 18px rgba(132, 194, 234, 0.22),
        0 4px 20px rgba(0, 0, 0, 0.9);
}

h1 {
    font-size: clamp(54px, 9vw, 104px);
}

h2 {
    font-size: clamp(38px, 6vw, 64px);
}

.screen-card p {
    max-width: 570px;
    margin: 22px auto 28px;
    color: #bdc9d1;
    font-family: "Share Tech Mono", monospace;
    font-size: 16px;
    line-height: 1.65;
}

.controls-grid {
    display: grid;
    grid-template-columns: minmax(120px, 180px) 1fr;
    gap: 10px 16px;
    max-width: 430px;
    margin: 0 auto 30px;
    text-align: left;
    align-items: center;
    color: #d9e5ec;
    font-family: "Share Tech Mono", monospace;
    font-size: 14px;
}

.controls-grid div {
    text-align: right;
}

.briefing-grid,
.scorecard-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    max-width: 520px;
    margin: 0 auto 30px;
    text-align: left;
}

.briefing-grid > div,
.scorecard-grid > div {
    border: 1px solid rgba(137, 164, 185, 0.2);
    background:
        linear-gradient(180deg, rgba(12, 22, 30, 0.76), rgba(4, 8, 12, 0.72)),
        radial-gradient(
            circle at 20% 0%,
            rgba(135, 188, 231, 0.09),
            transparent 55%
        );
    padding: 12px 14px;
    box-shadow:
        inset 0 0 18px rgba(0, 0, 0, 0.45),
        0 10px 24px rgba(0, 0, 0, 0.24);
}

.briefing-label {
    display: block;
    color: var(--muted);
    font-family: "Share Tech Mono", monospace;
    font-size: 12px;
    letter-spacing: 0.08em;
    margin-bottom: 4px;
    text-transform: uppercase;
}

.briefing-grid strong,
.scorecard-grid strong {
    color: #edf6fb;
    font-family: "Share Tech Mono", monospace;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.25;
    text-shadow: 0 0 12px rgba(135, 188, 231, 0.18);
}

.scorecard-grid > div:last-child {
    grid-column: 1 / -1;
    border-color: rgba(247, 195, 96, 0.38);
    background:
        linear-gradient(180deg, rgba(38, 28, 12, 0.78), rgba(8, 9, 10, 0.78)),
        radial-gradient(
            circle at 20% 0%,
            rgba(247, 195, 96, 0.16),
            transparent 58%
        );
}

#scorecard-total {
    color: #f7c360;
    font-size: 24px;
    text-shadow: 0 0 16px rgba(247, 195, 96, 0.4);
}

kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 26px;
    margin: 0 2px;
    padding: 0 8px;
    color: #eaf5fb;
    font-family: "Share Tech Mono", monospace;
    font-size: 13px;
    border: 1px solid rgba(172, 208, 230, 0.38);
    border-bottom-color: rgba(172, 208, 230, 0.18);
    background: linear-gradient(180deg, #14202a, #070b10);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        0 3px 8px rgba(0, 0, 0, 0.45);
}

button {
    border: 1px solid rgba(177, 215, 238, 0.5);
    background:
        linear-gradient(180deg, rgba(36, 68, 88, 0.95), rgba(8, 17, 24, 0.95)),
        radial-gradient(
            circle at 50% 0%,
            rgba(145, 211, 251, 0.24),
            transparent 65%
        );
    color: #eef8ff;
    padding: 14px 26px;
    min-width: 190px;
    font-family: "Share Tech Mono", monospace;
    font-size: 16px;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow:
        0 12px 24px rgba(0, 0, 0, 0.42),
        inset 0 0 20px rgba(122, 194, 240, 0.08);
    transition:
        transform 120ms ease,
        border-color 120ms ease,
        box-shadow 120ms ease;
}

button:hover,
button:focus-visible {
    transform: translateY(-1px);
    border-color: rgba(215, 238, 252, 0.9);
    box-shadow:
        0 16px 28px rgba(0, 0, 0, 0.5),
        0 0 18px rgba(116, 188, 235, 0.25),
        inset 0 0 20px rgba(122, 194, 240, 0.15);
    outline: none;
}

button:active {
    transform: translateY(1px);
}

@media (max-width: 760px) {
    .narrator-card {
        left: 50%;
        right: auto;
        bottom: 126px;
        width: min(420px, calc(100vw - 24px));
        grid-template-columns: 44px 1fr;
        padding: 8px 10px;
        min-height: 42px;
    }

    .voice-icon {
        transform: scale(0.75);
    }

    .hud-status {
        width: 210px;
        padding: 12px;
    }

    #minimap {
        top: 12px;
        right: 12px;
        width: 118px;
        height: 92px;
    }

    .stat-label,
    .screen-kicker {
        font-size: 12px;
    }

    .stat-value {
        font-size: 14px;
    }

    .controls-grid {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .controls-grid div {
        text-align: center;
    }

    .briefing-grid,
    .scorecard-grid {
        grid-template-columns: 1fr;
        max-width: 360px;
    }
}

@media (max-width: 540px) {
    .hud-status {
        left: 10px;
        bottom: 10px;
        width: 180px;
    }

    #minimap {
        top: 10px;
        right: 10px;
        width: 96px;
        height: 74px;
    }

    .narrator-card {
        bottom: 108px;
        width: min(420px, calc(100vw - 20px));
    }

    #narrator-text {
        font-size: 13px;
    }

    .briefing-grid strong,
    .scorecard-grid strong {
        font-size: 15px;
    }

    #scorecard-total {
        font-size: 20px;
    }
}

/* ── Loader ─────────────────────────────────────────────────────── */

#loader {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 50% 42%, rgba(6, 14, 22, 0.85) 0%, #020406 68%),
        #020406;
    cursor: pointer;
    transition: opacity 900ms ease, visibility 900ms ease;
}

#loader.loader-out {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

#loader::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
        0deg,
        rgba(255, 255, 255, 0.016) 0,
        rgba(255, 255, 255, 0.016) 1px,
        transparent 1px,
        transparent 4px
    );
    z-index: 0;
}

#loader::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    box-shadow: inset 0 0 150px rgba(0, 0, 0, 0.96);
    z-index: 0;
}

.loader-scan-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    top: -2px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(135, 188, 231, 0.55) 40%,
        rgba(180, 220, 255, 0.9) 50%,
        rgba(135, 188, 231, 0.55) 60%,
        transparent 100%
    );
    box-shadow: 0 0 18px rgba(135, 188, 231, 0.45), 0 0 6px rgba(135, 188, 231, 0.7);
    animation: loaderScanSwipe 3s 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    z-index: 1;
    pointer-events: none;
}

@keyframes loaderScanSwipe {
    0% {
        top: -2px;
        opacity: 1;
    }
    85% {
        opacity: 0.8;
    }
    100% {
        top: 100vh;
        opacity: 0;
    }
}

.loader-inner {
    position: relative;
    z-index: 2;
    text-align: center;
    width: min(600px, calc(100vw - 48px));
}

.loader-kicker {
    font-family: "Share Tech Mono", monospace;
    font-size: 11px;
    letter-spacing: 0.3em;
    color: rgba(135, 188, 231, 0.45);
    margin-bottom: 22px;
    animation: loaderFadeUp 0.9s 0.4s ease both;
}

.loader-title {
    font-family: "Rajdhani", sans-serif;
    font-size: clamp(46px, 8vw, 100px);
    font-weight: 700;
    color: #eef6ff;
    letter-spacing: 0.1em;
    line-height: 0.84;
    margin: 0 0 4px;
    text-transform: uppercase;
    text-shadow:
        0 0 24px rgba(135, 188, 231, 0.6),
        0 0 58px rgba(80, 148, 210, 0.24),
        0 6px 34px rgba(0, 0, 0, 0.96);
    animation:
        loaderReveal 1.2s 0.15s ease both,
        loaderTitleGlitch 9s 3s ease-in-out infinite;
}

.loader-tag {
    font-family: "Share Tech Mono", monospace;
    font-size: 12px;
    letter-spacing: 0.42em;
    color: rgba(135, 188, 231, 0.32);
    margin-bottom: 48px;
    animation: loaderFadeUp 1s 1.1s ease both;
}

.loader-divider {
    width: 100px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(135, 188, 231, 0.42), transparent);
    margin: 0 auto 48px;
    animation: loaderFadeUp 1s 1.2s ease both;
}

.loader-progress {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 14px;
    animation: loaderFadeUp 1s 1.3s ease both;
}

.loader-bar-track {
    flex: 1;
    height: 2px;
    background: rgba(135, 188, 231, 0.1);
    overflow: hidden;
}

.loader-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(
        90deg,
        rgba(55, 115, 175, 0.7),
        #87bce7,
        rgba(210, 238, 255, 0.95)
    );
    box-shadow: 0 0 10px rgba(135, 188, 231, 0.7), 0 0 22px rgba(80, 148, 210, 0.4);
    transition: width 300ms ease-out;
}

.loader-percent {
    font-family: "Share Tech Mono", monospace;
    font-size: 11px;
    color: rgba(135, 188, 231, 0.55);
    min-width: 34px;
    text-align: right;
    white-space: nowrap;
}

.loader-status {
    font-family: "Share Tech Mono", monospace;
    font-size: 11px;
    letter-spacing: 0.16em;
    color: rgba(180, 200, 216, 0.5);
    height: 15px;
    margin-bottom: 52px;
    animation: loaderFadeUp 1s 1.3s ease both;
}

.loader-enter {
    font-family: "Share Tech Mono", monospace;
    font-size: 13px;
    letter-spacing: 0.2em;
    color: var(--accent);
    margin: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 500ms ease;
}

.loader-enter.ready {
    opacity: 1;
    pointer-events: auto;
    animation: loaderEnterPulse 1.5s 0.2s ease-in-out infinite;
}

@keyframes loaderFadeUp {
    from {
        opacity: 0;
        transform: translateY(9px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes loaderReveal {
    0% {
        opacity: 0;
        clip-path: inset(0 0 100% 0);
    }
    18% {
        opacity: 1;
    }
    100% {
        opacity: 1;
        clip-path: inset(0 0 0% 0);
    }
}

@keyframes loaderTitleGlitch {
    0%,
    88%,
    100% {
        transform: translateX(0) skewX(0deg);
        text-shadow:
            0 0 24px rgba(135, 188, 231, 0.6),
            0 0 58px rgba(80, 148, 210, 0.24),
            0 6px 34px rgba(0, 0, 0, 0.96);
    }
    89.5% {
        transform: translateX(-5px) skewX(-1.2deg);
        text-shadow:
            5px 0 0 rgba(255, 55, 55, 0.82),
            -5px 0 0 rgba(50, 205, 255, 0.82),
            0 6px 34px rgba(0, 0, 0, 0.96);
    }
    91% {
        transform: translateX(4px) skewX(0.8deg);
        text-shadow:
            -4px 0 0 rgba(255, 55, 55, 0.65),
            4px 0 0 rgba(50, 205, 255, 0.65),
            0 6px 34px rgba(0, 0, 0, 0.96);
    }
    92.5% {
        transform: translateX(-2px) skewX(0deg);
        text-shadow:
            0 0 32px rgba(135, 188, 231, 0.85),
            0 0 70px rgba(80, 148, 210, 0.4),
            0 6px 34px rgba(0, 0, 0, 0.96);
    }
    94%,
    100% {
        transform: translateX(0) skewX(0deg);
        text-shadow:
            0 0 24px rgba(135, 188, 231, 0.6),
            0 0 58px rgba(80, 148, 210, 0.24),
            0 6px 34px rgba(0, 0, 0, 0.96);
    }
}

@keyframes loaderEnterPulse {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.18;
    }
}
