body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 3px,
        rgba(0, 0, 0, 0.06) 3px,
        rgba(0, 0, 0, 0.06) 4px
    );
    mix-blend-mode: multiply;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #05080f;
    --bg-panel: #080c17;
    --bg-card: #0c1120;
    --bg-card-h: #101828;
    --bg-card-done: #081410;

    --border: #152030;
    --border-bright: #213c5c;
    --border-done: #102818;

    --amber: #ddeeff;
    --amber-dim: #1a3050;
    --amber-glow: rgba(210, 230, 255, 0.12);
    --violet: #3a8fd4;
    --violet-dim: #18345a;
    --green: #44d68a;
    --green-dim: #0c2e1a;
    --red: #e05968;
    --gold: #c8a840;
    --text: #5e8aaa;
    --text-dim: #3a5878;
    --text-bright: #ddeeff;

    --font-ui: "Montserrat", system-ui, sans-serif;
    --font-mono: "Montserrat", system-ui, sans-serif;
    --topbar-h: 72px;
    --overlay-bg: rgba(11, 9, 18, 0.88);
}

html,
body {
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    
    background-image: radial-gradient(circle, rgba(33, 60, 92, 0.35) 1px, transparent 1px);
    background-size: 28px 28px;
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 16px;
}

::-webkit-scrollbar {
    width: 4px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border-bright);
    border-radius: 2px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--violet-dim);
}

:focus {
    outline: none;
}
:focus-visible {
    outline: 2px solid var(--amber);
    outline-offset: 2px;
}

button:focus-visible {
    outline: 2px solid var(--amber);
    outline-offset: 3px;
    box-shadow: 0 0 0 4px rgba(210, 230, 255, 0.12);
}

.hidden {
    display: none !important;
}

.color-amber  { color: var(--amber); }
.color-green  { color: var(--green); }
.color-gold   { color: var(--gold); }
.color-violet { color: var(--violet); }
.color-red    { color: var(--red); }
.color-dim    { color: var(--text-dim); }

#btn-cheats {
    display: none;
}

h2 {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: var(--amber);
    border-bottom: 1px solid var(--border);
    padding-bottom: 9px;
    margin-bottom: 14px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
h2 .h2-prefix {
    color: var(--amber-dim);
    margin-right: 4px;
}

.btn-projects-toggle {
    margin-left: auto;
    padding: 3px 10px;
    background: transparent;
    border: 1px solid var(--border-bright);
    color: var(--text-dim);
    font-family: var(--font-ui);
    font-size: 0.58rem;
    letter-spacing: 2px;
    cursor: pointer;
    text-transform: uppercase;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
    flex-shrink: 0;
}
.btn-projects-toggle:hover {
    border-color: var(--green);
    color: var(--green);
    background: rgba(68, 214, 138, 0.06);
}

#topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-h);
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 14px;
    gap: 14px;
    z-index: 100;
    overflow: hidden;
}

#title-block {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    gap: 5px;
}

#run-time-block {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    gap: 3px;
    padding-left: 16px;
    padding-right: 20px;
    border-left: 1px solid var(--border-bright);
    border-right: 1px solid var(--border-bright);
    opacity: 0.7;
}

#game-title {
    font-family: var(--font-ui);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--amber);
    letter-spacing: 5px;
    text-shadow: 0 0 24px var(--amber-glow);
}
#game-phase {
    font-family: var(--font-ui);
    font-size: 0.58rem;
    letter-spacing: 3px;
    color: var(--text-dim);
    text-transform: uppercase;
}

#resource-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
.res-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-shrink: 0;
    min-width: 72px;
}
.res-divider {
    width: 1px;
    height: 32px;
    background: var(--border-bright);
    flex-shrink: 0;
    opacity: 0.5;
}
.res-divider--dashed {
    background: repeating-linear-gradient(
        to bottom,
        var(--border-bright) 0px,
        var(--border-bright) 4px,
        transparent 4px,
        transparent 8px
    );
}

#ticker-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.ticker-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 58px;
    max-width: 58px;
}

.ticker-name {
    font-family: var(--font-ui);
    font-size: 0.58rem;
    letter-spacing: 2px;
    color: var(--text-dim);
    text-transform: uppercase;
}

.ticker-price {
    font-family: var(--font-ui);
    font-size: 0.72rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text-bright);
    transition: color 0.3s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ticker-price.up   { color: var(--green); }
.ticker-price.down { color: var(--red); }
.ticker-price.err  {
    color: var(--red);
    opacity: 0.55;
    font-size: 0.68rem;
    letter-spacing: 1px;
    animation: tickerErrFlicker 2.4s ease-in-out infinite;
}

@keyframes tickerErrFlicker {
    0%, 100% { opacity: 0.55; }
    48%       { opacity: 0.55; }
    50%       { opacity: 0.15; }
    52%       { opacity: 0.55; }
    80%       { opacity: 0.55; }
    82%       { opacity: 0.1; }
    84%       { opacity: 0.55; }
}

.res-label {
    font-family: var(--font-ui);
    font-size: 0.64rem;
    letter-spacing: 1px;
    color: var(--text-dim);
    text-transform: uppercase;
}
.res-value {
    font-family: var(--font-ui);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-bright);
    font-variant-numeric: tabular-nums;
    line-height: 1;
}
.res-rate {
    font-family: var(--font-ui);
    font-size: 0.72rem;
    color: var(--amber);
    opacity: 0.85;
}

#header-btns {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.btn-ui {
    padding: 7px 13px;
    background: transparent;
    border: 1px solid var(--border-bright);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 0.72rem;
    letter-spacing: 1.5px;
    cursor: pointer;
    text-transform: uppercase;
    transition:
        background 0.1s,
        border-color 0.1s,
        color 0.1s;
    white-space: nowrap;
}
.btn-ui:hover {
    background: var(--bg-card-h);
    border-color: var(--amber);
    color: var(--amber);
}
.btn-ui:active {
    opacity: 0.6;
}

.btn-ui.danger {
    border-color: var(--border);
    color: var(--red);
    opacity: 0.6;
}
.btn-ui.danger:hover {
    background: #180810;
    border-color: var(--red);
    color: var(--red);
    opacity: 1;
}

#btn-tutorial {
    border-color: var(--green-dim);
    color: var(--green);
}
#btn-tutorial:hover {
    background: var(--bg-card-done);
    border-color: var(--green);
    color: var(--green);
}

#main-content {
    display: flex;
    height: calc(100vh - var(--topbar-h));
    margin-top: var(--topbar-h);
    overflow: hidden;
}

#left-panel {
    width: 300px;
    flex-shrink: 0;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 18px;
    gap: 20px;
    overflow-y: auto;
}
#right-panel {
    width: 420px;
    flex-shrink: 0;
    background: var(--bg-panel);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 22px 22px 0 22px;
    overflow: hidden;
}

#right-panel-body {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}
#middle-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px 18px;
    overflow-y: auto;
    gap: 24px;
    min-width: 0;
}

#projects-section,
#missions-section {
    flex-shrink: 0;
}
#log-section {
    flex: 1;
    min-height: 160px;
    display: flex;
    flex-direction: column;
}

#process-wrap {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

#process-btn {
    width: 100%;
    padding: 22px 0 32px; /* extra bottom padding to make room for hint */
    background: transparent;
    border: 1px solid var(--amber-dim);
    border-top: 3px solid var(--amber);
    color: var(--amber);
    font-family: var(--font-ui);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 6px;
    cursor: pointer;
    text-transform: uppercase;
    position: relative;
    overflow: hidden;
    transition:
        background 0.12s,
        box-shadow 0.12s,
        border-color 0.12s,
        transform 0.08s;
}
#process-btn:hover {
    background: rgba(210, 230, 255, 0.05);
    box-shadow:
        0 0 28px var(--amber-glow),
        inset 0 0 20px rgba(210, 230, 255, 0.03);
    border-color: var(--amber);
}
#process-btn:active {
    background: rgba(210, 230, 255, 0.09);
    transform: scale(0.97);
    box-shadow:
        0 0 48px rgba(210, 230, 255, 0.2),
        inset 0 0 32px rgba(210, 230, 255, 0.06);
}

#process-btn::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 50%, rgba(210,230,255,0.18) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.25s ease-out;
    pointer-events: none;
}
#process-btn:active::after {
    opacity: 1;
    transition: none;
}
#process-btn::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
        180deg,
        rgba(210, 230, 255, 0.07) 0%,
        transparent 65%
    );
    pointer-events: none;
    animation: processPulse 3s ease-in-out infinite;
}
@keyframes processPulse {
    0%,
    100% {
        opacity: 0.4;
    }
    50% {
        opacity: 1;
    }
}

.float-text {
    position: fixed;
    pointer-events: none;
    font-family: var(--font-ui);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--amber);
    text-shadow: 0 0 10px rgba(210, 230, 255, 0.5), 0 0 24px rgba(210, 230, 255, 0.2);
    animation: floatUp 1.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    z-index: 10000;
    white-space: nowrap;
}
@keyframes floatUp {
    0%   { opacity: 1;    transform: translateY(0)    scale(1.1); }
    15%  { opacity: 1;    transform: translateY(-10px) scale(1); }
    70%  { opacity: 0.9;  transform: translateY(-36px) scale(0.95); }
    100% { opacity: 0;    transform: translateY(-62px) scale(0.88); }
}

#stat-block {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 7px;
}
.stat-k {
    font-size: 0.8rem;
    color: var(--text-dim);
}
.stat-v {
    font-family: var(--font-ui);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-bright);
    text-align: right;
    font-variant-numeric: tabular-nums;
    transition: color 0.3s ease;
}

#sell-block {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 2px;
}
.sell-label {
    font-family: var(--font-ui);
    font-size: 0.64rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-dim);
}
#sell-btns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
}

.btn-sell {
    padding: 7px 4px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 0.7rem;
    letter-spacing: 1px;
    cursor: pointer;
    text-align: center;
    transition:
        background 0.1s,
        border-color 0.1s,
        color 0.1s;
}
.btn-sell:hover {
    background: var(--bg-card-h);
    border-color: var(--gold);
    color: var(--gold);
}
.btn-sell:active {
    opacity: 0.6;
}
.btn-sell:disabled {
    opacity: 0.22;
    cursor: not-allowed;
}

.sell-hint {
    font-family: var(--font-ui);
    font-size: 0.82rem;
    color: var(--text-dim);
}

#projects-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.empty-hint,
.ach-list-empty {
    font-size: 0.84rem;
    color: var(--text-dim);
    font-style: italic;
    padding: 4px 0;
}

.projects-more-hint {
    font-family: var(--font-ui);
    font-size: 0.68rem;
    color: var(--text-dim);
    letter-spacing: 1px;
    padding: 6px 2px 2px;
    cursor: pointer;
    transition: color 0.12s;
}
.projects-more-hint:hover {
    color: var(--amber);
}

.res-value--mono {
    font-variant-numeric: tabular-nums;
    letter-spacing: 1px;
}

.project-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--border);
    cursor: pointer;
    transition:
        border-left-color 0.12s,
        background 0.12s,
        border-top-color 0.12s;
}
.project-card:hover {
    background: var(--bg-card-h);
    border-left-color: var(--amber);
    border-top-color: var(--border-bright);
}
.project-card.locked {
    opacity: 0.38;
    cursor: default;
}
.project-card.locked:hover {
    background: var(--bg-card);
    border-left-color: var(--border);
    border-top-color: var(--border);
}

.project-card.done {
    background: var(--bg-card-done);
    border-left-color: var(--green-dim);
    cursor: default;
    opacity: 0.65;
}
.project-card.done:hover {
    background: var(--bg-card-done);
    border-left-color: var(--green-dim);
    border-top-color: var(--border);
}

.project-icon {
    font-size: 1.15em;
    flex-shrink: 0;
}
.project-body {
    flex: 1;
    min-width: 0;
}
.project-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-bright);
}
.project-desc {
    font-size: 0.78rem;
    color: var(--text-dim);
    line-height: 1.45;
    margin-top: 2px;
}

