/* --- START OF FILE style.css --- */

 html {
    overflow: hidden;
}
 :root {
            --bg-color: #0d1b2a;
            --text-color: #e0e1dd;
            --text-shadow-color: #1b263b;
            --border-color: #415a77;
            --panel-bg: #1b263b;
            --highlight-color: #778da9;
            --accent-blue: #59A5D8;
            --accent-green: #84DCC6;
            --accent-red: #F26666;
            --accent-yellow: #F2D335;
        }

body {
    font-family: 'Press Start 2P', cursive;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh; /* CHANGED BACK from height */
    margin: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow: hidden; /* This is now supported by the html rule */
}

        #sky {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: -1;
            transition: background-color 5s linear;
        }
        
#gameWrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0; /* ADDED: Prevents the wrapper from shrinking */
    max-height: 95vh; /* ADDED: Ensures it fits on screen */
}

        #gameContainer {
            width: 95%;
            max-width: 900px;
            background-color: #3a3a3a; /* TV Casing color */
            padding: 15px;
            border: 4px solid #222;
            border-style: outset;
            text-shadow: 1px 1px 0 var(--text-shadow-color);
            border-radius: 15px; /* Rounded corners for the whole TV */
            box-shadow: 0 10px 20px rgba(0,0,0,0.5), inset 0 2px 3px rgba(255,255,255,0.1);
            position: relative; 
            overflow: hidden; 
        }

        #gameLayout {
            display: flex;
            flex-direction: row;
            gap: 8px;
            height: 700px;
        }

        #canvasContainer { 
            position: relative; 
            overflow: hidden;
            border-radius: 10px 0 0 10px;
            box-shadow: inset 0 0 25px 10px rgba(0,0,0,0.6);
            background-color: #000; /* Fallback */
            width: 600px;
            height: 700px;
            flex-shrink: 0;
        }
        
        #canvasContainer.edit-mode {
            cursor: help;
        }
        #canvasContainer.placing-mode {
             cursor: crosshair;
        }

        #canvasContainer::before { /* Scanlines */
            content: "";
            position: absolute;
            top: 0; left: 0; width: 100%; height: 100%;
            background: repeating-linear-gradient(0deg, rgba(0,0,0,0) 0px, rgba(0,0,0,0) 2px, rgba(0,0,0,0.4) 3px, rgba(0,0,0,0.4) 4px);
            z-index: 10;
            pointer-events: none;
        }

        #canvasContainer::after { /* Vignette/Curvature */
            content: "";
            position: absolute;
            top: 0; left: 0; width: 100%; height: 100%;
            background: radial-gradient(ellipse at center, rgba(0,0,0,0) 60%, rgba(0,0,0,0.8) 100%);
            z-index: 11;
            pointer-events: none;
        }

        canvas {
            border: none; /* Replaced by container styles */
            display: block;
            /* cursor is handled by container */
            transition: background-color 2s ease-in-out;
            image-rendering: pixelated;
            image-rendering: -moz-crisp-edges;
            image-rendering: crisp-edges;
            filter: blur(0.4px) saturate(1.1); /* Phosphor glow effect */
        }
        
        #noiseOverlay {
            position: absolute;
            top: -50%; left: -50%; width: 200%; height: 200%;
            z-index: 9;
            pointer-events: none;
            background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 250 250' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
            opacity: 0.08;
            animation: noise 0.2s infinite;
        }

        @keyframes noise {
            0% { transform: translate(0, 0); } 10% { transform: translate(-5%, -10%); } 20% { transform: translate(-15%, 5%); } 30% { transform: translate(7%, -25%); } 40% { transform: translate(-5%, 25%); } 50% { transform: translate(-15%, 10%); } 60% { transform: translate(15%, 0%); } 70% { transform: translate(0%, 15%); } 80% { transform: translate(3%, 35%); } 90% { transform: translate(-10%, 10%); } 100% { transform: translate(0, 0); }
        }

        #rightPanel {
            flex: 1;
            display: flex;
            flex-direction: column;
            border: 4px solid #333;
            border-left: 10px solid #222;
            border-style: outset;
            padding: 1rem;
            background: linear-gradient(90deg, #181818 0%, #282828 10%, #202020 90%, #151515 100%);
            position: relative;
            border-radius: 0 10px 10px 0;
        }

        #speakerGrille {
            position: absolute;
            bottom: 1rem;
            right: 1rem;
            left: 1rem;
            height: 60px;
            background: repeating-linear-gradient(0deg, #111, #111 2px, #2a2a2a 2px, #2a2a2a 4px);
            opacity: 0.5;
            z-index: 0;
        }

        /* --- CRT TV STYLING END --- */

        /* --- NEW: Scrollbar Styling --- */
        #scrollTrack {
            position: absolute;
            left: -30px;
            top: 0;
            bottom: 0;
            height: 100%;
            width: 18px;
            background: #222;
            border: 3px outset #444;
            border-radius: 10px;
            z-index: 250;
            box-sizing: border-box;
        }
        #scrollThumb {
            position: absolute;
            top: 0;
            left: 50%;
            transform: translateX(-50%);
            width: 26px; /* Wider for easier grabbing */
            height: 50%; /* Thumb is half the height of track */
            background: var(--border-color);
            border: 4px outset var(--highlight-color);
            border-radius: 8px;
            cursor: ns-resize;
            transition: top 0.1s linear; /* Smooth visual update */
        }
        #scrollThumb:active {
            border-style: inset;
            background: var(--highlight-color);
        }

        #uiContainer {
            display: flex; 
            flex-direction: column;
            align-items: flex-start;
            gap: 0.75rem;
            width: 100%; 
            padding-bottom: 1.5rem; 
            font-size: 0.8rem; 
            color: var(--highlight-color);
            border-bottom: 4px double var(--border-color);
            margin-bottom: 1.5rem;
            position: relative; z-index: 1;
        }
        .ui-item { display: flex; align-items: center; gap: 0.5rem; }
        .ui-item span { color: var(--text-color); }
        .currency-icon { width: 1.25em; height: 1.25em; stroke-width: 2; stroke: var(--accent-yellow); }

        #marketReport {
            margin-top: 1rem;
            font-size: 0.7rem;
            border-top: 2px solid var(--border-color);
            padding-top: 1rem;
        }
        #marketReport h3 {
            font-size: 0.8rem;
            margin: 0 0 0.5rem 0;
            color: var(--text-color);
            text-decoration: underline;
        }
        .market-item {
            display: flex;
            justify-content: space-between;
            margin-bottom: 0.25rem;
        }
        .market-item .trend.up { color: var(--accent-green); }
        .market-item .trend.down { color: var(--accent-red); }

        #dialogueBox {
            flex-grow: 1;
            font-size: 0.8rem;
            line-height: 1.6;
            color: var(--highlight-color);
            overflow-y: auto;
            position: relative; z-index: 1;
        }
        
        .shake { animation: shake 0.4s; }
        @keyframes shake {
            10%, 90% { transform: translate3d(-1px, 0, 0); } 20%, 80% { transform: translate3d(2px, 0, 0); }
            30%, 50%, 70% { transform: translate3d(-3px, 0, 0); } 40%, 60% { transform: translate3d(3px, 0, 0); }
        }

        .sell-mode-pulse {
    animation: sell-pulse 1.5s infinite;
}
@keyframes sell-pulse {
    0% { filter: drop-shadow(0 0 0px rgba(242, 102, 102, 0.7)); }
    50% { filter: drop-shadow(0 0 10px rgba(242, 102, 102, 0.9)); }
    100% { filter: drop-shadow(0 0 0px rgba(242, 102, 102, 0.7)); }
}

        .glitch-effect { animation: glitch 0.25s linear; }
        @keyframes glitch {
            0% { transform: translate(0, 0); clip-path: inset(0% 0% 0% 0%); }
            20% { transform: translate(-3px, 3px); clip-path: inset(10% 0% 85% 0%); }
            40% { transform: translate(3px, -3px); clip-path: inset(90% 0% 5% 0%); }
            60% { transform: translate(-3px, 3px); clip-path: inset(40% 0% 40% 0%); }
            80% { transform: translate(3px, -3px); clip-path: inset(80% 0% 10% 0%); }
            100% { transform: translate(0, 0); clip-path: inset(0% 0% 0% 0%); }
        }

        .modal {
            display: none; position: fixed; z-index: 201; left: 0; top: 0; width: 100%; height: 100%;
            overflow: auto; background-color: rgba(0,0,0,0.7); justify-content: center; align-items: center;
        }

        #tvStaticOverlay {
            position: fixed;
            top: 0; left: 0;
            width: 100vw; height: 100vh;
            background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 250 250' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.5' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
            opacity: 0;
            z-index: 99;
            pointer-events: none;
            display: none;
        }

        @keyframes tv-flicker {
            0% { opacity: 0; }
            20% { opacity: 0.8; transform: scale(1.05); }
            30% { opacity: 0.2; transform: translateY(-50px); }
            40% { opacity: 0.9; transform: translateY(0); }
            80% { opacity: 0.1; }
            100% { opacity: 0; }
        }

        @keyframes channel-change-in {
            from { opacity: 0; transform: scale(1.2); }
            to { opacity: 1; transform: scale(1); }
        }

        .modal.show-transition .modal-content {
            animation: channel-change-in 0.3s cubic-bezier(0.250, 0.460, 0.450, 0.940) 0.1s both;
        }

        #tvStaticOverlay.active {
            display: block;
            animation: tv-flicker 0.4s linear forwards;
        }

        #powerOverlay {
            position: absolute;
            top: 0; left: 0; width: 100%; height: 100%;
            background: #111;
            z-index: 200;
            pointer-events: none;
            opacity: 1;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        #powerOverlay.off { display: none; }
        #powerOverlay.power-on { animation: power-on-anim 1.5s forwards; }
        #powerOverlay.power-off { animation: power-off-anim 1.2s forwards; }

        #powerOverlay::before { /* The white line/dot */
            content: '';
            background: white;
            box-shadow: 0 0 10px 5px white, 0 0 20px 10px #aaf, 0 0 30px 15px #afa;
        }
        .power-on::before { animation: power-on-line 1.5s forwards; }
        .power-off::before { animation: power-off-line 1.2s forwards; }

        @keyframes power-on-line {
            0% { width: 0; height: 2px; opacity: 0; }
            20% { width: 100%; height: 2px; opacity: 1; }
            50% { width: 100%; height: 100%; opacity: 1; }
            100% { width: 100%; height: 100%; opacity: 0; }
        }
        @keyframes power-on-anim {
            0% { opacity: 1; }
            99% { opacity: 1; }
            100% { opacity: 0; }
        }
        @keyframes power-off-line {
            0% { width: 100%; height: 100%; opacity: 0; }
            30% { width: 100%; height: 2px; opacity: 1; }
            80% { width: 2px; height: 2px; opacity: 1; }
            100% { width: 0; height: 0; opacity: 0; }
        }
        @keyframes power-off-anim {
            0% { opacity: 0; }
            1% { opacity: 1; }
            100% { opacity: 1; }
        }

        .modal-content {
            background-color: var(--panel-bg);
            margin: auto; padding: 1.5rem; text-align: center; width: 90%; max-width: 450px;
            color: var(--highlight-color);
            border: 4px outset var(--border-color);
            text-shadow: 1px 1px 0 var(--text-shadow-color);
        }
        .modal-content h2 { font-size: 1.25rem; margin-bottom: 0.5rem; color: var(--text-color); }
        .modal-content p { margin-bottom: 1rem; line-height: 1.5; font-size: 0.9rem; position: relative; z-index: 1; /* Fix for potential overlap issues */ }
        
        #gameOverLogo {
            width: 80%;
            max-width: 350px;
            image-rendering: pixelated;
            margin: 1rem auto;
        }
        .game-over-text {
            color: var(--text-color);
            text-shadow: 2px 2px 0 var(--text-shadow-color);
            font-size: 2.5rem !important; /* Override other h2 styles */
            margin: 0;
        }
        .game-over-buttons {
            display: flex;
            justify-content: center;
            gap: 1.5rem;
            margin-top: 1.5rem;
        }
        .game-over-buttons .modal-button {
            width: 120px;
        }
        
        .side-panel-button {
            background-color: var(--border-color); color: var(--text-color); padding: 0.75rem 1.5rem;
            border: 4px outset var(--highlight-color);
            cursor: pointer; font-size: 1rem; font-family: 'Press Start 2P', cursive;
            text-shadow: 1px 1px 0 var(--text-shadow-color);
            width: 100%;
            margin-top: 1rem;
            position: relative; z-index: 1;
        }
        .side-panel-button:hover { background-color: var(--highlight-color); }
        .side-panel-button:active { border-style: inset; }

        #donePlacingButton { background-color: var(--accent-green); }
        #donePlacingButton:hover { background-color: #A6E4D8; }

        .modal-button {
            background-color: var(--border-color); color: var(--text-color); padding: 0.75rem 1.5rem;
            border: 4px outset var(--highlight-color); cursor: pointer; font-size: 1rem; 
            font-family: 'Press Start 2P', cursive; text-shadow: 1px 1px 0 var(--text-shadow-color);
        }

        #upgradeScreen {
            position: absolute;
            top: 0; left: 0;
            width: 100%; height: 100%;
            z-index: 150;
            background-color: rgba(13, 27, 42, 0.9);
            display: none; /* Initially hidden */
            justify-content: center;
            align-items: center;
            animation: channel-change-in 0.3s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
        }
        #upgradeScreen .modal-content {
            max-width: 500px;
            width: 90%;
            border-radius: 10px;
        }

        .shop-tabs { display: flex; border-bottom: 4px double var(--border-color); margin-bottom: 1rem; }
        .shop-tab { padding: 0.75rem 1rem; cursor: pointer; color: var(--highlight-color); position: relative; bottom: -4px; }
        .shop-tab.active { color: var(--accent-blue); border-bottom: 4px solid var(--accent-blue); }

        .shop-pane { 
            display: none; 
            max-height: 35vh;
            overflow-y: auto;
            padding-right: 10px; /* Space for scrollbar */
        } 
        .shop-pane.active { display: block; }

        .shop-pane::-webkit-scrollbar { width: 12px; }
        .shop-pane::-webkit-scrollbar-track {
            background: var(--bg-color);
            border: 2px inset var(--border-color);
        }
        .shop-pane::-webkit-scrollbar-thumb {
            background-color: var(--highlight-color);
            border: 2px outset var(--border-color);
        }
        .shop-pane::-webkit-scrollbar-thumb:hover { background-color: var(--accent-blue); }

        .swipe-indicator { color: var(--highlight-color); font-size: 0.75rem; margin-bottom: 1rem; }
        
        .upgrade-item {
            padding: 1rem; margin-bottom: 0.75rem; display: flex;
            justify-content: space-between; align-items: center; text-align: left;
            border-bottom: 2px solid var(--border-color); font-size: 0.8rem;
        }
        .upgrade-item button {
            background-color: var(--accent-blue); color: white; padding: 0.5rem 1rem; cursor: pointer;
            font-family: 'Press Start 2P', cursive; text-shadow: 1px 1px 0 var(--text-shadow-color);
            border: 2px outset var(--highlight-color);
            font-size: 0.75rem; flex-shrink: 0; margin-left: 1rem;
        }
        .upgrade-item button:hover { background-color: #89C2E3; }
        .upgrade-item button:disabled { background-color: #6c757d; cursor: not-allowed; opacity: 0.7; }
        .upgrade-item button:active { border-style: inset; }
        .price-diff { font-size: 0.65rem; opacity: 0.9; } 
        .profit-text { font-size: 0.7rem; display: block; text-align: right; }

        #tooltip {
            position: absolute; background-color: rgba(17, 24, 39, 0.9); color: white;
            padding: 0.5rem 1rem; font-size: 0.75rem; pointer-events: none; z-index: 200;
            border: 2px solid var(--accent-yellow);
        }
        .hidden { display: none !important; }

        #contextualUpgradeUI {
            position: absolute;
            background-color: var(--panel-bg);
            border: 2px outset var(--highlight-color);
            padding: 0.75rem;
            font-size: 0.7rem;
            text-align: center;
            z-index: 50;
            display: none; /* Initially hidden */
            min-width: 120px;
        }
        #contextualUpgradeUI p {
            margin: 0 0 0.5rem 0;
            color: var(--text-color);
        }
        .contextual-button {
            width: 100%;
            padding: 0.4rem;
            font-size: 0.65rem;
            font-family: 'Press Start 2P', cursive;
            border: 2px outset var(--highlight-color);
            cursor: pointer;
            margin-top: 0.5rem;
        }
        #contextualUpgradeButton {
            background-color: var(--accent-green);
            color: white;
        }
        #contextualRepairButton {
            background-color: var(--accent-yellow);
            color: #0d1b2a;
        }
        #contextualSellButton {
            background-color: var(--accent-red);
            color: white;
        }
        #contextualFortifyButton {
            background-color: var(--accent-blue);
            color: white;
        }
        #contextualGoatButton {
            background-color: var(--accent-green);
            color: white;
        }
        .contextual-button:disabled {
            background-color: #6c757d;
            cursor: not-allowed;
            opacity: 0.7;
        }

        #wateringTapButton {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 150px;
            height: 150px;
            background-color: #ff69b4;
            color: white;
            font-size: 2rem;
            border-radius: 50%;
            border: 8px outset white;
            z-index: 60;
            display: none; /* Initially hidden */
            cursor: pointer;
            text-shadow: 2px 2px 0 var(--text-shadow-color);
            line-height: 150px; /* Vertically center text */
            text-align: center;
            pointer-events: none; /* The canvas will handle clicks now */
        }
        
        #playerPortrait {
            display: block;
            margin: 1rem auto 0;
            max-width: 128px;
            image-rendering: pixelated;
        }

        #placementHelper {
            background-color: var(--panel-bg);
            border: 2px outset var(--border-color);
            color: var(--highlight-color);
            padding: 0.5rem;
            font-size: 0.7rem;
            text-align: center;
            margin-top: 1rem;
            position: relative;
            z-index: 1;
        }
        /* --- NEW: Consistent Scrollbar Styling --- */
#dialogueBox::-webkit-scrollbar {
    width: 16px;
}

#dialogueBox::-webkit-scrollbar-track {
    background: #222;
    border: 2px inset #444;
    border-radius: 10px;
}

#dialogueBox::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 8px;
    border: 4px outset var(--highlight-color);
}

#dialogueBox::-webkit-scrollbar-thumb:active {
    background-color: var(--highlight-color);
    border-style: inset;
}