/* ═══════════════════════════════════════════════════════
   STARCONQUEST — STYLE v0.5
═══════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --neon:   #00d4ff;
    --gold:   #ffd700;
    --dark:   #000008;
    --panel:  rgba(0,4,20,0.97);
    --border: rgba(0,212,255,0.25);
}

html, body {
    width: 100%; height: 100%;
    overflow: hidden;
    background: var(--dark);
    font-family: 'Exo 2', sans-serif;
    color: #c8e0ff;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: none;
}

canvas#gameCanvas {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    display: block;
}

/* ── Scanlines ── */
.scanlines {
    position: fixed; inset: 0;
    pointer-events: none; z-index: 999;
    background: repeating-linear-gradient(
        0deg,
        rgba(0,212,255,0.015),
        rgba(0,212,255,0.015) 1px,
        transparent 1px, transparent 2px
    );
}

/* ── SCREEN ── */
.screen {
    display: none;
    position: fixed; inset: 0;
    z-index: 100;
}
.screen.active { display: flex; flex-direction: column; }

/* ─────────────────────────────────
   MENU
───────────────────────────────── */
/* ═══════════════════════════════════════
   MAIN MENU
═══════════════════════════════════════ */
#menuScreen {
    background: radial-gradient(ellipse at 50% 30%, #000d20 0%, #000008 75%);
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* subtle animated grid overlay */
.menu-bg-grid {
    position: absolute; inset: 0;
    background-image:
        linear-gradient(rgba(0,212,255,0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0,212,255,0.025) 1px, transparent 1px);
    background-size: 60px 60px;
    animation: gridDrift 20s linear infinite;
    pointer-events: none;
}
@keyframes gridDrift {
    from { transform: translateY(0); }
    to   { transform: translateY(60px); }
}

.menu-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: min(460px, 92vw);
    padding: clamp(28px, 6vw, 52px) clamp(16px, 5vw, 32px);
}

/* Logo */
.menu-logo { margin-bottom: clamp(28px, 7vw, 48px); text-align: center; }
.logo-title {
    font-family: 'Orbitron', monospace;
    font-size: clamp(1.8rem, 8vw, 3.6rem);
    font-weight: 900;
    color: var(--neon);
    letter-spacing: clamp(4px, 2vw, 12px);
    text-shadow: 0 0 40px rgba(0,212,255,0.8), 0 0 80px rgba(0,212,255,0.3);
    animation: titlePulse 3s ease-in-out infinite;
}
@keyframes titlePulse {
    0%,100% { text-shadow: 0 0 40px rgba(0,212,255,0.8), 0 0 80px rgba(0,212,255,0.3); }
    50%      { text-shadow: 0 0 65px rgba(0,212,255,1),   0 0 120px rgba(0,212,255,0.5); }
}
.logo-sub {
    font-family: 'Orbitron', monospace;
    font-size: clamp(0.52rem, 2.2vw, 0.78rem);
    color: rgba(0,212,255,0.5);
    letter-spacing: clamp(3px, 1.5vw, 9px);
    margin-top: 8px;
}

/* Nav buttons */
.menu-nav {
    display: flex;
    flex-direction: column;
    gap: clamp(10px, 2.5vw, 14px);
    width: 100%;
    margin-bottom: clamp(24px, 6vw, 40px);
}

.mnav-btn {
    width: 100%;
    min-height: clamp(64px, 15vw, 78px);
    background: rgba(0,212,255,0.04);
    border: 1.5px solid rgba(0,212,255,0.2);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.22s cubic-bezier(0.34,1.56,0.64,1);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    padding: 0;
    overflow: hidden;
}
.mnav-btn--primary {
    border-color: rgba(0,212,255,0.55);
    background: rgba(0,212,255,0.07);
    box-shadow: 0 0 22px rgba(0,212,255,0.1);
}
.mnav-btn--primary:hover,
.mnav-btn--primary:active {
    background: rgba(0,212,255,0.16);
    box-shadow: 0 0 38px rgba(0,212,255,0.28);
    transform: translateY(-3px);
}
.mnav-btn--locked {
    opacity: 0.32;
    cursor: not-allowed;
}

.mnav-inner {
    display: flex;
    align-items: center;
    gap: clamp(12px, 3.5vw, 20px);
    padding: clamp(14px, 3.5vw, 20px) clamp(16px, 4vw, 24px);
}
.mnav-icon  {
    font-size: clamp(1.4rem, 5vw, 1.9rem);
    flex-shrink: 0;
    line-height: 1;
}
.mnav-labels {
    flex: 1;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.mnav-title {
    font-family: 'Orbitron', monospace;
    font-size: clamp(0.75rem, 3vw, 0.95rem);
    font-weight: 700;
    letter-spacing: clamp(1.5px, 0.5vw, 3px);
    color: var(--neon);
    line-height: 1;
}
.mnav-desc {
    font-family: 'Exo 2', sans-serif;
    font-size: clamp(0.58rem, 1.8vw, 0.7rem);
    color: rgba(0,212,255,0.44);
    line-height: 1;
}
.mnav-arrow {
    font-size: clamp(1.1rem, 3.5vw, 1.4rem);
    color: rgba(0,212,255,0.5);
    flex-shrink: 0;
}
.mnav-badge {
    font-family: 'Orbitron', monospace;
    font-size: 0.5rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    background: rgba(0,212,255,0.08);
    border: 1px solid rgba(0,212,255,0.2);
    color: rgba(0,212,255,0.42);
    padding: 3px 8px;
    border-radius: 4px;
    flex-shrink: 0;
}

/* Controls hint */
.menu-controls-hint {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: clamp(16px, 4vw, 28px);
    background: rgba(0,212,255,0.03);
    border: 1px solid rgba(0,212,255,0.1);
    border-radius: 8px;
    padding: clamp(10px, 2.5vw, 14px) clamp(14px, 4vw, 18px);
    width: 100%;
}
.hint-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: clamp(0.6rem, 2vw, 0.7rem);
    font-family: 'Exo 2', sans-serif;
}
.hint-key { color: rgba(0,212,255,0.55); min-width: 90px; }
.hint-sep { color: rgba(0,212,255,0.25); }
.hint-val { color: rgba(0,212,255,0.38); }