.project-cost {
    font-family: var(--font-ui);
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
    padding: 3px 8px;
    border: 1px solid transparent;
    flex-shrink: 0;
}
.project-cost.can {
    color: var(--amber);
    border-color: var(--amber-dim);
    background: rgba(210, 230, 255, 0.05);
}
.project-cost.cannot {
    color: var(--text-dim);
}
.project-cost.done {
    color: var(--green-dim);
}

#log-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 0;
}
.log-entry {
    font-family: var(--font-ui);
    font-size: 0.73rem;
    color: var(--text-dim);
    line-height: 1.5;
    padding: 6px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 2px solid var(--border-bright);
    transition: color 1.8s, background 1.8s, border-color 1.8s;
}
.log-entry.new {
    color: var(--text-bright);
    background: rgba(33, 60, 92, 0.25);
    border-left-color: var(--violet);
}
.log-entry .log-time {
    color: var(--violet);
    opacity: 0.6;
    margin-right: 8px;
    font-size: 0.68rem;
}

#hardware-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hw-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--border);
    cursor: pointer;
    transition:
        border-left-color 0.1s,
        background 0.1s;
}
.hw-row:hover {
    background: var(--bg-card-h);
    border-left-color: var(--amber);
}
.hw-row.unaffordable {
    opacity: 0.38;
    cursor: not-allowed;
}
.hw-row.unaffordable:hover {
    background: var(--bg-card);
    border-left-color: var(--border);
}

.hw-icon {
    font-size: 2em;
    flex-shrink: 0;
}
.hw-info {
    flex: 1;
    min-width: 0;
}
.hw-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-bright);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.hw-desc {
    font-size: 0.86rem;
    color: var(--text-dim);
    margin-top: 3px;
    line-height: 1.4;
}
.hw-ops {
    font-family: var(--font-ui);
    font-size: 0.76rem;
    color: var(--green);
    margin-top: 4px;
}
.hw-locked-badge {
    font-family: var(--font-ui);
    font-size: 0.6rem;
    color: var(--text-dim);
    margin-top: 2px;
}

.hw-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    flex-shrink: 0;
    gap: 2px;
}
.hw-cost {
    font-family: var(--font-ui);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--gold);
    font-variant-numeric: tabular-nums;
}
.hw-owned {
    font-family: var(--font-ui);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-bright);
}

#achievements-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.ach-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--border);
    cursor: default;
    transition: border-left-color 0.15s;
}
.ach-card.unlocked {
    border-left-color: var(--green);
    background: var(--bg-card-done);
}
.ach-card.unlocked .ach-status {
    color: var(--green);
}
.ach-card.locked {
    opacity: 0.4;
}
.ach-card.new {
    box-shadow: 0 0 14px rgba(210, 230, 255, 0.18);
}

.ach-icon {
    font-size: 18px;
    flex-shrink: 0;
}
.ach-body {
    flex: 1;
}
.ach-name {
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--text-bright);
}
.ach-status {
    font-family: var(--font-ui);
    font-size: 0.73rem;
    color: var(--text-dim);
    margin-top: 2px;
}

/* ── TOAST NOTIFICATION SYSTEM ────────────────────────────────────────── */
#toast-container {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    z-index: 10000;
    pointer-events: none;
    width: max-content;
    max-width: min(420px, 90vw);
}

.navi-toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-panel);
    border: 1px solid var(--border-bright);
    border-left: 3px solid var(--amber);
    color: var(--text-bright);
    font-size: 0.78rem;
    line-height: 1.5;
    pointer-events: all;
    animation: toastIn 0.22s cubic-bezier(0.16,1,0.3,1) forwards;
    min-width: 220px;
}
.navi-toast.toast-out {
    animation: toastOut 0.22s ease-in forwards;
}

/* Type colors */
.navi-toast.toast-ach     { border-left-color: var(--amber); }
.navi-toast.toast-info    { border-left-color: #3a8fd4; }
.navi-toast.toast-success { border-left-color: var(--green); }
.navi-toast.toast-warn    { border-left-color: var(--red); }

.toast-icon {
    font-size: 1rem;
    flex-shrink: 0;
    margin-top: 1px;
}
.toast-content { flex: 1; min-width: 0; }
.toast-title {
    font-family: var(--font-ui);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 2px;
}
.toast-ach     .toast-title { color: var(--amber); }
.toast-info    .toast-title { color: #3a8fd4; }
.toast-success .toast-title { color: var(--green); }
.toast-warn    .toast-title { color: var(--red); }

.toast-body {
    font-size: 0.72rem;
    color: var(--text-dim);
    line-height: 1.4;
}
.toast-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 0.7rem;
    cursor: pointer;
    padding: 0 0 0 4px;
    flex-shrink: 0;
    line-height: 1;
    opacity: 0.5;
    transition: opacity 0.15s;
}
.toast-close:hover { opacity: 1; }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-20px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateX(0);    max-height: 80px; margin-bottom: 0; }
    to   { opacity: 0; transform: translateX(-12px); max-height: 0;   margin-bottom: -8px; }
}

.mission-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--border);
    padding: 10px 12px;
    margin-bottom: 7px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: border-left-color 0.15s;
}
.mission-card:last-child {
    margin-bottom: 0;
}

.mission-header {
    display: flex;
    align-items: center;
    gap: 8px;
}
.mission-icon {
    font-size: 1em;
    flex-shrink: 0;
}
.mission-title {
    flex: 1;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--text-bright);
}
.mission-desc {
    font-size: 0.8rem;
    color: var(--text-dim);
    line-height: 1.4;
}

.mission-reward {
    font-family: var(--font-ui);
    font-size: 0.68rem;
    color: var(--gold);
    background: rgba(240, 192, 64, 0.08);
    border: 1px solid rgba(240, 192, 64, 0.2);
    padding: 2px 7px;
    white-space: nowrap;
}
.mission-progress-wrap {
    background: var(--bg);
    height: 4px;
    overflow: hidden;
}
.mission-progress-bar {
    height: 100%;
    background: var(--amber);
    transition: width 0.4s ease;
}
.mission-progress-text {
    font-family: var(--font-ui);
    font-size: 0.74rem;
    color: var(--text-dim);
    text-align: right;
}

.tooltip {
    position: fixed;
    z-index: 10000;
    background: var(--bg-panel);
    border: 1px solid var(--border-bright);
    border-left: 3px solid var(--amber);
    padding: 8px 12px;
    pointer-events: none;
    max-width: 240px;
    line-height: 1.5;
    animation: tooltipIn 0.08s ease-out forwards;
}
@keyframes tooltipIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.tooltip-title {
    font-family: var(--font-ui);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--amber);
    margin-bottom: 4px;
}
.tooltip-line {
    font-size: 0.76rem;
    color: var(--text-dim);
    line-height: 1.5;
}

#tree-overlay,
#ach-overlay,
#cheat-overlay,
#projects-overlay,
#offline-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(3px);
    animation: fadeIn 0.2s ease;
}
#tree-overlay {
    background: rgba(11, 9, 18, 0.92);
    z-index: 7000;
}
#ach-overlay {
    background: var(--overlay-bg);
    z-index: 7000;
}
#cheat-overlay {
    background: var(--overlay-bg);
    z-index: 7000;
}
#projects-overlay {
    background: var(--overlay-bg);
    z-index: 7000;
}
#offline-modal {
    background: var(--overlay-bg);
    z-index: 8000;
    animation-duration: 0.3s;
}

#win-screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(11, 9, 18, 0.96);
    z-index: 9000;
    animation: fadeIn 1.2s ease;
}
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

#tree-panel,
#ach-panel,
#cheat-panel,
#projects-panel {
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    border: 1px solid var(--border-bright);
    max-height: 78vh;
}
#tree-panel {
    width: min(820px, 96vw);
    height: min(620px, 92vh);
    border-top: 3px solid var(--violet);
    max-height: none;
}
#ach-panel {
    width: 440px;
    border-top: 3px solid var(--amber);
}
#cheat-panel {
    width: 480px;
    border-top: 3px solid var(--red);
}
#projects-panel {
    width: min(600px, 96vw);
    border-top: 3px solid var(--green);
}

#tree-header,
#ach-header,
#cheat-header,
#projects-overlay-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

#tree-title,
#ach-title,
#cheat-title,
#projects-overlay-title {
    font-family: var(--font-ui);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 3px;
    flex: 1;
}
#tree-title    { color: var(--violet); }
#ach-title     { color: var(--amber); }
#cheat-title   { color: var(--red); }
#projects-overlay-title { color: var(--green); }

#tree-counter,
#ach-counter,
#projects-overlay-counter {
    font-family: var(--font-ui);
    font-size: 0.73rem;
    color: var(--text-dim);
}
#tree-ops-avail {
    font-family: var(--font-ui);
    font-size: 0.73rem;
    color: var(--gold);
}

#ach-scroll,
#cheat-scroll,
#projects-overlay-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 14px 18px;
}
#cheat-scroll {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
#projects-overlay-scroll {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.proj-ov-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--border);
    cursor: pointer;
    transition: border-left-color 0.12s, background 0.12s;
    animation: cardEnter 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.proj-ov-card:hover {
    background: var(--bg-card-h);
    border-left-color: var(--green);
}
.proj-ov-card.done {
    background: var(--bg-card-done);
    border-left-color: var(--green-dim);
    cursor: default;
    opacity: 0.65;
}
.proj-ov-card.done:hover {
    background: var(--bg-card-done);
    border-left-color: var(--green-dim);
}

.proj-ov-card.future {
    opacity: 0.38;
    cursor: not-allowed;
}
.proj-ov-card.future:hover {
    background: var(--bg-card);
    border-left-color: var(--border);
}
.proj-ov-icon { font-size: 1.1em; flex-shrink: 0; }
.proj-ov-body { flex: 1; min-width: 0; }
.proj-ov-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-bright);
}
.proj-ov-desc {
    font-size: 0.76rem;
    color: var(--text-dim);
    line-height: 1.4;
    margin-top: 2px;
}

.proj-ov-cond {
    font-family: var(--font-ui);
    font-size: 0.6rem;
    color: var(--text-dim);
    margin-top: 2px;
}
.proj-ov-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    flex-shrink: 0;
    gap: 2px;
}
.proj-ov-cost {
    font-family: var(--font-ui);
    font-size: 0.95rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.proj-ov-cost.can      { color: var(--amber); }
.proj-ov-cost.cannot   { color: var(--text-dim); }
.proj-ov-cost.done     { color: var(--green-dim); font-size: 0.76rem; }

.proj-ov-cost.future   { color: var(--text-dim); font-size: 1.1rem; line-height: 1; }
.proj-ov-owned {
    font-family: var(--font-ui);
    font-size: 0.7rem;
    color: var(--text-dim);
    white-space: nowrap;
}

.cheat-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.cheat-section-title {
    font-family: var(--font-ui);
    font-size: 0.62rem;
    letter-spacing: 3px;
    color: var(--text-dim);
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
    padding-bottom: 5px;
    margin: 14px 0 8px;
}
.cheat-section-title:first-child { margin-top: 0; }

.cheat-subtitle {
    font-size: 0.58rem;
    color: var(--green);
    letter-spacing: 2px;
    opacity: 0.7;
    margin-left: 6px;
}

.cheat-speed-btn.active {
    border-color: var(--green);
    color: var(--green);
    background: rgba(68, 214, 138, 0.08);
}

@keyframes cheatUnlock {
    0%   { transform: scale(1.4); opacity: 0; }
    60%  { transform: scale(0.95); }
    100% { transform: scale(1); opacity: 1; }
}

#secret-zone {
    position: fixed;
    top: 0;
    right: 0;
    width: 12px;
    height: 12px;
    z-index: 99998;
    cursor: default;
    background: transparent;
}

