/* =====================================================================
   RED SIEGE — style.css
   Retro-futuristic military: slate metal, neon green, glowing amber.
   Landscape-first; scales from phones (≈360px tall) to desktop.
   ===================================================================== */
:root {
    --bg: #0d1114;
    --slate-1: #1a2026;
    --slate-2: #232b33;
    --slate-3: #313b45;
    --edge: #4a5866;
    --edge-hi: #6f8494;
    --neon: #9eff00;
    --amber: #ffb300;
    --gold: #ffcc00;
    --cyan: #4fe3ff;
    --red: #ff4d4d;
    --text: #d6dee4;
    --muted: #8d9aa5;
    --font: "Bahnschrift", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
    --panel-w: clamp(150px, 21vw, 270px);
}

* { box-sizing: border-box; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: manipulation;
}

button { font-family: inherit; touch-action: manipulation; }

/* ---------- Layout ---------- */
#app {
    display: flex;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#gameContainer {
    position: relative;
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, #151b20 0%, #090c0e 100%);
    overflow: hidden;
}

canvas {
    display: block;
    touch-action: none;           /* no scrolling / zooming while building */
    cursor: crosshair;
    border: 2px solid var(--edge);
    box-shadow: 0 0 24px rgba(0,0,0,0.9), 0 0 0 1px #000;
}

#sidePanel {
    width: var(--panel-w);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 6px;
    background:
        repeating-linear-gradient(90deg, rgba(255,255,255,0.015) 0 2px, transparent 2px 4px),
        linear-gradient(180deg, var(--slate-2) 0%, var(--slate-1) 100%);
    border-left: 2px solid var(--edge);
    box-shadow: inset 1px 0 0 rgba(255,255,255,0.06);
    min-height: 0;
}

