/* Cyberpunk Minimalist UI for Galaxy Trader */

:root {
    /* Core color palette - monochrome with cyan accent */
    --bg-black: #0a0a0a;
    --bg-dark: #141414;
    --bg-medium: #1a1a1a;
    --border-subtle: #2a2a2a;
    --text-primary: #ffffff;
    --text-secondary: #888888;
    --text-dim: #555555;
    
    /* Accent colors - cyberpunk cyan */
    --accent-primary: #00ffff;
    --accent-glow: rgba(0, 255, 255, 0.5);
    --accent-subtle: rgba(0, 255, 255, 0.1);
    --accent-border: rgba(0, 255, 255, 0.3);
    
    /* Status colors */
    --status-danger: #ff0040;
    --status-warning: #ffaa00;
    --status-success: #00ff88;
    
    /* Spacing system */
    --spacing-xs: 8px;
    --spacing-sm: 12px;
    --spacing-md: 20px;
    --spacing-lg: 32px;
    --spacing-xl: 48px;
}

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

body {
    background: var(--bg-black);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
    overflow: hidden;
    position: relative;
    width: 100vw;
    height: 100vh;
}

/* Top-left logo overlay */
.logo-overlay {
    position: fixed;
    top: 8px;
    left: 8px;
    z-index: 200; /* above canvas and HUD chrome */
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    pointer-events: none; /* never block gameplay interactions */
}
.logo-overlay img {
    height: 108px; /* larger for better visibility */
    width: auto;
    display: block;
    filter: drop-shadow(0 0 2px rgba(0,0,0,0.6));
}
.logo-overlay .version {
    font-size: 10px;
    color: var(--text-primary);
    letter-spacing: 0.4px;
    text-shadow: 0 0 3px rgba(0,0,0,0.6);
    opacity: 0.9;
}

/* Ship destroyed: dim and desaturate HUD widgets, disable radio interaction */
body.ship-destroyed #gameHUD {
    filter: grayscale(0.9) brightness(0.6);
}
body.ship-destroyed #shipRadio,
body.ship-destroyed #minimap,
body.ship-destroyed #centerViewport {
    opacity: 0.35;
}
body.ship-destroyed #shipRadio button { pointer-events: none; opacity: 0.6; }
body.ship-destroyed #shipRadio.offline #radioDial::after { display: none; }

#gameCanvas {
    display: block;
    background: #000;
    width: 100%;
    height: calc(100vh - 150px); /* HUD height (110px) + padding (40px) */
    position: absolute;
    top: 0;
    left: 0;
}

/* Reduce mouse-focus outline but preserve keyboard accessibility */
#gameCanvas:focus, #gameCanvas:focus-visible { outline: none !important; }

/* Generic rule: hide focus outlines for mouse focus across the HUD controls */
:focus:not(:focus-visible) { outline: none; box-shadow: none; }

/* Main HUD - Cyberpunk Minimalist */
#gameHUD {
    position: fixed;
    bottom: var(--spacing-md);
    left: var(--spacing-md);
    right: var(--spacing-md);
    height: 110px;  /* Increased height for content */
    z-index: 100;
    background: linear-gradient(180deg, 
        transparent 0%, 
        var(--bg-dark) 20%,
        var(--bg-dark) 100%);
    border: 1px solid var(--border-subtle);
    border-bottom: 2px solid var(--accent-border);
    /* Default: no backdrop blur to avoid heavy composite cost */
    backdrop-filter: none;
    /* Isolate HUD layout but allow children to paint outside (radio dial overflow) */
    contain: layout;
    overflow: visible;
}

/* Opt-in heavy HUD effects (blur) */
body.ui-heavy #gameHUD { backdrop-filter: blur(10px); }

/* QA: Lightweight UI mode reduces heavy effects during profiling */
body.ui-light #gameHUD { backdrop-filter: none !important; }
body.ui-light #radioViz::after { animation: none !important; }
body.ui-light #shipRadio.radio-radial.scanning #radioDial::after { animation: none !important; }
body.ui-light #logo-ascii::after { animation: none !important; }

/* HUD Container */
.hud-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start; /* pack items; center expands to fill */
    padding: var(--spacing-md) var(--spacing-md);
    gap: var(--spacing-md);
    overflow: visible;  /* Allow overflow */
}