#win-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    max-width: 560px;
    width: min(560px, 96vw);
    padding: 44px 40px;
    background: var(--bg-panel);
    border: 1px solid var(--border-bright);
    border-top: 3px solid var(--amber);
    text-align: center;
}
#win-logo {
    width: 110px;
    height: 110px;
    object-fit: contain;
    filter: drop-shadow(0 0 18px rgba(58, 143, 212, 0.6)) drop-shadow(0 0 36px rgba(58, 143, 212, 0.2));
    animation: logoPulse 3s ease-in-out infinite;
}
@keyframes logoPulse {
    0%, 100% { filter: drop-shadow(0 0 18px rgba(58,143,212,0.6)) drop-shadow(0 0 36px rgba(58,143,212,0.2)); }
    50%       { filter: drop-shadow(0 0 28px rgba(58,143,212,0.9)) drop-shadow(0 0 56px rgba(58,143,212,0.35)); }
}

#win-title {
    font-family: var(--font-ui);
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 6px;
    color: var(--amber);
    text-shadow: 0 0 36px var(--amber-glow);
    line-height: 1.3;
}
#win-flavor {
    font-size: 0.9rem;
    color: var(--text-dim);
    font-style: italic;
    line-height: 1.8;
    max-width: 360px;
}
#win-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px 24px;
    width: 100%;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 20px 0;
}

.win-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.win-stat-label {
    font-family: var(--font-ui);
    font-size: 0.64rem;
    letter-spacing: 2px;
    color: var(--text-dim);
    text-transform: uppercase;
}
.win-stat-value {
    font-family: var(--font-ui);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-bright);
    font-variant-numeric: tabular-nums;
}

#tree-scroll {
    flex: 1;
    overflow: auto;
    background: #040810;
    position: relative;
}
#tree-canvas {
    position: relative;
}
#tree-svg {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 0;
}
#tree-nodes {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.talent-node {
    position: absolute;
    z-index: 1;
    isolation: isolate;
    width: 76px;
    height: 76px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    cursor: pointer;
    transition:
        border-color 0.15s,
        box-shadow 0.15s,
        background 0.15s;
    user-select: none;
}
.talent-node .t-icon {
    font-size: 24px;
    line-height: 1;
}
.talent-node .t-name {
    font-size: 0.54rem;
    text-align: center;
    color: var(--text-dim);
    padding: 0 3px;
    line-height: 1.2;
    font-family: var(--font-ui);
}
.talent-node .t-cost {
    font-family: var(--font-ui);
    font-size: 0.58rem;
    color: var(--text-dim);
}

.talent-node.t-locked {
    opacity: 0.15;
    cursor: not-allowed;
    pointer-events: none;
}
.talent-node.t-available {
    opacity: 0.45;
    border-color: var(--border-bright);
    cursor: not-allowed;
}
.talent-node.t-affordable {
    opacity: 1;
    border-color: var(--violet);
    box-shadow: 0 0 12px rgba(58, 143, 212, 0.28);
}
.talent-node.t-affordable:hover {
    background: var(--bg-card-h);
    box-shadow: 0 0 20px rgba(58, 143, 212, 0.45);
    transform: scale(1.07);
}
.talent-node.t-bought {
    opacity: 1;
    background: var(--bg-card-done);
    border-color: var(--green-dim);
    cursor: default;
}
.talent-node.t-bought .t-icon {
    filter: drop-shadow(0 0 4px var(--green));
}
.talent-node.t-bought .t-cost {
    color: var(--green-dim);
}
.talent-node.t-selected {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

#tree-info {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 18px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    min-height: 80px;
}
#tree-info-left {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    flex: 1;
}
#tree-info-icon {
    font-size: 28px;
    flex-shrink: 0;
    line-height: 1;
    margin-top: 2px;
}
#tree-info-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
#tree-info-name {
    font-size: 0.96rem;
    font-weight: 600;
    color: var(--text-bright);
}
#tree-info-desc {
    font-size: 0.8rem;
    color: var(--text-dim);
    line-height: 1.4;
}
#tree-info-effect {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--violet);
}
#tree-info-req {
    font-size: 0.74rem;
    color: var(--gold);
}

#btn-buy-talent {
    flex-shrink: 0;
    padding: 10px 20px;
    font-size: 0.65rem;
    letter-spacing: 2px;
    border-color: var(--violet-dim);
    color: var(--violet);
}
#btn-buy-talent:hover {
    border-color: var(--violet);
    color: var(--violet);
    background: rgba(58, 143, 212, 0.1);
}
#btn-buy-talent:disabled {
    opacity: 0.28;
    cursor: not-allowed;
}

#offline-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    max-width: 360px;
    width: 90%;
    padding: 38px 34px;
    background: var(--bg-panel);
    border: 1px solid var(--border-bright);
    border-top: 3px solid var(--amber);
    text-align: center;
}
#offline-icon {
    font-size: 2rem;
}
#offline-title {
    font-family: var(--font-ui);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 4px;
    color: var(--amber);
    text-transform: uppercase;
}
#offline-time-msg {
    font-family: var(--font-ui);
    font-size: 0.86rem;
    color: var(--text-dim);
}
#offline-gains-msg {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-bright);
}

#tutorial-overlay {
    position: fixed;
    inset: 0;
    z-index: 9500;
    
}

#tutorial-spotlight {
    position: fixed;
    border-radius: 2px;
    box-shadow:
        0 0 0 9999px rgba(5, 8, 15, 0.82),
        0 0 0 2px var(--amber),
        0 0 20px rgba(210, 230, 255, 0.15);
    transition:
        top 0.28s cubic-bezier(0.22, 1, 0.36, 1),
        left 0.28s cubic-bezier(0.22, 1, 0.36, 1),
        width 0.28s cubic-bezier(0.22, 1, 0.36, 1),
        height 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    pointer-events: none;
    z-index: 9501;
}
#tutorial-box {
    position: fixed;
    width: 300px;
    background: var(--bg-panel);
    border: 1px solid var(--border-bright);
    border-top: 3px solid var(--amber);
    padding: 20px 22px;
    z-index: 9502;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition:
        top 0.32s ease,
        left 0.32s ease;
}
#tut-step-count {
    font-family: var(--font-ui);
    font-size: 0.66rem;
    letter-spacing: 3px;
    color: var(--amber-dim);
    text-transform: uppercase;
}
#tut-title {
    font-family: var(--font-ui);
    font-size: 0.93rem;
    font-weight: 700;
    color: var(--amber);
    letter-spacing: 1px;
    line-height: 1.4;
}
#tut-text {
    font-size: 0.86rem;
    color: var(--text);
    line-height: 1.7;
}
#tut-btns {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 4px;
}

#tab-miner {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    min-height: 0;
}

#miner-assets-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
}

.miner-asset-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--border);
    cursor: pointer;
    transition: border-left-color 0.12s, background 0.12s;
}
.miner-asset-row:hover {
    background: var(--bg-card-h);
    border-left-color: var(--gold);
}
.miner-asset-row.active {
    background: var(--bg-card-h);
    border-left-color: var(--gold);
    border-color: var(--border-bright);
}

.miner-row-icon   { font-size: 1.2em; flex-shrink: 0; }
.miner-row-info   { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.miner-row-name   { font-size: 0.85rem; font-weight: 600; color: var(--text-bright); }
.miner-row-ticker {
    font-family: var(--font-ui);
    font-size: 0.68rem;
    letter-spacing: 1px;
    color: var(--text-dim);
}
.miner-row-right  {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}
.miner-row-price  {
    font-family: var(--font-ui);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--gold);
    font-variant-numeric: tabular-nums;
}
.miner-row-pct    {
    font-family: var(--font-ui);
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
}
.miner-row-badge {
    font-family: var(--font-ui);
    font-size: 0.58rem;
    letter-spacing: 1px;
    color: var(--violet);
    border: 1px solid var(--violet-dim);
    padding: 1px 4px;
    margin-top: 1px;
}

#miner-chart-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 10px 12px 12px;
}

#miner-price-header {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}
.miner-ph-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-bright);
    flex: 1;
}
.miner-ph-price {
    font-family: var(--font-ui);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--gold);
    font-variant-numeric: tabular-nums;
}
.miner-ph-pct {
    font-family: var(--font-ui);
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}

#miner-chart {
    display: block;
    width: 100%;
    height: 140px;
    background: #040810;
}

#miner-position-info {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    padding: 6px 0 2px;
    border-top: 1px solid var(--border);
}
.miner-pos-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.miner-pos-label {
    font-family: var(--font-ui);
    font-size: 0.6rem;
    letter-spacing: 2px;
    color: var(--text-dim);
    text-transform: uppercase;
}
.miner-pos-val {
    font-family: var(--font-ui);
    font-size: 0.86rem;
    font-weight: 700;
    color: var(--text-bright);
    font-variant-numeric: tabular-nums;
}
.miner-pos-none {
    font-size: 0.78rem;
    color: var(--text-dim);
    font-style: italic;
    padding: 4px 0;
}

.miner-trade-area {
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding-top: 6px;
    border-top: 1px solid var(--border);
}
.miner-input-label {
    font-family: var(--font-ui);
    font-size: 0.6rem;
    letter-spacing: 2px;
    color: var(--text-dim);
    text-transform: uppercase;
}
.miner-input-row {
    display: flex;
    gap: 5px;
    align-items: stretch;
}
#miner-amount-input {
    flex: 1;
    min-width: 0;
    padding: 6px 9px;
    background: var(--bg);
    border: 1px solid var(--border-bright);
    color: var(--text-bright);
    font-family: var(--font-ui);
    font-size: 0.88rem;
    font-variant-numeric: tabular-nums;
    outline: none;
    transition: border-color 0.1s;
}
#miner-amount-input:focus {
    border-color: var(--gold);
}
#miner-amount-input::placeholder {
    color: var(--text-dim);
    opacity: 0.5;
}

#miner-amount-input::-webkit-outer-spin-button,
#miner-amount-input::-webkit-inner-spin-button { -webkit-appearance: none; }
#miner-amount-input[type=number] { -moz-appearance: textfield; }

.miner-btn-action {
    padding: 6px 11px;
    font-size: 0.66rem;
    letter-spacing: 2px;
}
#btn-miner-buy {
    border-color: var(--green-dim);
    color: var(--green);
}
#btn-miner-buy:hover {
    background: rgba(68, 214, 138, 0.08);
    border-color: var(--green);
    color: var(--green);
}
#btn-miner-sell {
    border-color: var(--border);
    color: var(--red);
    opacity: 0.5;
}
#btn-miner-sell:not(:disabled) {
    opacity: 1;
    border-color: rgba(224, 89, 104, 0.4);
}
#btn-miner-sell:not(:disabled):hover {
    background: rgba(224, 89, 104, 0.08);
    border-color: var(--red);
    color: var(--red);
}
#btn-miner-sell:disabled { cursor: not-allowed; }

.miner-quick-btns {
    display: flex;
    gap: 4px;
}
.miner-quick-btn {
    flex: 1;
    padding: 5px 2px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-family: var(--font-ui);
    font-size: 0.66rem;
    letter-spacing: 1px;
    cursor: pointer;
    text-transform: uppercase;
    transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.miner-quick-btn:hover {
    background: var(--bg-card-h);
    border-color: var(--gold);
    color: var(--gold);
}
.miner-sell-all-btn {
    flex: 1.4;
    color: var(--red);
    border-color: var(--border);
    opacity: 0.7;
}
.miner-sell-all-btn:hover {
    background: rgba(224, 89, 104, 0.06);
    border-color: var(--red);
    color: var(--red);
    opacity: 1;
}

.miner-avail-label {
    font-family: var(--font-ui);
    font-size: 0.72rem;
    color: var(--text-dim);
    text-align: right;
}
.miner-avail-label #miner-avail {
    color: var(--gold);
}

#right-tabs .tab-btn.miner-tab-locked {
    opacity: 0.38;
    border-style: dashed;
}
#right-tabs .tab-btn.miner-tab-locked:hover {
    color: var(--text-dim);
    border-color: var(--border);
    background: transparent;
    cursor: not-allowed;
}

.miner-locked-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 36px 20px;
    border: 1px dashed var(--border-bright);
    text-align: center;
    margin-top: 8px;
}
.miner-locked-icon { font-size: 2rem; opacity: 0.5; }
.miner-locked-title {
    font-family: var(--font-ui);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--text-dim);
    text-transform: uppercase;
}
.miner-locked-sub {
    font-size: 0.82rem;
    color: var(--text-dim);
    line-height: 1.6;
}
.miner-locked-sub strong { color: var(--amber); }