.menu-version {
    font-family: 'Orbitron', monospace;
    font-size: 0.52rem;
    color: rgba(0,212,255,0.22);
    letter-spacing: 3px;
}

/* ═══════════════════════════════════════
   LOBBY SCREEN
═══════════════════════════════════════ */
#lobbyScreen {
    background: radial-gradient(ellipse at 50% 28%, #000d20 0%, #000008 75%);
    align-items: center;
    justify-content: flex-start;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-top: clamp(16px, 4vw, 28px);
    padding-bottom: clamp(24px, 6vw, 40px);
}

.lobby-content {
    position: relative;
    width: min(460px, 92vw);
    padding: 0 clamp(12px, 4vw, 20px);
    display: flex;
    flex-direction: column;
}

.lobby-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 1px solid rgba(0,212,255,0.18);
    color: rgba(0,212,255,0.5);
    font-family: 'Orbitron', monospace;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 2px;
    padding: 9px 14px;
    border-radius: 6px;
    cursor: pointer;
    margin-bottom: clamp(16px, 4vw, 24px);
    align-self: flex-start;
    transition: all 0.18s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.lobby-back-btn:hover, .lobby-back-btn:active {
    border-color: rgba(0,212,255,0.5);
    color: var(--neon);
    background: rgba(0,212,255,0.06);
}

.lobby-heading {
    font-family: 'Orbitron', monospace;
    font-size: clamp(0.95rem, 4.5vw, 1.3rem);
    font-weight: 900;
    color: var(--neon);
    letter-spacing: clamp(3px, 1.5vw, 8px);
    text-shadow: 0 0 24px rgba(0,212,255,0.4);
    margin-bottom: clamp(20px, 5vw, 32px);
    margin-top: 0;
}

.lobby-section {
    margin-bottom: clamp(18px, 4.5vw, 28px);
}

.lobby-section-label {
    font-family: 'Orbitron', monospace;
    font-size: clamp(0.52rem, 1.8vw, 0.62rem);
    font-weight: 700;
    letter-spacing: 2.5px;
    color: rgba(0,212,255,0.42);
    margin-bottom: clamp(9px, 2.5vw, 13px);
    text-transform: uppercase;
}

.lobby-hint {
    font-family: 'Exo 2', sans-serif;
    font-size: clamp(0.58rem, 1.9vw, 0.68rem);
    color: rgba(0,212,255,0.32);
    margin-top: 9px;
    line-height: 1.55;
    min-height: 18px;
}

