:root {
    --bg: #0f1115;
    --bg2: #1b2230;
    --panel: rgba(18, 22, 30, 0.84);
    --line: rgba(153, 224, 255, 0.28);
    --text: #e9f4ff;
    --muted: #9cb7cc;
    --accent: #95ffd8;
    --accent2: #ffd99d;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
    background:
        radial-gradient(900px 520px at 8% 5%, rgba(149, 255, 216, 0.12), transparent 58%),
        radial-gradient(900px 520px at 90% -8%, rgba(255, 217, 157, 0.1), transparent 52%),
        linear-gradient(150deg, var(--bg), var(--bg2));
    animation: bg-shift 16s ease-in-out infinite alternate;
}

.bg-noise {
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: 0.26;
    background-image:
        radial-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
        radial-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px);
    background-size: 14px 14px, 22px 22px;
    background-position: 0 0, 5px 7px;
}

.wrap {
    width: min(1080px, 94vw);
    margin: 1.3rem auto 2rem;
    position: relative;
    z-index: 1;
}

.panel {
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--panel);
    backdrop-filter: blur(6px);
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.35);
    padding: 1rem;
    margin-bottom: 0.9rem;
    animation: panel-rise 0.55s ease both;
}

.eyebrow {
    margin: 0;
    font-family: "Press Start 2P", monospace;
    font-size: 0.58rem;
    letter-spacing: 0.16em;
    color: var(--accent);
}

h1,
h3 {
    margin: 0;
    font-family: "Orbitron", sans-serif;
}

.hero {
    display: grid;
    gap: 0.45rem;
}

.hero p {
    margin: 0;
    color: var(--muted);
}

.hero-links {
    display: flex;
    gap: 0.55rem;
    flex-wrap: wrap;
}

.hero-links a {
    color: var(--text);
    text-decoration: none;
    border: 1px solid rgba(149, 255, 216, 0.44);
    border-radius: 999px;
    padding: 0.4rem 0.7rem;
    font-size: 0.88rem;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.2s ease;
}

.hero-links a:hover {
    border-color: rgba(255, 217, 157, 0.78);
    transform: translateY(-1px);
    box-shadow: 0 0 16px rgba(255, 217, 157, 0.2);
}

.minigame-head p {
    margin: 0.25rem 0 0;
    color: var(--muted);
}

.td-stats,
.td-controls,
.td-difficulty,
.td-tower-types,
.td-upgrade-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.td-stats {
    margin-top: 0.7rem;
    font-size: 0.84rem;
}

.td-controls,
.td-difficulty,
.td-mode-row,
.td-tower-types,
.td-upgrade-panel {
    margin-top: 0.55rem;
}

button {
    border: 1px solid rgba(153, 224, 255, 0.45);
    border-radius: 10px;
    background: rgba(29, 42, 64, 0.92);
    color: var(--text);
    cursor: pointer;
    font-family: "Orbitron", sans-serif;
    font-size: 0.78rem;
    padding: 0.46rem 0.7rem;
    transition: transform 0.14s ease, border-color 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

button:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 0 14px rgba(149, 255, 216, 0.2);
}

button:active {
    transform: translateY(0);
    filter: brightness(0.95);
}

.td-type.active {
    border-color: rgba(149, 255, 216, 0.76);
    background: rgba(37, 67, 62, 0.9);
}

#tdPermadeathBtn {
    border-color: rgba(255, 130, 130, 0.62);
}

#tdPermadeathBtn.active {
    background: rgba(96, 22, 34, 0.92);
    border-color: rgba(255, 110, 110, 0.9);
    box-shadow: 0 0 14px rgba(255, 110, 110, 0.25);
}

#tdRangeBtn {
    border-color: rgba(143, 211, 255, 0.7);
}

.td-difficulty-btn.active {
    border-color: rgba(255, 217, 157, 0.82);
    background: rgba(74, 56, 28, 0.9);
}

