:root {
    /* Universal custom cursor — the masonic "kite" (square&compass
     * central white), point-UP so the sharp TOP tip is the click hotspot
     * (12,1 = the top tip pixel).  This is the static fallback; occ_core.js
     * overrides --ud-cursor on load with the fine vector kite.  OS-rendered
     * via CSS => zero render-pipeline lag. */
    --ud-cursor: url('../img/cursor/kite.png?v=6') 11 0, auto;   /* flipped on both axes 2026-11-07: hotspot on the TOP point (owner) */

    /* Witchcraft palette (option B): magenta is the primary text +
     * border tone, cyan is the highlight/accent.  Variable NAMES are
     * unchanged (--cga-green, --cga-yellow) on purpose — every rule
     * reads through them, so reassigning their values cascades
     * everywhere without renaming hundreds of references.  Read
     * --cga-green as "primary" and --cga-yellow as "accent" rather
     * than the literal hue. */
    --cga-black: #000000;
    --cga-bg-dark: #0a0612;
    --cga-green: #ff66ff;          /* primary text — magenta */
    --cga-green-dim: #aa00aa;      /* borders + secondary text — magenta-dim */
    --cga-red: #FF5555;            /* danger stays red */
    --cga-red-dim: #AA0000;
    --cga-yellow: #66ffff;         /* highlight + panel titles — cyan */
    --cga-yellow-dim: #00aaaa;

    /* CRT glow tuned to the new primary so panels still have the
     * expected halo without bleeding green. */
    --crt-glow: 0 0 5px rgba(255, 110, 255, 0.4);
    --border-thick: 2px solid var(--cga-green);
    --border-thin: 1px solid var(--cga-green-dim);
}

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

body, html {
    width: 100vw; height: 100vh;
    background-color: var(--cga-black);
    color: var(--cga-green);
    font-family: 'Courier New', Courier, monospace;
    font-weight: bold;
    overflow: hidden;
}

#UntoldDarkCanvas {
    /* Letterbox the 640×400 backbuffer at its native 8:5 aspect so
       square world units stay square on screen.  Old rule was
       width:100%; height:100% which stretched non-uniformly on any
       window that wasn't 1.6:1, making circles read as ovals and
       motion drift diagonally.  The DOM HUD floats over the letterbox
       gutters for now — Phase 2 migrates the HUD onto the canvas and
       this CSS becomes irrelevant. */
    position: absolute;
    /* Fill the viewport. The WebGL buffer (NATIVE_W×400) now tracks the
       window aspect, so square world units stay square without the 8:5
       letterbox — the canvas can stretch to the full window 1:1. */
    top: 0; left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
    /* Parent (.game-container) sets pointer-events: none so the empty
       overlay grid cells let clicks fall through to UI panels.  The
       canvas itself needs to opt back in so left-drag free-look fires. */
    pointer-events: auto;
    /* The 3D scene renders into an SVGA-density buffer (600 scanlines tall,
       width = screen aspect — see cga_pipeline _computeDisplay) and CSS
       upscales it to fill the viewport. Nearest-neighbour keeps the chunky
       SVGA pixels crisp instead of blurring them. (Swap back to `auto` for a
       smooth/soft upscale.) */
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    background: #000;
    /* Custom kite cursor (see --ud-cursor).  Replaces the old OS
       crosshair; the canvas-drawn pixel cursor stays disabled (it
       lagged the real mouse by the render latency). */
    cursor: var(--ud-cursor);
}

/* The old DOM HUD that lived in #UntoldDarkControlOverlay is retired (the
   HUD is the occult UI: occ_core.js + occult.css); the empty container is
   hidden below. */

/* Suppress the desktop blue drag-selection rectangle that, prior to this
 * rule, repainted the whole game viewport once the pilot accidentally
 * mouse-dragged across it.  Editable inputs (login, modal text fields)
 * still allow selection — the browser default for <input> overrides
 * `user-select:none` on ancestors.  The transparent ::selection makes
 * any selection that does happen invisible.  -webkit-tap-highlight-color
 * removes the grey flash iOS draws on tap. */
html, body {
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    /* Universal kite cursor everywhere the cursor isn't more specifically
       set (canvases set it explicitly above; buttons keep their own). */
    cursor: var(--ud-cursor);
}
::selection      { background: transparent; }
::-moz-selection { background: transparent; }