/* Pills */
.lobby-pills {
    display: flex;
    gap: clamp(7px, 2vw, 11px);
}
.lobby-pill {
    flex: 1;
    min-height: clamp(52px, 13vw, 64px);
    background: rgba(0,212,255,0.03);
    border: 1.5px solid rgba(0,212,255,0.14);
    border-radius: 9px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: clamp(8px, 2vw, 12px) 6px;
    transition: all 0.18s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.lobby-pill:active { transform: scale(0.96); }
.lobby-pill:hover:not(.lobby-pill--active) {
    border-color: rgba(0,212,255,0.36);
    background: rgba(0,212,255,0.06);
}
.lobby-pill--active {
    border-color: var(--neon);
    background: rgba(0,212,255,0.12);
    box-shadow: 0 0 14px rgba(0,212,255,0.18);
}
.pill-name {
    font-family: 'Orbitron', monospace;
    font-size: clamp(0.65rem, 2.5vw, 0.8rem);
    font-weight: 700;
    letter-spacing: 0.5px;
    color: rgba(0,212,255,0.55);
    line-height: 1;
    transition: color 0.15s;
}
.lobby-pill--active .pill-name { color: var(--neon); }
.pill-sub {
    font-family: 'Exo 2', sans-serif;
    font-size: clamp(0.5rem, 1.5vw, 0.58rem);
    color: rgba(0,212,255,0.35);
}
.lobby-pill--active .pill-sub { color: rgba(0,212,255,0.6); }

/* Mode cards */
.lobby-modecards {
    display: flex;
    flex-direction: column;
    gap: clamp(8px, 2vw, 11px);
}
.lobby-modecard {
    display: flex;
    align-items: center;
    gap: clamp(11px, 3vw, 16px);
    padding: clamp(13px, 3.5vw, 17px) clamp(14px, 4vw, 18px);
    background: rgba(0,212,255,0.03);
    border: 1.5px solid rgba(0,212,255,0.14);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.18s;
    text-align: left;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    min-height: clamp(60px, 14vw, 74px);
}
.lobby-modecard:active { transform: scale(0.98); }
.lobby-modecard:hover:not(.lobby-modecard--active) {
    border-color: rgba(0,212,255,0.36);
    background: rgba(0,212,255,0.06);
}
.lobby-modecard--active {
    border-color: var(--neon);
    background: rgba(0,212,255,0.1);
    box-shadow: 0 0 16px rgba(0,212,255,0.14);
}
.modecard-icon { font-size: clamp(1.2rem, 4vw, 1.5rem); flex-shrink: 0; }
.modecard-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.modecard-title {
    font-family: 'Orbitron', monospace;
    font-size: clamp(0.65rem, 2.5vw, 0.8rem);
    font-weight: 700;
    letter-spacing: 1px;
    color: rgba(0,212,255,0.6);
    line-height: 1;
    transition: color 0.15s;
}
.lobby-modecard--active .modecard-title { color: var(--neon); }
.modecard-desc {
    font-family: 'Exo 2', sans-serif;
    font-size: clamp(0.55rem, 1.7vw, 0.65rem);
    color: rgba(0,212,255,0.35);
    line-height: 1.4;
}
.modecard-check {
    font-size: 1rem;
    color: var(--neon);
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s;
}
.lobby-modecard--active .modecard-check { opacity: 1; }

/* Summary */
.lobby-summary {
    background: rgba(0,212,255,0.04);
    border: 1px solid rgba(0,212,255,0.13);
    border-radius: 8px;
    padding: clamp(10px, 2.5vw, 14px) clamp(14px, 4vw, 18px);
    font-family: 'Exo 2', sans-serif;
    font-size: clamp(0.6rem, 2vw, 0.72rem);
    color: rgba(0,212,255,0.44);
    letter-spacing: 0.5px;
    margin-bottom: clamp(18px, 4.5vw, 26px);
    text-align: center;
}

/* Start button */
.lobby-start-btn {
    width: 100%;
    padding: clamp(17px, 4.5vw, 22px);
    background: rgba(0,212,255,0.09);
    border: 2px solid var(--neon);
    color: var(--neon);
    font-family: 'Orbitron', monospace;
    font-size: clamp(0.85rem, 3.5vw, 1rem);
    font-weight: 900;
    letter-spacing: clamp(3px, 1.5vw, 6px);
    cursor: pointer;
    border-radius: 10px;
    transition: all 0.22s cubic-bezier(0.34,1.56,0.64,1);
    box-shadow: 0 0 22px rgba(0,212,255,0.13);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.lobby-start-btn:hover, .lobby-start-btn:active {
    background: rgba(0,212,255,0.2);
    box-shadow: 0 0 40px rgba(0,212,255,0.3);
    transform: translateY(-2px);
}

/* ─────────────────────────────────
   TOP HUD BAR
───────────────────────────────── */
#topBar {
    position: fixed; top: 0; left: 0; right: 0;
    height: 42px;
    background: rgba(0,3,14,0.95);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center;
    padding: 0 10px; gap: 2px;
    z-index: 200;
    box-shadow: 0 2px 16px rgba(0,0,0,0.6);
    /* Prevent overflow on small screens */
    overflow: hidden;
}

.res-group {
    display: flex; align-items: center; gap: 4px;
    padding: 0 8px;
    border-right: 1px solid rgba(0,212,255,0.1);
    height: 100%;
    flex-shrink: 0;
}
.res-icon {
    font-size: clamp(0.7rem, 2.5vw, 1rem);
    color: var(--neon); opacity: 0.8;
}
.res-svg {
    width: clamp(13px, 3.5vw, 16px);
    height: clamp(13px, 3.5vw, 16px);
    flex-shrink: 0;
    opacity: 0.9;
}
.res-val-wrap { display: flex; flex-direction: column; justify-content: center; line-height: 1; }
.res-value {
    font-family: 'Orbitron', monospace;
    font-size: clamp(0.72rem, 2.5vw, 0.95rem);
    font-weight: 700; color: #e8f4ff;
}
.res-rate {
    font-size: clamp(0.5rem, 1.5vw, 0.62rem);
    color: rgba(0,212,255,0.55);
}

.hud-spacer { flex: 1; }

.game-time {
    font-family: 'Orbitron', monospace;
    font-size: clamp(0.7rem, 2vw, 0.85rem);
    color: rgba(0,212,255,0.6);
    letter-spacing: 2px;
    padding: 0 8px;
}

.hud-btn {
    background: transparent;
    border: 1px solid rgba(0,212,255,0.22);
    color: rgba(0,212,255,0.7);
    font-family: 'Orbitron', monospace;
    font-size: clamp(0.58rem, 2vw, 0.68rem);
    font-weight: 700; letter-spacing: 1px;
    padding: 0 10px; height: 30px;
    cursor: pointer; margin-left: 5px;
    transition: all 0.18s; white-space: nowrap;
    border-radius: 3px;
    -webkit-tap-highlight-color: transparent;
    /* Larger touch target */
    min-width: 34px;
}
.hud-btn:hover, .hud-btn:active {
    background: rgba(0,212,255,0.12);
    border-color: var(--neon); color: var(--neon);
}

.zoom-btn {
    font-size: 1.1rem; font-weight: 900;
    padding: 0 10px;
}

/* ─────────────────────────────────
   PLANET PANEL
───────────────────────────────── */
#planetPanel {
    position: fixed;
    bottom: -360px;
    left: 50%;
    transform: translateX(-50%);
    width: min(440px, 96vw);
    background: var(--panel);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 14px 14px 0 0;
    padding: 16px 18px 24px;
    z-index: 200;
    transition: bottom 0.26s cubic-bezier(0.22,1,0.36,1);
    box-shadow: 0 -6px 36px rgba(0,212,255,0.1);
}
#planetPanel.visible { bottom: 0; }

