/* =========================================================================
   OBJECTIVE: PAPERCLIPS - VIBRANT CARTOON & PIXEL ART EDITION
   Scaled Up & Crisp UI Edition
   ========================================================================= */

:root {
    --bg-main: #120924;
    --bg-darker: #0b0517;
    --bg-panel: #1e113b;
    --bg-card: #28174f;
    --bg-card-hover: #371f6d;
    --border-ink: #0a0414;
    --border-highlight: #4d2b99;
    
    --neon-cyan: #00f0ff;
    --neon-pink: #ff2a85;
    --neon-yellow: #ffe600;
    --neon-green: #00ff88;
    --neon-orange: #ff7700;
    --neon-purple: #a855f7;
    
    --text-main: #ffffff;
    --text-sub: #c9b8e8;
    --text-muted: #7e69a8;
    
    --font-pixel: 'Press Start 2P', monospace;
    --font-cartoon: 'Fredoka', 'Lilita One', 'Inter', -apple-system, sans-serif;
    
    --comic-shadow: 0 4px 0 var(--border-ink);
    --comic-shadow-lg: 0 6px 0 var(--border-ink);
    --comic-shadow-btn: 0 4px 0 #0a0414, 0 6px 12px rgba(0, 0, 0, 0.4);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
}

body {
    background-color: var(--bg-main);
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(255, 42, 133, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(0, 240, 255, 0.08) 0%, transparent 40%),
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 100% 100%, 100% 100%, 24px 24px, 24px 24px;
    color: var(--text-main);
    font-family: var(--font-cartoon);
    font-size: 15px;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-darker);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb {
    background: var(--neon-purple);
    border-radius: 4px;
    border: 2px solid var(--border-ink);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--neon-pink);
}

/* =========================================================================
   TOP HEADER BAR (Bigger & Crisp)
   ========================================================================= */

.app-header {
    height: 52px;
    background: #190e32;
    border-bottom: 3px solid var(--border-ink);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    z-index: 100;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-logo {
    font-family: var(--font-pixel);
    font-size: 13px;
    color: var(--neon-yellow);
    text-shadow: 2px 2px 0 var(--border-ink), 0 0 10px rgba(255, 230, 0, 0.4);
    letter-spacing: 1px;
}

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

.hdr-btn {
    background: var(--bg-card);
    border: 2px solid var(--border-ink);
    color: var(--text-main);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-family: var(--font-cartoon);
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 3px 0 var(--border-ink);
    transition: all 0.1s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.hdr-btn:hover {
    transform: translateY(-1px);
    background: var(--bg-card-hover);
    color: var(--neon-cyan);
    box-shadow: 0 4px 0 var(--border-ink);
}

.hdr-btn:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 var(--border-ink);
}

.hdr-btn.btn-danger {
    background: #ff2a55;
    color: #ffffff;
}

.btn-danger:hover {
    background: #ff0033;
    color: #ffffff;
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.volume-slider {
    width: 70px;
    accent-color: var(--neon-cyan);
    cursor: pointer;
}

/* =========================================================================
   MAIN APP WORKSPACE (Symmetrical 3-Column: 360px | 1fr | 360px)
   ========================================================================= */

.app-workspace {
    flex: 1;
    display: grid;
    grid-template-columns: 360px 1fr 385px;
    height: calc(100vh - 52px);
    overflow: hidden;
    position: relative;
}

/* =========================================================================
   COLUMN 1: LEFT PEDESTAL (Progress, Clicker & Resources)
   ========================================================================= */

.left-pedestal {
    background: var(--bg-panel);
    border-right: 3px solid var(--border-ink);
    box-shadow: inset -4px 0 12px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    padding: 10px 12px;
    gap: 8px;
    overflow-y: auto;
    z-index: 10;
}

/* Big Cartoon Odometer (Compact & Punchy) */
.odometer-card {
    text-align: center;
    background: linear-gradient(180deg, #2b1754 0%, #1a0d33 100%);
    border: 3px solid var(--border-ink);
    border-radius: 12px;
    padding: 8px 10px;
    box-shadow: var(--comic-shadow);
}

.odometer-number {
    font-family: var(--font-cartoon);
    font-size: 38px;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: 0.5px;
    text-shadow: 2px 2px 0 var(--border-ink), 0 0 18px rgba(0, 240, 255, 0.5);
    line-height: 1.1;
}

.odometer-sub {
    font-family: var(--font-pixel);
    font-size: 11px;
    color: var(--neon-cyan);
    letter-spacing: 1px;
    margin-top: 3px;
}

.odometer-cps {
    font-family: var(--font-cartoon);
    font-size: 16px;
    font-weight: 700;
    color: var(--neon-green);
    margin-top: 2px;
    transition: color 0.2s ease;
}

.odometer-cps.starved {
    color: #ff9100;
    animation: pulseStarved 1.6s ease-in-out infinite;
}

@keyframes pulseStarved {
    0%, 100% { opacity: 1; text-shadow: 0 0 6px rgba(255, 145, 0, 0.4); }
    50% { opacity: 0.75; text-shadow: 0 0 14px rgba(255, 60, 0, 0.8); }
}

/* Bouncy Cartoon Paperclip Hero Target (Tightened & Zero Dead Space) */
.hero-clicker-wrapper {
    width: 100%;
    height: 140px;
    background: radial-gradient(circle, #341a66 0%, #190c33 80%);
    border: 3px solid var(--border-ink);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--comic-shadow), inset 0 0 20px rgba(0, 0, 0, 0.4);
    transition: transform 0.08s ease, border-color 0.15s ease;
    overflow: hidden;
    position: relative;
}

.hero-clicker-wrapper:hover {
    border-color: var(--neon-cyan);
}

.hero-clip-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 110px;
    height: 110px;
    animation: gentleWobble 4s ease-in-out infinite;
}

.hero-paperclip-svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.5));
    transition: transform 0.06s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.hero-clicker-wrapper:active .hero-paperclip-svg {
    transform: scale(0.84) rotate(-6deg);
}

