:root {
    --neon-green: #0f0;
    --neon-cyan: #8fd;
    --neon-blue: #00f2ff;
    --neon-purple: #d8f;
    --panel-bg: #0a0a0a;
    --app-bg: #000;
    --dash-border: #1a3a3a;
    --header-border: #1f3f3f;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    background-color: #000;
    color: var(--neon-cyan);
    font-family: 'Courier New', Courier, monospace;
    overflow: hidden;
    overscroll-behavior: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    justify-content: center;
    align-items: center;
}

#app {
    width: 100%;
    max-width: 560px;
    height: 100%;
    background-color: #050505;
    border-left: 1px solid var(--dash-border);
    border-right: 1px solid var(--dash-border);
    display: flex;
    flex-direction: column;
    position: relative;
}

#game-header {
    flex: 0 0 45px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px;
    border-bottom: 1px solid var(--header-border);
    background: #0d0d0d;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
    z-index: 100;
}

.header-title {
    font-weight: bold;
    font-size: 1.1rem;
    color: #fff;
    text-shadow: 0 0 5px #fff;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-subtitle {
    font-size: 0.7rem;
    color: var(--neon-green);
    opacity: 0.7;
}

.header-btn {
    background: transparent;
    border: 1px solid var(--dash-border);
    color: #888;
    font-family: inherit;
    font-size: 0.6rem;
    padding: 2px 6px;
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.2s;
    outline: none;
}

.header-btn:hover {
    color: #f55;
    border-color: #f55;
    background: rgba(255, 0, 0, 0.1);
}

#resource-bar {
    flex: 0 0 35px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: #080808;
    border-bottom: 2px solid var(--header-border);
    font-size: 0.8rem;
    font-weight: bold;
    z-index: 10;
}

.res-item {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #fff;
}

.res-icon {
    font-size: 1rem;
    font-weight: bold;
    text-shadow: 0 0 5px currentColor;
}

#res-h-val {
    color: #ccc;
}

#res-dm-val {
    color: var(--neon-purple);
    text-shadow: 0 0 5px var(--neon-purple);
}

#view-port {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.game-view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    padding: 5px;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

.game-view.active {
    display: flex;
    opacity: 1;
    z-index: 5;
}

.panel {
    border: 1px solid var(--dash-border);
    background: var(--panel-bg);
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    background: rgba(26, 58, 58, 0.4);
    padding: 5px 10px;
    border-bottom: 1px solid var(--dash-border);
    text-align: center;
}

.panel-title {
    color: var(--neon-cyan);
    opacity: 0.8;
    letter-spacing: 1.5px;
    font-size: 0.8rem;
    font-weight: bold;
}

.panel-content {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#dashboard .panel-content {
    padding: 10px;
}

#view-dashboard .dash-stack {
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
    display: flex;
    flex-direction: column;
}

#view-dashboard #dashboard {
    flex: 1 !important;
    margin-bottom: 0 !important;
}

#view-dashboard #illuminator {
    flex: 0 0 25%;
    padding: 0;
}

#illuminator .panel-content {
    padding: 0;
    margin: 0;
    width: 100%;
    height: 100%;
}

#sky-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: #87CEEB;
    transition: opacity 0.1s linear;
    z-index: 1;
}

canvas {
    position: absolute;
    top: 0;
    left: 0;
    display: block;
    width: 100%;
    height: 100%;
    z-index: 5;
}

#earth-surface {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40%;
    background: linear-gradient(to bottom, #1a3a3a 0%, #0a0a0a 100%);
    box-shadow: 0 -15px 30px rgba(100, 255, 100, 0.2);
    z-index: 10;
}

.major-value {
    font-size: clamp(2.5rem, 10vw, 3.5rem);
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 10px #fff;
    margin-top: 5px;
}

.sub-label {
    font-size: 0.8rem;
    opacity: 0.8;
    margin-top: -10px;
}

.progress-container {
    width: 100%;
    height: 15px;
    border: 1px solid var(--dash-border);
    margin-top: 5px;
    position: relative;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 3px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(to right, var(--neon-blue), var(--neon-cyan));
    box-shadow: 0 0 10px var(--neon-blue);
    transition: width 0.1s;
    border-radius: 2px;
}

#progress-val {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.65rem;
    font-weight: bold;
    color: #fff;
    text-shadow: 1px 1px 2px #000;
}