/* ---------- Stats ---------- */
#stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3px;
}
.stat-item {
    background: #0a0e11;
    border: 1px solid #2a343d;
    border-top-color: #05080a;
    padding: 2px 6px;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 12px;
    font-weight: 700;
    color: var(--neon);
    text-shadow: 0 0 6px rgba(158,255,0,0.35);
    white-space: nowrap;
    overflow: hidden;
}
.stat-item .lbl { color: var(--muted); font-size: 9px; letter-spacing: 1px; text-shadow: none; margin-right: 4px; }
.stat-item.credits { grid-column: 1 / -1; font-size: 16px; }
.gold-text { color: var(--gold); text-shadow: 0 0 8px rgba(255,204,0,0.45); }
.power-ok { color: #00ff88; }
.power-low { color: var(--red); animation: blink 0.6s infinite; }
@keyframes blink { 50% { opacity: 0.35; } }

/* ---------- Build cards ---------- */
.build-cards {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-auto-rows: minmax(0, 1fr);
    gap: 4px;
    max-height: 520px;
}
.card {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 2px 3px;
    min-height: 0;
    overflow: hidden;
    cursor: pointer;
    color: var(--text);
    background: linear-gradient(180deg, #2b343d 0%, #1a2128 100%);
    border: 1px solid var(--edge);
    border-top-color: var(--edge-hi);
    border-bottom-color: #0b0f12;
    border-radius: 3px;
    transition: transform 0.08s;
}
.card:active:not(.locked) { transform: scale(0.96); }
@media (hover: hover) { .card:hover:not(.locked) { border-color: var(--amber); } }
.card.active:not(.locked) {
    border: 2px solid var(--amber);
    background: linear-gradient(180deg, #3b3315 0%, #221d0b 100%);
    box-shadow: inset 0 0 12px rgba(255,179,0,0.35), 0 0 8px rgba(255,179,0,0.25);
}
.card.locked { opacity: 0.4; cursor: not-allowed; filter: grayscale(0.8); }
.card.hint:not(.active) { animation: hintPulse 1.1s ease-in-out infinite; }
@keyframes hintPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(158,255,0,0); border-color: var(--edge); }
    50% { box-shadow: 0 0 10px 2px rgba(158,255,0,0.55); border-color: var(--neon); }
}
.card-icon { font-size: 15px; line-height: 1.1; }
.card-title { font-size: 10px; font-weight: 700; color: #fff; letter-spacing: 0.5px; line-height: 1.15; }
.card-cost { font-size: 11px; font-weight: 700; color: var(--gold); line-height: 1.15; }
.card-cost.cant-afford { color: var(--red); }
.card-sub { font-size: 8.5px; color: var(--muted); line-height: 1.1; margin-top: 1px; }
.green { color: var(--neon) !important; }
.red { color: var(--red) !important; }
.amber { color: var(--amber) !important; }
.cyan { color: var(--cyan) !important; }
.hotkey {
    position: absolute; top: 2px; left: 3px;
    font-size: 8px; font-weight: 700; color: #000;
    background: var(--neon); padding: 0 3px; border-radius: 2px;
}
@media (hover: none) { .hotkey { display: none; } }

/* ---------- Action buttons ---------- */
.panel-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}
.action-btn, .top-btn {
    background: linear-gradient(180deg, #3a4651 0%, #222a31 100%);
    color: #fff;
    border: 1px solid var(--edge-hi);
    border-bottom-color: #0b0f12;
    border-radius: 3px;
    padding: 6px 4px;
    font-weight: 700;
    font-size: 11px;
    cursor: pointer;
    min-height: 34px;
}
.action-btn:disabled, .top-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.action-btn.strike { background: linear-gradient(180deg, #a3161b 0%, #5c0a0d 100%); border-color: #ff6b6b; }
.top-btn.big { padding: 12px 20px; font-size: 14px; }

.ad-btn {
    background: linear-gradient(180deg, #a86f00 0%, #5a3a00 100%);
    color: #fff;
    border: 1px solid var(--amber);
    border-bottom-color: #2b1c00;
    border-radius: 3px;
    padding: 4px;
    font-weight: 700;
    font-size: 11px;
    cursor: pointer;
    min-height: 34px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.15;
}
.ad-btn .ad-sub { font-size: 8.5px; color: #ffe9b0; }
.ad-btn:disabled { background: #262c31; border-color: #3c464f; color: #77828c; cursor: not-allowed; }
.ad-btn:disabled .ad-sub { color: #77828c; }
.ad-btn.big { padding: 12px 20px; font-size: 14px; }

/* ---------- In-game banners ---------- */
#topOverlay {
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 92%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    z-index: 14;
    pointer-events: none;
}
#hintBar {
    max-width: 100%;
    background: rgba(8, 12, 10, 0.88);
    border: 1px solid var(--neon);
    color: #e8ffd0;
    font-size: 12px;
    font-weight: 700;
    padding: 5px 12px;
    border-radius: 3px;
    text-align: center;
    pointer-events: none;
    z-index: 12;
    display: none;
    box-shadow: 0 0 10px rgba(158,255,0,0.25);
}
#toastStack {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    z-index: 13;
    pointer-events: none;
}
.toast {
    background: rgba(8, 12, 14, 0.9);
    border: 1px solid;
    font-size: 11.5px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 3px;
    white-space: nowrap;
    transition: opacity 0.5s;
}
.toast.fade { opacity: 0; }
@media (max-height: 460px) { .toast { font-size: 10px; } #airstrikeBanner { font-size: 11px; padding: 3px 10px; } #topOverlay { top: 4px; gap: 3px; } }
#phaseBanner {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    align-items: center;
    gap: 10px;
    background: rgba(8, 18, 24, 0.9);
    border: 1px solid var(--cyan);
    color: var(--cyan);
    font-weight: 700;
    font-size: 13px;
    padding: 4px 6px 4px 12px;
    border-radius: 3px;
    z-index: 12;
    white-space: nowrap;
    box-shadow: 0 0 12px rgba(79,227,255,0.25);
}
#skipPrepBtn {
    background: #0e3a47;
    color: #fff;
    border: 1px solid var(--cyan);
    border-radius: 2px;
    font-weight: 700;
    font-size: 11px;
    padding: 5px 9px;
    cursor: pointer;
}
#airstrikeBanner {
    background: rgba(170, 0, 0, 0.9);
    border: 1px solid var(--gold);
    color: #fff;
    padding: 5px 16px;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 1px;
    z-index: 15;
    display: none;
    white-space: nowrap;
    pointer-events: none;
    animation: blink 0.35s infinite;
}

/* ---------- Overlays ---------- */
.overlay {
    position: absolute;
    inset: 0;
    background: rgba(8, 11, 13, 0.94);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 30;
    text-align: center;
    padding: 12px;
    overflow-y: auto;
}
.overlay h1 {
    color: #ff3b3b;
    font-size: clamp(24px, 6vh, 44px);
    margin: 0 0 6px 0;
    letter-spacing: 4px;
    text-shadow: 0 0 18px rgba(255, 40, 40, 0.75), 2px 2px 0 #000;
}
.menu-sub { color: #c9f59a; font-size: 12.5px; max-width: 640px; margin: 4px 0; line-height: 1.4; }
.menu-best { margin-top: 10px; color: var(--amber); font-weight: 700; font-size: 13px; }
.muted { color: var(--muted); font-size: 12.5px; margin: 4px 0 8px; }
.tiny { font-size: 10px; color: var(--muted); margin-top: 10px; }

.sector-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 10px;
    width: min(640px, 100%);
}
.sector-btn {
    background: linear-gradient(180deg, #2a333b 0%, #181e23 100%);
    border: 1px solid var(--edge-hi);
    border-bottom-color: #090c0e;
    border-radius: 3px;
    color: #fff;
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    text-align: left;
    min-height: 54px;
}
.sector-btn:active { border-color: var(--amber); }
@media (hover: hover) { .sector-btn:hover { border-color: var(--amber); background: #2e2716; } }
.sector-btn span { display: block; font-size: 11px; color: var(--muted); font-weight: 400; margin-top: 3px; }

.go-buttons, .modal-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 10px; }

.fullscreen-modal {
    position: fixed;
    inset: 0;
    background: rgba(5, 7, 9, 0.96);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    text-align: center;
    padding: 10px;
}
.modal-box {
    border: 1px solid var(--edge-hi);
    border-radius: 4px;
    padding: 16px 18px;
    background: linear-gradient(180deg, #222a31 0%, #161b20 100%);
    width: min(540px, 94vw);
    max-height: 94vh;
    overflow-y: auto;
    text-align: center;
    box-shadow: 0 0 40px #000, inset 0 1px 0 rgba(255,255,255,0.06);
}
.modal-box.wide { width: min(660px, 94vw); }
.modal-box h2 { margin: 0 0 4px; letter-spacing: 1px; }
#adTimerText { font-size: 38px; color: var(--neon); margin: 10px 0; font-weight: 700; text-shadow: 0 0 10px rgba(158,255,0,0.45); }
.progress-bar { width: 100%; height: 18px; background: #070a0c; border: 1px solid #39444e; }
#adProgress { width: 0%; height: 100%; background: linear-gradient(90deg, var(--amber), var(--gold)); transition: width 0.2s; }

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    background: #10151a;
    border: 1px solid #2c363f;
    padding: 6px 10px;
    margin: 5px 0;
    font-size: 12px;
    text-align: left;
}
.toggle-btn { padding: 6px 10px; font-weight: 700; cursor: pointer; border: 1px solid #555; border-radius: 2px; white-space: nowrap; font-size: 11px; }
.toggle-on { background: #1b5e20; color: #fff; border-color: #4caf50; }
.toggle-off { background: #4a1515; color: #ccc; border-color: #aa2222; }

.perk-grid { display: flex; gap: 8px; margin-top: 8px; }
.perk-card {
    flex: 1;
    background: linear-gradient(180deg, #24313a 0%, #141b20 100%);
    border: 1px solid var(--neon);
    border-radius: 3px;
    padding: 10px 8px;
    cursor: pointer;
    color: #fff;
}
.perk-card:active { transform: scale(0.97); }
@media (hover: hover) { .perk-card:hover { border-color: var(--amber); transform: translateY(-2px); } }
.perk-icon { font-size: 22px; }
.perk-count { font-size: 10px; color: var(--muted); margin-top: 5px; letter-spacing: 1px; }
.perk-card.maxed { opacity: 0.35; pointer-events: none; border-color: var(--edge); }
.perk-title { font-weight: 700; margin: 5px 0; font-size: 12.5px; }
.perk-desc { font-size: 11px; color: #c4ccd2; }

/* ---------- Portrait phones: ask to rotate ---------- */
#rotateOverlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: var(--bg);
    color: var(--neon);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 16px;
    font-weight: 700;
    text-align: center;
    padding: 20px;
}
.rotate-icon { font-size: 48px; }
@media (orientation: portrait) and (max-width: 900px) {
    #rotateOverlay { display: flex; }
}

/* ---------- Short landscape phones: compact everything ---------- */
@media (max-height: 460px) {
    #sidePanel { gap: 3px; padding: 4px; }
    .stat-item { font-size: 11px; padding: 1px 5px; }
    .stat-item.credits { font-size: 14px; }
    .card-sub { display: none; }
    .card-icon { font-size: 13px; }
    .card-title { font-size: 9.5px; }
    .action-btn, .ad-btn { min-height: 30px; font-size: 10px; padding: 3px; }
    .ad-btn .ad-sub { font-size: 8px; }
    #hintBar { font-size: 10.5px; padding: 3px 8px; }
    #phaseBanner { font-size: 11px; bottom: 4px; }
    .menu-sub { font-size: 11px; }
    .sector-btn { padding: 6px 10px; min-height: 44px; font-size: 12px; }
    .sector-btn span { font-size: 10px; }
    .modal-box { padding: 10px 12px; }
    .setting-row { padding: 4px 8px; margin: 3px 0; }
    #adTimerText { font-size: 28px; margin: 6px 0; }
    .perk-card { padding: 6px; }
    .perk-desc { font-size: 10px; }
}
@media (max-height: 360px) {
    .stat-item .lbl { display: none; }
    .card-icon { display: none; }
}

/* =====================================================================
   v6 — menus, missions, cards, banners, boss bar, combo
   ===================================================================== */
.card.ghost { visibility: hidden; }
.build-cards { max-height: 600px; }

.menu-bg {
    background:
        radial-gradient(ellipse at 50% 30%, rgba(255, 40, 40, 0.10) 0%, transparent 60%),
        repeating-linear-gradient(0deg, rgba(255,255,255,0.025) 0 1px, transparent 1px 4px),
        rgba(8, 11, 13, 0.96);
}
.title {
    font-size: clamp(34px, 11vh, 72px) !important;
    letter-spacing: 8px !important;
    margin-bottom: 0 !important;
    animation: titleGlow 2.4s ease-in-out infinite;
}
@keyframes titleGlow {
    0%, 100% { text-shadow: 0 0 18px rgba(255, 40, 40, 0.75), 3px 3px 0 #000; }
    50% { text-shadow: 0 0 34px rgba(255, 60, 60, 1), 3px 3px 0 #000; }
}
.tagline { color: var(--amber); letter-spacing: 4px; font-size: 12px; font-weight: 700; margin-bottom: 8px; }
.menu-medals { color: var(--gold); font-weight: 700; font-size: 13px; margin: 4px 0 10px; }
.menu-buttons { display: flex; flex-direction: column; gap: 8px; width: min(420px, 90%); }
.menu-btn {
    background: linear-gradient(180deg, #2f3a44 0%, #1a2128 100%);
    color: #fff;
    border: 1px solid var(--edge-hi);
    border-bottom-color: #0b0f12;
    border-radius: 4px;
    padding: 12px 16px;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 1px;
    cursor: pointer;
    transition: transform 0.08s;
}
.menu-btn:active { transform: scale(0.97); }
.menu-btn.primary {
    background: linear-gradient(180deg, #5e8f00 0%, #2f4a00 100%);
    border-color: var(--neon);
    box-shadow: 0 0 14px rgba(158,255,0,0.35);
    animation: pulseBtn 1.6s ease-in-out infinite;
}
@keyframes pulseBtn { 50% { box-shadow: 0 0 24px rgba(158,255,0,0.6); } }
.menu-btn.glow { border-color: var(--gold); box-shadow: 0 0 12px rgba(255,204,0,0.5); }
.menu-btn.glow::after { content: " • NEW"; color: var(--gold); }
@media (hover: hover) { .menu-btn:hover { border-color: var(--amber); } }

.mission-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    width: min(760px, 100%);
    margin: 6px 0 10px;
}
.mission-card {
    position: relative;
    background: linear-gradient(180deg, #2a333b 0%, #161c21 100%);
    border: 1px solid var(--edge-hi);
    border-radius: 4px;
    padding: 8px 8px 6px;
    text-align: left;
    cursor: pointer;
    min-height: 82px;
    overflow: hidden;
}
.mission-card::before { content: ""; position: absolute; inset: 0; opacity: 0.25; pointer-events: none; }
.mission-card.woodland::before { background: linear-gradient(135deg, #3d5a2a, transparent 70%); }
.mission-card.desert::before { background: linear-gradient(135deg, #8a6534, transparent 70%); }
.mission-card.frozen::before { background: linear-gradient(135deg, #9fb4bf, transparent 70%); }
.mission-card.ironwaste::before { background: linear-gradient(135deg, #7a1d12, transparent 70%); }
.mission-card:active:not(.locked) { transform: scale(0.97); }
@media (hover: hover) { .mission-card:hover:not(.locked) { border-color: var(--amber); } }
.mission-card.locked { opacity: 0.4; cursor: not-allowed; }
.mc-num { position: absolute; right: 8px; top: 2px; font-size: 26px; font-weight: 700; color: rgba(255,255,255,0.12); }
.mc-name { font-weight: 700; font-size: 12.5px; color: #fff; position: relative; }
.mc-info { font-size: 10px; color: var(--muted); margin-top: 2px; position: relative; }
.mc-stars { margin-top: 6px; font-size: 16px; color: #3a434b; position: relative; }
.mc-stars .on { color: var(--gold); text-shadow: 0 0 6px rgba(255,204,0,0.6); }

.meta-list { display: flex; flex-direction: column; gap: 6px; width: min(560px, 100%); margin: 6px 0 10px; }
.meta-row {
    display: flex; align-items: center; gap: 10px;
    background: #10151a; border: 1px solid #2c363f; border-radius: 3px;
    padding: 6px 10px; text-align: left;
}
.meta-icon { font-size: 22px; }
.meta-text { flex: 1; }
.meta-name { font-weight: 700; font-size: 12.5px; color: #fff; }
.meta-lvl { color: var(--neon); font-size: 11px; letter-spacing: 1px; margin-left: 4px; }
.meta-desc { font-size: 11px; color: var(--muted); }
.meta-desc b { color: #e8ffd0; }
.meta-buy { min-width: 64px; }

/* Upgrade cards */
.card-choices { display: flex; gap: 10px; margin: 10px 0; flex-wrap: wrap; justify-content: center; }
.upgrade-card {
    width: clamp(130px, 22vw, 190px);
    background: linear-gradient(180deg, #26313a 0%, #141a1f 100%);
    border: 2px solid var(--edge-hi);
    border-radius: 6px;
    padding: 10px 8px;
    cursor: pointer;
    text-align: center;
    animation: cardIn 0.35s cubic-bezier(.2,1.4,.4,1) both;
    transition: transform 0.1s;
}
.upgrade-card:active { transform: scale(0.95); }
@media (hover: hover) { .upgrade-card:hover { transform: translateY(-4px); } }
@keyframes cardIn { from { opacity: 0; transform: translateY(30px) scale(0.85); } to { opacity: 1; transform: none; } }
.upgrade-card.common { border-color: #8fa0a8; }
.upgrade-card.rare { border-color: #4fa8ff; box-shadow: 0 0 14px rgba(79,168,255,0.35); }
.upgrade-card.epic { border-color: #c56bff; box-shadow: 0 0 20px rgba(197,107,255,0.5); }
.uc-rarity { font-size: 9px; letter-spacing: 2px; font-weight: 700; color: var(--muted); }
.upgrade-card.rare .uc-rarity { color: #4fa8ff; }
.upgrade-card.epic .uc-rarity { color: #c56bff; }
.uc-icon { font-size: 30px; margin: 4px 0; }
.uc-name { font-weight: 700; font-size: 13px; color: #fff; }
.uc-desc { font-size: 11.5px; color: #c4ccd2; margin: 4px 0; min-height: 30px; }
.uc-rank { font-size: 9.5px; color: var(--neon); letter-spacing: 1px; }

/* Victory */
.win-title { color: var(--neon) !important; text-shadow: 0 0 18px rgba(158,255,0,0.6), 2px 2px 0 #000 !important; }
.victory-stars { font-size: clamp(40px, 12vh, 70px); letter-spacing: 8px; margin: 2px 0; }
.vstar { color: #2b333a; display: inline-block; }
.vstar.on { color: var(--gold); animation: starPop 0.5s cubic-bezier(.2,1.6,.4,1) both; text-shadow: 0 0 18px rgba(255,204,0,0.8); }
@keyframes starPop { from { transform: scale(0) rotate(-90deg); opacity: 0; } to { transform: none; opacity: 1; } }
.victory-stats { font-size: 13px; color: #e8ffd0; font-weight: 700; }
.unlock-note { color: var(--gold); font-weight: 700; margin-top: 6px; font-size: 13px; animation: blink 1s 3; }
.small { font-size: 11px; }
.tip { color: var(--amber); font-size: 12px; margin-top: 10px; }

/* Wave HUD bits */
#missionTag {
    font-size: 10px; letter-spacing: 2px; font-weight: 700; color: var(--muted);
    background: rgba(8,12,14,0.7); padding: 2px 8px; border-radius: 2px;
}
#missionTag:empty { display: none; }
#bossBar { display: none; width: min(420px, 80%); }
.boss-label { color: #ff4d4d; font-weight: 700; font-size: 11px; letter-spacing: 2px; text-align: center; text-shadow: 0 0 8px rgba(255,0,0,0.6); }
.boss-track { height: 10px; background: #1a0606; border: 1px solid #ff4d4d; border-radius: 2px; overflow: hidden; }
#bossFill { height: 100%; width: 100%; background: linear-gradient(90deg, #ff1744, #ff8a00); transition: width 0.15s; }

#comboMeter {
    display: none;
    position: absolute; right: 12px; top: 50%;
    transform: translateY(-50%) rotate(-4deg);
    color: #ff9800; font-weight: 700; font-size: 20px;
    text-shadow: 0 0 12px rgba(255,120,0,0.8), 2px 2px 0 #000;
    pointer-events: none; z-index: 13;
    animation: comboPulse 0.4s ease-in-out infinite alternate;
}
@keyframes comboPulse { to { transform: translateY(-50%) rotate(-4deg) scale(1.12); } }

#bigBanner {
    position: absolute; left: 0; right: 0; top: 38%;
    text-align: center; pointer-events: none; z-index: 16;
    opacity: 0;
}
#bigBanner.show { animation: bannerIn 1.9s ease-out both; }
@keyframes bannerIn {
    0% { opacity: 0; transform: scale(1.8); }
    12% { opacity: 1; transform: scale(1); }
    80% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(0.95) translateY(-10px); }
}
.bb-title { font-size: clamp(22px, 7vh, 44px); font-weight: 700; letter-spacing: 3px; text-shadow: 0 0 20px currentColor, 3px 3px 0 #000; }
.bb-sub { color: var(--gold); font-weight: 700; font-size: clamp(14px, 3.5vh, 22px); text-shadow: 2px 2px 0 #000; }

@media (max-height: 460px) {
    .mission-grid { grid-template-columns: repeat(5, 1fr); gap: 5px; }
    .mission-card { min-height: 64px; padding: 5px 6px; }
    .mc-name { font-size: 11px; }
    .mc-stars { font-size: 13px; margin-top: 3px; }
    .menu-btn { padding: 8px 12px; font-size: 12.5px; }
    .menu-buttons { gap: 5px; }
    .upgrade-card { padding: 6px; }
    .uc-icon { font-size: 22px; margin: 2px 0; }
    .uc-desc { font-size: 10.5px; min-height: 0; }
    .meta-row { padding: 4px 8px; }
    .meta-icon { font-size: 18px; }
    #comboMeter { font-size: 16px; }
}
@media (max-width: 640px) {
    .mission-grid { grid-template-columns: repeat(2, 1fr); }
}

body.in-menu #sidePanel { display: none; }

#hintBar { pointer-events: auto; cursor: pointer; }
.hint-x { display: inline-block; margin-left: 6px; padding: 0 5px; border: 1px solid rgba(158,255,0,0.5); border-radius: 2px; font-size: 10px; color: #9eff00; }

/* =====================================================================
   v7 — industrial command panel
   ===================================================================== */
:root { --font: "Rajdhani", "Bahnschrift", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif; --led: "Orbitron", "Rajdhani", monospace; }
body { font-weight: 600; }
#sidePanel {
    background:
        radial-gradient(circle at 8px 8px, #9aa4aa 1.2px, transparent 1.6px) 0 0 / 100% 100% no-repeat,
        radial-gradient(circle at calc(100% - 8px) 8px, #9aa4aa 1.2px, transparent 1.6px) 0 0 / 100% 100% no-repeat,
        repeating-linear-gradient(90deg, rgba(255,255,255,0.025) 0 1px, transparent 1px 3px),
        linear-gradient(180deg, #3a4249 0%, #22282d 45%, #191d21 100%);
    border-left: 3px solid #12161a;
    box-shadow: inset 2px 0 0 rgba(255,255,255,0.08), inset -1px 0 0 rgba(0,0,0,0.5), -4px 0 14px rgba(0,0,0,0.6);
}
#stats { background: #0b0f12; border: 1px solid #000; border-radius: 3px; padding: 3px; box-shadow: inset 0 0 8px rgba(0,0,0,0.9), 0 1px 0 rgba(255,255,255,0.08); }
.stat-item { background: transparent; border: none; border-bottom: 1px solid #1c2328; font-family: var(--led); font-weight: 600; font-size: 11px; letter-spacing: 0.5px; }
.stat-item .lbl { font-family: var(--font); font-weight: 700; color: #7d8a94; }
.stat-item.credits { font-size: 17px; border-bottom: 1px solid #2a3238; }
.gold-text { color: #ffcc33; text-shadow: 0 0 10px rgba(255,190,40,0.7); }

.card {
    background: linear-gradient(180deg, #2c343a 0%, #1a1f23 100%);
    border: 1px solid #0d1013;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.1), inset 0 -1px 0 rgba(0,0,0,0.6);
    border-radius: 3px;
    justify-content: flex-end;
    padding-bottom: 3px;
}
.card-icon { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; width: 100%; font-size: 0; }
.card-icon img { height: 100%; max-height: 44px; width: auto; max-width: 70%; object-fit: contain; filter: drop-shadow(0 2px 2px rgba(0,0,0,0.6)); }
.card-title { font-family: var(--font); font-weight: 700; font-size: 11px; letter-spacing: 1px; line-height: 1; }
.card-cost { font-family: var(--led); font-size: 10px; line-height: 1.2; }
.card-sub { display: none; }
.card.active:not(.locked) {
    border: 1px solid #9eff00;
    background: linear-gradient(180deg, #2f3d1c 0%, #18200d 100%);
    box-shadow: inset 0 0 14px rgba(158,255,0,0.25), 0 0 10px rgba(158,255,0,0.35);
}
.card.locked { filter: grayscale(1) brightness(0.55); opacity: 1; }
.card.locked::after { content: "🔒"; position: absolute; top: 3px; right: 4px; font-size: 11px; }
@media (min-height: 600px) { .card-sub { display: block; } .card-icon img { max-height: 56px; } }

.action-btn, .top-btn, .menu-btn {
    font-family: var(--font);
    font-weight: 700;
    letter-spacing: 1px;
    background: linear-gradient(180deg, #4a545c 0%, #2a3136 50%, #20262a 100%);
    border: 1px solid #0d1013;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.18), 0 2px 3px rgba(0,0,0,0.5);
}
.action-btn.strike { background: linear-gradient(180deg, #b3261e 0%, #6d0f0b 100%); box-shadow: inset 0 1px 0 rgba(255,255,255,0.25), 0 0 8px rgba(255,40,30,0.35); }
.ad-btn { font-family: var(--font); letter-spacing: 1px; background: linear-gradient(180deg, #c48a00 0%, #6e4b00 100%); box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), 0 0 8px rgba(255,180,0,0.3); }
.menu-btn.primary { background: linear-gradient(180deg, #6fa300 0%, #335000 100%); }

#phaseBanner, #hintBar, .toast, #missionTag {
    font-family: var(--font);
    background: linear-gradient(180deg, rgba(20,26,30,0.92), rgba(8,11,13,0.92));
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 2px 8px rgba(0,0,0,0.6);
}
.title { font-family: var(--led) !important; font-weight: 800 !important;
    background: linear-gradient(180deg, #ff8a7a 0%, #ff2b1a 45%, #8a0b05 100%);
    -webkit-background-clip: text; background-clip: text; color: transparent !important;
    filter: drop-shadow(0 0 14px rgba(255,40,30,0.6)) drop-shadow(3px 3px 0 #000); text-shadow: none !important; animation: none !important; }
.bb-title, .win-title, .overlay h1, .overlay h2 { font-family: var(--led); letter-spacing: 3px; }
.menu-bg { background: radial-gradient(ellipse at 50% 40%, rgba(10,14,16,0.35) 0%, rgba(5,7,9,0.88) 75%); }
.mission-card, .upgrade-card, .meta-row { box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 3px 8px rgba(0,0,0,0.5); }
.mc-name, .uc-name, .meta-name { font-family: var(--font); letter-spacing: 1px; }
canvas { border: 2px solid #0d1013; box-shadow: 0 0 0 1px #3a4249, 0 0 30px rgba(0,0,0,0.9); }

.card-icon { flex: 1 1 auto; min-height: 0; height: auto; max-height: 60px; }
.card-icon img { height: 100%; max-height: 100%; max-width: 90%; }
.card-title { white-space: nowrap; font-size: clamp(9px, 2.4vh, 12px); }

#stats .stat-item:has(#powerDisplay) { grid-column: 1 / -1; }

/* Phones (short landscape): icon on the left, name + price stacked on the right */
@media (max-height: 520px) {
    .build-cards .card {
        display: grid;
        grid-template-columns: 30px 1fr;
        grid-template-rows: 1fr 1fr;
        align-items: center;
        justify-items: start;
        column-gap: 4px;
        padding: 2px 5px;
        text-align: left;
    }
    .build-cards .card .card-icon { grid-row: 1 / 3; grid-column: 1; width: 30px; height: 30px; max-height: 30px; flex: none; }
    .build-cards .card .card-icon img { width: 30px; height: 30px; max-width: none; max-height: none; }
    .build-cards .card .card-title { grid-row: 1; grid-column: 2; align-self: end; font-size: 10px; letter-spacing: 0.5px; white-space: nowrap; }
    .build-cards .card .card-cost { grid-row: 2; grid-column: 2; align-self: start; }
    .build-cards .card .card-sub { display: none; }
}
@media (max-height: 520px) {
    .build-cards .card.locked::after { top: auto; bottom: 3px; right: 4px; font-size: 9px; }
    #card-repair .card-cost, #card-sell .card-cost { font-size: 9px; white-space: nowrap; }
}

/* war HUD: hostiles / kills / crew */
#warHud { position: absolute; top: 6px; right: 8px; display: none; flex-direction: column; align-items: flex-end; gap: 3px; z-index: 13; pointer-events: none; }
.wh-pill { display: flex; align-items: center; gap: 5px; background: rgba(8,10,12,0.82); border: 1px solid #3a444c; border-radius: 3px; padding: 2px 8px; font-family: var(--led, monospace); font-weight: 700; font-size: 13px; color: #e8eef2; }
.wh-ico { font-size: 12px; }
.wh-lbl { font-size: 8px; letter-spacing: 1.5px; color: #9aa7b0; font-family: var(--font); }
.wh-host { color: #ffb4a8; border-color: #6b2a24; }
.wh-host.danger { color: #fff; background: rgba(140,10,10,0.85); border-color: #ff4d4d; animation: blink 0.8s infinite; }
.wh-kill { color: #ffcc33; }
.wh-crew { color: #9fe0ff; font-size: 11px; }
@media (max-height: 460px) { .wh-pill { font-size: 11px; padding: 1px 6px; } #warHud { top: 4px; right: 4px; } }

body.cine #topOverlay, body.cine #bigBanner, body.cine #comboMeter, body.cine #warHud, body.cine #phaseBanner { visibility: hidden; }

.bb-title.long { font-size: clamp(16px, 4.6vh, 30px); letter-spacing: 1.5px; padding: 0 12px; }
.bb-sub { padding: 0 12px; }

/* infantry squad class picker (floats over the battlefield while the INFANTRY tool is selected) */
#squadBar { position: absolute; left: 8px; bottom: 8px; display: none; flex-direction: column; gap: 4px; z-index: 14; }
body.squad-mode #squadBar { display: flex; }
body.cine #squadBar { visibility: hidden; }
.sq-chip { display: flex; flex-direction: column; align-items: flex-start; text-align: left; min-width: 150px; padding: 5px 9px; border-radius: 3px;
    background: rgba(10,14,16,0.9); border: 1px solid #3a444c; color: #dfe8ee; font-family: var(--font); cursor: pointer; }
.sq-chip b { font-size: 12px; letter-spacing: 0.5px; }
.sq-chip span { font-size: 9.5px; color: #9aa7b0; }
.sq-chip.on { border-color: #9eff00; background: rgba(30,48,14,0.92); box-shadow: 0 0 8px rgba(158,255,0,0.35); }
.name-select { background: #10161a; color: #e8f1f6; border: 1px solid #3a444c; border-radius: 3px; padding: 5px 6px; font-family: var(--font); font-weight: 700; font-size: 11px; max-width: 48%; }
@media (max-height: 460px) { .sq-chip { min-width: 120px; padding: 3px 7px; } .sq-chip b { font-size: 10.5px; } .sq-chip span { font-size: 8.5px; } }

/* squad picker: compact row in the top-left corner so it doesn't hide the battlefield */
#squadBar { top: 34px; bottom: auto; left: 6px; flex-direction: row; gap: 4px; }
.sq-chip { min-width: 0; padding: 4px 8px; }
.sq-chip span { display: none; }
@media (max-height: 460px) { #squadBar { top: 28px; } .sq-chip { padding: 2px 6px; } }
#squadBar { flex-direction: column; align-items: flex-start; }
.sq-chip b { font-size: 11px; }

/* ---------- v10: low power alert ---------- */
body.lowpower #gameContainer::after {
    content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 4;
    box-shadow: inset 0 0 40px rgba(255, 30, 30, 0.45);
    animation: lpEdge 1.4s ease-in-out infinite;
}
body.lowpower-severe #gameContainer::after { box-shadow: inset 0 0 70px rgba(255, 20, 20, 0.7); animation-duration: 0.8s; }
@keyframes lpEdge { 50% { opacity: 0.25; } }
body.lowpower .stat-item:has(#powerDisplay) { background: rgba(255, 40, 40, 0.18); outline: 1px solid rgba(255, 70, 70, 0.7); }
body.lowpower #card-power:not(.active) { animation: lpCard 0.9s ease-in-out infinite; }
@keyframes lpCard {
    50% { box-shadow: 0 0 0 2px #ff3b2a, 0 0 18px rgba(255, 59, 42, 0.8); border-color: #ff3b2a; }
}
body.in-menu #gameContainer::after { display: none; }
#hintBar { cursor: pointer; }

/* ---------- v10: seasons, daily supply, ad stats ---------- */
.season-strip {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center;
    background: linear-gradient(90deg, rgba(255,179,0,0.12), rgba(158,255,0,0.08));
    border: 1px solid rgba(255,179,0,0.45); border-radius: 3px;
    padding: 5px 12px; margin: 2px 0 8px; font-size: 12px; font-weight: 700; cursor: pointer; color: #ffe9b0;
}
.season-strip .ss-day { color: var(--neon); }
.season-strip .ss-tier { color: var(--muted); font-weight: 600; }
.sbar { display: inline-block; width: 90px; height: 7px; background: #070a0c; border: 1px solid #3a444d; vertical-align: middle; }
.sbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--amber), var(--neon)); }
.season-mini { display: flex; gap: 10px; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #ffe9b0; margin-top: 4px; }
.season-head { margin-bottom: 8px; }
.season-head .amber { font-family: "Orbitron", sans-serif; font-size: 17px; letter-spacing: 1px; }
.season-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; width: min(720px, 100%); margin-bottom: 10px; }
.tier { background: #141a1f; border: 1px solid #2f3a43; border-radius: 3px; padding: 5px 2px; font-size: 11px; color: var(--muted); position: relative; min-height: 50px; }
.tier .t-num { font-family: "Orbitron", sans-serif; font-size: 12px; color: #cfd8dc; }
.tier .t-rew { margin-top: 2px; font-weight: 700; }
.tier .t-rank { font-size: 8.5px; color: var(--amber); letter-spacing: 0.5px; }
.tier.big { border-color: rgba(255,179,0,0.5); }
.tier.got { background: rgba(158,255,0,0.12); border-color: rgba(158,255,0,0.55); color: var(--neon); }
.tier.next { border-color: var(--amber); box-shadow: 0 0 10px rgba(255,179,0,0.4); }
.tier .t-bar { position: absolute; left: 3px; right: 3px; bottom: 3px; height: 3px; background: #070a0c; }
.tier .t-bar i { display: block; height: 100%; background: var(--amber); }
.link-btn { background: none; border: none; color: var(--muted); font-size: 11px; margin-top: 8px; cursor: pointer; text-decoration: underline; font-family: inherit; }
.daily-box { width: min(600px, 94vw); }
.daily-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 10px 0 4px; }
.dslot { background: #10151a; border: 1px solid #2f3a43; border-radius: 3px; padding: 7px 2px; font-size: 10.5px; color: var(--muted); }
.dslot b { display: block; font-size: 13px; color: #ffe9b0; margin-top: 3px; }
.dslot.done { opacity: 0.55; }
.dslot.done b { color: var(--neon); }
.dslot.today { border-color: var(--amber); box-shadow: 0 0 12px rgba(255,179,0,0.5); background: rgba(255,179,0,0.1); transform: scale(1.06); }
.stats-body { width: min(760px, 100%); }
.ad-table { width: 100%; border-collapse: collapse; font-size: 12px; margin: 8px 0; }
.ad-table th, .ad-table td { border: 1px solid #2f3a43; padding: 4px 6px; text-align: center; }
.ad-table th { background: #1a2127; color: var(--amber); font-size: 11px; }
.ad-table td:first-child { text-align: left; color: #e8eef2; }
#adSkipBtn { margin-top: 10px; visibility: hidden; }
@media (max-height: 520px) {
    .season-grid { grid-template-columns: repeat(10, 1fr); gap: 3px; }
    .tier { min-height: 40px; padding: 3px 1px; font-size: 10px; }
    .season-strip { padding: 3px 8px; margin: 0 0 4px; font-size: 11px; }
    .ad-table { font-size: 10.5px; }
    .ad-table th, .ad-table td { padding: 2px 4px; }
}
.season-strip > span { white-space: nowrap; flex-shrink: 0; }
.tier .t-bar { top: 3px; bottom: auto; }
.ad-table td { background: #0e1317; }

/* ---------- v11: story intro ---------- */
#storyCanvas { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 9000; display: none; background: #000; touch-action: none; cursor: pointer; }

/* ---------- v11: role colours + build tips ---------- */
#buildTip {
    display: none; pointer-events: auto; cursor: pointer;
    margin: 6px auto 0; max-width: min(520px, 92%);
    background: rgba(10, 14, 18, 0.94); border: 1px solid #3a4651; border-radius: 6px;
    padding: 6px 10px; gap: 10px; align-items: center; text-align: left;
    box-shadow: 0 4px 18px rgba(0,0,0,0.6);
}
#buildTip.show { display: flex; animation: cardIn 0.25s ease-out; }
#buildTip img { width: 40px; height: 40px; flex-shrink: 0; }
#buildTip b { display: block; font-size: 13px; letter-spacing: 1px; }
#buildTip span { font-size: 12px; color: #d9e2e8; line-height: 1.3; }
@media (max-height: 520px) {
    .build-cards .card { grid-template-columns: 30px max-content; justify-content: start; overflow: hidden; }
}
.uc-affects { font-size: 10.5px; color: #4fe3ff; font-weight: 700; letter-spacing: 0.5px; margin-top: 3px; }
.uc-plain { font-size: 10.5px; color: #c9d4da; margin-top: 3px; line-height: 1.25; }
@media (max-height: 460px) { .uc-plain { display: none; } }

/* ---------- v11: cyber attack ---------- */
body.cyber #gameContainer::before {
    content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 5;
    background: repeating-linear-gradient(0deg, rgba(57,255,138,0.07) 0 2px, transparent 2px 5px);
    box-shadow: inset 0 0 60px rgba(57,255,138,0.35);
    animation: cyberFlick 0.18s steps(2) infinite;
}
@keyframes cyberFlick { 50% { opacity: 0.55; transform: translateX(1px); } }
body.cyber .build-cards { filter: grayscale(0.8) brightness(0.6); }
@media (max-height: 520px) {
    .build-cards .card { grid-template-columns: 26px max-content; column-gap: 3px; padding: 2px 3px 2px 4px; }
    .build-cards .card .card-icon, .build-cards .card .card-icon img { width: 26px; height: 26px; }
    .build-cards .card .card-title { font-size: 9.5px !important; letter-spacing: 0 !important; }
}

/* ---------- v12: video story layer ---------- */
#storyLayer { position: fixed; inset: 0; z-index: 9000; background: #000; display: none; cursor: pointer; opacity: 1; transition: opacity 0.35s; }
#storyLayer.out { opacity: 0; }
#storyLayer video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
#storyLayer .sv-shade { position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(180deg, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0) 22%, rgba(0,0,0,0) 70%, rgba(0,0,0,0.75) 100%); }
#storyLayer .sv-title { position: absolute; top: 14px; left: 18px; font-family: var(--led, "Orbitron", sans-serif); font-size: clamp(16px, 4vh, 26px); font-weight: 800;
    color: #ff3b3b; letter-spacing: 2px; text-shadow: 0 0 14px rgba(255,40,30,0.6), 2px 2px 0 #000; }
#storyLayer .sv-title small { display: block; font-size: 0.55em; color: #ffb300; letter-spacing: 3px; }
#storyLayer .sv-cap { position: absolute; left: 50%; bottom: 5vh; transform: translateX(-50%); width: min(92%, 900px); text-align: center;
    font-family: var(--font, sans-serif); font-weight: 700; font-size: clamp(14px, 3.6vh, 22px); color: #f2ede0; text-shadow: 0 2px 6px #000, 0 0 2px #000; }
#storyLayer .sv-cap.red { color: #ff6b5b; }
#storyLayer .sv-tag { position: absolute; right: 4vw; bottom: 16vh; display: none; background: rgba(0,0,0,0.75); border: 1px solid #ffb300;
    color: #ffcc33; font-family: var(--font, sans-serif); font-weight: 700; letter-spacing: 1px; padding: 6px 12px; font-size: clamp(12px, 3vh, 16px); }
#storyLayer .sv-skip { position: absolute; top: 12px; right: 14px; background: rgba(0,0,0,0.55); border: 1px solid #ffcc33; color: #ffcc33;
    font-weight: 700; letter-spacing: 1px; padding: 6px 12px; border-radius: 3px; font-family: var(--font, sans-serif); cursor: pointer; }

/* ---------- v13: isometric battlefield ---------- */
body.iso #gameCanvas { border: none; box-shadow: none; touch-action: none; cursor: grab; }
body.iso #gameCanvas:active { cursor: grabbing; }

/* ---------- v13.1: very short screens (phone browser with address bar) ---------- */
#sidePanel { overflow-y: auto; overscroll-behavior: contain; }
@media (max-height: 340px) {
    #stats { padding: 3px 6px !important; gap: 0 !important; }
    #stats .stat-item { padding: 0 !important; min-height: 0 !important; }
    #stats .lbl { font-size: 8px !important; }
    #stats span:not(.lbl) { font-size: 12px !important; }
    #stats .credits span:not(.lbl) { font-size: 15px !important; }
    .build-cards { gap: 3px !important; }
    .build-cards .card { min-height: 0 !important; height: 32px !important; padding: 1px 3px 1px 4px !important; }
    .build-cards .card .card-icon, .build-cards .card .card-icon img { width: 22px !important; height: 22px !important; }
    .build-cards .card .card-title { font-size: 9px !important; }
    .build-cards .card .card-cost { font-size: 9px !important; }
    .build-cards .card .hotkey { display: none !important; }
    .panel-actions { gap: 3px !important; }
    .panel-actions button { padding: 3px 4px !important; min-height: 0 !important; font-size: 10px !important; }
    .panel-actions .ad-sub { display: none !important; }
}
@media (max-height: 340px) {
    #stats .lbl { display: inline-block !important; font-size: 8px !important; margin-right: 4px; opacity: 0.85; }
    #stats .stat-item { display: flex !important; align-items: baseline; justify-content: space-between; }
}