@keyframes gentleWobble {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-4px) rotate(2deg); }
}

/* Flywheel Overclock Gauge (Compact) */
.flywheel-card {
    background: #190c33;
    border: 2px solid var(--border-ink);
    border-radius: 10px;
    padding: 6px 10px;
    box-shadow: var(--comic-shadow);
}

.flywheel-label-row {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-pixel);
    font-size: 9px;
    color: var(--neon-yellow);
    margin-bottom: 4px;
}

.flywheel-track {
    height: 12px;
    background: #090312;
    border: 2px solid var(--border-ink);
    border-radius: 6px;
    overflow: hidden;
}

.flywheel-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #00f0ff 0%, #ffe600 60%, #ff2a85 100%);
    box-shadow: 0 0 10px rgba(255, 230, 0, 0.7);
    transition: width 0.1s linear;
}

/* Clean Essential Resource Badges (Bigger text & Less Dead Space) */
.resources-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.res-badge {
    background: var(--bg-card);
    border: 2px solid var(--border-ink);
    border-radius: 10px;
    padding: 8px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--comic-shadow);
    gap: 8px;
}

.res-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.res-icon {
    font-size: 24px;
}

.res-details {
    display: flex;
    flex-direction: column;
}

.res-title {
    font-family: var(--font-pixel);
    font-size: 9px;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.res-amount {
    font-family: var(--font-cartoon);
    font-size: 18px;
    font-weight: 800;
    color: #ffffff;
}

.wire-badge .res-amount { color: #ffd166; }
.ops-badge .res-amount { color: var(--neon-cyan); }
.pop-badge .res-amount { color: var(--neon-pink); }

/* Wire In/Out Rates Sub-row */
.wire-rates-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
    font-family: var(--font-cartoon);
    font-size: 11px;
    font-weight: 700;
}

.wire-rate-in {
    color: #00e676;
}

.wire-rate-out {
    color: #ff9100;
}

.wire-rate-sep {
    color: var(--text-muted);
    font-size: 10px;
}

.wire-penalty-tag {
    font-family: var(--font-pixel);
    font-size: 8px;
    color: #ffffff;
    background: #dc2626;
    border: 1.5px solid var(--border-ink);
    border-radius: 4px;
    padding: 1px 4px;
    margin-left: 6px;
    letter-spacing: 0.5px;
    display: inline-block;
    vertical-align: middle;
    animation: pulseStarved 1.6s ease-in-out infinite;
}

/* Active Machinery Stack Rack in Left Pedestal */
.building-machinery-card {
    background: linear-gradient(180deg, #1f113a 0%, #120824 100%);
    border: 3px solid var(--border-ink);
    border-radius: 12px;
    padding: 10px;
    box-shadow: var(--comic-shadow);
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 280px;
    overflow-y: auto;
}

.machinery-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid var(--border-ink);
    padding-bottom: 6px;
}

.machinery-title {
    font-family: var(--font-pixel);
    font-size: 10px;
    color: var(--neon-cyan);
    letter-spacing: 0.8px;
}

.machinery-summary {
    font-family: var(--font-cartoon);
    font-size: 13px;
    font-weight: 800;
    color: var(--neon-yellow);
}

.building-icons-stack {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.machinery-row {
    background: rgba(0, 0, 0, 0.35);
    border: 1.5px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    padding: 6px 8px;
    display: flex;
    align-items: center;
    gap: 9px;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.machinery-row:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--neon-cyan);
}

.machinery-icon-container {
    width: 32px;
    height: 32px;
    background: #140929;
    border: 1.5px solid var(--border-ink);
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 0 var(--border-ink);
}

.equip-vector-svg {
    width: 22px;
    height: 22px;
    display: block;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.machinery-meta {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.machinery-name-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
}

.machinery-name {
    font-family: var(--font-cartoon);
    font-weight: 700;
    color: #ffffff;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.machinery-count {
    font-family: var(--font-cartoon);
    font-weight: 800;
    color: var(--neon-cyan);
    font-size: 12px;
    flex-shrink: 0;
}

.machinery-rate-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
}

.machinery-category {
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.machinery-rate {
    font-family: var(--font-cartoon);
    font-weight: 700;
    color: var(--neon-green);
    font-size: 11px;
    flex-shrink: 0;
}

.machinery-rate.wire-rate {
    color: var(--neon-orange);
}

.building-card-icon-col {
    width: 38px;
    height: 38px;
    background: #140929;
    border: 2px solid var(--border-ink);
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 0 var(--border-ink);
}

.building-card-icon-col .equip-vector-svg {
    width: 26px;
    height: 26px;
}

/* =========================================================================
   COLUMN 2: CENTER ARENA (Pixel Art Visualizer & Falling/Spilling Fluid)
   ========================================================================= */

.center-arena {
    position: relative;
    background: #090414;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Floating News Pill (Hidden for now) */
.news-ticker-pill {
    display: none !important;
}

/* Canvas Container */
.canvas-container {
    flex: 1;
    width: 100%;
    height: 100%;
    position: relative;
}

#cosmic-canvas {
    width: 100%;
    height: 100%;
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    cursor: pointer;
}

/* =========================================================================
   BOTTOM COMIC DIALOGUE BUBBLE (3x Bigger & Ultra-Crisp Comic HUD)
   ========================================================================= */

.dialogue-bubble {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(180deg, #2f195c 0%, #15092a 100%);
    border: 4px solid var(--border-ink);
    border-radius: 26px;
    padding: 22px 28px;
    display: flex;
    align-items: center;
    gap: 22px;
    box-shadow: 0 10px 0 var(--border-ink), 0 20px 48px rgba(0, 0, 0, 0.85), 0 0 36px rgba(0, 240, 255, 0.4);
    z-index: 50;
    max-width: 980px;
    width: 95%;
    animation: popInBounce 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: auto;
}

@keyframes popInBounce {
    0% { transform: translateX(-50%) scale(0.85) translateY(20px); opacity: 0; }
    100% { transform: translateX(-50%) scale(1) translateY(0); opacity: 1; }
}

.bubble-avatar {
    font-size: 58px;
    background: #140924;
    border: 4px solid var(--border-ink);
    border-radius: 20px;
    width: 96px;
    height: 96px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 5px 0 var(--border-ink);
}

.bubble-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow: hidden;
}

.bubble-sender {
    font-family: var(--font-pixel);
    font-size: 14px;
    color: var(--neon-cyan);
    letter-spacing: 1.5px;
    margin-bottom: 2px;
    text-shadow: 1px 1px 0 var(--border-ink);
    font-weight: bold;
}

.bubble-text {
    font-family: var(--font-cartoon);
    font-size: 26px;
    font-weight: 800;
    color: #ffffff;
    line-height: 1.35;
    text-shadow: 2px 2px 0 var(--border-ink);
}

.bubble-next-btn {
    background: linear-gradient(180deg, #ffe600 0%, #ff9900 100%);
    border: 3.5px solid var(--border-ink);
    border-radius: 16px;
    color: #100620;
    font-family: var(--font-cartoon);
    font-weight: 900;
    font-size: 20px;
    padding: 16px 28px;
    cursor: pointer;
    box-shadow: 0 6px 0 var(--border-ink);
    transition: all 0.1s ease;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.bubble-next-btn:hover {
    transform: translateY(-2px);
    background: linear-gradient(180deg, #fff04d 0%, #ffbe1a 100%);
    box-shadow: 0 8px 0 var(--border-ink);
}

.bubble-next-btn:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 var(--border-ink);
}

.bubble-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 28px;
    cursor: pointer;
    padding: 6px 10px;
    transition: color 0.1s;
    flex-shrink: 0;
}

.bubble-close:hover {
    color: var(--neon-pink);
}

.dialogue-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 12px;
}

.dialogue-choice-btn {
    background: linear-gradient(180deg, #ff007b 0%, #a8004e 100%);
    border: 3px solid var(--border-ink);
    border-radius: 12px;
    color: #ffffff;
    font-family: var(--font-cartoon);
    font-weight: 800;
    font-size: 15px;
    padding: 12px 18px;
    cursor: pointer;
    box-shadow: 0 4px 0 var(--border-ink);
    transition: all 0.1s ease;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    text-shadow: 1px 1px 0 var(--border-ink);
    line-height: 1.3;
    text-align: left;
    width: 100%;
}

.dialogue-choice-btn:nth-child(2) {
    background: linear-gradient(180deg, #00d2ff 0%, #0066aa 100%);
}

.dialogue-choice-btn:nth-child(3) {
    background: linear-gradient(180deg, #ffe600 0%, #d48800 100%);
    color: #120524;
    text-shadow: none;
}

.dialogue-choice-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 var(--border-ink);
    filter: brightness(1.15);
}

.dialogue-choice-btn:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 var(--border-ink);
}

.choice-excuse {
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.3px;
}

.choice-detail {
    font-size: 12px;
    font-weight: 600;
    opacity: 0.92;
    background: rgba(0, 0, 0, 0.25);
    padding: 3px 8px;
    border-radius: 6px;
    margin-top: 2px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* =========================================================================
   COLUMN 3: RIGHT PEDESTAL (Exact same width as Left: 360px)
   ========================================================================= */

.right-pedestal {
    background: var(--bg-panel);
    border-left: 3px solid var(--border-ink);
    box-shadow: inset 4px 0 12px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    padding: 10px 14px;
    gap: 10px;
    overflow-y: auto;
    z-index: 10;
}

/* Symmetrical Tab Header (Store & Tech Switcher) */
.right-tabs-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    background: #140a28;
    border: 2px solid var(--border-ink);
    border-radius: 12px;
    padding: 5px;
    box-shadow: var(--comic-shadow);
}

.right-tab-btn {
    background: transparent;
    border: 2px solid transparent;
    border-radius: 8px;
    padding: 9px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--text-muted);
    font-family: var(--font-pixel);
    font-size: 12px;
    font-weight: bold;
    position: relative;
    transition: all 0.12s ease;
}

.right-tab-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.05);
}