.pp-header {
    display: flex; align-items: flex-start;
    justify-content: space-between; margin-bottom: 10px;
}
.pp-title-group { display: flex; flex-direction: column; gap: 3px; }
.pp-name {
    font-family: 'Orbitron', monospace;
    font-size: clamp(0.9rem, 4vw, 1.1rem);
    font-weight: 700; color: var(--neon); letter-spacing: 2px;
}
.pp-type  { font-size: 0.65rem; color: rgba(200,224,255,0.45); letter-spacing: 2px; text-transform: uppercase; }
.pp-owner { font-size: 0.72rem; font-weight: 600; margin-top: 2px; }

.pp-close {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(200,224,255,0.5);
    width: 30px; height: 30px; border-radius: 50%;
    cursor: pointer; font-size: 0.8rem; flex-shrink: 0;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.pp-close:hover, .pp-close:active {
    background: rgba(255,255,255,0.1); color: #fff;
}

.pp-prod {
    display: flex; align-items: center; gap: 10px;
    background: rgba(0,212,255,0.04);
    border: 1px solid rgba(0,212,255,0.1);
    border-radius: 6px; padding: 7px 12px; margin-bottom: 4px;
}
.pp-prod-label { font-size: 0.58rem; color: rgba(200,224,255,0.4); letter-spacing: 2px; white-space: nowrap; }
.pp-prod-vals  { font-size: 0.8rem; font-weight: 600; color: #a0d8ff; }

.pp-divider { height: 1px; background: rgba(0,212,255,0.1); margin: 10px 0; }

.pp-workers-row {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;
}
.pp-section-title { font-size: 0.7rem; font-weight: 600; letter-spacing: 2px; color: var(--gold); }
.pp-worker-count  {
    font-family: 'Orbitron', monospace;
    font-size: 0.88rem; font-weight: 700; color: var(--gold);
}

.pp-queue { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; min-height: 26px; }
.pp-queue-empty {
    font-size: 0.7rem; color: rgba(200,224,255,0.28);
    padding: 5px 0; letter-spacing: 1px;
}
.pp-queue-item {
    display: grid;
    grid-template-columns: 1fr 70px 34px;
    align-items: center; gap: 8px;
    background: rgba(255,215,0,0.04);
    border: 1px solid rgba(255,215,0,0.1);
    border-radius: 5px; padding: 6px 10px;
}
.pp-queue-label { font-size: 0.7rem; color: var(--gold); }
.pp-queue-bar   { height: 4px; background: rgba(255,215,0,0.1); border-radius: 2px; overflow: hidden; }
.pp-queue-fill  { height: 100%; background: var(--gold); border-radius: 2px; transition: width 0.4s; }
.pp-queue-pct   { font-size: 0.65rem; font-weight: 700; color: var(--gold); text-align: right; }

.pp-build-btn {
    width: 100%; padding: 13px 16px;
    background: rgba(255,215,0,0.07);
    border: 1px solid rgba(255,215,0,0.32);
    color: var(--gold);
    font-family: 'Orbitron', monospace;
    font-size: clamp(0.6rem, 2.5vw, 0.72rem);
    font-weight: 700; letter-spacing: 1.5px;
    cursor: pointer; border-radius: 7px;
    transition: all 0.2s;
    display: flex; align-items: center;
    justify-content: center; gap: 8px; flex-wrap: wrap;
    -webkit-tap-highlight-color: transparent;
}
.pp-build-btn:hover:not(:disabled), .pp-build-btn:active:not(:disabled) {
    background: rgba(255,215,0,0.17);
    border-color: var(--gold);
    box-shadow: 0 0 20px rgba(255,215,0,0.22);
}
.pp-build-btn:disabled { opacity: 0.32; cursor: not-allowed; }
.pp-build-icon { font-size: 1.1rem; }
.pp-build-cost { font-size: 0.6rem; opacity: 0.6; font-family: 'Exo 2', sans-serif; font-weight: 400; }

/* ─────────────────────────────────
   MINIMAP
───────────────────────────────── */
#minimap {
    position: fixed;
    bottom: 14px; right: 14px;
    width: 140px; height: 105px;
    border: 1px solid rgba(0,212,255,0.22);
    border-radius: 5px;
    z-index: 150;
    cursor: pointer;
    box-shadow: 0 0 16px rgba(0,0,0,0.6);
}
@media (max-width: 480px) {
    #minimap { width: 110px; height: 82px; bottom: 10px; right: 10px; }
}

/* ─────────────────────────────────
   TOAST MESSAGE
───────────────────────────────── */
.fog-msg {
    position: fixed;
    top: 64px; left: 50%;
    transform: translateX(-50%);
    background: rgba(0,4,20,0.88);
    border: 1px solid rgba(0,212,255,0.3);
    border-radius: 20px;
    padding: 7px 20px;
    font-size: clamp(0.68rem, 2.5vw, 0.8rem);
    color: var(--neon);
    letter-spacing: 1px;
    pointer-events: none; z-index: 300;
    opacity: 0;
    white-space: nowrap;
    max-width: 90vw; overflow: hidden; text-overflow: ellipsis;
}
@keyframes fadeOut {
    0%   { opacity: 1; transform: translateX(-50%) translateY(0); }
    70%  { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-8px); }
}

/* ─────────────────────────────────
   MOBILE TWEAKS
───────────────────────────────── */
@media (max-width: 480px) {
    #topBar { height: 38px; padding: 0 6px; gap: 0; }
    .res-group { padding: 0 5px; }
    .hud-btn { margin-left: 3px; padding: 0 7px; height: 27px; }
    .game-time { padding: 0 5px; font-size: 0.65rem; }
    #planetPanel { padding: 14px 14px 20px; }
    .pp-name { font-size: 0.92rem; }
}