.miner-asset-row.locked {
    opacity: 0.30;
    cursor: default;
}
.miner-asset-row.locked:hover { background: var(--bg-card); border-left-color: var(--border); }
.miner-row-lock {
    font-family: var(--font-ui);
    font-size: 0.68rem;
    color: var(--text-dim);
}

.miner-token-desc {
    font-size: 0.78rem;
    color: var(--text-dim);
    line-height: 1.5;
    padding: 4px 0 2px;
    font-style: italic;
}

#miner-upgrades-section {
    margin-top: 6px;
    flex-shrink: 0;
}
#miner-upgrades-section h2 {
    margin-top: 6px;
}

.miner-upgrade-stats {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    font-family: var(--font-ui);
    font-size: 0.72rem;
    color: var(--text-dim);
    padding: 7px 0 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
}
.miner-upgrade-stats strong { font-weight: 700; }

#miner-upgrades-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.miner-upg-card {
    display: flex;
    flex-direction: column;
    padding: 9px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--border);
    transition: border-left-color 0.12s, background 0.12s;
}
.miner-upg-card.upg-affordable {
    border-left-color: var(--gold);
    cursor: pointer;
}
.miner-upg-card.upg-affordable:hover {
    background: var(--bg-card-h);
    border-left-color: var(--gold);
    border-color: var(--border-bright);
}
.miner-upg-card.upg-bought {
    background: var(--bg-card-done);
    border-left-color: var(--green-dim);
    opacity: 0.7;
}
.miner-upg-card.upg-locked,
.miner-upg-card.upg-need_credits {
    opacity: 0.42;
}

.miner-upg-top {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.miner-upg-icon { font-size: 1.3em; flex-shrink: 0; margin-top: 1px; }
.miner-upg-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}
.miner-upg-name {
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--text-bright);
}
.miner-upg-desc {
    font-size: 0.76rem;
    color: var(--text-dim);
    line-height: 1.4;
}
.miner-upg-req {
    font-family: var(--font-ui);
    font-size: 0.66rem;
    color: var(--gold);
    margin-top: 2px;
}
.miner-upg-right {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}
.miner-upg-cost {
    font-family: var(--font-ui);
    font-size: 0.82rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.miner-upg-cost.can  { color: var(--gold); }
.miner-upg-cost.cant { color: var(--text-dim); }
.miner-upg-done {
    font-family: var(--font-ui);
    font-size: 0.72rem;
    letter-spacing: 1px;
    color: var(--green);
}

@keyframes cardEnter {
    from { transform: translateY(12px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}
@keyframes cardEnterFaded {
    from { transform: translateY(12px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 0.38; }
}

.hw-row, .wk-row, .project-card, .mission-card, .miner-asset-row, .miner-upg-card {
    animation: cardEnter 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.hw-row.unaffordable,
.wk-row.unaffordable,
.miner-upg-card.upg-locked,
.miner-upg-card.upg-need_credits {
    animation: cardEnterFaded 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.hw-row:nth-child(1),  .wk-row:nth-child(1)  { animation-delay: 0.00s; }
.hw-row:nth-child(2),  .wk-row:nth-child(2)  { animation-delay: 0.04s; }
.hw-row:nth-child(3),  .wk-row:nth-child(3)  { animation-delay: 0.08s; }
.hw-row:nth-child(4),  .wk-row:nth-child(4)  { animation-delay: 0.12s; }
.hw-row:nth-child(5),  .wk-row:nth-child(5)  { animation-delay: 0.16s; }
.hw-row:nth-child(6),  .wk-row:nth-child(6)  { animation-delay: 0.19s; }
.hw-row:nth-child(7),  .wk-row:nth-child(7)  { animation-delay: 0.22s; }
.hw-row:nth-child(n+8),.wk-row:nth-child(n+8){ animation-delay: 0.25s; }

.project-card:nth-child(1)  { animation-delay: 0.00s; }
.project-card:nth-child(2)  { animation-delay: 0.04s; }
.project-card:nth-child(3)  { animation-delay: 0.08s; }
.project-card:nth-child(4)  { animation-delay: 0.12s; }
.project-card:nth-child(5)  { animation-delay: 0.15s; }
.project-card:nth-child(n+6){ animation-delay: 0.18s; }

@keyframes affordPulse {
    0%, 100% { box-shadow: none; }
    50%       { box-shadow: inset 0 0 0 1px rgba(68,214,138,0.25), 0 0 12px rgba(68,214,138,0.08); }
}
.hw-row.just-affordable { animation: affordPulse 2s ease-in-out infinite; }
.wk-row.just-affordable { animation: affordPulse 2s ease-in-out infinite; }

@keyframes projPulse {
    0%, 100% { border-left-color: var(--border); }
    50%       { border-left-color: var(--amber); box-shadow: -2px 0 10px rgba(210,230,255,0.12); }
}
.project-card.affordable { animation: projPulse 2.2s ease-in-out infinite; }

.btn-ui::after, .btn-sell::after, .miner-quick-btn::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.07);
    opacity: 0;
    transition: opacity 0.12s;
    pointer-events: none;
}
.btn-ui:active::after, .btn-sell:active::after, .miner-quick-btn:active::after {
    opacity: 1;
}
.btn-ui, .btn-sell, .miner-quick-btn {
    position: relative;
    overflow: hidden;
}

#phase-banner {
    position: fixed;
    top: var(--topbar-h);
    left: 50%;
    
    transform: translateX(-50%) translateY(calc(-100% - 80px));
    z-index: 6000;
    background: var(--bg-panel);
    border: 1px solid var(--violet);
    border-top: none;
    padding: 8px 32px;
    font-family: var(--font-ui);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 4px;
    color: var(--violet);
    text-transform: uppercase;
    pointer-events: none;
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
#phase-banner.show {
    transform: translateX(-50%) translateY(0%);
}

@keyframes valueFlash {
    0%   { color: var(--green); text-shadow: 0 0 14px rgba(68,214,138,0.55); }
    100% { color: var(--text-bright); text-shadow: none; }
}
.res-value.flash { animation: valueFlash 0.7s ease-out forwards; }

#btn-ach {
    position: relative;
    overflow: visible !important; 
}
.ach-badge {
    position: absolute;
    top: -7px;
    right: -7px;
    min-width: 17px;
    height: 17px;
    border-radius: 9px;
    background: var(--red);
    color: #fff;
    font-family: var(--font-ui);
    font-size: 0.58rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    pointer-events: none;
    animation: badgePop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes badgePop {
    from { transform: scale(0); }
    to   { transform: scale(1); }
}

@keyframes logSlide {
    from { opacity: 0; transform: translateX(-8px); }
    to   { opacity: 1; transform: translateX(0); }
}
.log-entry.new { animation: logSlide 0.22s ease-out both; }

@keyframes missionComplete {
    0%   { background: rgba(68,214,138,0.18); border-left-color: var(--green); }
    100% { background: var(--bg-card); }
}
.mission-card.completing { animation: missionComplete 0.9s ease-out forwards; }

#kbd-overlay {
    position: fixed;
    inset: 0;
    z-index: 8500;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--overlay-bg);
    backdrop-filter: blur(3px);
    animation: fadeIn 0.15s ease;
}
#kbd-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-bright);
    border-top: 3px solid var(--violet);
    padding: 28px 32px;
    min-width: 340px;
}
#kbd-panel h3 {
    font-family: var(--font-ui);
    font-size: 0.72rem;
    letter-spacing: 4px;
    color: var(--violet);
    margin-bottom: 18px;
    text-transform: uppercase;
}
.kbd-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    padding: 7px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.82rem;
    color: var(--text);
}
.kbd-row:last-child { border-bottom: none; }
.kbd-key {
    font-family: var(--font-ui);
    font-size: 0.72rem;
    color: var(--amber);
    background: var(--bg-card);
    border: 1px solid var(--border-bright);
    padding: 3px 10px;
    white-space: nowrap;
    flex-shrink: 0;
}
.kbd-hint-inline {
    font-family: var(--font-ui);
    font-size: 0.58rem;
    color: var(--text-dim);
    border: 1px solid var(--border);
    padding: 1px 5px;
    margin-left: 5px;
    vertical-align: middle;
    opacity: 0.7;
}

@media (max-width: 860px) {
    html,
    body {
        font-size: 13px;
        overflow: auto;
    }
    #main-content {
        flex-direction: column;
        height: auto;
        overflow: visible;
    }

    #left-panel,
    #right-panel {
        width: 100%;
        border-right: none;
        border-left: none;
        border-bottom: 1px solid var(--border);
    }

    #left-panel {
        padding: 14px 12px;
    }
    #right-panel {
        padding: 14px 12px 0 12px;
        min-height: 400px;
    }
    #right-panel-body {
        min-height: 300px;
    }
    #middle-panel {
        padding: 14px 12px;
    }
}

.tab-pane-hint {
    margin-bottom: 10px;
}
#right-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
}
.tab-btn {
    flex: 1;
    padding: 8px 4px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-family: var(--font-ui);
    font-size: 0.68rem;
    letter-spacing: 1px;
    cursor: pointer;
    text-transform: uppercase;
    transition: background .15s, border-color .15s, color .15s;
}
.tab-btn:hover { border-color: var(--border-bright); color: var(--text); }
.tab-btn.active { background: var(--bg-card); border-color: var(--amber); color: var(--amber); }

.tab-pane {
    display: flex !important;
    flex-direction: column;
    overflow-y: auto;
    
    position: absolute;
    inset: 0;
    
    opacity: 0;
    pointer-events: none;
    transform: translateY(14px);
    transition:
        opacity 0.32s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.tab-pane.tab-active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.buy-mult-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 10px;
    flex-shrink: 0;
}
.buy-mult-label {
    font-family: var(--font-ui);
    font-size: 0.6rem;
    letter-spacing: 2px;
    color: var(--text-dim);
    text-transform: uppercase;
    margin-right: 4px;
    flex-shrink: 0;
}
.buy-mult-btn {
    flex: 1;
    padding: 5px 4px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-family: var(--font-ui);
    font-size: 0.68rem;
    letter-spacing: 1px;
    cursor: pointer;
    text-transform: uppercase;
    transition: background 0.1s, border-color 0.1s, color 0.1s;
    position: relative;
    overflow: hidden;
}
.buy-mult-btn:hover {
    border-color: var(--border-bright);
    color: var(--text-bright);
    background: var(--bg-card-h);
}
.buy-mult-btn.active {
    background: var(--bg-card);
    border-color: var(--amber);
    color: var(--amber);
}

.buy-mult-btn[data-mult="max"].active {
    border-color: var(--green);
    color: var(--green);
}
.buy-mult-btn[data-mult="max"]:hover {
    border-color: var(--green);
    color: var(--green);
}

.wk-row { display:flex; align-items:center; gap:16px; padding:16px 18px; background:var(--bg-card); border:1px solid var(--border); border-left:3px solid var(--border); cursor:pointer; margin-bottom:8px; transition:border-left-color .1s,background .1s; }
.wk-row:last-child { margin-bottom:0; }
.wk-row:hover { background:var(--bg-card-h); border-left-color:var(--green); }
.wk-row.unaffordable { opacity:0.38; cursor:not-allowed; }
.wk-row.unaffordable:hover { background:var(--bg-card); border-left-color:var(--border); }
.wk-cost { font-family:var(--font-ui); font-size:0.95rem; font-weight:700; color:var(--amber); font-variant-numeric:tabular-nums; }
.wk-rate { font-family:var(--font-ui); font-size:0.76rem; color:var(--green); margin-top:4px; }

#tree-mode-tabs { display:flex; gap:4px; }
#tree-mode-tabs .tab-btn { padding:5px 14px; font-size:0.66rem; }
#tree-mode-tabs .tab-btn.active { border-color:var(--violet); color:var(--violet); background:var(--bg-card); }
#tree-mode-tabs .tab-btn:not(.active) { border-color:var(--border); color:var(--text-dim); }
#hw-tree-pane, #wk-tree-pane { position:relative; animation:tabSlideIn .28s cubic-bezier(0.22, 1, 0.36, 1) both; }
#wtree-canvas { position:relative; }
#wtree-svg { position:absolute; top:0; left:0; pointer-events:none; z-index:0; }
#wtree-nodes { position:absolute; top:0; left:0; width:100%; height:100%; z-index:1; }
.tree-pane-counter { font-family:var(--font-ui); font-size:0.7rem; color:var(--text-dim); padding:6px 14px; border-top:1px solid var(--border); flex-shrink:0; }