/* Tighter layout on medium screens to prevent overflow */
@media (max-width: 1280px) {
    .hud-container { padding: var(--spacing-sm); gap: var(--spacing-sm); }
}

/* Ship Radio - compact widget between left and center */
#shipRadio {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: 28px 34px 28px; /* prev | play/pause | next */
    grid-auto-rows: auto;
    align-items: center;
    justify-items: center;
    column-gap: 6px;
    row-gap: 4px;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(0,255,255,0.05);
    padding: 6px 8px;
    min-width: 130px;
    width: max-content;
    /* Isolate layout only; allow paint to overflow for dial */
    contain: layout;
}

#shipRadio.radio-radial {
    position: relative;
    width: 192px; /* dial + side buttons region */
    min-width: 192px;
    height: 140px; /* larger than HUD (110px) to overflow top/bottom */
    padding: 0; /* radial uses absolute children */
    grid-template-columns: none;
    grid-auto-rows: initial;
    background: transparent !important; /* backplate handled via pseudo-elements */
    border: none !important;
    overflow: visible; /* allow the dial to exceed HUD bounds */
    z-index: 200; /* ensure above HUD chrome/borders */
    /* layout variables for precise alignment */
    --dial-size: 128px;
    --dial-offset: 6px;
    --button-col-right: 8px; /* legacy; not used when docking to dial */
    --dot-hit: 24px;   /* reduced hit area to bring dots closer */
    --dot-size: 14px;  /* keep visual dot sizeable */
    --btn-w: var(--dot-hit);
    --btn-h: var(--dot-hit); /* uniform circular hit area for all buttons */
    --dot-gap: 2px;    /* tighter visual space between dots */
    --dial-center: calc(var(--dial-offset) + (var(--dial-size) / 2));
    --half-h: calc(var(--btn-h) / 2);
    --onehalf-h: calc(var(--btn-h) + var(--half-h));
}

/* Hide linear viz in radial mode */
#shipRadio.radio-radial #radioViz { display: none; }

/* Molded backplate around the dial and button column */
#shipRadio.radio-radial::before,
#shipRadio.radio-radial::after {
    content: '';
    position: absolute;
    z-index: 0; /* behind dial/title/buttons */
    background: var(--bg-dark);
    border: 1px solid var(--accent-border);
    box-shadow: 0 0 18px rgba(0,0,0,0.6), 0 0 12px var(--accent-subtle) inset;
    pointer-events: none; /* never block button clicks */
}
/* Circular backplate for dial */
#shipRadio.radio-radial::before {
    /* Center the circular backplate precisely on the dial center to keep rings concentric */
    top: calc(var(--dial-offset) + (var(--dial-size) / 2));
    left: calc(var(--dial-offset) + (var(--dial-size) / 2));
    transform: translate(-50%, -50%);
    width: calc(var(--dial-size) + 16px);
    height: calc(var(--dial-size) + 16px);
    border-radius: 50%;
}
/* Rounded-rect backplate for the right-side button column */
#shipRadio.radio-radial::after {
    /* Tighten to hug the three buttons with even padding and move slightly under dial edge */
    top: calc(var(--dial-center) - (var(--btn-h) * 1.5) - 4px);
    left: calc(var(--dial-offset) + var(--dial-size) - 2px); /* slight overlap */
    width: calc(var(--btn-w) + 4px); /* narrower bar for symmetric padding */
    height: calc(var(--btn-h) * 3 + 8px);
    border-radius: 8px;
    z-index: 2; /* ensure bar sits above dial ring at overlap */
}

/* Radial dial visuals */
#radioDial {
    position: absolute;
    top: var(--dial-offset); left: var(--dial-offset);
    width: var(--dial-size); height: var(--dial-size); /* fixed dial, leaves room for side buttons */
    border-radius: 50%;
    border: 1px solid var(--accent-border);
    background-color: var(--bg-black); /* ensure opaque interior */
    background:
        radial-gradient(circle at 50% 50%, rgba(0,255,255,0.06) 0 38%, transparent 39%),
        repeating-conic-gradient(
            rgba(0,255,255,0.18) 0 1deg,
            transparent 1deg 30deg
        ),
        radial-gradient(circle, rgba(0,0,0,0.6) 62%, rgba(0,0,0,0.2) 84%, rgba(0,0,0,0.0) 100%);
    box-shadow: inset 0 0 10px rgba(0,255,255,0.08), 0 0 10px rgba(0,255,255,0.04);
    overflow: hidden;
    z-index: 1;
}