/* Interactive overlays catch events; canvas catches the rest */


/* Scrollable planet panel */
#planetPanel {
    max-height: 75vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
#planetPanel::-webkit-scrollbar { width: 4px; }
#planetPanel::-webkit-scrollbar-track { background: transparent; }
#planetPanel::-webkit-scrollbar-thumb { background: rgba(0,212,255,0.25); border-radius: 2px; }

/* Only the game screen passes clicks through to canvas */
#gameScreen { pointer-events: none; }
#gameScreen #topBar,
#gameScreen #planetPanel,
#gameScreen #minimap { pointer-events: auto; }

/* Research button */
.research-btn {
    border-color: rgba(100,180,255,0.35) !important;
    color: #88ccff !important;
    background: rgba(100,180,255,0.06) !important;
    margin-top: 8px;
}
.research-btn:hover:not(:disabled) {
    background: rgba(100,180,255,0.15) !important;
    border-color: #88ccff !important;
    box-shadow: 0 0 20px rgba(100,180,255,0.2) !important;
}
.pp-research-fill {
    height: 100%; background: linear-gradient(90deg, #4488ff, #88ccff);
    border-radius: 2px; transition: width 0.5s;
}

/* ════════════════════════════════════════════════════════
   TABS
════════════════════════════════════════════════════════ */
.pp-tabs {
    display: flex; gap: 6px; margin: 10px 0 12px;
}
.pp-tab {
    flex: 1; padding: 8px 6px;
    background: rgba(0,212,255,0.04);
    border: 1px solid rgba(0,212,255,0.18);
    color: rgba(0,212,255,0.5);
    font-family:'Orbitron',monospace; font-size:0.62rem;
    font-weight:700; letter-spacing:1.5px; cursor:pointer;
    border-radius:5px; transition:all 0.18s;
    -webkit-tap-highlight-color:transparent;
}
.pp-tab:hover { border-color:rgba(0,212,255,0.4); color:rgba(0,212,255,0.8); }
.pp-tab.active {
    background: rgba(0,212,255,0.14);
    border-color: var(--neon); color: var(--neon);
    box-shadow: 0 0 12px rgba(0,212,255,0.2);
}
.pp-tab-content { display:none; }
.pp-tab-content.active { display:block; }

/* ════════════════════════════════════════════════════════
   SHIP GRID  (Cossacks-style: alle Schiffe sichtbar)
════════════════════════════════════════════════════════ */
.pp-fleet-header {
    display:flex; justify-content:space-between; align-items:center;
    margin-bottom:8px;
}
.pp-ship-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 7px;
    margin-bottom: 10px;
}
@media (min-width: 420px) {
    .pp-ship-grid { grid-template-columns: repeat(4, 1fr); }
}

.pp-ship-card {
    display: flex; flex-direction: column; align-items: center;
    gap: 4px; padding: 10px 6px 8px;
    border: 1px solid rgba(0,212,255,0.16);
    border-radius: 8px;
    background: rgba(0,212,255,0.04);
    cursor: pointer; transition: all 0.18s;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}
.pp-ship-card:hover:not(.locked):not([disabled]) {
    background: rgba(0,212,255,0.12);
    border-color: var(--neon);
    box-shadow: 0 0 16px rgba(0,212,255,0.2);
    transform: translateY(-2px);
}
.pp-ship-card:active:not(.locked):not([disabled]) { transform:scale(0.97); }

.pp-ship-card.locked {
    opacity: 0.35; cursor:not-allowed;
    filter: grayscale(0.6);
}
.pp-ship-card.cant-afford {
    opacity: 0.55; cursor:not-allowed;
}
.pp-ship-card.civil { border-color:rgba(255,215,0,0.22); }
.pp-ship-card.civil:hover:not(.locked):not([disabled]) {
    border-color:#ffd700; background:rgba(255,215,0,0.1);
    box-shadow:0 0 16px rgba(255,215,0,0.2);
}

.psc-icon  { font-size:1.6rem; line-height:1; }
.psc-label { font-size:0.62rem; font-weight:700; letter-spacing:1px; text-align:center; color:var(--text); }
.psc-cost  { font-size:0.53rem; color:rgba(200,224,255,0.5); text-align:center; line-height:1.4; }
.psc-stat  { font-size:0.52rem; color:rgba(200,224,255,0.4); text-align:center; }
.psc-lock  {
    position:absolute; top:5px; right:6px;
    font-size:0.6rem; opacity:0.7;
}
.psc-req {
    font-size:0.5rem; color:rgba(255,160,80,0.8); text-align:center; letter-spacing:0.5px;
}

/* ════════════════════════════════════════════════════════
   BUILD QUEUE
════════════════════════════════════════════════════════ */
.pp-queue { display:flex; flex-direction:column; gap:5px; min-height:24px; }
.pp-queue-empty {
    font-size:0.68rem; color:rgba(200,224,255,0.25);
    padding:4px 0; letter-spacing:1px;
}
.pp-queue-item {
    display:grid;
    grid-template-columns: 22px auto 1fr auto 22px;
    align-items:center; gap:6px;
    background:rgba(255,215,0,0.04);
    border:1px solid rgba(255,215,0,0.12);
    border-radius:5px; padding:5px 8px;
    transition: background 0.15s;
}
.pp-queue-item:hover { background:rgba(255,215,0,0.07); }