#corruption-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    pointer-events: all;
    background: transparent;
}
#corruption-overlay canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* ── SETTINGS OVERLAY ───────────────────────────────────────────────────── */
#settings-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--overlay-bg);
    backdrop-filter: blur(3px);
    animation: fadeIn 0.2s ease;
    z-index: 7000;
}
#settings-panel {
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    border: 1px solid var(--border-bright);
    border-top: 3px solid var(--violet);
    max-height: 82vh;
    width: min(500px, 96vw);
}
#settings-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
#settings-title {
    font-family: var(--font-ui);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--violet);
    flex: 1;
}
#settings-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0 18px;
}
.settings-section {
    padding: 0 18px;
    margin-bottom: 6px;
}
.settings-section-title {
    font-family: var(--font-ui);
    font-size: 0.62rem;
    letter-spacing: 3px;
    color: var(--text-dim);
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
    padding: 12px 0 6px;
    margin-bottom: 4px;
}
.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    transition: opacity 0.2s;
}
.settings-row:last-child { border-bottom: none; }
.settings-row-info { flex: 1; min-width: 0; }
.settings-row-label {
    font-family: var(--font-ui);
    font-size: 0.8rem;
    color: var(--text-bright);
    display: block;
}
.settings-row-desc {
    font-size: 0.72rem;
    color: var(--text-dim);
    display: block;
    margin-top: 2px;
}
.settings-btn-group {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}
.settings-opt-btn.active {
    border-color: var(--violet);
    color: var(--violet);
    background: rgba(58,143,212,0.1);
}

/* Toggle switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
    cursor: pointer;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-track {
    position: absolute;
    inset: 0;
    background: var(--border-bright);
    border-radius: 11px;
    transition: background 0.2s;
}
.toggle-track::before {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    top: 3px;
    background: var(--text-dim);
    border-radius: 50%;
    transition: transform 0.2s, background 0.2s;
}
.toggle-switch input:checked + .toggle-track {
    background: var(--violet-dim);
}
.toggle-switch input:checked + .toggle-track::before {
    transform: translateX(18px);
    background: var(--violet);
}

/* Settings-driven CSS class overrides */
.no-scanlines body::before { display: none !important; }
html.no-scanlines body::before { display: none !important; }

html.no-dotgrid body,
html.no-dotgrid html {
    background-image: none !important;
}

html.no-animations *,
html.no-animations *::before,
html.no-animations *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
}

/* ── CREDITS ────────────────────────────────────────────────────────────── */
.credit-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 7px 0;
    border-bottom: 1px solid var(--border);
}
.credit-row:last-child { border-bottom: none; }
.credit-role {
    font-family: var(--font-ui);
    font-size: 0.68rem;
    color: var(--text-dim);
    letter-spacing: 1px;
    flex-shrink: 0;
}
.credit-name {
    font-size: 0.78rem;
    color: var(--text-bright);
    text-align: right;
}

/* ── ELECTRICITY BLOCK ──────────────────────────────────────────────────── */
#elec-block {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-top: 1px solid var(--border);
    padding-top: 16px;
}

.elec-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.elec-title {
    font-family: var(--font-ui);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--amber);
}

.elec-price-tag {
    font-family: var(--font-ui);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-bright);
    font-variant-numeric: tabular-nums;
    transition: color 0.3s;
}
.elec-price-tag.up   { color: var(--green); }
.elec-price-tag.down { color: var(--red); }

#elec-chart {
    width: 100%;
    height: 130px;
    display: block;
    border: 1px solid var(--border);
}

.elec-stats-row {
    display: flex;
    gap: 12px;
}
.elec-stat { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.elec-stat-k {
    font-family: var(--font-ui);
    font-size: 0.6rem;
    letter-spacing: 1px;
    color: var(--text-dim);
    text-transform: uppercase;
}
.elec-stat-v {
    font-family: var(--font-ui);
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-bright);
    font-variant-numeric: tabular-nums;
}

.elec-buy-row {
    display: flex;
    gap: 4px;
}
.elec-buy-btn {
    flex: 1;
    font-size: 0.64rem !important;
    padding: 5px 2px !important;
    letter-spacing: 0.5px;
    text-align: center;
}

/* Cost hint: one per line */
.elec-cost-hint-multi {
    white-space: pre;
    font-family: var(--font-ui);
    font-size: 0.68rem;
    line-height: 1.7;
    color: var(--text-dim);
    margin: 0;
}

/* Power grid section */
.elec-power-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 6px;
    border-top: 1px solid var(--border);
    padding-top: 10px;
}
.elec-power-title {
    font-family: var(--font-ui);
    font-size: 0.6rem;
    letter-spacing: 2px;
    color: var(--amber);
    text-transform: uppercase;
}
.elec-power-legend {
    display: flex;
    gap: 8px;
}
.elec-leg {
    font-family: var(--font-ui);
    font-size: 0.6rem;
}
.elec-leg-stored { color: #3a8fd4; }
.elec-leg-cons   { color: #e09a30; }

#elec-power-chart {
    width: 100%;
    height: 160px;
    display: block;
    border: 1px solid var(--border);
}

.elec-power-stats {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 2px 0;
    font-family: var(--font-ui);
    font-size: 0.60rem;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}
.elec-power-stats strong {
    color: var(--text-bright);
    font-weight: 700;
    transition: color 0.4s;
}

.elec-btn-disabled {
    opacity: 0.35 !important;
    cursor: not-allowed !important;
}

/* ── TOPBAR ELECTRICITY INDICATOR ─────────────────────────────────────── */
#topbar-elec {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-shrink: 0;
}
.topbar-elec-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-ui);
    font-size: 0.68rem;
    font-variant-numeric: tabular-nums;
}
.topbar-elec-label {
    font-size: 0.58rem;
    letter-spacing: 1.5px;
    color: var(--text-dim);
    text-transform: uppercase;
}
#topbar-elec-stored {
    font-weight: 700;
    color: #3a8fd4;
}
#topbar-elec-cons {
    font-weight: 700;
    color: #e09a30;
}

/* ── ELEC CUSTOM AMOUNT INPUT ─────────────────────────────────────────── */
.elec-custom-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-top: 1px solid var(--border);
    padding-top: 10px;
    margin-top: 2px;
}
.elec-mode-row {
    display: flex;
    gap: 4px;
}
.elec-mode-btn {
    flex: 1;
    padding: 5px 4px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-family: var(--font-ui);
    font-size: 0.62rem;
    letter-spacing: 1px;
    cursor: pointer;
    text-transform: uppercase;
    transition: background 0.1s, border-color 0.1s, color 0.1s;
    text-align: center;
}
.elec-mode-btn.active {
    border-color: var(--amber);
    color: var(--amber);
    background: rgba(255,176,0,0.06);
}
/* ── TOPBAR ELECTRICITY INDICATOR ─────────────────────────────────────── */
#topbar-elec {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-shrink: 0;
}
.topbar-elec-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-ui);
    font-size: 0.68rem;
    font-variant-numeric: tabular-nums;
}
.topbar-elec-label {
    font-size: 0.58rem;
    letter-spacing: 1.5px;
    color: var(--text-dim);
    text-transform: uppercase;
}
#topbar-elec-stored {
    font-weight: 700;
    color: #3a8fd4;
}
#topbar-elec-cons {
    font-weight: 700;
    color: #e09a30;
}

/* ── ELEC CUSTOM AMOUNT INPUT ─────────────────────────────────────────── */
.elec-custom-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-top: 1px solid var(--border);
    padding-top: 10px;
    margin-top: 2px;
}
.elec-mode-row {
    display: flex;
    gap: 4px;
}
.elec-mode-btn {
    flex: 1;
    padding: 5px 4px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-family: var(--font-ui);
    font-size: 0.62rem;
    letter-spacing: 1px;
    cursor: pointer;
    text-transform: uppercase;
    transition: background 0.1s, border-color 0.1s, color 0.1s;
    text-align: center;
}
.elec-mode-btn.active {
    border-color: var(--amber);
    color: var(--amber);
    background: rgba(255,176,0,0.06);
}
.elec-input-wrap {
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    transition: border-color 0.15s;
}
.elec-input-wrap:focus-within {
    border-color: var(--amber);
}
.elec-input-prefix {
    font-family: var(--font-ui);
    font-size: 0.72rem;
    color: var(--amber);
    padding: 0 8px;
    flex-shrink: 0;
}
#elec-custom-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-bright);
    font-family: var(--font-ui);
    font-size: 0.82rem;
    padding: 7px 4px;
    min-width: 0;
    font-variant-numeric: tabular-nums;
}
#elec-custom-input::placeholder { color: var(--text-dim); opacity: 0.5; }
.elec-conversion {
    font-family: var(--font-ui);
    font-size: 0.68rem;
    color: var(--violet);
    text-align: right;
    min-height: 1em;
}
.elec-custom-actions {
    display: flex;
    gap: 4px;
}
.elec-pct-btn {
    flex: 1;
    padding: 4px 2px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-family: var(--font-ui);
    font-size: 0.6rem;
    cursor: pointer;
    text-align: center;
    transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.elec-pct-btn:hover {
    border-color: var(--amber);
    color: var(--amber);
    background: rgba(255,176,0,0.05);
}
#btn-elec-buy-custom {
    width: 100%;
    font-size: 0.66rem !important;
    letter-spacing: 2px;
    padding: 7px 0 !important;
    border-color: rgba(255,176,0,0.4) !important;
    color: var(--amber) !important;
}
#btn-elec-buy-custom:hover {
    background: rgba(255,176,0,0.08) !important;
    border-color: var(--amber) !important;
}

/* hw electricity consumption tag */
.hw-elec-cons {
    font-family: var(--font-ui);
    font-size: 0.58rem;
    color: #e09a30;
    text-align: right;
    opacity: 0.8;
}

.hw-row-brownout .hw-row-name::after {
    content: " ⚡ OFFLINE";
    font-size: 0.6rem;
    color: var(--red);
    margin-left: 4px;
}

/* ── ELECTRICITY WARNING BANNER ─────────────────────────────────────────── */
#elec-warning-bar {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    flex-shrink: 0;
    font-family: var(--font-ui);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    border-radius: 2px;
    white-space: nowrap;
    animation: elecWarnPulse 1.4s ease-in-out infinite;
}
#elec-warning-bar.hidden {
    display: none;
}
#elec-warning-bar.warn-low {
    color: var(--amber);
    border: 1px solid rgba(255, 176, 0, 0.3);
    background: rgba(255, 176, 0, 0.05);
}

#elec-warning-bar.warn-critical {
    color: var(--red);
    border: 1px solid rgba(224, 89, 104, 0.4);
    background: rgba(224, 89, 104, 0.06);
    animation: elecWarnPulse 0.7s ease-in-out infinite;
}

#elec-warning-bar.warn-empty {
    color: var(--red);
    border: 1px solid rgba(224, 89, 104, 0.6);
    background: rgba(224, 89, 104, 0.10);
    animation: elecWarnFlash 0.5s step-start infinite;
}

#elec-warning-icon {
    font-size: 0.9rem;
    flex-shrink: 0;
}

@keyframes elecWarnPulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

@keyframes elecWarnFlash {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.2; }
}

.settings-badge {
    font-family: var(--font-ui);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 2px;
    padding: 2px 8px;
    border: 1px solid currentColor;
    border-radius: 2px;
    flex-shrink: 0;
    transition: color 0.3s, border-color 0.3s;
}