/* Pseudo-fullscreen fallback for iOS Safari / iPhone Firefox / iPad
 * Firefox — engines whose Fullscreen API either doesn't exist or
 * silently rejects requestFullscreen() on non-<video> elements.  When
 * the toggle below detects that path, it adds `.pseudo-fullscreen` to
 * <body> instead and we fill the viewport here. */
body.pseudo-fullscreen { overflow: hidden; margin: 0; }
body.pseudo-fullscreen #UntoldDarkLoginBg,
body.pseudo-fullscreen #UntoldDarkGameUI {
    position: fixed; inset: 0;
    width: 100vw; height: 100vh;
    z-index: 99999;
}

/* Login background canvas — the full-window 3D scene (a dim world over the
 * stars) behind the occult summoning circle (#OccultLogin, occult.css). */
#UntoldDarkLoginBg {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
    background: #000;
    cursor: var(--ud-cursor);   /* universal kite cursor */
    /* Without this, iOS Safari steals one-finger drags as scroll/zoom
     * before our pointer handlers see them. */
    touch-action: none;
}
#UntoldDarkCanvas { touch-action: none; }

/* The real-DOM auth form: its inputs ride on the summoning circle's
 * engraved lines (index.php occLogin; their look is occult.css), so
 * password managers can autofill / save credentials. */
#UntoldDarkAuthForm {
    position: fixed; top: 0; left: 0;
    width: 0; height: 0;
    margin: 0; padding: 0;
    pointer-events: none;
    z-index: 2;
}
#UntoldDarkAuthForm input {
    position: fixed;
    pointer-events: auto;
    background: transparent;
    border: 0; margin: 0; padding: 0 4px;
    color: transparent;
    -webkit-text-fill-color: transparent;
    caret-color: transparent;
    text-shadow: none;
    outline: none;
    cursor: var(--ud-cursor);   /* universal kite (was 'none', which hid it over the login inputs) */
    /* >=16px so iOS Safari doesn't auto-zoom on focus */
    font: 16px monospace;
    box-sizing: border-box;
}
#UntoldDarkAuthForm input::selection           { color: transparent; background: transparent; }
#UntoldDarkAuthForm input::-moz-selection      { color: transparent; background: transparent; }
#UntoldDarkAuthForm input.is-hidden            { display: none !important; }
#UntoldDarkAuthForm button {
    position: fixed; top: -9999px; left: -9999px;
    width: 1px; height: 1px; opacity: 0;
}
/* Mute Chrome's autofill yellow background + dark forced text colour.  The
 * 600000s transition delay is the standard trick to defer the autofill
 * paint indefinitely. */
#UntoldDarkAuthForm input:-webkit-autofill,
#UntoldDarkAuthForm input:-webkit-autofill:hover,
#UntoldDarkAuthForm input:-webkit-autofill:focus,
#UntoldDarkAuthForm input:-webkit-autofill:active {
    -webkit-text-fill-color: transparent !important;
    transition: background-color 600000s 0s, color 600000s 0s;
}

/* The .btn-tactical legacy class is still referenced by some in-game
 * panels; preserve a minimal style so they don't lose their button look. */
.btn-tactical {
    background: var(--cga-black);
    color: var(--cga-green);
    border: 1px solid var(--cga-green-dim);
    padding: 6px;
    font-weight: bold;
    cursor: pointer;
    font-size: 0.82rem;
    font-family: inherit;
}
.btn-tactical:hover { background: var(--cga-green); color: var(--cga-black); }

/* Main Game Overlay - Compressed & Responsive Grid */
.game-container { position: absolute; top: 0; left: 0; width: 100vw; height: 100vh; z-index: 10; pointer-events: none; }

/* Continuous-job progress panel — floats at the top-centre of the
   viewport while a mine / salvage / scrap loop is running.  Shows
   the action label, target name, progress bar, and a STOP button.
   Pointer-events auto since the user needs to click STOP.  Hidden
   (removed from DOM) when no job is running. */
.job-progress-panel {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 60;
    min-width: 320px;
    padding: 6px 10px 7px 10px;
    background: rgba(8, 14, 8, 0.88);
    border: 1px solid var(--cga-green-dim);
    color: var(--cga-green);
    font-family: inherit;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    pointer-events: auto;
}
.job-progress-head,
.job-progress-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}
.job-progress-label  { color: var(--cga-yellow); font-weight: bold; }
.job-progress-target { color: var(--cga-green-dim); }
.job-progress-track {
    margin: 4px 0;
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--cga-green-dim);
}
.job-progress-fill {
    height: 100%;
    background: var(--cga-yellow);
    transition: width 200ms linear;
}
.job-progress-remaining {
    color: var(--cga-green);
    font-variant-numeric: tabular-nums;
}
.btn-job-stop {
    padding: 0 10px !important;
    font-size: 0.7rem !important;
    color: var(--cga-red) !important;
    border-color: var(--cga-red) !important;
    background: transparent !important;
    cursor: pointer;
}
.btn-job-stop:hover { background: var(--cga-red) !important; color: var(--cga-black) !important; }