.td-mode-btn.active {
    border-color: rgba(255, 203, 132, 0.9);
    background: rgba(76, 55, 28, 0.92);
}

.td-upgrade-panel {
    border: 1px solid rgba(153, 224, 255, 0.24);
    border-radius: 11px;
    padding: 0.6rem;
    background: rgba(10, 18, 30, 0.7);
}

.td-upgrade-panel p {
    margin: 0 0 0.4rem;
    font-size: 0.82rem;
    color: #d2e8fb;
}

.panel-lite {
    margin-top: 0.6rem;
    border: 1px solid rgba(153, 224, 255, 0.24);
    border-radius: 11px;
    padding: 0.55rem;
    background: rgba(9, 17, 29, 0.68);
}

.td-meta p {
    margin: 0;
    color: #d8ebfb;
    font-size: 0.82rem;
}

.td-meta-modes {
    margin-top: 0.45rem;
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.td-meta-modes button {
    font-size: 0.72rem;
}

.td-objective-list {
    margin-top: 0.45rem;
    display: grid;
    gap: 0.3rem;
}

.td-objective-item {
    border: 1px solid rgba(153, 224, 255, 0.22);
    border-radius: 8px;
    padding: 0.34rem 0.45rem;
    background: rgba(11, 20, 34, 0.6);
    color: #cde3f9;
    font-size: 0.74rem;
}

.td-objective-item.done {
    border-color: rgba(157, 255, 146, 0.6);
    color: #d8ffd2;
}

.td-active-controls {
    margin-top: 0.45rem;
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.td-wave-panel p,
.td-enemy-panel p {
    margin: 0;
    color: #d8ebfb;
    font-size: 0.82rem;
}

.td-incoming-list {
    margin-top: 0.45rem;
    display: grid;
    gap: 0.32rem;
}

.td-incoming-row {
    border: 1px solid rgba(153, 224, 255, 0.22);
    border-radius: 8px;
    padding: 0.35rem 0.45rem;
    background: rgba(11, 20, 34, 0.6);
    font-size: 0.75rem;
    color: #cbe0f4;
}

.td-enemy-legend {
    margin-top: 0.45rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.34rem;
}

.td-enemy-legend button {
    font-size: 0.69rem;
    padding: 0.32rem 0.5rem;
}

#tdEnemyTooltip {
    min-height: 1.4em;
}

#tdCanvas {
    width: 100%;
    max-width: 100%;
    height: auto;
    margin-top: 0.58rem;
    display: block;
    border: 1px solid rgba(153, 224, 255, 0.42);
    border-radius: 10px;
    background: rgba(10, 21, 38, 0.9);
    box-shadow: inset 0 0 18px rgba(149, 255, 216, 0.06), 0 0 0 1px rgba(153, 224, 255, 0.08);
}

.td-help {
    margin: 0.5rem 0 0;
    color: var(--muted);
    font-size: 0.8rem;
}

.terminal-feedback {
    margin-top: 0.35rem;
    font-size: 0.84rem;
    color: var(--accent);
}

#tdMutator {
    color: var(--accent2);
    font-weight: 600;
    animation: mutator-pulse 1.8s ease-in-out infinite;
}

#tdMapLabel {
    color: #b9ffe4;
}

#tdWaveIntel {
    color: #b8dcff;
}

@keyframes panel-rise {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bg-shift {
    from {
        background-position: 0% 0%, 100% 0%, 0% 0%;
    }
    to {
        background-position: 8% 3%, 92% -2%, 0% 0%;
    }
}

@keyframes mutator-pulse {
    0% {
        text-shadow: 0 0 0 rgba(255, 217, 157, 0);
    }
    50% {
        text-shadow: 0 0 12px rgba(255, 217, 157, 0.45);
    }
    100% {
        text-shadow: 0 0 0 rgba(255, 217, 157, 0);
    }
}

@media (max-width: 720px) {
    .wrap {
        width: min(1080px, 96vw);
    }

    button {
        font-size: 0.73rem;
    }
}