.right-tab-btn.active {
    background: linear-gradient(180deg, #ff7700 0%, #e04400 100%);
    border-color: var(--border-ink);
    color: #ffffff;
    box-shadow: 0 3px 0 var(--border-ink);
}

.right-tab-btn[data-tab="tech"].active {
    background: linear-gradient(180deg, #a855f7 0%, #7e22ce 100%);
}

.tab-icon {
    font-size: 20px;
}

.tab-label {
    letter-spacing: 0.5px;
    font-size: 12px;
    text-shadow: 1px 1px 0 var(--border-ink);
}

.tab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--neon-yellow);
    color: var(--border-ink);
    border: 2px solid var(--border-ink);
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-family: var(--font-cartoon);
    font-weight: 800;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 0 var(--border-ink);
    animation: pulseBadge 1.2s infinite;
}

@keyframes pulseBadge {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* Tab Content Views */
.tab-content-view {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    overflow-y: auto;
}

/* Multiplier Bar */
.multiplier-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    border: 2px solid var(--border-ink);
    border-radius: 12px;
    padding: 9px 12px;
    box-shadow: var(--comic-shadow);
}

.mult-label {
    font-family: var(--font-pixel);
    font-size: 11px;
    color: var(--neon-yellow);
}

.mult-group {
    display: flex;
    gap: 6px;
}