#UntoldDarkControlOverlay {
    /* Legacy DOM HUD retired -- the HUD is the occult UI now.  The
       overlay element stays in the DOM for any future fallback path
       but is hidden so it never takes layout space. */
    display: none;
}

.chart-header { display: none; }

/* WEAVING TABLE modal — uses .chart-modal as a full-screen darken
 * overlay only.  Window + grid are its own so it doesn't inherit
 * chart-modal-window's three-row sidebar layout. */
.craft-modal-window {
    width: min(900px, 92vw);
    height: min(640px, 80vh);
    background-color: var(--cga-bg-dark);
    border: 1px solid var(--cga-green-dim);
    display: grid;
    grid-template-rows: auto 1fr;
    overflow: hidden;
}
.craft-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--cga-yellow);
    text-shadow: var(--crt-glow);
    font-size: 1.05rem;
    letter-spacing: 2px;
    padding: 8px 12px;
    border-bottom: var(--border-thin);
}
.craft-modal-close {
    background: rgba(255, 85, 85, 0.15);
    color: var(--cga-red);
    border: none;
    padding: 2px 10px;
    cursor: pointer;
    font-weight: bold;
    font-family: 'Courier New', monospace;
}
.craft-modal-close:hover { background: var(--cga-red); color: var(--cga-black); }
/* Death overlay still uses .craft-modal-window + .craft-modal-header
 * (its DOM template above) so the modal chrome rules at the top of
 * this file stay; the per-pane / per-row craft + market + faction
 * sub-selectors are gone with the _renderXxxModal renderers. */
.death-modal-window { width: min(560px, 92vw); }

/* Idle "are you still there?" modal */
#idle-modal {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 500;
    display: flex; justify-content: center; align-items: center;
    pointer-events: auto;
}
.idle-modal-window {
    background: var(--cga-bg-dark);
    color: var(--cga-green);
    padding: 24px 32px;
    max-width: 480px; width: 90vw;
    font-family: 'Courier New', monospace;
    text-align: center;
}
.idle-title {
    color: var(--cga-yellow);
    font-size: 1.1rem;
    letter-spacing: 2px;
    margin-bottom: 14px;
}
.idle-body {
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 18px;
}
.idle-body #idle-countdown {
    color: var(--cga-red);
    font-weight: bold;
}
.idle-actions {
    display: flex; gap: 10px; justify-content: center;
}
.idle-actions .btn-tactical { width: auto; min-width: 140px; margin: 0; }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--cga-black); }
::-webkit-scrollbar-thumb { background: var(--cga-green-dim); }

.btn-tactical { margin-bottom: 0; font-size: 0.8rem; padding: 6px; }

/* ================================================================= */
/* CHART COURSE modal — large celestial-chart window with pannable canvas */
/* ================================================================= */
.chart-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 200;
    display: none;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
}
.chart-modal.open { display: flex; }
.chart-modal-window {
    width: 90vw;
    height: 88vh;
    max-width: 1400px;
    background-color: var(--cga-bg-dark);
    display: grid;
    grid-template-columns: 1fr 280px;
    grid-template-rows: auto 1fr auto;
    gap: 8px;
    padding: 10px;
}
.chart-header {
    grid-column: 1 / span 2;
    grid-row: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--cga-yellow);
    font-size: 1.1rem;
    text-shadow: var(--crt-glow);
    border-bottom: var(--border-thin);
    padding-bottom: 6px;
}
.chart-header .btn-close {
    background: rgba(255, 85, 85, 0.15);
    color: var(--cga-red);
    border: none;
    padding: 4px 12px;
    cursor: pointer;
    font-weight: bold;
}
.chart-header .btn-close:hover { background: var(--cga-red); color: var(--cga-black); }
.chart-footer {
    grid-column: 1 / span 2;
    grid-row: 3;
    border-top: var(--border-thin);
    padding-top: 6px;
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}