/* Radio dial static overlay canvas (lightweight, non-interactive) */
#shipRadio.radio-radial #radioDial canvas#radioStatic {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    pointer-events: none;
    z-index: 0; /* under sweep (::after) */
}

#shipRadio.radio-radial.scanning #radioDial::after,
#shipRadio.radio-radial.tuned #radioDial::after {
    content: '';
    position: absolute;
    inset: -30%;
    border-radius: 50%;
    background: conic-gradient(from 0deg, rgba(0,255,255,0.32) 0 12deg, transparent 12deg 360deg);
    transform: rotate(0deg);
    opacity: 0.6;
    z-index: 1;
}

/* Default: no radial sweep animation (opt-in via body.ui-heavy) */
#shipRadio.radio-radial.scanning #radioDial::after { animation: none; }
body.ui-heavy #shipRadio.radio-radial.scanning #radioDial::after { animation: radial-sweep 1.6s linear infinite; }

#shipRadio.radio-radial.tuned #radioDial::after {
    animation: none;
    opacity: 0.2;
}

@keyframes radial-sweep {
    to { transform: rotate(360deg); }
}

/* Readout centered in dial */
#shipRadio.radio-radial #radioTitle {
    position: absolute;
    top: calc(var(--dial-offset) + (var(--dial-size) / 2));
    left: calc(var(--dial-offset) + (var(--dial-size) / 2));
    transform: translate(-50%, -50%);
    width: 110px; /* constrained to dial interior */
    font-family: 'VT323', monospace;
    font-size: 11px;
    letter-spacing: 1px;
    border: none;
    background: transparent;
    text-align: center;
    padding: 0;
    z-index: 3; /* above dial */
    text-shadow: 0 0 6px rgba(0,255,255,0.18);
}

/* Buttons moved to a right-hand side column (stereo receiver feel) */
#shipRadio.radio-radial #radioPrev,
#shipRadio.radio-radial #radioPlay,
#shipRadio.radio-radial #radioNext {
    position: absolute;
    /* Keep buttons centered within the tightened backplate */
    left: calc(var(--dial-offset) + var(--dial-size) + 0px);
    right: auto;
    width: var(--btn-w); height: var(--btn-h);
    border-radius: 50%;
    display: grid; place-items: center;
    background: transparent; /* visual dot handled by ::before */
    border: none;
    color: transparent; /* hide glyphs */
    font-size: 0; line-height: 0; /* ensure no visible text */
    z-index: 4; /* above bar backplate and dial */
}

/* Remove focus rings/ink for radio buttons */
#shipRadio button,
#shipRadio.radio-radial button { outline: none; -webkit-tap-highlight-color: transparent; }
#shipRadio button:focus,
#shipRadio.radio-radial button:focus { outline: none; }

/* Visual dot inside each button, keeps large hit area */
#shipRadio.radio-radial #radioPrev::before,
#shipRadio.radio-radial #radioPlay::before,
#shipRadio.radio-radial #radioNext::before {
    content: '';
    width: var(--dot-size);
    height: var(--dot-size);
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    border: 1px solid var(--accent-border);
    box-shadow: 0 0 4px rgba(0,255,255,0.15), inset 0 0 6px rgba(0,255,255,0.08);
}

#shipRadio.radio-radial #radioPrev:hover::before,
#shipRadio.radio-radial #radioPlay:hover::before,
#shipRadio.radio-radial #radioNext:hover::before {
    background: var(--accent-subtle);
    border-color: var(--accent-primary);
    box-shadow: 0 0 10px var(--accent-glow), inset 0 0 6px rgba(0,255,255,0.15);
}

#shipRadio.radio-radial #radioPrev:active::before,
#shipRadio.radio-radial #radioPlay:active::before,
#shipRadio.radio-radial #radioNext:active::before {
    transform: none; /* no click ring/scale */
}

/* Tiny glyphs centered within dots */
#shipRadio.radio-radial #radioPrev::after,
#shipRadio.radio-radial #radioPlay::after,
#shipRadio.radio-radial #radioNext::after {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 9px; /* readable glyph inside 14px dot */
    line-height: 1;
    color: var(--accent-primary);
    text-shadow: 0 0 6px rgba(0,255,255,0.18);
    pointer-events: none;
}