.mult-btn {
    background: #190c33;
    border: 2px solid var(--border-ink);
    color: var(--text-sub);
    padding: 6px 11px;
    border-radius: 7px;
    font-family: var(--font-pixel);
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 0 var(--border-ink);
    transition: all 0.1s ease;
}

.mult-btn:hover {
    color: #ffffff;
    background: #2b1754;
}

.mult-btn.active {
    background: var(--neon-cyan);
    color: var(--border-ink);
    box-shadow: 0 2px 0 var(--border-ink);
}

/* Single Next Upgrade Shelf */
.single-upgrade-shelf {
    background: #170b2e;
    border: 2px solid var(--border-ink);
    border-radius: 14px;
    padding: 12px;
    box-shadow: var(--comic-shadow);
}

.shelf-label {
    font-family: var(--font-pixel);
    font-size: 11px;
    color: var(--neon-cyan);
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.next-upgrade-card {
    background: var(--bg-card);
    border: 2px solid var(--border-ink);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: var(--comic-shadow);
}

.upgrade-top-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.upgrade-icon-box {
    width: 46px;
    height: 46px;
    background: #190c33;
    border: 2px solid var(--border-ink);
    border-radius: 10px;
    font-size: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.upgrade-header-info {
    flex: 1;
    overflow: hidden;
}

.upgrade-title {
    font-family: var(--font-cartoon);
    font-weight: 800;
    font-size: 17px;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.upgrade-discipline {
    font-family: var(--font-pixel);
    font-size: 10px;
    color: var(--neon-pink);
    margin-top: 2px;
}

.upgrade-effect {
    font-size: 14px;
    color: var(--text-sub);
    line-height: 1.35;
}

.btn-buy-upgrade {
    border: 2px solid var(--border-ink);
    border-radius: 10px;
    padding: 10px 14px;
    font-family: var(--font-cartoon);
    font-weight: 800;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 3px 0 var(--border-ink);
    transition: all 0.1s ease;
}

.btn-buy-upgrade.affordable {
    background: linear-gradient(180deg, #ffe600 0%, #e6a800 100%);
    color: #0c0717;
}

.btn-buy-upgrade.affordable:hover {
    transform: translateY(-1px);
    background: linear-gradient(180deg, #fff04d 0%, #ffbe1a 100%);
    box-shadow: 0 4px 0 var(--border-ink);
}

.btn-buy-upgrade.unaffordable {
    background: #25183d;
    color: #7b6a9e;
    cursor: not-allowed;
    opacity: 0.7;
}

.no-upgrades-box {
    text-align: center;
    padding: 16px;
    font-family: var(--font-cartoon);
    font-weight: 800;
    color: var(--neon-green);
    font-size: 15px;
}

/* Buildings Section (Larger text & clear stats) */
/* Store Submenus & Accordion Sections */
.store-submenus-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.store-accordion-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(18, 9, 36, 0.6);
    border: 2px solid var(--border-ink);
    border-radius: 14px;
    padding: 9px;
    box-shadow: 0 3px 0 var(--border-ink);
}

.store-accordion-header {
    width: 100%;
    background: linear-gradient(180deg, #2b1754 0%, #190c33 100%);
    border: 2px solid var(--border-ink);
    border-radius: 10px;
    padding: 9px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    box-shadow: 0 2px 0 var(--border-ink);
    transition: all 0.15s ease;
    font-family: var(--font-cartoon);
}

.store-accordion-header:hover {
    background: linear-gradient(180deg, #3d2077 0%, #25134c 100%);
    border-color: var(--neon-cyan);
    transform: translateY(-1px);
}

.accordion-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.accordion-chevron {
    font-size: 12px;
    color: var(--neon-yellow);
    transition: transform 0.2s ease;
    display: inline-block;
}

.store-accordion-section.collapsed .accordion-chevron {
    transform: rotate(-90deg);
}

.store-accordion-section.collapsed .store-accordion-content {
    display: none;
}

.accordion-icon {
    font-size: 18px;
}

.accordion-title {
    font-family: var(--font-pixel);
    font-size: 11px;
    color: var(--neon-yellow);
    letter-spacing: 0.6px;
}

.accordion-rate-pill {
    font-family: var(--font-cartoon);
    font-size: 13px;
    font-weight: 800;
    color: var(--neon-green);
    background: #0d061c;
    border: 1.5px solid var(--border-ink);
    border-radius: 6px;
    padding: 2px 8px;
}

.accordion-rate-pill.wire-rate-pill {
    color: var(--neon-orange);
}

.accordion-rate-pill.starved {
    color: #ff9100;
    border-color: #ff9100;
    animation: pulseStarved 1.6s ease-in-out infinite;
}

.store-accordion-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.locked-wire-teaser {
    background: #130926;
    border: 2px dashed #402373;
    border-radius: 10px;
    padding: 14px 12px;
    text-align: center;
    font-family: var(--font-cartoon);
    color: var(--text-sub);
    font-size: 13px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.locked-wire-icon {
    font-size: 24px;
}

.locked-wire-sub {
    font-size: 11px;
    color: var(--text-muted);
}

/* =========================================================================
   STORE & BUILDING CARDS (Optimized Gameplay Hierarchy: Price -> Rate -> Count)
   ========================================================================= */

.buildings-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.building-card {
    background: #160a2c;
    border: 2.5px solid var(--border-ink);
    border-radius: 14px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    box-shadow: var(--comic-shadow);
    transition: all 0.12s ease;
    position: relative;
}

.building-card.affordable {
    background: linear-gradient(180deg, #381a6e 0%, #220e45 100%);
    border-color: var(--neon-cyan);
    box-shadow: 0 4px 0 var(--border-ink), 0 0 14px rgba(0, 240, 255, 0.35);
}

.building-card.affordable:hover {
    transform: translateY(-2px);
    background: linear-gradient(180deg, #4c2299 0%, #2e145e 100%);
    border-color: #ffffff;
    box-shadow: 0 6px 0 var(--border-ink), 0 0 20px rgba(0, 240, 255, 0.6);
}

.building-card.affordable:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 var(--border-ink);
}

.building-card.wire-card.affordable {
    background: linear-gradient(180deg, #4d2612 0%, #2e1408 100%);
    border-color: var(--neon-orange);
    box-shadow: 0 4px 0 var(--border-ink), 0 0 14px rgba(255, 119, 0, 0.35);
}

.building-card.wire-card.affordable:hover {
    transform: translateY(-2px);
    background: linear-gradient(180deg, #663319 0%, #3d1b0a 100%);
    border-color: #ffe600;
    box-shadow: 0 6px 0 var(--border-ink), 0 0 20px rgba(255, 119, 0, 0.6);
}

.building-card.wire-card.affordable:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 var(--border-ink);
}

.building-card.locked {
    opacity: 0.5;
    background: #120721;
    border-color: #211136;
    box-shadow: 0 2px 0 var(--border-ink);
    cursor: not-allowed;
    filter: grayscale(35%);
}

.building-icon {
    font-size: 30px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #110722;
    border: 2px solid var(--border-ink);
    border-radius: 10px;
    flex-shrink: 0;
}

.building-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: hidden;
}

.building-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.building-name {
    font-family: var(--font-cartoon);
    font-weight: 800;
    font-size: 16px;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.building-count-badge {
    font-family: var(--font-pixel);
    font-size: 11px;
    font-weight: bold;
    color: var(--neon-cyan);
    background: #0f061e;
    border: 1.5px solid var(--border-ink);
    border-radius: 7px;
    padding: 2px 7px;
    white-space: nowrap;
    flex-shrink: 0;
}

.building-card.wire-card .building-count-badge {
    color: var(--neon-orange);
}

/* Gameplay Metrics: Price (Primary) & Production Rate (Secondary) */
.building-metrics-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.building-price-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #0d041c;
    border: 2px solid #ffe600;
    border-radius: 8px;
    padding: 3px 9px;
    box-shadow: 0 2px 0 var(--border-ink);
}

.building-card.affordable .building-price-pill {
    background: linear-gradient(180deg, #3d2400 0%, #170d00 100%);
    border-color: #ffe600;
    box-shadow: 0 2px 0 var(--border-ink), 0 0 10px rgba(255, 230, 0, 0.4);
}

.building-card.locked .building-price-pill {
    border-color: #4a3866;
    background: #0d041c;
    box-shadow: none;
}

.price-symbol {
    font-size: 15px;
}

.building-cost-amount {
    font-family: var(--font-cartoon);
    font-size: 19px;
    font-weight: 900;
    color: #ffe600;
    text-shadow: 1px 1px 0 #000000;
    letter-spacing: 0.5px;
    line-height: 1.1;
}

.building-card.locked .building-cost-amount {
    color: #8c7ba3;
    text-shadow: none;
}

.building-rate-pill {
    display: inline-flex;
    align-items: center;
    background: rgba(0, 255, 136, 0.12);
    border: 1.5px solid var(--neon-green);
    border-radius: 8px;
    padding: 3px 8px;
}

.building-card.wire-card .building-rate-pill {
    background: rgba(255, 119, 0, 0.12);
    border-color: var(--neon-orange);
}

.building-card.locked .building-rate-pill {
    background: rgba(255, 255, 255, 0.04);
    border-color: #4a3866;
}

.building-rate-amount {
    font-family: var(--font-cartoon);
    font-size: 14px;
    font-weight: 800;
    color: var(--neon-green);
}

.building-card.wire-card .building-rate-amount {
    color: var(--neon-orange);
}

.building-card.locked .building-rate-amount {
    color: #7e69a8;
}

/* Floating Popups */
#floating-popups {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 1000;
}

.floating-number {
    position: absolute;
    font-family: var(--font-cartoon);
    font-weight: 800;
    font-size: 20px;
    text-shadow: 2px 2px 0 #000000;
    animation: floatUpFade 1s ease-out forwards;
}

.spark-popup {
    color: var(--neon-cyan);
}

.gold-popup {
    color: var(--neon-yellow);
    font-size: 24px;
}

.warn-popup {
    color: #ff3344;
    font-size: 22px;
}

@keyframes floatUpFade {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    100% { transform: translateY(-50px) scale(1.15); opacity: 0; }
}

/* Toast Container (Achievement Notifications - Anchored Top-Right to Never Overlap Bottom Dialogue) */
#toast-container {
    position: fixed;
    top: 68px;
    right: 380px; /* Top right corner of center arena */
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 500;
    pointer-events: none;
}

.toast {
    background: #1c0e3a;
    border: 2px solid var(--neon-yellow);
    border-radius: 12px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 0 var(--border-ink), 0 8px 20px rgba(0, 0, 0, 0.6);
    color: #ffffff;
    font-family: var(--font-cartoon);
    font-weight: 700;
    font-size: 15px;
    animation: toastSlideIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes toastSlideIn {
    0% { transform: translateX(60px); opacity: 0; }
    100% { transform: translateX(0); opacity: 1; }
}

/* =========================================================================
   SETTINGS & PREFERENCES MODAL
   ========================================================================= */

.settings-cog-btn {
    background: linear-gradient(180deg, #2f195c 0%, #170933 100%);
    border: 2px solid var(--border-ink);
    color: #ffffff;
    padding: 7px 14px;
    border-radius: 10px;
    font-family: var(--font-cartoon);
    font-weight: 800;
    font-size: 13px;
    cursor: pointer;
    box-shadow: 0 3px 0 var(--border-ink);
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
}

.settings-cog-btn:hover {
    transform: translateY(-2px);
    border-color: var(--neon-cyan);
    background: linear-gradient(180deg, #442385 0%, #251052 100%);
    box-shadow: 0 5px 0 var(--border-ink), 0 0 14px rgba(0, 240, 255, 0.4);
    color: var(--neon-cyan);
}

.settings-cog-btn:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 var(--border-ink);
}

.settings-cog-icon {
    font-size: 16px;
    display: inline-block;
    transition: transform 0.3s ease;
}

.settings-cog-btn:hover .settings-cog-icon {
    transform: rotate(45deg);
}

.settings-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(9, 4, 20, 0.82);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeInBackdrop 0.15s ease-out;
}

@keyframes fadeInBackdrop {
    from { opacity: 0; }
    to { opacity: 1; }
}

.settings-modal-card {
    background: linear-gradient(180deg, #25124d 0%, #120726 100%);
    border: 4px solid var(--border-ink);
    border-radius: 20px;
    width: 94%;
    max-width: 520px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 0 var(--border-ink), 0 20px 48px rgba(0, 0, 0, 0.8), 0 0 35px rgba(0, 240, 255, 0.25);
    animation: popInBounce 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    overflow: hidden;
}

.settings-modal-header {
    padding: 16px 20px;
    background: #190c36;
    border-bottom: 3px solid var(--border-ink);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.settings-modal-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-pixel);
    font-size: 12px;
    color: var(--neon-yellow);
    text-shadow: 2px 2px 0 var(--border-ink);
    letter-spacing: 0.5px;
}

.settings-modal-icon {
    font-size: 20px;
}

.settings-close-btn {
    background: #2b1452;
    border: 2px solid var(--border-ink);
    border-radius: 8px;
    color: var(--text-sub);
    font-size: 16px;
    font-weight: bold;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 0 var(--border-ink);
    transition: all 0.1s ease;
}

.settings-close-btn:hover {
    background: #ff2a55;
    color: #ffffff;
    border-color: var(--border-ink);
    transform: translateY(-1px);
    box-shadow: 0 3px 0 var(--border-ink);
}

.settings-close-btn:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 var(--border-ink);
}

.settings-modal-body {
    padding: 18px 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.settings-section {
    background: rgba(18, 9, 36, 0.7);
    border: 2px solid var(--border-ink);
    border-radius: 12px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 3px 0 var(--border-ink);
}

.settings-section-title {
    font-family: var(--font-pixel);
    font-size: 9.5px;
    color: var(--neon-cyan);
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.settings-label {
    font-family: var(--font-cartoon);
    font-weight: 700;
    font-size: 14px;
    color: #ffffff;
}

.settings-control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.settings-mute-btn {
    padding: 6px 10px;
    font-size: 16px;
}

.settings-value-readout {
    font-family: var(--font-pixel);
    font-size: 10px;
    color: var(--neon-yellow);
    min-width: 40px;
    text-align: right;
}

.settings-grid-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.settings-action-btn {
    width: 100%;
    justify-content: center;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 800;
}