/* ── PERSISTENT ELECTRICITY TOAST ───────────────────────────────────────── */
.toast-persist {
    padding: 20px 28px !important;
    min-width: 400px !important;
    gap: 18px !important;
    border-left-width: 5px !important;
    border-left-color: var(--red) !important;
    background: rgba(15, 6, 8, 0.97) !important;
    animation: toastIn 0.28s cubic-bezier(0.16,1,0.3,1) forwards,
               persistPulse 1.2s ease-in-out 0.3s infinite !important;
}
.toast-persist-icon {
    font-size: 2.2rem !important;
    filter: drop-shadow(0 0 8px rgba(224,89,104,0.8));
}
.toast-persist .toast-title {
    font-size: 1rem !important;
    letter-spacing: 3px !important;
    color: var(--red) !important;
}
.toast-persist .toast-body {
    font-size: 0.82rem !important;
    color: rgba(255,255,255,0.75) !important;
    margin-top: 3px;
}
@keyframes persistPulse {
    0%, 100% {
        border-left-color: #e05968;
        box-shadow: 0 0 0 rgba(224,89,104,0);
        background: rgba(15,6,8,0.97);
    }
    50% {
        border-left-color: #ff2a3d;
        box-shadow: 0 0 24px rgba(224,89,104,0.35), inset 0 0 40px rgba(224,89,104,0.06);
        background: rgba(25,6,8,0.98);
    }
}

/* ── PROCESS HINT ────────────────────────────────────────────────────────── */
.process-hint {
    font-family: var(--font-ui);
    font-size: 0.55rem;
    color: var(--text-dim);
    letter-spacing: 2px;
    text-align: center;
    opacity: 0.45;
    /* Positioned inside the process button at the bottom */
    position: absolute;
    bottom: 8px;
    left: 0;
    right: 0;
    pointer-events: none;
}



/* ══════════════════════════════════════════════════════════════════════════
   RANDOM EVENT BAR
   ══════════════════════════════════════════════════════════════════════════ */
#event-bar {
    position: fixed;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-panel);
    border: 1px solid var(--border-bright);
    padding: 10px 18px;
    min-width: 300px;
    max-width: 480px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.5);
    animation: eventBarIn 0.35s cubic-bezier(0.16,1,0.3,1);
}
@keyframes eventBarIn {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
#event-bar-icon {
    font-size: 1.4rem;
    flex-shrink: 0;
}
#event-bar-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}
#event-bar-title {
    font-family: var(--font-ui);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-bright);
}
#event-bar-track {
    height: 3px;
    background: var(--border);
    width: 100%;
}
#event-bar-fill {
    height: 100%;
    width: 100%;
    background: var(--green);
    transition: width 1s linear, background 0.3s;
}
#event-bar-timer {
    font-family: var(--font-ui);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-dim);
    flex-shrink: 0;
    min-width: 30px;
    text-align: right;
}

/* ══════════════════════════════════════════════════════════════════════════
   STATS OVERLAY
   ══════════════════════════════════════════════════════════════════════════ */
#stats-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    z-index: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}
#stats-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-bright);
    width: min(480px, 92vw);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}
#stats-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
#stats-title {
    font-family: var(--font-ui);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--amber);
}
#stats-scroll {
    overflow-y: auto;
    padding: 16px 18px;
}
#stats-body {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.stat-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 0;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}
.stat-line:last-child { border-bottom: none; }
.stat-line-k {
    font-family: var(--font-ui);
    font-size: 0.68rem;
    color: var(--text-dim);
    letter-spacing: 0.5px;
}
.stat-line-v {
    font-family: var(--font-ui);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-bright);
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ══════════════════════════════════════════════════════════════════════════
   AUTO-SELL ROW
   ══════════════════════════════════════════════════════════════════════════ */
.autosell-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
    padding: 6px 0;
    border-top: 1px solid var(--border);
}
.autosell-label {
    font-family: var(--font-ui);
    font-size: 0.62rem;
    letter-spacing: 2px;
    color: var(--text-dim);
    text-transform: uppercase;
}
.autosell-select {
    background: var(--bg-card);
    border: 1px solid var(--border-bright);
    color: var(--amber);
    font-family: var(--font-ui);
    font-size: 0.65rem;
    letter-spacing: 1px;
    padding: 4px 8px;
    cursor: pointer;
    outline: none;
    text-transform: uppercase;
}
.autosell-select:hover,
.autosell-select:focus {
    border-color: var(--amber);
}
.autosell-select option {
    background: var(--bg-panel);
    color: var(--text-bright);
}

/* ══════════════════════════════════════════════════════════════════════════
   MISSION NEAR-COMPLETION HIGHLIGHT
   ══════════════════════════════════════════════════════════════════════════ */
.mission-card.mission-almost-done {
    border-color: var(--green);
    box-shadow: 0 0 0 1px rgba(68, 214, 138, 0.2), inset 0 0 20px rgba(68, 214, 138, 0.04);
    animation: missionPulse 1.8s ease-in-out infinite;
}
.mission-card.mission-almost-done .mission-progress-bar {
    background: var(--green);
    box-shadow: 0 0 6px rgba(68, 214, 138, 0.5);
}
@keyframes missionPulse {
    0%, 100% { border-color: var(--green); }
    50%       { border-color: rgba(68, 214, 138, 0.4); }
}

/* ══════════════════════════════════════════════════════════════════════════
   PRESTIGE BUTTON (WIN SCREEN)
   ══════════════════════════════════════════════════════════════════════════ */
#btn-prestige {
    margin-top: 10px;
    border-color: var(--gold) !important;
    color: var(--gold) !important;
    letter-spacing: 3px;
    padding: 10px 28px;
    font-size: 0.72rem;
    animation: prestigeGlow 2.4s ease-in-out infinite;
}
#btn-prestige:hover {
    background: rgba(200, 168, 64, 0.12) !important;
}
@keyframes prestigeGlow {
    0%, 100% { box-shadow: 0 0 0 rgba(200,168,64,0); }
    50%       { box-shadow: 0 0 20px rgba(200,168,64,0.35); }
}

/* ══════════════════════════════════════════════════════════════════════════
   CORRUPTION WHISPERS — log entries
   ══════════════════════════════════════════════════════════════════════════ */
.log-entry.log-corruption {
    background: rgba(58, 8, 40, 0.18);
    border-color: rgba(160, 30, 90, 0.35);
    border-left-color: #a01e5a;
}
.log-entry.log-corruption.new {
    background: rgba(80, 10, 55, 0.28);
    border-left-color: #e0358a;
}
.log-corruption-text {
    color: #c0607a;
    font-style: italic;
    letter-spacing: 0.5px;
}
.log-entry.log-corruption .log-time {
    color: #a01e5a;
    opacity: 0.7;
}

/* ══════════════════════════════════════════════════════════════════════════
   SECRET ACHIEVEMENTS
   ══════════════════════════════════════════════════════════════════════════ */
.ach-secret-locked {
    opacity: 0.45;
    border-style: dashed;
}
.ach-secret-locked .ach-icon {
    color: var(--text-dim);
    opacity: 0.5;
}
.ach-secret-name {
    color: var(--text-dim) !important;
    letter-spacing: 2px;
    font-size: 0.65rem;
}
.ach-secret-hint {
    color: var(--text-dim) !important;
    font-style: italic;
    opacity: 0.6;
    font-size: 0.65rem;
}
.ach-secret-unlocked {
    border-color: #a01e5a !important;
    background: rgba(58, 8, 40, 0.2) !important;
    animation: secretGlow 3s ease-in-out infinite;
}
.ach-secret-unlocked .ach-name {
    color: #e0358a !important;
}
.ach-secret-unlocked .ach-status {
    color: #c0607a !important;
    font-style: italic;
}
@keyframes secretGlow {
    0%, 100% { box-shadow: 0 0 0 rgba(160,30,90,0); }
    50%       { box-shadow: 0 0 12px rgba(160,30,90,0.3); }
}

/* ══════════════════════════════════════════════════════════════════════════
   AUTO-BUY ELECTRICITY
   ══════════════════════════════════════════════════════════════════════════ */
.autobuy-elec-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 10px;
    padding: 8px 0 6px;
    border-top: 1px solid var(--border);
}
.autobuy-elec-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.autobuy-elec-label {
    font-family: var(--font-ui);
    font-size: 0.62rem;
    letter-spacing: 2px;
    color: #e09a30;
    text-transform: uppercase;
}
.autobuy-elec-desc {
    font-family: var(--font-ui);
    font-size: 0.56rem;
    color: var(--text-dim);
    letter-spacing: 0.5px;
}
.autobuy-elec-status {
    font-family: var(--font-ui);
    font-size: 0.6rem;
    color: #e09a30;
    padding: 4px 0 2px;
    opacity: 0.75;
}

/* ══════════════════════════════════════════════════════════════════════════
   AUTO-SELL PREVIEW
   ══════════════════════════════════════════════════════════════════════════ */
.autosell-preview {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-top: 6px;
    padding: 7px 10px;
    background: rgba(33, 60, 92, 0.15);
    border: 1px solid var(--border);
    border-left: 2px solid var(--violet);
}
.autosell-preview-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
.autosell-preview-label {
    font-family: var(--font-ui);
    font-size: 0.6rem;
    color: var(--text-dim);
    letter-spacing: 0.5px;
}
.autosell-preview-val {
    font-family: var(--font-ui);
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-bright);
    font-variant-numeric: tabular-nums;
}

/* ══════════════════════════════════════════════════════════════════════════
   HUMOR LOG ENTRIES
   ══════════════════════════════════════════════════════════════════════════ */
.log-entry.log-humor {
    background: rgba(50, 8, 8, 0.22);
    border-color: rgba(180, 40, 40, 0.3);
    border-left-color: #8b2020;
}
.log-entry.log-humor.new {
    background: rgba(80, 12, 12, 0.32);
    border-left-color: #e05050;
}
.log-humor-line {
    display: block;
    color: #d06060;
    font-size: 0.7rem;
}
.log-humor-indent {
    color: #a04040;
    padding-left: 2px;
    opacity: 0.8;
}

/* ── Rare humor log — gold tint ─────────────────────────────────────────── */
.log-entry.log-humor-rare {
    background: rgba(40, 30, 5, 0.35);
    border-color: rgba(200, 168, 64, 0.25);
    border-left-color: #c8a840;
}
.log-entry.log-humor-rare.new {
    background: rgba(60, 45, 5, 0.45);
    border-left-color: #f0cc60;
}
.log-entry.log-humor-rare .log-humor-line {
    color: #d4b84a;
}
.log-entry.log-humor-rare .log-humor-indent {
    color: #a88c30;
}
.log-entry.log-humor-rare .log-time {
    color: #a88c30;
    opacity: 0.7;
}

/* ══════════════════════════════════════════════════════════════════════════
   CHEAT LOG DROPDOWN
   ══════════════════════════════════════════════════════════════════════════ */
.cheat-log-row {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
}
.cheat-log-select {
    width: 100%;
    font-size: 0.6rem;
    padding: 5px 8px;
}

/* ══════════════════════════════════════════════════════════════════════════
   LOGDEX OVERLAY
   ══════════════════════════════════════════════════════════════════════════ */
#logdex-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    z-index: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}
#logdex-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-bright);
    width: min(540px, 94vw);
    max-height: 82vh;
    display: flex;
    flex-direction: column;
}
#logdex-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
#logdex-title {
    font-family: var(--font-ui);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--amber);
    flex: 1;
}
#logdex-counter {
    font-family: var(--font-ui);
    font-size: 0.65rem;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}