.speed-row {
    width: 100%;
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    font-weight: bold;
    color: var(--neon-cyan);
    opacity: 0.9;
}

.log-terminal {
    width: 100%;
    padding: 5px;
    font-size: 0.65rem;
    color: #aaa;
    border-top: 1px solid var(--dash-border);
    margin-top: auto;
    height: 48px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.log-terminal .log-item {
    margin-bottom: 2px;
    display: flex;
    gap: 5px;
}

#cockpit-bar {
    padding: 10px 15px 10px 15px !important;
    flex: 0 0 auto !important;
    margin-top: auto !important;
    background: #020202;
    border: 1px solid var(--dash-border);
    border-radius: 4px;
}

.cockpit-controls {
    display: flex;
    gap: 10px !important;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
}

.cockpit-controls button {
    padding: 10px 5px !important;
    min-height: 60px !important;
    height: auto !important;
}

#auto-btn {
    flex: 0 0 35%;
    max-width: 140px;
    border-radius: 8px;
    background: #111;
    border: 2px solid #555;
    color: #888;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: bold;
    text-align: left;
    transition: all 0.2s;
    outline: none;
    touch-action: manipulation;
}

#auto-btn.active {
    background: rgba(0, 255, 255, 0.1);
    border-color: var(--neon-cyan);
    color: var(--neon-cyan);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.3), inset 0 0 10px rgba(0, 255, 255, 0.2);
}

#auto-btn.active .rocket-icon {
    text-shadow: 0 0 10px var(--neon-cyan);
}

#tap-btn {
    flex: 1;
    max-width: 220px;
    border-radius: 35px;
    background: radial-gradient(circle, #0a4d0a 0%, #000 100%);
    border: 3px solid var(--neon-green);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-align: left;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: bold;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.3), inset 0 0 15px rgba(0, 255, 0, 0.2);
    transition: transform 0.05s, box-shadow 0.05s;
    outline: none;
    touch-action: manipulation;
}

#tap-btn:active {
    transform: scale(0.92);
    box-shadow: 0 0 35px var(--neon-green);
}

.rocket-icon {
    font-size: 1.5rem;
}

.btn-text {
    line-height: 1.2;
}

#view-logs {
    padding: 5px;
}

.logs-view-content {
    display: flex;
    flex-direction: column;
}

.log-list-container {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
    font-size: clamp(0.7rem, 2.5vw, 0.8rem);
    line-height: 1.4;
    color: #aaa;
}

.log-item {
    margin-bottom: 5px;
    display: flex;
    gap: 8px;
}

.log-time {
    color: var(--neon-cyan);
    opacity: 0.7;
    font-weight: bold;
    white-space: nowrap;
}

.log-msg {
    color: #eee;
}

.log-system {
    color: var(--neon-cyan);
    font-weight: bold;
    text-shadow: 0 0 5px rgba(0, 255, 255, 0.3);
}

.log-upgrade {
    color: var(--neon-green);
    font-weight: bold;
    text-shadow: 0 0 5px rgba(0, 255, 0, 0.3);
}

.log-achievement {
    color: #fa5;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(255, 170, 85, 0.4);
}

.leaderboard-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    height: 100%;
    padding-right: 5px;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: #0a0a0a;
    border: 1px solid var(--dash-border);
    border-radius: 4px;
    font-size: 0.85rem;
    font-family: 'Courier New', Courier, monospace;
}

.leaderboard-item.rank-1 {
    border-color: #ffd700;
    color: #ffd700;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.1);
}

.leaderboard-item.rank-2 {
    border-color: #c0c0c0;
    color: #c0c0c0;
}

.leaderboard-item.rank-3 {
    border-color: #cd7f32;
    color: #cd7f32;
}

/* === ИССЛЕДОВАНИЯ И МОДИФИКАЦИИ === */
#view-research {
    padding: 5px;
}

.research-view-content {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
}

.research-item-wrapper {
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
}

.research-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    border: 1px solid var(--dash-border);
    border-radius: 4px;
    background: #0d0d0d;
    transition: border-color 0.2s;
    position: relative;
    z-index: 2;
}

.clickable-card {
    cursor: pointer;
}

.research-item.inactive {
    opacity: 0.4;
    border-color: #333;
    filter: grayscale(1);
}

.research-item.special {
    border-color: #38a;
}

.tech-icon {
    font-size: 2.5rem;
    width: 50px;
    text-align: center;
}