#shipRadio.radio-radial #radioPrev::after { content: '<'; }
#shipRadio.radio-radial #radioPlay::after { content: '~'; }
#shipRadio.radio-radial #radioNext::after { content: '>'; }

/* Place buttons with exact equal spacing around dial center (gap is space between edges) */
#shipRadio.radio-radial #radioPlay { top: calc(var(--dial-center) - var(--half-h)); }
#shipRadio.radio-radial #radioPrev { top: calc(var(--dial-center) - (var(--btn-h) + var(--dot-gap)) - var(--half-h)); }
#shipRadio.radio-radial #radioNext { top: calc(var(--dial-center) + (var(--btn-h) + var(--dot-gap)) - var(--half-h)); }

#shipRadio button {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    font-family: inherit;
    font-size: 10px;
    padding: 1px 6px;
    cursor: pointer;
    width: 100%;
}

#shipRadio button:hover {
    color: var(--accent-primary);
    border-color: var(--accent-border);
}

#radioTitle {
    grid-column: 1 / 4; /* above viz + buttons */
    grid-row: 1;
    color: var(--text-secondary);
    font-family: 'VT323', monospace;
    font-size: 11px;
    letter-spacing: 1px;
    min-width: 120px;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center; /* digital readout */
    border: 1px solid var(--accent-border);
    padding: 2px 6px;
    background:
        radial-gradient(circle at 1px 1px, rgba(0,255,255,0.18) 1px, transparent 1.6px) 0 0 / 6px 6px,
        rgba(0,0,0,0.35);
    text-shadow: 0 0 6px rgba(0,255,255,0.15);
}

/* Thin scanning visualization under readout */
#radioViz {
    grid-column: 1 / 4;
    grid-row: 2;
    height: 8px;
    width: 100%;
    border: 1px solid var(--accent-border);
    background:
        repeating-linear-gradient(90deg,
            rgba(0,255,255,0.15) 0 6px,
            rgba(0,0,0,0.25) 6px 12px);
    position: relative;
    overflow: hidden;
}
#radioViz::after {
    content: '';
    position: absolute;
    top: 0; left: -30%;
    width: 30%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0,255,255,0.3), transparent);
    /* Default: no animation to minimize compositor work; opt-in via body.ui-heavy */
    animation: none;
}
body.ui-heavy #radioViz::after { animation: scan-sweep 1.2s linear infinite; }
@keyframes scan-sweep {
    to { transform: translateX(450%); }
}

/* Place buttons in a single row under viz */
#radioPrev { grid-column: 1; grid-row: 3; width: 100%; }
#radioPlay { grid-column: 2; grid-row: 3; width: 100%; }
#radioNext { grid-column: 3; grid-row: 3; width: 100%; }

/* remove volume slider */

/* Radio keeps vertical layout across sizes; no collapse */


/* Left Panel - Ship Status */
.hud-left {
    height: 100%;  /* Full height */
    display: flex;
    align-items: center;
    margin: 0;  /* No margin */
    padding: 4px var(--spacing-md);  /* Minimal vertical padding */
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(0, 255, 255, 0.05);
    box-sizing: border-box;
    overflow: visible;  /* Allow overflow for bottom values */
    position: relative;
    contain: layout; /* isolate layout only (no paint clipping) */
}

/* no responsive width adjustments needed */

.status-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: repeat(2, 1fr);
    gap: 4px 6px;  /* Tighter horizontal gap */
    width: calc(100% - 8px);
    height: calc(100% - 8px);  /* Slight padding */
    margin: 0;
    padding: 4px 0;
    align-content: center;  /* Center content */
    contain: layout; /* layout containment only */
}

.status-item {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    padding: 3px 4px;  /* Slightly more padding */
    min-height: 35px;  /* Minimum height to ensure content fits */
    min-width: 0;
    width: 100%;
    overflow: hidden;  /* Back to hidden */
    box-sizing: border-box;
}

.status-label {
    color: var(--text-dim);
    font-size: 8px;  /* Slightly smaller */
    text-transform: uppercase;
    letter-spacing: 1px;  /* Less spacing */
    margin-bottom: 1px;
    width: 100%;  /* Full width */
    display: block;
}

.status-value {
    color: var(--text-primary);
    font-size: 10px;  /* Even smaller */
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    display: block;
    line-height: 1.2;  /* Tighter line height */
}