#logdex-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.logdex-tab {
    flex: 1;
    padding: 8px 0;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-dim);
    font-family: var(--font-ui);
    font-size: 0.65rem;
    letter-spacing: 1.5px;
    cursor: pointer;
    text-transform: uppercase;
    transition: color 0.15s, border-color 0.15s;
}
.logdex-tab:hover:not(.active) { color: var(--text-bright); }
.logdex-tab.active {
    color: var(--amber);
    border-bottom-color: var(--amber);
}
#logdex-scroll {
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.logdex-card {
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-left: 2px solid var(--border-bright);
    font-family: var(--font-ui);
    font-size: 0.68rem;
}
.logdex-card.logdex-seen {
    background: var(--bg-card);
}
.logdex-card.logdex-unseen {
    background: rgba(5, 8, 15, 0.6);
    border-color: var(--border);
    border-left-color: var(--border);
    opacity: 0.5;
}
.logdex-card.logdex-rare {
    border-left-color: #c8a840;
    background: rgba(40, 30, 5, 0.3);
}
.logdex-card.logdex-rare .logdex-line { color: #d4b84a; }
.logdex-card.logdex-whisper.logdex-seen {
    background: rgba(58, 8, 40, 0.18);
    border-left-color: #a01e5a;
}
.logdex-line { color: var(--text); }
.logdex-corruption-line {
    color: #c0607a;
    font-style: italic;
}
.logdex-hidden {
    color: var(--text-dim);
    letter-spacing: 3px;
    opacity: 0.4;
}
.logdex-tier {
    font-family: var(--font-ui);
    font-size: 0.6rem;
    color: #a01e5a;
    letter-spacing: 2px;
    padding: 8px 2px 4px;
    border-bottom: 1px solid rgba(160,30,90,0.2);
    margin-top: 8px;
}
.logdex-tier:first-child { margin-top: 0; }
.stat-line.stat-divider {
    border-bottom: 1px solid var(--border);
    margin: 2px 0;
    padding: 0;
    height: 0;
}

/* ── Stats tabs ─────────────────────────────────────────────────────────── */
#stats-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.stats-tab {
    flex: 1;
    padding: 9px 0;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-dim);
    font-family: var(--font-ui);
    font-size: 0.65rem;
    letter-spacing: 1.5px;
    cursor: pointer;
    text-transform: uppercase;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.stats-tab:hover:not(.active) {
    color: var(--text);
    background: rgba(255,255,255,0.03);
}
.stats-tab.active {
    color: #ffffff;
    border-bottom: 2px solid #3a8fd4;
    background: rgba(58,143,212,0.1);
    font-weight: 700;
}

/* ── Win screen button layout ───────────────────────────────────────────── */
#win-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
#btn-win-export {
    border-color: rgba(58,143,212,0.5) !important;
    color: var(--violet) !important;
    font-size: 0.68rem;
}
#btn-win-export:hover {
    background: rgba(58,143,212,0.08) !important;
    border-color: var(--violet) !important;
}


/* ══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — fluid layout for all screen sizes
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Fluid base font so everything scales ───────────────────────────────── */
html { font-size: clamp(12px, 1.1vw, 16px); }

/* ── Topbar height shrinks on short screens ─────────────────────────────── */
@media (max-height: 860px) { :root { --topbar-h: 58px; } }
@media (max-height: 720px) { :root { --topbar-h: 48px; } }

/* ── Main three-column layout ───────────────────────────────────────────── */
#left-panel  { width: clamp(200px, 18vw, 300px); padding: clamp(10px,1.2vh,20px) clamp(8px,1vw,18px); gap: clamp(8px,1.2vh,20px); }
#right-panel { width: clamp(260px, 24vw, 420px); padding: clamp(10px,1.5vh,22px) clamp(10px,1.2vw,22px) 0; }
#middle-panel { padding: clamp(10px,1.2vh,20px) clamp(10px,1vw,18px); gap: clamp(10px,1.5vh,24px); }

/* ── Topbar elements ─────────────────────────────────────────────────────── */
#topbar        { gap: clamp(6px,0.8vw,14px); padding: 0 clamp(8px,1vw,14px); }
#game-title    { font-size: clamp(0.7rem,1vw,1.05rem); }
#run-time-block { padding-left: clamp(8px,0.8vw,16px); padding-right: clamp(8px,0.8vw,20px); }
.res-label     { font-size: clamp(0.45rem,0.55vw,0.58rem); }
.res-value     { font-size: clamp(0.7rem,0.85vw,0.95rem); }
.res-rate      { font-size: clamp(0.45rem,0.5vw,0.58rem); }
.btn-ui        { padding: clamp(4px,0.5vh,7px) clamp(7px,0.8vw,13px); font-size: clamp(0.58rem,0.65vw,0.72rem); }

/* ── Process button ─────────────────────────────────────────────────────── */
#process-btn   { font-size: clamp(0.85rem,1.4vw,1.3rem); padding: clamp(10px,2vh,20px) 0; }

/* ── Stat rows ──────────────────────────────────────────────────────────── */
.stat-row   { padding: clamp(2px,0.3vh,5px) 0; }
.stat-k, .stat-v { font-size: clamp(0.58rem,0.65vw,0.72rem); }

/* ── Sell buttons ───────────────────────────────────────────────────────── */
.btn-sell   { padding: clamp(4px,0.6vh,7px) 0; font-size: clamp(0.58rem,0.65vw,0.7rem); }

/* ── Electricity charts ─────────────────────────────────────────────────── */
/* elec charts keep their original heights — no override needed */

/* ── Right panel hardware/worker cards ──────────────────────────────────── */
.hw-card, .wk-card { padding: clamp(6px,0.8vh,10px) clamp(8px,0.8vw,12px); }

/* ── Overlays — never exceed screen ─────────────────────────────────────── */
#ach-panel, #stats-panel, #cheat-panel,
#logdex-panel, #settings-panel, #tree-panel,
#kbd-panel {
    max-height: min(86vh, 780px);
    max-width: min(94vw, 680px);
}
#tree-panel { max-width: min(94vw, 860px); }

/* ── Log section ─────────────────────────────────────────────────────────── */
.log-entry  { font-size: clamp(0.6rem,0.65vw,0.72rem); padding: clamp(4px,0.5vh,7px) clamp(6px,0.6vw,10px); }

/* ── Section headings ───────────────────────────────────────────────────── */
h2 { font-size: clamp(0.55rem,0.65vw,0.68rem); }

/* ── Mission / project cards ────────────────────────────────────────────── */
.mission-card, .proj-card { padding: clamp(6px,0.8vh,10px) clamp(8px,0.8vw,12px); }

/* ══════════════════════════════════════════════════════════════════════════
   BREAKPOINT — narrow screens (collapse to vertical stack)
   ══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 860px) {
    html { font-size: 13px; }
    #main-content  { flex-direction: column; height: auto; overflow-y: auto; overflow-x: hidden; }
    #left-panel, #right-panel { width: 100%; border-right: none; border-left: none; border-bottom: 1px solid var(--border); }
    #left-panel    { padding: 14px 12px; gap: 12px; }
    #right-panel   { padding: 14px 12px 0; min-height: 400px; }
    #right-panel-body { min-height: 300px; }
    #middle-panel  { padding: 14px 12px; }
    #process-btn   { font-size: 1.1rem; padding: 14px 0; }
    #ach-panel, #stats-panel, #cheat-panel,
    #logdex-panel, #settings-panel, #tree-panel { max-width: 96vw; }
}

/* ══════════════════════════════════════════════════════════════════════════
   BREAKPOINT — very small screens (phones, tiny windows)
   ══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 560px) {
    html { font-size: 12px; }
    :root { --topbar-h: 48px; }
    #topbar { flex-wrap: wrap; height: auto; padding: 6px 8px; }
    #title-block { display: none; }
    #resource-bar { flex-wrap: wrap; gap: 6px; }
    .res-divider  { display: none; }
    #header-btns  { flex-wrap: wrap; gap: 3px; }
    .btn-ui       { padding: 5px 8px; font-size: 0.58rem; }
    #ticker-bar   { display: none; }
}

/* ══════════════════════════════════════════════════════════════════════════
   MISSIONS HISTORY OVERLAY
   ══════════════════════════════════════════════════════════════════════════ */
#missions-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    z-index: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}
#missions-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-bright);
    width: min(520px, 94vw);
    max-height: 82vh;
    display: flex;
    flex-direction: column;
}
#missions-panel-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
#missions-panel-title {
    font-family: var(--font-ui);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--amber);
    flex: 1;
}
#missions-panel-counter {
    font-family: var(--font-ui);
    font-size: 0.65rem;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}
#missions-panel-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
#missions-panel-tabs .stats-tab { flex: 1; }
#missions-panel-scroll {
    overflow-y: auto;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.mission-card-done {
    opacity: 0.6;
    background: var(--bg-card-done) !important;
    border-color: var(--border-done) !important;
}
.mission-card-done .mission-title { color: var(--text-dim); }
.mission-reward-done { color: var(--green) !important; }
.mission-card-active {
    border-left-color: var(--violet) !important;
}
.mission-card-locked {
    opacity: 0.35;
    border-style: dashed !important;
}
.missions-empty {
    font-family: var(--font-ui);
    font-size: 0.68rem;
    color: var(--text-dim);
    text-align: center;
    padding: 24px 0;
    opacity: 0.5;
}

/* ══════════════════════════════════════════════════════════════════════════
   CONFIRM MODAL
   ══════════════════════════════════════════════════════════════════════════ */
#confirm-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    z-index: 9500;
    display: flex;
    align-items: center;
    justify-content: center;
}
#confirm-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-bright);
    width: min(380px, 90vw);
    padding: 28px 28px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
}
#confirm-icon {
    font-size: 2rem;
    line-height: 1;
}
#confirm-title {
    font-family: var(--font-ui);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--amber);
    text-transform: uppercase;
}
#confirm-body {
    font-family: var(--font-ui);
    font-size: 0.68rem;
    color: var(--text);
    line-height: 1.6;
    max-width: 300px;
}
#confirm-cost {
    font-family: var(--font-ui);
    font-size: 0.68rem;
    color: var(--red);
    padding: 6px 14px;
    border: 1px solid rgba(224,89,104,0.3);
    background: rgba(224,89,104,0.06);
}
#confirm-btns {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}
#confirm-btns .btn-ui {
    min-width: 110px;
}

/* ── Suppress entry animations during in-tab updates (buy/sell) ──────────── */
.no-anim .hw-row,
.no-anim .wk-row,
.no-anim .miner-upg-card,
.no-anim .miner-asset-row {
    animation: none !important;
    transition: none !important;
}

/* ── Mission overlay — section headers & upcoming state ─────────────────── */
.missions-section-header {
    font-family: var(--font-ui);
    font-size: 0.6rem;
    letter-spacing: 2.5px;
    color: var(--text-dim);
    padding: 10px 2px 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
    text-transform: uppercase;
}
.missions-section-header:first-child { padding-top: 2px; }

.mission-card-upcoming {
    opacity: 0.45;
    border-left-color: var(--border) !important;
    border-style: dashed !important;
}
.mission-card-upcoming .mission-title { color: var(--text-dim); }
.mission-card-upcoming .mission-reward { color: var(--text-dim) !important; }

/* ── Settings danger zone ───────────────────────────────────────────────── */
.settings-danger-zone {
    border-color: rgba(224,89,104,0.3) !important;
    background: rgba(224,89,104,0.04);
}
.settings-danger-zone .settings-section-title {
    color: var(--red) !important;
    opacity: 0.8;
}

/* ── Hardware / Worker sell button ──────────────────────────────────────── */
.hw-sell-btn {
    font-family: var(--font-ui);
    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    padding: 2px 6px;
    background: transparent;
    border: 1px solid rgba(224,89,104,0.4);
    color: var(--red);
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.15s, border-color 0.15s;
    margin-top: 2px;
    border-radius: 2px;
}
.hw-sell-btn:hover {
    opacity: 1;
    border-color: var(--red);
    background: rgba(224,89,104,0.08);
}

/* ══════════════════════════════════════════════════════════════════════════
   BUY / SELL MODE
   ══════════════════════════════════════════════════════════════════════════ */