.tech-details {
    flex: 1;
}

.tech-details h3 {
    margin: 0;
    font-size: 0.9rem;
    color: #fff;
    text-shadow: 0 0 5px #fff;
    margin-bottom: 3px;
}

.tech-effect {
    margin: 2px 0 6px 0 !important;
    font-size: 0.7rem !important;
    color: #888 !important;
}

.tech-details p {
    margin: 0;
    font-size: 0.75rem;
    color: #aaa;
}

.tech-stats-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 4px;
}

.tech-lvl {
    font-size: 0.75rem;
    color: #ccc;
}

.tech-cost {
    font-size: 0.7rem;
    color: #8fd;
    background: rgba(0, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
}

.add-btn {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: rgba(0, 255, 0, 0.1);
    border: 2px solid var(--neon-green);
    color: var(--neon-green);
    font-size: 1.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    outline: none;
    flex-shrink: 0;
    padding-bottom: 4px;
}

.add-btn:hover:not(:disabled) {
    background: rgba(0, 255, 0, 0.25);
    box-shadow: 0 0 12px rgba(0, 255, 0, 0.4);
}

.add-btn:active:not(:disabled) {
    transform: scale(0.9);
}

.add-btn:disabled {
    opacity: 0.3;
    border-color: #555;
    color: #555;
    background: transparent;
    cursor: not-allowed;
}

.add-btn.small {
    width: 32px;
    height: 32px;
    font-size: 1.4rem;
    border-radius: 6px;
    padding-bottom: 2px;
}

.modifiers-list {
    background: #080808;
    border: 1px solid var(--dash-border);
    border-top: none;
    border-radius: 0 0 6px 6px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: -2px;
    z-index: 1;
}

.mod-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #111;
    padding: 8px 12px;
    border-radius: 4px;
    border: 1px dashed #333;
}

.mod-info h4 {
    margin: 0 0 4px 0;
    font-size: 0.8rem;
    color: #ddd;
}

.mod-info h4 span {
    color: var(--neon-cyan);
}

.mod-info p {
    margin: 0;
    font-size: 0.65rem;
    color: #888;
}

.mod-action {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mod-cost {
    font-size: 0.75rem;
    font-weight: bold;
    color: #8fd;
}

.tech-divider {
    margin-top: 15px;
    border-bottom: 1px dashed var(--dash-border);
    text-align: center;
    color: var(--neon-cyan);
    opacity: 0.7;
    font-size: 0.75rem;
    padding-bottom: 5px;
    letter-spacing: 1px;
}

#game-nav {
    flex: 0 0 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-top: 2px solid var(--header-border);
    background: #0d0d0d;
    z-index: 100;
}

.nav-tab {
    flex: 1;
    height: 100%;
    background: transparent;
    border: none;
    border-right: 1px solid var(--dash-border);
    color: var(--neon-cyan);
    opacity: 0.6;
    font-family: inherit;
    font-size: clamp(0.55rem, 1.6vw, 0.7rem);
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.nav-tab:last-child {
    border-right: none;
}

.nav-tab:hover {
    background: rgba(0, 255, 255, 0.1);
    opacity: 1;
}

.nav-tab.active {
    background: linear-gradient(to bottom, rgba(0, 255, 255, 0.15) 0%, rgba(0, 0, 0, 0) 100%);
    color: #fff;
    opacity: 1;
    text-shadow: 0 0 5px var(--neon-cyan);
    box-shadow: inset 0 3px 0 var(--neon-cyan);
}

.buy-btn {
    background: rgba(0, 255, 0, 0.1);
    border: 1px solid var(--neon-green);
    color: var(--neon-green);
    padding: 5px 12px;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: bold;
    cursor: pointer;
    margin-top: 5px;
    transition: all 0.2s;
    outline: none;
}

.buy-btn:hover:not(:disabled) {
    background: rgba(0, 255, 0, 0.2);
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.4);
}

.buy-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.buy-btn:disabled {
    opacity: 0.4;
    border-color: #555;
    color: #888;
    background: #111;
    cursor: not-allowed;
}

.buy-btn.unlock-btn {
    background: rgba(0, 150, 255, 0.1);
    border-color: #38a;
    color: #8df;
}

.buy-btn.unlock-btn:hover:not(:disabled) {
    background: rgba(0, 150, 255, 0.2);
    box-shadow: 0 0 10px rgba(0, 150, 255, 0.4);
}