.status-value.critical {
    color: var(--status-danger);
    text-shadow: 0 0 8px var(--status-danger);
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

@keyframes shake {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    10% { transform: translateX(-52%) translateY(-2px); }
    20% { transform: translateX(-48%) translateY(0); }
    30% { transform: translateX(-52%) translateY(2px); }
    40% { transform: translateX(-48%) translateY(0); }
    50% { transform: translateX(-52%) translateY(-1px); }
    60% { transform: translateX(-48%) translateY(0); }
    70% { transform: translateX(-52%) translateY(1px); }
    80% { transform: translateX(-48%) translateY(0); }
    90% { transform: translateX(-51%) translateY(-1px); }
}

.hud-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-width: 0;
    padding: var(--spacing-md) var(--spacing-md) var(--spacing-xs) var(--spacing-md);
    position: relative;
}

/* Cyberpunk Minimalist Logo */
#logo-container {
    position: relative;
    margin-bottom: 2px;
    margin-top: 4px;
}

#logo-container #logo-img {
    display: block;
    max-height: 128px; /* larger presence; can overflow HUD (allowed) */
    width: auto;
    opacity: 0.95;
    filter: drop-shadow(0 0 6px rgba(0,255,255,0.12));
    margin: 0 auto; /* center horizontally */
    transform: translateY(-5px); /* nudge upward ~5px */
}

#logo-ascii {
    font-family: 'Orbitron', 'Michroma', 'JetBrains Mono', monospace;
    font-size: 16px;
    font-weight: 300;
    letter-spacing: 8px;
    text-transform: uppercase;
    color: var(--text-primary);
    position: relative;
    white-space: normal; /* allow multi-line */
    text-align: center;
    opacity: 0.9;
}

#logo-ascii::after {
    content: 'GALAXY\A TRADER';
    position: absolute;
    top: 0;
    left: 0;
    color: var(--accent-primary);
    opacity: 0.15;
    filter: blur(8px);
    animation: glow-pulse 4s ease-in-out infinite;
    white-space: pre; /* support line break */
    width: 100%;
    text-align: center;
}

@keyframes glow-pulse {
    0%, 100% { opacity: 0.15; }
    50% { opacity: 0.25; }
}

/* removed subtitle element in HTML */

/* Compact stats line inside the logo block */
/* Removed compact key-stats under logo; credits/weapon moved left */

/* Key Stats Bar */
/* removed global key-stats row */

.key-stat {
    display: flex;
    align-items: baseline;
    gap: var(--spacing-xs);
}

/* separators not used in the earlier look */

.key-stat .status-label {
    color: var(--text-dim);
    font-size: 9px;
}

.key-stat .status-value {
    font-size: 14px;
    font-weight: 600;
}

.credits-value {
    color: var(--accent-primary);
    text-shadow: 0 0 10px var(--accent-glow);
}

.weapon-value {
    color: var(--text-primary);
}

/* Ensure logo is visible again */
#logo-container { display: block; }

/* Right Panel - Controls & Radar */
.hud-right {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    height: calc(100% - var(--spacing-sm));
    margin: var(--spacing-xs) 0;
}

/* Viewport + Minimap sizing stay compact */
#centerViewport, #minimap { width: 80px; height: 80px; }

/* Controls Panel */
.controls-panel {
    padding: var(--spacing-xs);
    overflow: hidden;
}

.controls {
    display: grid;
    grid-template-columns: auto auto auto auto; /* key action | key action */
    gap: 2px var(--spacing-xs);
    font-size: 9px;
}
/* Keep two key/action pairs per row; do not drop to 3 or 2 columns */

.control-key {
    color: var(--accent-primary);
    font-weight: 500;
    font-size: 9px;
    opacity: 0.8;
    white-space: nowrap;
}

.control-action {
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 8px;
    white-space: nowrap;
}

/* Fuel zero alert (blink red when thrust/brake with zero fuel) */
#health, #shield, #fuel, #speed, #cargo, #location, #credits, #weapon { transition: color 120ms linear; }
#fuel.fuel-alert { animation: fuel-blink 0.6s steps(2, end) infinite; }
@keyframes fuel-blink {
    0%, 100% { color: #ff4444; }
    50% { color: #ffffff; }
}

/* Minimap/Viewport - Cyberpunk Radar */
#centerViewport, #minimap {
    width: 80px;
    height: 80px;
    outline: 1px solid var(--accent-border);
    position: relative;
    overflow: hidden;
    contain: content;
}

/* Keep CSS crosshair + gradient only on minimap; TargetCam draws its own */
#minimap {
    background: radial-gradient(circle at center,
        var(--accent-subtle) 0%,
        transparent 40%,
        var(--bg-black) 70%);
}