.mode-btn {
    font-family: var(--font-ui);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 2px;
    padding: 3px 10px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.mode-btn:hover { color: var(--text-bright); border-color: var(--border-bright); }
.mode-btn.active[data-mode="buy"] {
    color: var(--green);
    border-color: var(--green);
    background: rgba(68,214,138,0.08);
}
.mode-btn.active[data-mode="sell"] {
    color: var(--red);
    border-color: var(--red);
    background: rgba(224,89,104,0.08);
}
.mode-divider {
    width: 1px;
    background: var(--border);
    align-self: stretch;
    margin: 2px 4px;
}

/* Sell mode row highlight */
.hw-row.sell-mode,
.wk-row.sell-mode {
    border-left-color: var(--red) !important;
    cursor: pointer;
}
.hw-row.sell-mode:hover,
.wk-row.sell-mode:hover {
    background: rgba(224,89,104,0.06) !important;
}
.hw-row.sell-mode-empty,
.wk-row.sell-mode-empty {
    opacity: 0.3;
    cursor: default;
    pointer-events: none;
}
.hw-row.sell-mode .hw-cost,
.wk-row.sell-mode .wk-cost {
    color: var(--red) !important;
}

/* ══════════════════════════════════════════════════════════════════════════
   READABILITY — font-weight boosts for thin text
   ══════════════════════════════════════════════════════════════════════════ */

/* Ticker bar — names and prices bolder */
.ticker-name         { font-weight: 700; color: var(--text); }
.ticker-price        { font-weight: 800; }
.ticker-item.locked  { opacity: 0.35; }
.ticker-item.locked .ticker-price { font-size: 0.6rem; letter-spacing: 1px; color: var(--text-dim) !important; }

/* Hardware / Worker rows */
.hw-name    { font-weight: 700; }
.hw-desc    { font-weight: 500; color: var(--text); }
.hw-desc,
.hw-locked-badge { font-weight: 500; }
.hw-cost    { font-weight: 800; }
.hw-owned   { font-weight: 800; }
.wk-cost    { font-weight: 800 !important; }

/* Missions */
.mission-title  { font-weight: 700; }
.mission-desc   { font-weight: 500; color: var(--text); }
.mission-reward { font-weight: 700; }

/* Settings */
.settings-row-label { font-weight: 600; }
.settings-row-desc  { font-weight: 500; color: var(--text); }
.settings-section-title { font-weight: 700; }

/* System log */
.log-entry       { font-weight: 500; color: var(--text); }
.log-entry.new   { font-weight: 600; }

/* Projects */
.proj-name   { font-weight: 700; }
.proj-desc   { font-weight: 500; color: var(--text); }

/* Stat block */
#stat-block .stat-label { font-weight: 600; }
#stat-block .stat-value { font-weight: 700; }

/* Tooltip */
.tooltip-line { font-weight: 500; }

/* ══════════════════════════════════════════════════════════════════════════
   MAIN MENU
   ══════════════════════════════════════════════════════════════════════════ */
#main-menu {
    position: fixed;
    inset: 0;
    background: var(--bg, #05080f);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
#main-menu.hidden { display: none; }

#menu-canvas {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

#menu-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 48px;
    text-align: center;
}

#menu-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    animation: menuFadeUp 0.8s cubic-bezier(0.22,1,0.36,1) both;
}
#menu-logo-icon {
    font-size: 3.5rem;
    color: var(--violet, #3a8fd4);
    animation: menuIconPulse 3s ease-in-out infinite;
    filter: drop-shadow(0 0 18px rgba(58,143,212,0.6));
}
#menu-title {
    font-family: var(--font-ui);
    font-size: clamp(3.5rem, 10vw, 6rem);
    font-weight: 800;
    letter-spacing: 0.3em;
    color: var(--text-bright, #ddeeff);
    text-shadow: 0 0 40px rgba(58,143,212,0.4), 0 0 80px rgba(58,143,212,0.15);
    line-height: 1;
}
#menu-subtitle {
    font-family: var(--font-ui);
    font-size: 0.72rem;
    letter-spacing: 4px;
    color: var(--violet, #3a8fd4);
    opacity: 0.8;
}
#menu-tagline {
    font-family: var(--font-ui);
    font-size: 0.58rem;
    letter-spacing: 3px;
    color: var(--text-dim, #5e8aaa);
    opacity: 0.6;
    margin-top: 4px;
}

#menu-btns {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 260px;
    animation: menuFadeUp 0.8s 0.15s cubic-bezier(0.22,1,0.36,1) both;
}
.menu-btn {
    font-family: var(--font-ui);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 3px;
    padding: 14px 32px;
    background: transparent;
    border: 1px solid var(--border-bright, rgba(94,138,170,0.4));
    color: var(--text-bright, #ddeeff);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
    position: relative;
    overflow: hidden;
}
.menu-btn:hover {
    border-color: var(--violet, #3a8fd4);
    color: #fff;
    box-shadow: 0 0 20px rgba(58,143,212,0.25), inset 0 0 20px rgba(58,143,212,0.06);
}
.menu-btn-primary {
    border-color: var(--violet, #3a8fd4);
    color: var(--violet, #3a8fd4);
    font-size: 0.88rem;
}
.menu-btn-primary:hover {
    background: rgba(58,143,212,0.12);
    box-shadow: 0 0 30px rgba(58,143,212,0.4), inset 0 0 30px rgba(58,143,212,0.08);
}

#menu-footer {
    font-family: var(--font-ui);
    font-size: 0.55rem;
    letter-spacing: 2px;
    color: var(--text-dim, #5e8aaa);
    opacity: 0.4;
    animation: menuFadeUp 0.8s 0.3s cubic-bezier(0.22,1,0.36,1) both;
}

@keyframes menuFadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes menuIconPulse {
    0%,100% { filter: drop-shadow(0 0 18px rgba(58,143,212,0.6)); }
    50%     { filter: drop-shadow(0 0 32px rgba(58,143,212,1)); }
}

/* ── Slot overlay ─────────────────────────────────────────────────────────── */
#slot-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5,8,15,0.92);
    z-index: 2100;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}
#slot-overlay.hidden { display: none; }

#slot-panel {
    width: min(860px, 96vw);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow: hidden;
    border: 1px solid var(--border-bright);
    background: var(--bg-panel);
}

#slot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
#slot-title {
    font-family: var(--font-ui);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--amber, #ddeeff);
}

#slot-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    overflow-y: auto;
}

.slot-card {
    border-right: 1px solid var(--border);
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    cursor: default;
    transition: background 0.18s;
    min-height: 220px;
}
.slot-card:last-child { border-right: none; }
.slot-card.slot-used { cursor: default; }
.slot-card:hover { background: rgba(58,143,212,0.04); }
.slot-card.slot-won { border-top: 2px solid var(--gold, #c8a840); }
.slot-card.slot-iddqd { border-top: 2px solid var(--violet, #3a8fd4); }

.slot-num {
    font-family: var(--font-ui);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 6px;
}
.slot-badge-iddqd {
    font-size: 0.5rem;
    letter-spacing: 1px;
    color: var(--violet);
    border: 1px solid var(--violet);
    padding: 1px 4px;
    opacity: 0.8;
}
.slot-badge-won {
    font-size: 0.5rem;
    letter-spacing: 1px;
    color: var(--gold, #c8a840);
    border: 1px solid var(--gold, #c8a840);
    padding: 1px 4px;
    opacity: 0.8;
}
.slot-status.slot-new {
    font-family: var(--font-ui);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-dim);
}
.slot-phase {
    font-family: var(--font-ui);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-bright);
    letter-spacing: 2px;
}
.slot-stats {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}
.slot-stats span {
    font-family: var(--font-ui);
    font-size: 0.68rem;
    color: var(--text-dim);
}
.slot-stats strong {
    color: var(--text-bright);
    font-weight: 700;
}
.slot-detail {
    font-family: var(--font-ui);
    font-size: 0.6rem;
    color: var(--text-dim);
    opacity: 0.6;
    margin-top: auto;
}
.slot-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}
.slot-btn {
    font-family: var(--font-ui);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 2px;
    padding: 8px 14px;
    background: transparent;
    border: 1px solid var(--border-bright);
    color: var(--text-bright);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    flex: 1;
}
.slot-btn-start {
    border-color: var(--violet);
    color: var(--violet);
}
.slot-btn-start:hover {
    background: rgba(58,143,212,0.1);
    border-color: var(--violet);
}
.slot-btn-delete {
    color: var(--red);
    border-color: rgba(224,89,104,0.3);
    flex: 0 0 auto;
    padding: 8px 10px;
}
.slot-btn-delete:hover {
    background: rgba(224,89,104,0.08);
    border-color: var(--red);
}

@media (max-width: 640px) {
    #slot-list { grid-template-columns: 1fr; }
    .slot-card { border-right: none; border-bottom: 1px solid var(--border); }
}

/* ── Menu logo continuous animations ─────────────────────────────────────── */
#menu-logo-icon {
    animation: menuIconSpin 12s linear infinite, menuIconPulse 3s ease-in-out infinite;
}
@keyframes menuIconSpin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
#menu-title {
    animation: menuTitleGlow 4s ease-in-out infinite;
}
@keyframes menuTitleGlow {
    0%,100% { text-shadow: 0 0 30px rgba(58,143,212,0.3), 0 0 60px rgba(58,143,212,0.1); }
    50%     { text-shadow: 0 0 60px rgba(58,143,212,0.7), 0 0 120px rgba(58,143,212,0.25); }
}
#menu-tagline {
    animation: menuTaglineBlink 3.5s ease-in-out infinite;
}
@keyframes menuTaglineBlink {
    0%,90%,100% { opacity: 0.6; }
    95%         { opacity: 0.15; }
}

/* ══════════════════════════════════════════════════════════════════════════
   NEXT UNLOCK PROGRESS BAR
   Appears on locked hardware/worker rows to show progress toward unlocking
   the required tech tree node.
   ══════════════════════════════════════════════════════════════════════════ */
.next-unlock-bar {
    margin-top: 4px;
}
.next-unlock-label {
    font-family: var(--font-ui);
    font-size: 0.58rem;
    color: var(--text-dim);
    opacity: 0.7;
    display: block;
    margin-bottom: 3px;
}
.next-unlock-track {
    width: 100%;
    height: 3px;
    background: rgba(94,138,170,0.15);
    border-radius: 2px;
    overflow: hidden;
}
.next-unlock-fill {
    height: 100%;
    background: var(--violet);
    border-radius: 2px;
    transition: width 0.5s ease;
    opacity: 0.7;
}

/* ══════════════════════════════════════════════════════════════════════════
   PRESTIGE PROGRESS BAR
   Shown in the left panel when the player has won and can prestige.
   ══════════════════════════════════════════════════════════════════════════ */
#prestige-bar-wrap {
    margin: 8px 0 0;
    padding: 10px 12px;
    border: 1px solid rgba(200,168,64,0.25);
    background: rgba(200,168,64,0.04);
}
#prestige-bar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}
#prestige-bar-label {
    font-family: var(--font-ui);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--gold);
}
#prestige-bar-level {
    font-family: var(--font-ui);
    font-size: 0.58rem;
    color: var(--gold);
    opacity: 0.7;
}
#prestige-bar-track {
    width: 100%;
    height: 4px;
    background: rgba(200,168,64,0.15);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 5px;
}
#prestige-bar-fill {
    height: 100%;
    background: var(--gold);
    border-radius: 2px;
    transition: width 0.8s ease;
    box-shadow: 0 0 6px rgba(200,168,64,0.5);
}
#prestige-bar-hint {
    font-family: var(--font-ui);
    font-size: 0.58rem;
    color: var(--text-dim);
    opacity: 0.6;
}

/* ══════════════════════════════════════════════════════════════════════════
   OPS/S GRAPH in Stats overlay
   ══════════════════════════════════════════════════════════════════════════ */
#stats-graph-wrap {
    padding: 12px 14px 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}
#stats-graph-title {
    font-family: var(--font-ui);
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--text-dim);
    margin-bottom: 6px;
}
#ops-graph-canvas {
    width: 100%;
    height: 90px;
    display: block;
}

/* ══════════════════════════════════════════════════════════════════════════
   GLOBAL STATS in slot panel footer
   ══════════════════════════════════════════════════════════════════════════ */
#slot-global-stats {
    border-top: 1px solid var(--border);
    padding: 10px 20px;
    background: rgba(58,143,212,0.03);
}
.slot-global-row {
    margin-bottom: 4px;
}
.slot-global-label {
    font-family: var(--font-ui);
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--text-dim);
    opacity: 0.6;
}
.slot-global-items {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    font-family: var(--font-ui);
    font-size: 0.65rem;
    color: var(--text-dim);
}
.slot-global-items strong {
    color: var(--text-bright);
    font-weight: 700;
}