#start-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    text-align: center;
    transition: opacity 0.6s ease;
}

.start-title {
    font-size: 2.2rem;
    color: #fff;
    text-shadow: 0 0 15px var(--neon-cyan);
    margin-bottom: 20px;
    font-weight: bold;
    letter-spacing: 2px;
}

.start-annotation {
    font-size: 0.9rem;
    color: #aaa;
    margin-bottom: 30px;
    line-height: 1.6;
    max-width: 90%;
}

#player-name-input {
    padding: 10px;
    margin-bottom: 20px;
    width: 250px;
    background: rgba(0, 255, 255, 0.05);
    border: 1px solid var(--dash-border);
    color: var(--neon-cyan);
    font-family: inherit;
    font-size: 1rem;
    text-align: center;
    text-transform: uppercase;
    outline: none;
}

#player-name-input:focus {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.2);
}

#start-btn {
    padding: 15px 50px;
    font-size: 1.2rem;
    background: rgba(0, 255, 255, 0.05);
    color: var(--neon-cyan);
    border: 2px solid var(--neon-cyan);
    border-radius: 8px;
    cursor: pointer;
    text-shadow: 0 0 5px var(--neon-cyan);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.2), inset 0 0 10px rgba(0, 255, 255, 0.1);
    transition: all 0.2s;
    font-family: inherit;
    font-weight: bold;
    letter-spacing: 1px;
    outline: none;
}

#start-btn:hover {
    background: rgba(0, 255, 255, 0.2);
    box-shadow: 0 0 25px rgba(0, 255, 255, 0.5);
    transform: scale(1.05);
}

#start-btn:active {
    transform: scale(0.95);
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.5);
}

::-webkit-scrollbar-thumb {
    background: var(--dash-border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.dash-stack {
    display: flex;
    flex-direction: column;
    flex: 1 !important;
}

#mini-log {
    flex: 1 !important;
    min-height: 80px !important;
    height: auto !important;
    margin-top: 10px !important;
    overflow-y: auto !important;
}

.mod-toggle-hint {
    font-size: 0.6rem;
    color: var(--neon-cyan);
    background: rgba(0, 255, 255, 0.05);
    border: 1px solid rgba(0, 255, 255, 0.2);
    padding: 3px 6px;
    border-radius: 4px;
    display: inline-block;
    margin-top: 8px;
    letter-spacing: 1px;
}

.mod-toggle-hint span {
    font-size: 0.6rem;
    margin-left: 4px;
    vertical-align: middle;
}

#floating-text-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 10;
}

.floating-text {
    position: absolute;
    color: #8fd;
    font-weight: bold;
    font-size: 1.5rem;
    text-shadow: 0 0 5px #8fd, 0 0 10px #055;
    animation: floatUpFade 4s ease-out forwards;
    transform: translate(-50%, -50%);
}

@keyframes floatUpFade {
    0% {
        opacity: 1;
        transform: translate(-50%, 0) scale(0.8);
    }
    10% {
        transform: translate(-50%, -10px) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -60px) scale(1);
    }
}

.floating-text-fast {
    position: absolute;
    font-weight: bold;
    font-size: 1.2rem;
    text-shadow: 0 0 5px currentColor, 0 0 10px currentColor;
    animation: floatUpFadeFast 2s ease-out forwards;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 10;
}

@keyframes floatUpFadeFast {
    0% {
        opacity: 1;
        transform: translate(-50%, 0) scale(0.8);
    }
    20% {
        transform: translate(-50%, -10px) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -40px) scale(1);
    }
}

#volume-slider {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;
}

#volume-slider:focus {
    outline: none;
}

#volume-slider::-webkit-slider-runnable-track {
    background: var(--dash-border);
    height: 4px;
    border-radius: 2px;
}

#volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    height: 12px;
    width: 12px;
    background: var(--neon-cyan);
    border-radius: 50%;
    margin-top: -4px;
    box-shadow: 0 0 8px var(--neon-cyan);
    transition: transform 0.1s;
}

#volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* --- МОДАЛЬНОЕ ОКНО НАСТРОЕК --- */
.modal-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
}
.modal-content {
    width: 85%;
    max-width: 350px;
    background: #0a0a0a;
    border: 1px solid var(--neon-cyan);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.2);
}
.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #ccc;
    font-size: 0.85rem;
    font-weight: bold;
}