﻿:root {
            --bg-color: #080506;
            --panel-bg: rgba(13, 9, 11, 0.96);
            --border-color: #684026;
            --accent-color: #f7c55f;
            --mana-blue: #46c7ff;
            --text-color: #f5ead7;
            --danger-color: #9f1d18;
            --boss-color: #7e1c2a;
            --pixel-outline: #120b0a;
        }

        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
            font-family: Georgia, 'Times New Roman', serif;
            user-select: none;
        }

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

        body {
            background-color: var(--bg-color);
            color: var(--text-color);
            overflow: hidden;
            width: 100vw;
            height: 100vh;
            height: 100dvh;
            background-image:
                radial-gradient(at 50% 10%, rgba(247, 197, 95, 0.08) 0, transparent 44%),
                radial-gradient(at 80% 78%, rgba(159, 29, 24, 0.13) 0, transparent 48%),
                linear-gradient(180deg, #070405 0%, #150b0c 100%);
        }

        #game-container {
            position: fixed;
            inset: 0;
            width: 100vw;
            height: 100vh;
            height: 100dvh;
            background: #171210;
            border: 0;
            border-radius: 0;
            box-shadow:
                inset 0 0 100px rgba(0,0,0,0.8);
            overflow: hidden;
            image-rendering: pixelated;
        }

        #hud {
            position: absolute;
            top: 14px;
            left: 16px;
            width: calc(100% - 32px);
            height: 48px;
            background:
                linear-gradient(180deg, rgba(18, 12, 13, 0.72) 0%, rgba(7, 5, 8, 0.82) 100%),
                linear-gradient(90deg, rgba(249, 115, 22, 0.08), rgba(70, 199, 255, 0.035), rgba(127, 29, 29, 0.08));
            border: 1px solid rgba(201, 124, 55, 0.52);
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 10px;
            padding: 0 14px;
            z-index: 10;
            box-shadow:
                0 8px 24px rgba(0, 0, 0, 0.42),
                inset 0 1px 0 rgba(255, 220, 150, 0.11),
                inset 0 -1px 0 rgba(0, 0, 0, 0.55);
            backdrop-filter: blur(2px);
        }

        .hud-item {
            display: flex;
            align-items: center;
            gap: 7px;
            font-weight: bold;
            font-size: 0.8rem;
            letter-spacing: 0.7px;
            text-transform: uppercase;
            text-shadow: 0 2px 4px #000, 1px 1px 0 #000;
            background: rgba(4, 4, 7, 0.46);
            border: 1px solid rgba(244, 198, 96, 0.17);
            padding: 5px 10px 5px 7px;
            min-height: 32px;
            min-width: 0;
            white-space: nowrap;
            box-shadow: inset 0 1px 0 rgba(255, 220, 150, 0.05);
        }

        .hud-label {
            color: #b9915e;
            margin-right: 2px;
            opacity: 0.86;
        }

        .hud-value {
            color: #f2d28a;
            text-shadow: 0 0 8px rgba(249, 115, 22, 0.26), 1px 1px 0 #000;
        }

        .pixel-icon {
            width: 26px;
            height: 26px;
            flex: 0 0 26px;
            background-image: url('../assets/images/ui/siege-hud-icons.png');
            background-size: 130px 26px;
            image-rendering: pixelated;
            filter: drop-shadow(1px 2px 0 #000) drop-shadow(0 0 5px rgba(249, 115, 22, 0.16));
        }

        .icon-wave { background-position: 0 0; }
        .icon-skull { background-position: -26px 0; }
        .icon-coin { background-position: -52px 0; }
        .icon-shield { background-position: -78px 0; }
        .icon-shield-broken { background-position: -104px 0; }
        .icon-heart,
        .icon-heart-empty {
            background-image: url('../assets/images/ui/life-heart-icons.png');
            background-size: 52px 26px;
        }
        .icon-heart { background-position: 0 0; }
        .icon-heart-empty { background-position: -26px 0; }

        #lives-container {
            display: flex;
            align-items: center;
            gap: 2px;
        }

        .super-hud {
            gap: 7px;
            padding-right: 8px;
        }

        #super-meter {
            width: 96px;
            height: 10px;
            background: #080506;
            border: 1px solid rgba(178, 105, 48, 0.72);
            box-shadow: inset 0 2px 5px rgba(0,0,0,0.9), 0 0 8px rgba(0,0,0,0.35);
            overflow: hidden;
        }

        #super-fill {
            width: 0%;
            height: 100%;
            background: linear-gradient(90deg, #ef4444 0%, #f97316 50%, #f3c85a 100%);
            box-shadow: 0 0 10px rgba(249, 115, 22, 0.7);
            transition: width 0.15s ease;
        }

        .super-ready #super-fill {
            animation: superPulse 0.7s infinite alternate ease-in-out;
        }

        @keyframes superPulse {
            0% { filter: brightness(1); }
            100% { filter: brightness(1.55); }
        }

        canvas {
            display: block;
            width: 100%;
            height: 100%;
            image-rendering: pixelated;
        }

        #input-panel {
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 74px;
            background:
                linear-gradient(180deg, rgba(10, 8, 10, 0) 0%, rgba(8, 5, 6, 0.72) 36%, rgba(5, 3, 4, 0.92) 100%);
            border-top: 1px solid rgba(201, 124, 55, 0.34);
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 0 18px;
            z-index: 10;
            box-shadow: inset 0 1px 0 rgba(255, 211, 112, 0.04);
        }

        #word-input {
            width: min(520px, calc(100vw - 384px));
            height: 42px;
            background: rgba(5, 4, 6, 0.82);
            border: 1px solid rgba(211, 151, 67, 0.74);
            border-radius: 0;
            padding: 0 20px;
            font-size: 1.12rem;
            color: #f7ead2;
            text-align: center;
            letter-spacing: 2px;
            outline: none;
            transition: all 0.2s ease;
            box-shadow:
                0 8px 24px rgba(0, 0, 0, 0.42),
                inset 0 2px 8px rgba(0,0,0,0.86),
                0 0 0 1px rgba(0,0,0,0.6);
        }

        #word-input:focus {
            border-color: #f3c85a;
            box-shadow:
                0 0 18px rgba(226, 177, 60, 0.22),
                0 0 36px rgba(70, 199, 255, 0.08),
                inset 0 2px 6px rgba(0,0,0,0.9);
        }

        #word-input.tutorial-focus {
            border-color: #facc15;
            box-shadow:
                0 0 0 2px rgba(250, 204, 21, 0.7),
                0 0 28px rgba(250, 204, 21, 0.42),
                inset 0 2px 6px rgba(0,0,0,0.9);
            animation: tutorialInputPulse 0.75s steps(2, end) infinite;
        }

        #word-input::placeholder {
            color: #6e5546;
            letter-spacing: 0;
            font-size: 0.95rem;
            font-style: italic;
        }

        .tutorial-overlay {
            position: absolute;
            inset: 0;
            z-index: 16;
            pointer-events: none;
        }

        #tutorial-spotlight {
            position: absolute;
            width: 96px;
            height: 54px;
            border: 2px solid #facc15;
            background: rgba(250, 204, 21, 0.08);
            box-shadow:
                0 0 0 9999px rgba(3, 2, 3, 0.48),
                0 0 18px rgba(250, 204, 21, 0.72),
                inset 0 0 14px rgba(255, 255, 255, 0.16);
            transform: translate(-50%, -50%);
            image-rendering: pixelated;
            animation: tutorialSpotlightPulse 0.7s steps(2, end) infinite;
        }

        #tutorial-popup {
            position: absolute;
            width: min(340px, calc(100vw - 32px));
            background:
                linear-gradient(180deg, rgba(27, 15, 12, 0.96), rgba(7, 5, 6, 0.98));
            border: 2px solid #a16207;
            padding: 16px 18px;
            color: #f9efd7;
            box-shadow:
                0 12px 32px rgba(0,0,0,0.58),
                inset 0 1px 0 rgba(255, 236, 179, 0.18);
            text-shadow: 1px 1px 0 #000;
            pointer-events: auto;
        }

        #tutorial-popup::before {
            content: '';
            position: absolute;
            left: -10px;
            top: 22px;
            width: 14px;
            height: 14px;
            background: #1b0f0c;
            border-left: 2px solid #a16207;
            border-bottom: 2px solid #a16207;
            transform: rotate(45deg);
        }

        .tutorial-kicker {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            color: #facc15;
            font-size: 0.68rem;
            text-transform: uppercase;
            letter-spacing: 1.4px;
            margin-bottom: 8px;
        }

        .tutorial-kicker::before {
            content: '';
            width: 18px;
            height: 18px;
            background-image: url('../assets/images/ui/siege-hud-icons.png');
            background-size: 90px 18px;
            background-position: -54px 0;
            image-rendering: pixelated;
            filter: drop-shadow(1px 1px 0 #000);
        }

        #tutorial-popup h2 {
            margin: 0 0 8px;
            color: #f7d77d;
            font-size: 1.08rem;
            line-height: 1.1;
            text-transform: uppercase;
            letter-spacing: 0.9px;
        }

        #tutorial-popup p {
            margin: 0;
            color: #d9c6a9;
            font-size: 0.9rem;
            line-height: 1.38;
        }

        #tutorial-next-btn {
            display: none;
        }

        #tutorial-next-btn:hover {
            display: none;
        }

        .hidden {
            display: none !important;
        }

        @keyframes tutorialSpotlightPulse {
            0% { filter: brightness(1); }
            100% { filter: brightness(1.45); }
        }

        @keyframes tutorialInputPulse {
            0% { filter: brightness(1); }
            100% { filter: brightness(1.25); }
        }

        @media (max-width: 900px) {
            #hud {
                height: auto;
                min-height: 52px;
                flex-wrap: wrap;
                align-content: center;
                padding: 6px 8px;
                top: 8px;
                left: 8px;
                width: calc(100% - 16px);
            }

            .hud-item {
                font-size: 0.68rem;
                padding: 4px 5px;
            }

            .pixel-icon {
                width: 22px;
                height: 22px;
                flex-basis: 22px;
                background-size: 110px 22px;
            }

            .icon-skull { background-position: -22px 0; }
            .icon-coin { background-position: -44px 0; }
            .icon-shield { background-position: -66px 0; }
            .icon-shield-broken { background-position: -88px 0; }
            .icon-heart,
            .icon-heart-empty {
                background-size: 44px 22px;
            }
            .icon-heart { background-position: 0 0; }
            .icon-heart-empty { background-position: -22px 0; }

            #input-panel {
                height: 68px;
                padding: 0 10px;
                justify-content: center;
            }

            #word-input {
                width: min(520px, calc(100vw - 28px));
                height: 38px;
                font-size: 0.95rem;
                padding: 0 12px;
            }

            .menu-logo {
                width: min(94vw, 720px);
                margin-top: -4vh;
            }

            #start-btn {
                margin-top: -8px;
            }
        }

        .screen-overlay {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background:
                linear-gradient(rgba(8, 5, 6, 0.9), rgba(8, 5, 6, 0.94)),
                url('../assets/images/backgrounds/siege-battlefield-overlay.png') center / cover no-repeat;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            z-index: 20;
            image-rendering: pixelated;
        }

        #start-screen {
            background:
                linear-gradient(90deg, rgba(3, 5, 12, 0.24) 0%, rgba(3, 5, 12, 0.16) 46%, rgba(3, 5, 12, 0.32) 100%),
                radial-gradient(circle at 52% 48%, rgba(70, 199, 255, 0.16), transparent 22%),
                linear-gradient(180deg, rgba(0, 0, 0, 0.86) 0%, rgba(0, 0, 0, 0.12) 44%, rgba(0, 0, 0, 0.82) 100%),
                url('../assets/images/backgrounds/game-menu-screen.png') center / cover no-repeat;
            overflow: hidden;
            animation: menuFadeIn 1.35s ease-out both;
        }

        #start-screen.menu-exit {
            pointer-events: none;
            animation: menuFadeOut 0.9s ease-in both;
        }

        #start-screen::before {
            content: '';
            position: absolute;
            inset: 0;
            background:
                linear-gradient(180deg, rgba(0,0,0,0.9), transparent 22%, transparent 72%, rgba(0,0,0,0.88)),
                radial-gradient(circle at 70% 28%, rgba(185, 28, 28, 0.28), transparent 28%);
            opacity: 0;
            animation: menuDarkLift 1.4s ease-out 0.15s forwards;
        }

        .menu-logo {
            position: relative;
            z-index: 1;
            display: grid;
            place-items: center;
            width: min(72vw, 1260px);
            margin-top: -6vh;
            text-align: center;
            opacity: 0;
            transform: translateY(18px) scale(0.96);
            animation: logoRise 1.1s steps(10, end) 0.55s forwards, logoFlash 1.05s steps(2, end) 1.38s 2;
        }

        .menu-logo img {
            display: block;
            width: 100%;
            height: auto;
            image-rendering: auto;
            filter:
                drop-shadow(0 8px 10px rgba(0, 0, 0, 0.82))
                drop-shadow(0 0 24px rgba(249, 115, 22, 0.28));
            pointer-events: none;
        }

        #start-btn {
            position: relative;
            z-index: 1;
            margin-top: clamp(-22px, -1.2vw, -10px);
            opacity: 0;
            transform: translateY(14px);
            animation: playButtonReveal 0.75s steps(8, end) 2.35s forwards;
        }

        @keyframes menuFadeIn {
            0% { filter: brightness(0); }
            100% { filter: brightness(1); }
        }

        @keyframes menuFadeOut {
            0% { opacity: 1; filter: brightness(1); }
            100% { opacity: 0; filter: brightness(0); }
        }

        @keyframes menuDarkLift {
            0% { opacity: 1; }
            100% { opacity: 0.18; }
        }

        @keyframes logoRise {
            0% { opacity: 0; transform: translateY(18px) scale(0.96); }
            100% { opacity: 1; transform: translateY(0) scale(1); }
        }

        @keyframes logoFlash {
            0%, 100% { filter: brightness(1); }
            50% { filter: brightness(2.1); }
        }

        @keyframes playButtonReveal {
            0% { opacity: 0; transform: translateY(14px); }
            100% { opacity: 1; transform: translateY(0); }
        }

        .screen-overlay.hidden {
            display: none;
        }

        #game-over-screen,
        #victory-screen {
            background:
                linear-gradient(90deg, rgba(0,0,0,0.9), rgba(0,0,0,0.45) 45%, rgba(0,0,0,0.92)),
                radial-gradient(circle at 50% 42%, rgba(249, 115, 22, 0.18), transparent 25%),
                url('../assets/images/backgrounds/siege-battlefield-final-fire.png') center / cover no-repeat;
        }

        #victory-screen {
            background:
                linear-gradient(90deg, rgba(0,0,0,0.86), rgba(4, 20, 24, 0.44) 48%, rgba(0,0,0,0.9)),
                radial-gradient(circle at 50% 38%, rgba(250, 204, 21, 0.18), transparent 24%),
                url('../assets/images/backgrounds/siege-battlefield-normal.png') center / cover no-repeat;
        }

        .end-card {
            position: relative;
            width: min(620px, calc(100vw - 34px));
            padding: 34px 42px 36px;
            background:
                linear-gradient(180deg, rgba(24, 13, 11, 0.94), rgba(7, 5, 6, 0.98)),
                repeating-linear-gradient(0deg, rgba(255,255,255,0.025) 0 2px, transparent 2px 5px);
            border: 2px solid rgba(208, 138, 54, 0.86);
            box-shadow:
                0 26px 70px rgba(0,0,0,0.72),
                inset 0 1px 0 rgba(255, 232, 180, 0.16),
                inset 0 -12px 32px rgba(0,0,0,0.42);
            text-align: center;
            animation: endCardEnter 0.6s steps(10, end) both;
        }

        .end-card::before,
        .end-card::after {
            content: '';
            position: absolute;
            left: 18px;
            right: 18px;
            height: 2px;
            background: linear-gradient(90deg, transparent, rgba(250, 204, 21, 0.68), transparent);
        }

        .end-card::before { top: 14px; }
        .end-card::after { bottom: 14px; }

        .defeat-card {
            border-color: rgba(153, 27, 27, 0.95);
            box-shadow:
                0 26px 70px rgba(0,0,0,0.76),
                0 0 46px rgba(127, 29, 29, 0.34),
                inset 0 1px 0 rgba(255, 232, 180, 0.08);
        }

        .victory-card {
            border-color: rgba(250, 204, 21, 0.92);
            box-shadow:
                0 26px 70px rgba(0,0,0,0.68),
                0 0 52px rgba(250, 204, 21, 0.2),
                inset 0 1px 0 rgba(255, 255, 255, 0.16);
        }

        .end-emblem {
            width: 58px;
            height: 58px;
            margin: 0 auto 12px;
            image-rendering: pixelated;
            background-image: url('../assets/images/ui/siege-hud-icons.png');
            background-size: 290px 58px;
            filter: drop-shadow(2px 3px 0 #000) drop-shadow(0 0 16px rgba(249, 115, 22, 0.4));
        }

        .danger-emblem { background-position: -58px 0; }
        .victory-emblem { background-position: -156px 0; }

        .end-kicker {
            display: block;
            color: #d08a36;
            font-size: 0.82rem;
            text-transform: uppercase;
            letter-spacing: 4px;
            margin-bottom: 9px;
            text-shadow: 2px 2px 0 #000;
        }

        h1 {
            font-size: 3.2rem;
            font-weight: normal;
            margin-bottom: 15px;
            text-transform: uppercase;
            letter-spacing: 4px;
            text-align: center;
            color: #d1c2a5;
            text-shadow: 2px 2px 4px rgba(0,0,0,0.6);
        }

        .highlight-text {
            color: var(--accent-color);
            text-shadow:
                3px 3px 0 #1a0905,
                0 0 20px rgba(226, 177, 60, 0.42),
                0 0 42px rgba(250, 204, 21, 0.24);
        }

        .danger-text {
            color: #ef4444;
            text-shadow:
                3px 3px 0 #160606,
                0 0 20px rgba(185, 28, 28, 0.5),
                0 0 40px rgba(127, 29, 29, 0.36);
        }

        p.subtitle {
            font-size: 1.05rem;
            color: #a39081;
            margin-bottom: 35px;
            max-width: 680px;
            text-align: center;
            line-height: 1.6;
            font-style: italic;
        }

        .btn-group {
            display: flex;
            gap: 20px;
        }

        .btn {
            background: linear-gradient(180deg, #8f3f1f 0%, #4d170c 100%);
            border: 3px solid #c37a3d;
            border-radius: 0;
            color: #f1ebd9;
            padding: 14px 40px;
            font-size: 1.05rem;
            text-transform: uppercase;
            letter-spacing: 2px;
            cursor: pointer;
            transition: all 0.2s;
            box-shadow: 0 5px 0 #1c0905, 0 10px 18px rgba(0,0,0,0.5);
        }

        .btn:hover {
            transform: translateY(-1px);
            border-color: var(--accent-color);
            filter: brightness(1.15);
        }

        .btn.secondary {
            background: linear-gradient(135deg, #2e2520 0%, #1c1512 100%);
            border: 2px solid #4a3b32;
        }

        #stats-summary,
        .stats-summary {
            margin: 25px 0;
            padding: 25px;
            background:
                linear-gradient(180deg, rgba(6, 5, 6, 0.88), rgba(20, 12, 10, 0.82));
            border: 1px solid rgba(208, 138, 54, 0.42);
            min-width: min(380px, 100%);
            box-shadow:
                inset 0 0 20px rgba(0,0,0,0.62),
                0 0 18px rgba(0,0,0,0.25);
        }

        .stats-row {
            display: flex;
            justify-content: space-between;
            margin-bottom: 12px;
            font-size: 1.05rem;
            border-bottom: 1px dashed #3a2d26;
            padding-bottom: 4px;
            color: #c9ad84;
            text-transform: uppercase;
            letter-spacing: 1px;
        }

        .stats-row:last-child {
            margin-bottom: 0;
            border-bottom: 0;
        }

        @keyframes endCardEnter {
            0% { opacity: 0; transform: translateY(18px) scale(0.96); filter: brightness(0.6); }
            100% { opacity: 1; transform: translateY(0) scale(1); filter: brightness(1); }
        }

        .rules-card {
            background: rgba(26, 19, 16, 0.6);
            border: 2px solid #3d2f26;
            border-left: 4px solid var(--accent-color);
            padding: 20px;
            margin-bottom: 35px;
            max-width: 650px;
            font-size: 0.95rem;
            color: #a39081;
            line-height: 1.6;
        }
        .rules-card ul { margin-left: 20px; margin-top: 10px; }
        .rules-card li { margin-bottom: 6px; }

        #wave-announcement {
            position: absolute;
            top: 45%;
            left: 50%;
            transform: translate(-50%, -50%);
            font-size: 3.5rem;
            color: #f1ebd9;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.3s ease;
            z-index: 5;
            text-transform: uppercase;
            text-align: center;
        }

        #wave-announcement.show {
            opacity: 1;
            animation: textGlowPulse 1.8s infinite alternate ease-in-out;
        }

        @keyframes textGlowPulse {
            0% { text-shadow: 0 0 15px rgba(226, 177, 60, 0.4); transform: translate(-50%, -50%) scale(0.97); }
            100% { text-shadow: 0 0 35px rgba(185, 28, 28, 0.7); transform: translate(-50%, -50%) scale(1.03); }
        }