#minimap::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 1px;
    background: var(--accent-border);
    transform: translate(-50%, -50%);
    opacity: 0.3;
}

#minimap::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1px;
    height: 100%;
    background: var(--accent-border);
    transform: translate(-50%, -50%);
    opacity: 0.3;
}

#minimapCanvas, #centerViewportCanvas {
    width: 100%;
    height: 100%;
    position: absolute;
    inset: 0;
    display: block; /* avoid baseline spacing */
    z-index: 1;
}

/* Center viewport is styled same as minimap; no special centering */

/* Landing Overlay - Cyberpunk Terminal */
#landingOverlay {
    position: fixed;
    bottom: 150px;  /* Sit above HUD (110px HUD + 40px padding) */
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-dark);
    border: 1px solid var(--accent-border);
    color: var(--text-primary);
    font-family: inherit;
    display: none;  /* Changed to flex when shown */
    flex-direction: column;
    width: 850px;  /* Fixed width */
    height: 600px;  /* Fixed height */
    max-width: 95vw;
    max-height: calc(100vh - 170px);  /* Screen height minus HUD and margins */
    z-index: 1000;
    box-shadow: 
        0 0 100px var(--accent-subtle),
        inset 0 0 30px rgba(0, 0, 0, 0.5);
    overflow: hidden;  /* Prevent content overflow */
}

#landingHeader {
    background: var(--bg-medium);
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--accent-border);
    position: relative;
}



#landingHeader::before {
    content: '// STATION INTERFACE';
    position: absolute;
    top: var(--spacing-xs);
    left: var(--spacing-md);
    font-size: 9px;
    color: var(--text-dim);
    letter-spacing: 2px;
}

#landingHeader h3 {
    margin: 0;
    font-size: 20px;
    letter-spacing: 4px;
    text-transform: uppercase;
    font-weight: 300;
    color: var(--accent-primary);
    text-shadow: 0 0 20px var(--accent-glow);
}

#landingContent {
    display: flex;
    flex: 1;  /* Take available space */
    min-height: 0;  /* Allow shrinking */
    height: calc(100% - 130px);  /* Fixed height minus header and buttons */
    position: relative;
    overflow: hidden;
}

#planetVisual {
    width: 420px;  /* Fixed width for landscape section */
    height: 100%;  /* Full height of content area */
    padding: 0;  /* No padding - use full width */
    background: var(--bg-black);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;  /* Prevent shrinking */
    overflow: hidden;  /* Clip overflowing content */
    position: relative;  /* For film grain overlay positioning */
}

#planetCanvas {
    display: block;
    width: 420px !important;  /* Force full container width */
    height: 472.5px !important;  /* Maintain 8:9 aspect ratio */
    image-rendering: auto;  /* Prefer smooth scaling for photographic images */
    position: relative;
}

#landingInfo {
    flex: 1;
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    min-height: 0;  /* Allow shrinking */
    overflow: hidden;  /* Avoid scroll for one-shot landing page */
}

#landingMessage {
    font-size: 11px;
    color: var(--status-success);
    text-transform: uppercase;
    letter-spacing: 2px;
}

#planetDescription {
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-secondary);
    flex: 1;
    /* Clamp to keep landing page one-shot without scroll */
    display: -webkit-box;
    -webkit-line-clamp: 8; /* visible lines */
    -webkit-box-orient: vertical;
    overflow: hidden;
}

#landingDetails {
    font-size: 11px;
    line-height: 1.4;
}

#landingButtons {
    padding: var(--spacing-md);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    gap: var(--spacing-sm);
    justify-content: center;
}

#landingButtons button {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    padding: var(--spacing-xs) var(--spacing-md);
    cursor: pointer;
    font-family: inherit;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 2px;
    transition: all 0.2s;
    position: relative;
}

#landingButtons button:hover {
    color: var(--accent-primary);
    border-color: var(--accent-border);
    background: var(--accent-subtle);
    box-shadow: 0 0 20px var(--accent-subtle);
}