.pp-qi-reorder {
    display:flex; flex-direction:column; gap:1px;
    align-items:center;
}
.pp-qi-move {
    background:transparent; border:none;
    color:rgba(255,215,0,0.35); cursor:pointer;
    font-size:0.5rem; line-height:1; padding:1px 3px;
    transition: color 0.15s;
    border-radius:2px;
}
.pp-qi-move:hover:not(:disabled) { color:#ffd700; background:rgba(255,215,0,0.1); }
.pp-qi-move:disabled { opacity:0.18; cursor:default; }

.pp-qi-icon  { font-size:0.88rem; text-align:center; }
.pp-qi-info  { display:flex; flex-direction:column; gap:1px; min-width:0; }
.pp-qi-label { font-size:0.67rem; color:var(--gold); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.pp-qi-timer   { color:#ffd700; font-weight:700; }
.pp-qi-waiting { color:rgba(255,215,0,0.45); font-style:italic; }
.pp-qi-pct   { font-size:0.62rem; font-weight:700; color:var(--gold); opacity:0.7; text-align:right; white-space:nowrap; }
.pp-qi-cancel {
    background:transparent; border:none; color:rgba(255,80,80,0.4);
    cursor:pointer; font-size:0.72rem; padding:2px 3px;
    transition: color 0.15s, background 0.15s;
    border-radius:2px;
}
.pp-qi-cancel:hover { color:#ff5050; background:rgba(255,80,80,0.1); }

/* ════════════════════════════════════════════════════════
   ACTIVE RESEARCH BAR
════════════════════════════════════════════════════════ */
.pp-active-research {
    display:flex; align-items:center; gap:10px;
    background:rgba(100,180,255,0.07);
    border:1px solid rgba(100,180,255,0.25);
    border-radius:7px; padding:8px 12px; margin-bottom:12px;
}
.pp-ar-icon { font-size:1.3rem; }
.pp-ar-info { flex:1; display:flex; flex-direction:column; gap:4px; }
.pp-ar-label{ font-size:0.72rem; font-weight:700; color:#88ccff; letter-spacing:1px; }
.pp-ar-time { font-family:'Orbitron',monospace; font-size:0.82rem; font-weight:700; color:#88ccff; white-space:nowrap; }
.pp-research-fill {
    height:100%; background:linear-gradient(90deg,#3366ff,#88ccff);
    border-radius:2px; transition:width 0.5s;
}

/* ════════════════════════════════════════════════════════
   TECH TREE  (Cossacks-style visual grid)
════════════════════════════════════════════════════════ */
.pp-tech-wrap {
    position:relative; width:100%; overflow-x:auto;
    -webkit-overflow-scrolling:touch;
}
.tech-canvas {
    display:block;
    /* sized by JS */
}
.tech-overlay {
    position:absolute; top:0; left:0;
    pointer-events:none; /* nodes inside get pointer-events:auto */
}

/* Individual tech node (absolutely positioned over canvas) */
.tech-node {
    position:absolute;
    width:72px; height:88px;
    display:flex; flex-direction:column; align-items:center;
    justify-content:flex-start; gap:3px;
    padding:8px 4px 6px;
    border-radius:8px;
    border:1.5px solid rgba(100,180,255,0.2);
    background:rgba(0,4,20,0.88);
    cursor:default;
    transition:border-color 0.2s, box-shadow 0.2s, transform 0.15s;
    pointer-events:auto;
    box-sizing:border-box;
    text-align:center;
    -webkit-tap-highlight-color:transparent;
    user-select:none;
}
.tech-node.available {
    border-color:rgba(0,212,255,0.55);
    cursor:pointer;
}
.tech-node.available:hover {
    border-color:#00d4ff;
    box-shadow:0 0 18px rgba(0,212,255,0.35);
    transform:scale(1.06);
}
.tech-node.available:active { transform:scale(0.97); }
.tech-node.researching {
    border-color:#88ccff;
    box-shadow:0 0 20px rgba(100,160,255,0.4);
    animation:techPulse 1.4s ease-in-out infinite;
}
@keyframes techPulse {
    0%,100%{ box-shadow:0 0 10px rgba(100,160,255,0.3); }
    50%    { box-shadow:0 0 26px rgba(100,160,255,0.7); }
}
.tech-node.done {
    border-color:rgba(0,255,136,0.5);
    background:rgba(0,30,15,0.9);
}
.tech-node.locked {
    border-color:rgba(80,80,120,0.3);
    opacity:0.45; cursor:not-allowed;
}

.tn-icon   { font-size:1.4rem; line-height:1; }
.tn-label  { font-size:0.52rem; font-weight:700; letter-spacing:0.5px; color:var(--text); line-height:1.2; }
.tn-cost   { font-size:0.46rem; color:rgba(200,224,255,0.45); line-height:1.3; }
.tn-badge  { font-size:0.55rem; margin-top:2px; }

/* Unlock ship chip inside node */
.tn-unlock {
    font-size:0.44rem; background:rgba(0,212,255,0.12);
    border:1px solid rgba(0,212,255,0.3);
    border-radius:3px; padding:1px 4px;
    color:#88e8ff; letter-spacing:0.5px;
    line-height:1.4;
}

/* Tech tree layout fixes */
.pp-tech-wrap {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    margin-top: 4px;
    border: 1px solid rgba(100,160,255,0.1);
    border-radius: 8px;
    background: rgba(0,2,12,0.6);
    padding: 10px 8px 8px;
}
.tech-canvas { display:block; }
.tech-overlay {
    position: absolute; top: 10px; left: 8px;
    pointer-events: none;
}
.tech-node { pointer-events: auto; }

/* ════ DIFFICULTY SELECTOR ════ */
.difficulty-label {
    font-size: 0.6rem; letter-spacing: 3px; color: rgba(0,212,255,0.5);
    margin-bottom: 10px; font-family: 'Orbitron', monospace;
}
.difficulty-row {
    display: flex; gap: 8px; margin-bottom: 12px;
}
.diff-btn {
    flex: 1; padding: 10px 6px;
    background: rgba(0,212,255,0.04);
    border: 1.5px solid rgba(0,212,255,0.2);
    color: rgba(0,212,255,0.5);
    font-family: 'Orbitron', monospace; font-size: 0.65rem;
    font-weight: 700; letter-spacing: 2px; cursor: pointer;
    border-radius: 6px; transition: all 0.18s;
    -webkit-tap-highlight-color: transparent;
}
.diff-btn:hover { border-color: rgba(0,212,255,0.6); color: rgba(0,212,255,0.9); }
.diff-btn.active { background: rgba(0,212,255,0.15); border-color: #00d4ff; color: #00d4ff; box-shadow: 0 0 16px rgba(0,212,255,0.2); }
.diff-btn[data-diff="hard"].active { background: rgba(255,50,85,0.12); border-color: #ff3355; color: #ff3355; box-shadow: 0 0 16px rgba(255,50,85,0.2); }
.diff-btn[data-diff="easy"].active { background: rgba(0,255,136,0.1); border-color: #00ff88; color: #00ff88; box-shadow: 0 0 16px rgba(0,255,136,0.15); }
.diff-desc {
    font-size: 0.65rem; color: rgba(0,212,255,0.45);
    min-height: 32px; margin-bottom: 18px;
    line-height: 1.5; letter-spacing: 0.5px;
}

/* ════ GAME OVER OVERLAY ════ */
.game-over-overlay {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(0,0,0,0.88);
    display: flex; align-items: center; justify-content: center;
    animation: goFadeIn 0.5s ease;
}
@keyframes goFadeIn { from { opacity:0; } to { opacity:1; } }
.game-over-box {
    text-align: center; font-family: 'Orbitron', monospace;
    border: 1px solid; border-radius: 12px;
    padding: 48px 56px;
    background: rgba(0,2,14,0.96);
    animation: goScale 0.4s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes goScale { from { transform:scale(0.82); } to { transform:scale(1); } }
.go-title  { font-size: clamp(2rem,8vw,3.5rem); font-weight: 900; letter-spacing: 4px; margin-bottom: 8px; }
.go-sub    { font-size: 0.85rem; opacity: 0.6; margin-bottom: 32px; letter-spacing: 2px; }
.go-stats  { font-size: 0.72rem; color: rgba(200,224,255,0.55); margin-bottom: 32px; line-height: 2; }
.go-btn {
    background: transparent; border: 2px solid;
    font-family: 'Orbitron', monospace; font-size: 0.82rem; font-weight: 700;
    padding: 14px 40px; letter-spacing: 2px; cursor: pointer; border-radius: 6px;
    transition: all 0.2s;
}
.go-btn:hover { opacity: 0.8; transform: translateY(-2px); }

/* ════ PAN MODE BUTTON ════ */
.pan-btn { font-size: 0.95rem; }
.pan-btn.active {
    background: rgba(255,215,0,0.2) !important;
    border-color: #ffd700 !important;
    color: #ffd700 !important;
    box-shadow: 0 0 14px rgba(255,215,0,0.35);
}

/* Pan mode cursor on canvas */
body.pan-mode #gameCanvas { cursor: grab; }
body.pan-mode #gameCanvas:active { cursor: grabbing; }

/* ════════════════════════════════════════════════════════
   RTS SELECTION PANEL
════════════════════════════════════════════════════════ */
.sel-panel {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 74px;
    background: rgba(0,2,14,0.97);
    border-top: 1px solid rgba(0,212,255,0.22);
    display: none;           /* hidden when nothing selected */
    align-items: stretch;
    z-index: 180;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.7);
    pointer-events: auto;
}
.sel-panel.visible { display: flex; }

/* ── Portrait (left) ── */
.sel-portrait {
    width: 72px;
    flex-shrink: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 2px;
    border-right: 1px solid rgba(0,212,255,0.12);
    padding: 5px 5px;
    background: rgba(0,212,255,0.03);
}
.sel-portrait-icon {
    font-size: 1.5rem; line-height: 1;
    filter: drop-shadow(0 0 8px currentColor);
}
.sel-portrait-name {
    font-size: 0.47rem; font-weight: 700; letter-spacing: 1.5px;
    color: var(--neon); text-align: center; text-transform: uppercase;
}
.sel-portrait-stat {
    font-size: 0.42rem; color: rgba(200,224,255,0.45); text-align: center;
}

/* ── Ship grid (center) ── */
.sel-grid {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 4px;
    padding: 5px 8px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-width: 0;
}
.sel-grid::-webkit-scrollbar { width: 3px; }
.sel-grid::-webkit-scrollbar-thumb { background: rgba(0,212,255,0.3); border-radius:2px; }

/* Individual ship card in selection grid */
.sel-ship {
    width: 36px; height: 36px;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 2px;
    border: 1.5px solid rgba(0,212,255,0.18);
    border-radius: 6px;
    background: rgba(0,212,255,0.04);
    cursor: pointer;
    transition: all 0.12s;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}
.sel-ship:hover    { border-color: rgba(0,212,255,0.55); background: rgba(0,212,255,0.12); }
.sel-ship.focused  { border-color: #ffd700; background: rgba(255,215,0,0.1); box-shadow: 0 0 10px rgba(255,215,0,0.3); }
.sel-ship.worker-card  { border-color: rgba(255,215,0,0.2); }
.sel-ship.fighter-card { border-color: rgba(0,255,136,0.2); }
.sel-ship.destroyer-card { border-color: rgba(255,153,0,0.2); }
.sel-ship.cruiser-card { border-color: rgba(255,51,85,0.2); }

.sel-ship-icon  { font-size: 0.9rem; line-height: 1; }
.sel-ship-label { font-size: 0.4rem; letter-spacing: 0.5px; color: rgba(200,224,255,0.5); }

/* HP bar inside ship card */
.sel-ship-hp {
    position: absolute; bottom: 3px; left: 4px; right: 4px;
    height: 2px; background: rgba(255,255,255,0.1); border-radius: 1px; overflow: hidden;
}
.sel-ship-hp-fill {
    height: 100%; border-radius: 1px;
    transition: width 0.3s;
}

/* Group count badge (when >1 of same type) */
.sel-group {
    width: 44px; height: 36px;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 1px;
    border: 1.5px solid rgba(0,212,255,0.18);
    border-radius: 6px;
    background: rgba(0,212,255,0.04);
    cursor: pointer;
    position: relative;
    transition: all 0.12s;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}
.sel-group:hover { border-color: rgba(0,212,255,0.55); background: rgba(0,212,255,0.12); }
.sel-group.active { border-color: #ffd700; background: rgba(255,215,0,0.08); }

.sel-group-icon  { font-size: 0.9rem; line-height: 1; }
.sel-group-count {
    font-family: 'Orbitron', monospace;
    font-size: 0.65rem; font-weight: 700; color: #ffd700;
    line-height: 1;
}
.sel-group-label { font-size: 0.4rem; color: rgba(200,224,255,0.45); letter-spacing: 0.5px; }

/* ── Commands (right) ── */
.sel-cmds {
    width: 50px;
    flex-shrink: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 4px;
    border-left: 1px solid rgba(0,212,255,0.12);
    padding: 5px 4px;
}
.sel-cmd-btn {
    width: 34px; height: 22px;
    background: rgba(0,212,255,0.05);
    border: 1px solid rgba(0,212,255,0.2);
    border-radius: 5px;
    color: rgba(0,212,255,0.7);
    font-size: 0.72rem; cursor: pointer;
    transition: all 0.15s;
    display: flex; align-items: center; justify-content: center;
    -webkit-tap-highlight-color: transparent;
}
.sel-cmd-btn:hover  { background: rgba(0,212,255,0.15); border-color: var(--neon); color: var(--neon); }
.sel-cmd-btn:active { transform: scale(0.92); }
.sel-cmd-desel { border-color: rgba(255,80,80,0.25); color: rgba(255,80,80,0.6); }
.sel-cmd-desel:hover { background: rgba(255,80,80,0.12); border-color: #ff5050; color: #ff5050; }

/* Minimap lift when panel open */
.sel-panel.visible ~ #minimap,
#gameScreen:has(.sel-panel.visible) #minimap {
    bottom: 110px;
}

/* Mobile tweaks */
@media (max-width: 480px) {
    .sel-panel    { height: 68px; }
    .sel-portrait { width: 60px; }
    .sel-portrait-icon { font-size: 1.3rem; }
    .sel-ship     { width: 32px; height: 32px; }
    .sel-group    { width: 38px; height: 32px; }
    .sel-cmds     { width: 42px; }
    .sel-cmd-btn  { width: 30px; height: 20px; }
}

/* ════════════════════════════════════════════════════════
   ARMY PANEL
════════════════════════════════════════════════════════ */
.pp-army-grid {
    display: flex; flex-direction: column;
    gap: 8px; padding: 6px 0;
}

.army-card {
    border: 1px solid rgba(0,212,255,0.2);
    border-radius: 8px;
    background: rgba(0,212,255,0.04);
    padding: 10px 12px;
    cursor: pointer;
    transition: all 0.15s;
}
.army-card:hover:not(.army-locked) {
    background: rgba(0,212,255,0.1);
    border-color: rgba(0,212,255,0.5);
    box-shadow: 0 0 14px rgba(0,212,255,0.15);
}
.army-card.army-locked {
    opacity: 0.45; cursor: default;
    filter: grayscale(0.4);
}

.army-header {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 4px;
}
.army-rank      { font-size: 1rem; line-height: 1; }
.army-header-text { display: flex; flex-direction: column; gap: 1px; }
.army-rank-label {
    font-family: 'Orbitron', monospace;
    font-size: 0.65rem; font-weight: 700;
    color: #ffd700; letter-spacing: 2px;
}
.army-name-label {
    font-size: 0.58rem; color: rgba(200,224,255,0.55);
    letter-spacing: 0.5px;
}
.army-desc {
    font-size: 0.6rem; color: rgba(200,224,255,0.5);
    margin-bottom: 5px; line-height: 1.4;
}
.army-cost-row {
    display: flex; gap: 8px; align-items: center;
    font-size: 0.6rem; color: rgba(200,224,255,0.7);
}
.army-cost-row.army-cant { color: rgba(255,100,100,0.6); }
.army-time { margin-left: auto; color: rgba(200,224,255,0.4); }
.army-req {
    font-size: 0.55rem; color: rgba(255,160,80,0.7);
    margin-top: 4px;
}