/* Trading and Shop Panels */
#tradingPanel, #shopPanel {
    display: none;
    flex: 1;
    flex-direction: column;
    min-height: 0;  /* Allow shrinking */
    height: 100%;  /* Full height of content area */
    background: var(--bg-black);
    min-width: 350px;  /* Ensure readability */
}

/* Trading Panel specific structure */
#tradingPanel {
    padding: 0;  /* Remove padding from main container */
}

.trading-header {
    flex-shrink: 0;  /* Never shrink */
    padding: var(--spacing-md) var(--spacing-md) 0 var(--spacing-md);
    background: var(--bg-black);
    border-bottom: 1px solid var(--border-subtle);
}

.trading-content {
    flex: 1;
    overflow-y: auto;  /* Only this part scrolls */
    padding: 0 var(--spacing-md) var(--spacing-md) var(--spacing-md);
    min-height: 0;  /* Allow shrinking */
}

/* Shop Panel adopts same header/content split as Trading */
#shopPanel {
    padding: 0; /* mirror trading panel */
}

/* Trading System Styles */
.commodity-header {
    font-family: 'Orbitron', monospace;
    font-size: 14px;
    color: var(--accent-primary);
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-xs);
    border-bottom: 1px solid var(--accent-border);
}

.commodity-section {
    font-size: 10px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin: var(--spacing-md) 0 var(--spacing-sm) 0;
    padding-left: var(--spacing-xs);
}

.commodity-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-sm);
    margin-bottom: var(--spacing-xs);
    background: var(--bg-medium);
    border: 1px solid var(--border-subtle);
    transition: all 0.2s;
}

.commodity-item:hover {
    border-color: var(--accent-border);
    background: var(--accent-subtle);
}

.commodity-icon {
    font-size: 18px;
    margin-right: var(--spacing-sm);
}

.commodity-name {
    flex: 1;
    font-size: 11px;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.commodity-price {
    font-size: 12px;
    color: var(--accent-primary);
    font-weight: 600;
    margin-right: var(--spacing-md);
    font-variant-numeric: tabular-nums;
}

.commodity-price.profit {
    color: var(--status-success);
}

.commodity-price.loss {
    color: var(--status-danger);
}

.trade-btn {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    padding: 6px 12px;
    cursor: pointer;
    font-family: inherit;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.2s;
    min-width: 80px;
}

.trade-btn:hover:not(:disabled) {
    background: var(--accent-subtle);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.trade-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    color: var(--text-dim);
}

.trade-btn.buy-btn:hover:not(:disabled) {
    background: rgba(0, 255, 136, 0.1);
    border-color: var(--status-success);
    color: var(--status-success);
}

.trade-btn.sell-btn:hover:not(:disabled) {
    background: rgba(255, 170, 0, 0.1);
    border-color: var(--status-warning);
    color: var(--status-warning);
}

#commodityList, #shopList {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.commodity-row, .shop-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm);
    margin-bottom: var(--spacing-xs);
    background: var(--bg-medium);
    border: 1px solid var(--border-subtle);
    transition: all 0.2s;
    min-height: 40px;
}

.commodity-row:hover, .shop-item:hover {
    border-color: var(--accent-border);
    background: var(--accent-subtle);
}

.commodity-info, .item-info {
    flex: 1;
}

.commodity-name, .item-name {
    font-weight: 500;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 11px;
    margin-bottom: 4px;
}

.price {
    color: var(--accent-primary);
    margin: 0 var(--spacing-md);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.buy-sell-buttons button, .shop-buy-button {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    padding: 6px 12px;
    margin: 0 2px;
    cursor: pointer;
    font-family: inherit;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.2s;
}

.buy-sell-buttons button:hover:not(:disabled), 
.shop-buy-button:hover:not(:disabled) {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
    background: var(--accent-subtle);
}

.buy-sell-buttons button:disabled, 
.shop-buy-button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Tutorial Hint - tiny status line above HUD, aligned with stats */
#tutorialHint {
    position: fixed;
    left: var(--spacing-md);
    bottom: calc(110px + var(--spacing-md) + 6px);
    transform: none;
    background: transparent;
    border: none;
    color: #ffffff; /* Always white for ONLINE/OFFLINE */
    padding: 0;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 1px;
    z-index: 1000;  /* above HUD */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease-in-out;
    will-change: opacity;
    text-shadow: 0 0 6px rgba(255, 255, 255, 0.18);
}

#tutorialHint.visible { opacity: 1; }

/* Hide hint when ship is destroyed (UI already shows a banner) */
body.ship-destroyed #tutorialHint { display: none !important; }

/* Cargo Status Bar */
.cargo-status {
    margin-bottom: var(--spacing-md);
    padding: var(--spacing-sm);
    background: var(--bg-medium);
    border-left: 2px solid var(--accent-primary);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 11px;
    color: var(--text-secondary);
}

.cargo-status strong {
    color: var(--text-primary);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-black);
}

::-webkit-scrollbar-thumb {
    background: var(--border-subtle);
    border-radius: 0;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-border);
}

/* Landing overlay responsive adjustments */
@media (max-height: 700px) {
    #landingOverlay {
        height: 500px;  /* Smaller on shorter screens */
        max-height: calc(100vh - 170px);  /* Ensure it doesn't overlap HUD */
    }
    
    #planetVisual {
        width: 380px;  /* Adjusted for smaller screens */
    }
    
    #planetCanvas {
        width: 380px !important;  /* Match container */
        height: 427.5px !important;  /* Maintain 8:9 aspect ratio */
    }
    
    #landingButtons button {
        padding: 6px 12px;  /* Smaller buttons */
        font-size: 10px;
    }
}

@media (max-height: 550px) {
    #landingOverlay {
        height: 380px;  /* Much smaller for tiny screens */
        width: 750px;
        bottom: 120px;  /* Slightly less spacing on very small screens */
    }
    
    #landingHeader {
        padding: 10px;
    }
    
    #landingHeader h3 {
        font-size: 16px;
    }
    
    #planetVisual {
        width: 250px;  /* Adjusted for tiny screens */
    }
    
    #planetCanvas {
        width: 250px !important;  /* Match container */
        height: 281.25px !important;  /* Maintain 8:9 aspect ratio */
    }
}

@media (max-width: 900px) {
    #landingOverlay {
        width: 95vw;  /* Use full width on narrow screens */
    }
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .controls { font-size: 8px; gap: 1px var(--spacing-xs); }
    .control-key { font-size: 8px; }
    .control-action { font-size: 7px; }
    #centerViewport, #minimap { width: 70px; height: 70px; }
}

@media (max-width: 768px) {
    #gameHUD {
        height: 80px;
    }
    
    #landingOverlay {
        bottom: 100px;  /* Adjust for smaller HUD */
        max-height: calc(100vh - 120px);
    }
    
    .hud-container {
        padding: var(--spacing-sm);
        gap: var(--spacing-sm);
    }
    
    .hud-left {
        flex: 0 0 240px;  /* Narrower to preserve space */
        padding: var(--spacing-xs) var(--spacing-sm);
    }
    
    .status-grid {
        gap: 4px 6px;
    }
    
    .status-item {
        padding: 4px 4px;
    }
    
    #logo-ascii {
        font-size: 12px;
        letter-spacing: 3px;
    }
    
    .key-stats {
        gap: var(--spacing-sm);
    }
    
    #centerViewport, #minimap { width: 60px; height: 60px; }
}

/* Game notifications - unified style */
.game-notification {
    position: fixed;
    top: calc(var(--spacing-lg) + 60px);  /* Offset below tutorial hint */
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-dark);
    border: 1px solid var(--accent-border);
    color: var(--text-primary);
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 12px;
    letter-spacing: 1px;
    z-index: 9999;  /* Just below tutorial hint */
    animation: notificationSlide 0.3s ease-out;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    transition: top 0.2s ease-out, opacity 0.25s ease-in, transform 0.25s ease-in;
}

/* Stack multiple notifications */
.game-notification:nth-of-type(2) {
    top: calc(var(--spacing-lg) + 110px);
}

.game-notification:nth-of-type(3) {
    top: calc(var(--spacing-lg) + 160px);
}

.game-notification:nth-of-type(4) {
    top: calc(var(--spacing-lg) + 210px);
}

@keyframes notificationSlide {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Rolodex-style fade out */
.game-notification.fade-out {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
}

.game-notification.success {
    border-left: 3px solid var(--status-success);
}

.game-notification.error {
    border-left: 3px solid var(--status-danger);
}

.game-notification.info {
    border-left: 3px solid var(--accent-primary);
}
/* No special portrait overrides in earlier look */
