:root {
            /* Curated field-guide surfaces over a luminous, restrained cosmic world. */
            --neon-blue: #59b9e8;
            --neon-pink: #ef7d77;
            --neon-yellow: #f6bd5a;
            --neon-green: #72bd8c;
            --bg-dark: #172744;
            --glass: rgba(255, 250, 235, 0.88);
            --border-glass: rgba(48, 73, 105, 0.16);
            --cream: #fff8e8;
            --paper: #f3e7cd;
            --ink: #263a55;
            --muted-ink: #718299;
            --sky: #8ad7f5;
            --mint: #8ed7ad;
            --sun: #f6bd5a;
            --peach: #f49a79;
            --berry: #da7184;
            --lavender: #a99be5;
        }

        * {
            box-sizing: border-box;
            user-select: none;
            -webkit-user-select: none;
        }

        body, html {
            margin: 0;
            padding: 0;
            width: 100%;
            height: 100%;
            overflow: hidden;
            background: radial-gradient(circle at 50% 35%, #163459 0%, #09172c 48%, #040a15 100%);
            font-family: "Avenir Next", Avenir, "Trebuchet MS", system-ui, sans-serif;
            color: var(--ink);
        }
        body::before { content:''; position:fixed; z-index:0; inset:0; pointer-events:none; background: radial-gradient(ellipse at 50% 48%, transparent 35%, rgba(2,8,20,.35) 100%); }
        button { -webkit-tap-highlight-color: transparent; }

        #canvas-container {
            width: 100%;
            height: 100%;
            position: absolute;
            top: 0;
            left: 0;
            z-index: 1;
        }

        /* --- UI Overlays --- */
        .overlay {
            position: absolute;
            z-index: 10;
            pointer-events: none;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            width: 100%;
            height: 100%;
            padding: 20px;
        }

        /* Header HUD */
        .hud-header {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            width: 100%;
        }

        .hud-box {
            background: var(--glass);
            border: 1px solid var(--border-glass);
            backdrop-filter: blur(10px);
            border-radius: 8px;
            padding: 12px 18px;
            pointer-events: auto;
            box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
        }

        .planet-info h1 {
            margin: 0;
            font-size: 1.4rem;
            letter-spacing: 2px;
            color: var(--neon-blue);
            text-shadow: 0 0 8px rgba(0, 240, 255, 0.5);
        }

        .planet-info p {
            margin: 4px 0 0 0;
            font-size: 0.8rem;
            opacity: 0.7;
        }

        .timer-box {
            text-align: center;
        }

        .timer-box .label {
            font-size: 0.7rem;
            text-transform: uppercase;
            letter-spacing: 1px;
            opacity: 0.6;
        }

        .timer-box .value {
            font-size: 2rem;
            font-weight: bold;
            color: var(--neon-pink);
            text-shadow: 0 0 10px rgba(255, 0, 127, 0.6);
        }

        /* Sidebar Stats */
        .hud-sidebar {
            position: absolute;
            left: 20px;
            top: 100px;
            display: flex;
            flex-direction: column;
            gap: 15px;
            width: 240px;
            pointer-events: auto;
        }

        .stat-card {
            background: var(--glass);
            border: 1px solid var(--border-glass);
            backdrop-filter: blur(10px);
            border-radius: 8px;
            padding: 12px;
            box-shadow: 0 4px 10px rgba(0,0,0,0.3);
        }

        .stat-label {
            display: flex;
            justify-content: space-between;
            font-size: 0.8rem;
            margin-bottom: 6px;
            text-transform: uppercase;
            letter-spacing: 1px;
        }

        .stat-bar-container {
            width: 100%;
            height: 14px;
            background: rgba(255, 255, 255, 0.05);
            border: 1px solid rgba(255, 255, 255, 0.2);
            border-radius: 7px;
            overflow: hidden;
            position: relative;
        }

        .stat-bar {
            height: 100%;
            width: 50%;
            transition: width 0.3s ease, background-color 0.3s ease;
        }

        .stat-bar.heat {
            background: linear-gradient(90deg, #00f0ff, #ffee00, #ff0055);
        }

        .stat-bar.water {
            background: linear-gradient(90deg, #ffee00, #00f0ff, #0055ff);
        }

        .stat-bar.population {
            background: var(--neon-green);
            box-shadow: 0 0 8px rgba(57, 255, 20, 0.5);
        }

        .stat-marker {
            position: absolute;
            top: 0;
            width: 2px;
            height: 100%;
            background: #fff;
            box-shadow: 0 0 5px #fff;
        }

        /* Tool drawer bottom */
        .hud-footer {
            width: 100%;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 10px;
            pointer-events: auto;
            margin-bottom: 10px;
        }

        .tools-container {
            display: flex;
            gap: 15px;
            background: var(--glass);
            border: 1px solid var(--border-glass);
            backdrop-filter: blur(10px);
            padding: 10px 20px;
            border-radius: 50px;
            box-shadow: 0 5px 20px rgba(0,0,0,0.4);
        }

        .tool-btn {
            width: 55px;
            height: 55px;
            border-radius: 50%;
            border: 2px solid rgba(255, 255, 255, 0.2);
            background: rgba(255, 255, 255, 0.05);
            color: #fff;
            font-size: 1.5rem;
            cursor: pointer;
            display: flex;
            justify-content: center;
            align-items: center;
            transition: all 0.2s ease;
            position: relative;
        }

        .tool-btn:hover {
            background: rgba(255, 255, 255, 0.1);
            transform: scale(1.05);
        }

        .tool-btn.active {
            border-color: var(--neon-blue);
            box-shadow: 0 0 15px var(--neon-blue);
            background: rgba(0, 240, 255, 0.15);
            transform: scale(1.1);
        }

        .tool-btn::after {
            content: attr(data-tooltip);
            position: absolute;
            bottom: 65px;
            background: rgba(0, 0, 0, 0.85);
            color: #fff;
            font-size: 0.7rem;
            padding: 4px 8px;
            border-radius: 4px;
            white-space: nowrap;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.2s;
            border: 1px solid rgba(255, 255, 255, 0.1);
        }

        .tool-btn:hover::after {
            opacity: 1;
        }

        .action-help {
            font-size: 0.8rem;
            opacity: 0.8;
            text-shadow: 0 1px 3px rgba(0,0,0,0.8);
            background: rgba(0,0,0,0.4);
            padding: 4px 12px;
            border-radius: 12px;
        }

        /* Screens */
        .screen {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 100;
            display: flex;
            justify-content: center;
            align-items: center;
            backdrop-filter: blur(8px);
            background: rgba(5, 5, 12, 0.85);
            transition: opacity 0.5s ease;
        }

        .hidden {
            opacity: 0;
            pointer-events: none;
        }

        .panel-menu {
            width: 90%;
            max-width: 460px;
            background: var(--glass);
            border: 2px solid var(--border-glass);
            border-radius: 16px;
            padding: 30px;
            text-align: center;
            box-shadow: 0 0 30px rgba(0, 240, 255, 0.2);
            position: relative;
        }

        .panel-menu h2 {
            font-size: 1.8rem;
            margin-top: 0;
            letter-spacing: 3px;
            color: var(--neon-blue);
            text-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
        }

        .panel-menu p {
            font-size: 0.85rem;
            line-height: 1.5;
            opacity: 0.8;
            margin-bottom: 24px;
        }

        .btn-action {
            width: 100%;
            padding: 14px;
            background: transparent;
            border: 2px solid var(--neon-blue);
            color: var(--neon-blue);
            border-radius: 8px;
            font-family: inherit;
            font-size: 1rem;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.2s ease;
            text-transform: uppercase;
            letter-spacing: 2px;
            margin-top: 10px;
            box-shadow: inset 0 0 0 rgba(0, 240, 255, 0);
        }

        .btn-action:hover {
            background: var(--neon-blue);
            color: #000;
            box-shadow: 0 0 15px rgba(0, 240, 255, 0.5);
        }

        .seed-input {
            width: 100%;
            padding: 12px;
            background: rgba(255, 255, 255, 0.05);
            border: 1px solid var(--border-glass);
            border-radius: 6px;
            color: #fff;
            font-family: inherit;
            text-align: center;
            margin-bottom: 15px;
            outline: none;
            font-size: 1rem;
            letter-spacing: 1px;
        }

        .seed-input:focus {
            border-color: var(--neon-blue);
            box-shadow: 0 0 8px rgba(0, 240, 255, 0.3);
        }

        /* Postcard styles */
        .postcard-frame {
            border: 4px double var(--neon-pink);
            padding: 20px;
            margin-bottom: 20px;
            background: rgba(0,0,0,0.5);
            text-align: left;
            border-radius: 8px;
        }

        .postcard-row {
            display: flex;
            justify-content: space-between;
            border-bottom: 1px dashed rgba(255,255,255,0.2);
            padding: 8px 0;
            font-size: 0.9rem;
        }

        .postcard-row:last-child {
            border-bottom: none;
        }

        .postcard-val {
            font-weight: bold;
            color: var(--neon-yellow);
        }

        .rating-stamp {
            font-size: 3rem;
            font-weight: 900;
            color: var(--neon-pink);
            text-shadow: 0 0 15px rgba(255,0,127,0.5);
            border: 3px solid var(--neon-pink);
            padding: 5px 15px;
            display: inline-block;
            transform: rotate(-10deg);
            margin: 15px 0;
            letter-spacing: 2px;
        }

        /* Float Messages */
        #float-msg {
            position: absolute;
            top: 25%;
            left: 50%;
            transform: translate(-50%, -50%);
            font-size: 1.2rem;
            color: var(--neon-yellow);
            font-weight: bold;
            pointer-events: none;
            z-index: 50;
            text-align: center;
            text-shadow: 0 0 10px rgba(255, 238, 0, 0.8), 0 2px 4px #000;
            transition: opacity 0.3s;
            opacity: 0;
        }

        /* --- Genesis field guide HUD: cozy low-poly expedition kit --- */
        .overlay { padding: max(15px, env(safe-area-inset-top)) max(15px, env(safe-area-inset-right)) max(15px, env(safe-area-inset-bottom)) max(15px, env(safe-area-inset-left)); }
        .overlay::before { content: ''; position: absolute; z-index: -1; inset: 0; pointer-events: none; background: linear-gradient(180deg, rgba(4,17,38,.73), transparent 22%, transparent 70%, rgba(4,14,29,.84)); }
        .hud-header { align-items: flex-start; gap: 9px; }
        .hud-box { color: var(--ink); background: linear-gradient(135deg, rgba(255,251,239,.97), rgba(239,246,237,.94)); border: 1px solid rgba(255,255,255,.92); border-radius: 14px 18px 15px 19px; box-shadow: 0 3px 0 rgba(24,48,76,.38), 0 15px 36px rgba(3,14,31,.36); backdrop-filter: blur(8px); }
        .planet-info { min-width: 224px; position: relative; padding: 11px 15px 10px; overflow: hidden; background: linear-gradient(135deg, #fff8e8 0 74%, #e8f5ec 74%); }
        .planet-info::before { content: '✦'; position: absolute; right: 12px; top: 5px; color: var(--sun); font-size: 1.45rem; transform: rotate(14deg); opacity: .9; }
        .planet-info::after { content: ''; position: absolute; right: -18px; bottom: -26px; width: 78px; height: 57px; background: #9ed7b0; clip-path: polygon(50% 0,100% 54%,77% 100%,21% 91%,0 47%); opacity: .55; }
        .era-chip { position: relative; z-index: 1; display: inline-block; margin: 0 0 4px; padding: 3px 7px; border-radius: 20px; color: #587a67; background: #dcefdc; font-size: .54rem; font-weight: 800; letter-spacing: 1px; }
        .header-settings { position: absolute; z-index: 2; top: 7px; right: 8px; min-height: 32px; padding: 4px 7px; color: #58728a; background: rgba(255,255,255,.64); border: 1px solid #d7e0d4; border-radius: 10px; font: 900 .48rem inherit; letter-spacing: .45px; cursor: pointer; }
        .planet-info h1 { position: relative; z-index: 1; max-width: 184px; color: var(--ink); font-family: Georgia, "Times New Roman", serif; font-size: 1.08rem; letter-spacing: .6px; text-shadow: none; }
        .planet-info p { position: relative; z-index: 1; color: var(--muted-ink); font-size: .59rem; font-weight: 700; letter-spacing: .45px; }
        .postcard-val { color: #be7650; }
        .resource-row { position: relative; z-index: 1; gap: 9px; margin-top: 8px; padding-top: 7px; border-top: 1px dashed rgba(67,93,113,.25); color: var(--muted-ink); font-size: .57rem; font-weight: 800; letter-spacing: .2px; }
        .resource-value { color: var(--ink); font-size: .68rem; }
        .timer-box { min-width: 83px; padding: 10px 10px; background: #f2e7fb; border-radius: 18px 13px 18px 14px; text-align: center; }
        .timer-box .label { color: #7b6c9f; font-size: .5rem; font-weight: 800; letter-spacing: .8px; }
        .timer-box .value { color: #5b4b82; font-family: Georgia, serif; font-size: 1.32rem; text-shadow: none; }
        .doom-wrap { right: 18px; top: 108px; width: 146px; }
        .doom-card { position: relative; overflow: hidden; padding: 9px 10px 10px 35px; color: var(--ink); background: linear-gradient(135deg, #fff7e7, #f7ead7); border: 1px solid rgba(255,255,255,.94); border-radius: 19px 13px 18px 15px; box-shadow: 0 3px 0 rgba(95,67,45,.34), 0 12px 24px rgba(4,18,37,.27); cursor: pointer; }
        .doom-card::before { content: '☁'; position: absolute; left: 9px; top: 6px; color: #e29a6c; font-size: 1.2rem; }
        .doom-label { display: flex; justify-content: space-between; gap: 4px; color: #8b614a; font-size: .51rem; font-weight: 900; letter-spacing: .55px; }
        .doom-track { height: 6px; margin-top: 7px; background: #e6d4bb; border: 0; border-radius: 8px; }
        .doom-fill { background: linear-gradient(90deg, #8ccb9d, #f4c268 60%, #e57f75); box-shadow: none; }
        .hud-sidebar { left: 18px; top: 121px; width: 138px; gap: 7px; }
        .stat-card { padding: 8px 9px 9px; color: var(--ink); background: rgba(255,250,239,.93); border: 1px solid rgba(255,255,255,.95); border-radius: 15px 11px 15px 12px; box-shadow: 0 3px 0 rgba(25,49,77,.28), 0 9px 20px rgba(4,18,37,.22); backdrop-filter: blur(8px); }
        .stat-card:nth-child(2) { border-radius: 11px 16px 12px 15px; background: rgba(239,246,255,.94); }
        .stat-card:nth-child(3) { border-radius: 16px 12px 12px 17px; background: rgba(237,248,238,.94); }
        .stat-label { color: var(--muted-ink); font-size: .54rem; font-weight: 800; margin-bottom: 6px; letter-spacing: .25px; text-transform: none; }
        .stat-label .postcard-val { color: var(--ink); font-size: .66rem; }
        #txt-population-count { color: #668177; font-size: .52rem; font-weight: 900; white-space: nowrap; }
        .growth-rate { display: block; min-height: 10px; margin: -3px 0 5px; color: #668177; font-size: .46rem; font-weight: 900; letter-spacing: .28px; }
        .growth-rate.declining { color: #bd695f; }
        .growth-rate.steady { color: #92794c; }
        .stat-bar-container { height: 7px; background: rgba(66,91,116,.13); border: 0; border-radius: 7px; }
        .stat-bar { border-radius: 8px; box-shadow: none; }
        .stat-bar.heat, .stat-bar.population { background: linear-gradient(90deg, #79c5a0, #aad68c); color: #79c5a0; }
        .stat-bar.water { background: linear-gradient(90deg, #8bbce7, #a7a0dc); color: #8bbce7; }
        .stat-marker { display: none; }
        .hud-footer { width: min(430px, 100%); gap: 8px; margin: 0 auto 2px; }
        .context-card { position: relative; width: 100%; overflow: hidden; padding: 12px 112px 12px 15px; color: var(--ink); background: linear-gradient(135deg, #fffaf0, #eef6ed); border: 1px solid rgba(255,255,255,.95); border-radius: 20px 15px 18px 14px; box-shadow: 0 4px 0 rgba(25,49,77,.34), 0 16px 30px rgba(4,18,37,.34); backdrop-filter: blur(8px); }
        .context-card::before { content: '✦'; position: absolute; width: auto; inset: 8px auto auto 8px; color: var(--sun); background: none; box-shadow: none; font-size: .65rem; }
        .context-title { margin-left: 11px; color: #5b8070; font-size: .6rem; font-weight: 900; letter-spacing: .75px; }
        .context-text { min-height: 18px; margin: 5px 0 0; color: #53677c; font-size: .66rem; line-height: 1.35; }
        .context-action { right: 10px; bottom: 10px; padding: 9px 10px; color: #fffaf0; background: #5d9fc8; border: 2px solid #fffdf4; border-radius: 12px 10px 13px 9px; box-shadow: 0 3px 0 #39759e; font: 900 .52rem "Trebuchet MS", sans-serif; letter-spacing: .55px; }
        .context-action:active { transform: translateY(3px); box-shadow: none; }
        .action-help { display: none; }
        .tools-container { gap: 6px; padding: 6px; background: rgba(255,250,239,.94); border: 1px solid rgba(255,255,255,.92); border-radius: 20px 16px 18px 15px; box-shadow: 0 4px 0 rgba(25,49,77,.34), 0 14px 26px rgba(4,18,37,.3); backdrop-filter: blur(8px); }
        .tool-btn { width: 45px; height: 39px; color: #526c81; background: linear-gradient(135deg, #f6fbf4, #e4efe4); border: 1px solid rgba(85,114,129,.12); border-radius: 13px 10px 12px 9px; box-shadow: inset 0 1px rgba(255,255,255,.8); font-size: 1.05rem; }
        .tool-btn:nth-child(2) { background: #eeeafa; }
        .tool-btn:nth-child(3) { background: #e9f3fb; }
        .tool-btn:nth-child(4) { background: #e8f4e9; }
        .tool-glyph { position:relative; display:block; width:18px; height:18px; color:currentColor; }
        .glyph-sun { border:2px solid currentColor; border-radius:50%; box-shadow: 0 -8px 0 -6px currentColor, 0 8px 0 -6px currentColor, 8px 0 0 -6px currentColor, -8px 0 0 -6px currentColor, 6px 6px 0 -6px currentColor, -6px -6px 0 -6px currentColor, 6px -6px 0 -6px currentColor, -6px 6px 0 -6px currentColor; }
        .glyph-moon { border:2px solid currentColor; border-radius:50%; overflow:hidden; }
        .glyph-moon::after { content:''; position:absolute; width:15px; height:15px; border-radius:50%; background:#eeeafa; top:-3px; left:5px; }
        .glyph-comet { width:16px; height:16px; border:2px solid currentColor; border-radius:50%; }
        .glyph-comet::after { content:''; position:absolute; width:14px; height:2px; background:currentColor; transform:rotate(-35deg); transform-origin:right center; left:-10px; top:12px; border-radius:4px; }
        .glyph-shield { width:17px; height:19px; border:2px solid currentColor; border-radius:8px 8px 10px 10px; clip-path:polygon(50% 0,100% 18%,87% 76%,50% 100%,13% 76%,0 18%); }
        .tool-btn:hover { background: #f9efd9; transform: translateY(-2px) rotate(-1deg); }
        .tool-btn.active { color: var(--ink); background: linear-gradient(135deg, #f9dd8b, #f0b95c); border-color: #fff8e8; box-shadow: 0 3px 0 #bd7f38, 0 7px 14px rgba(226,160,63,.28); transform: translateY(-2px); }
        .tool-btn::after { display: none; }
        .sheet { bottom: max(10px, env(safe-area-inset-bottom)); padding: 20px; color: var(--ink); background: linear-gradient(135deg, rgba(255,251,239,.98), rgba(241,248,240,.97)); border: 1px solid rgba(255,255,255,.95); border-radius: 23px 20px 14px 16px; box-shadow: 0 -2px 0 rgba(76,111,130,.25), 0 -18px 44px rgba(4,18,37,.46); backdrop-filter: blur(15px); }
        .sheet::before { content:''; display:block; width: 38px; height: 5px; margin: -10px auto 13px; background: #d4c5aa; border-radius: 7px; }
        .sheet h3 { color: var(--ink); font-family: Georgia, serif; font-size: 1rem; letter-spacing: .5px; }
        .sheet p { color: #63768a; }
        .sheet-close { color: #708197; }
        .choice { color: var(--ink); background: #f6ecd7; border: 2px solid #fffdf6; border-radius: 14px 11px 13px 10px; box-shadow: 0 2px 0 rgba(93,117,133,.18); padding: 12px; }
        .choice strong { color: #a66b4d; font-size: .71rem; }
        .choice span { color: #607285; }
        .choice:hover { border-color: #9fcce3; background: #edf6f8; }
        .offline-report { color: var(--ink); background: #e8f4ed; border: 2px solid #c9e2cf; border-radius: 13px; }
        #float-msg { padding: 8px 13px; color: #76513e; background: #fff4d9; border: 2px solid #fffdf5; border-radius: 14px 10px 15px 11px; box-shadow: 0 4px 0 rgba(82,54,40,.25), 0 10px 20px rgba(0,0,0,.2); font-family: "Trebuchet MS", sans-serif; font-size: .75rem; letter-spacing: .4px; text-shadow: none; }
        .screen { background: rgba(18,39,70,.68); backdrop-filter: blur(8px) saturate(75%); }
        .panel-menu { color: var(--ink); background: #fff8e8; border: 3px solid #fffdf5; border-radius: 25px 19px 23px 17px; box-shadow: 0 7px 0 rgba(25,49,77,.31), 0 18px 45px rgba(2,13,31,.4); }
        .panel-menu::before { content: '✦'; display: block; color: var(--sun); font-size: 1.6rem; line-height: 1; margin-bottom: 5px; }
        .panel-menu h2 { color: var(--ink); font-family: Georgia, "Times New Roman", serif; font-size: 1.65rem; letter-spacing: .6px; text-shadow: none; }
        .panel-menu h2 span { color: #d97972 !important; }
        .panel-menu p { color: #5d7083; }
        .seed-input { color: var(--ink); background: #f4ead5; border: 2px solid #e2d2b8; border-radius: 12px 9px 13px 10px; font-family: inherit; }
        .seed-input:focus { border-color: #8fc9e4; box-shadow: 0 0 0 3px rgba(143,201,228,.23); }
        .btn-action { color: #fffaf0; background: linear-gradient(135deg, #6bb5dc, #4e8fbd); border: 1px solid rgba(255,255,255,.86); border-radius: 13px 10px 14px 9px; box-shadow: 0 4px 0 #39759e, 0 9px 18px rgba(44,113,156,.27); font-family: inherit; font-size: .8rem; letter-spacing: .85px; }
        .btn-action:hover { color: #fffaf0; background: #76b5d7; box-shadow: 0 4px 0 #39759e; }
        .btn-action:active { transform: translateY(4px); box-shadow: none; }
        .postcard-frame { color: var(--ink); background: #f5ead4; border: 2px dashed #b8a27e; border-radius: 14px; }
        .postcard-row { border-bottom-color: rgba(92,113,131,.2); }
        .rating-stamp { color: #b96862; border-color: #c87a71; text-shadow: none; border-radius: 9px; font-family: Georgia, serif; }

        /* Functional bottom sheets and the fail-safe Big Bang onboarding. */
        button, input { min-height: 44px; touch-action: manipulation; }
        .sheet { position: fixed; z-index: 140; left: 50%; width: min(520px, calc(100% - 20px)); max-height: min(72vh, 680px); overflow-y: auto; transform: translate(-50%, calc(100% + 48px)); opacity: 0; pointer-events: none; transition: transform .28s ease, opacity .2s ease; }
        .sheet.open { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
        .sheet-close { position: absolute; top: 7px; right: 9px; width: 44px; height: 44px; border: 0; background: transparent; font: 700 1.45rem/1 system-ui; cursor: pointer; }
        .choice { display: block; width: 100%; min-height: 62px; margin: 9px 0; text-align: left; font-family: inherit; cursor: pointer; }
        .choice strong, .choice span { display: block; line-height: 1.35; }
        .choice span { margin-top: 4px; font-size: .78rem; }
        .choice:disabled { opacity: .48; cursor: not-allowed; }
        .offline-report { margin: 10px 0; padding: 12px; font-size: .82rem; line-height: 1.55; text-align: left; }
        .objective-card { margin: 10px 0; padding: 12px; display: flex; flex-direction: column; gap: 5px; text-align: left; color: var(--ink); background: #f6ecd7; border: 2px solid #e7d6b7; border-radius: 14px 10px 13px 11px; }
        .objective-card > b { color: #a66b4d; font-size: .78rem; letter-spacing: .04em; }
        .objective-card > span { color: #607285; font-size: .8rem; line-height: 1.42; }
        .objective-card small { color: #75869a; font-weight: 700; }
        .objective-card em { color: #75869a; font-size: .72rem; font-style: normal; }
        .objective-card.ready { background: #e8f4ed; border-color: #a9d7b8; }
        .objective-card.claimed { opacity: .72; background: #edf6f8; border-color: #b8d9e6; }
        .objective-claim { margin-bottom: 0; }
        /* A short, first-world field guide turns the first project into a clear invitation, not a menu lesson. */
        .playing-guide { text-align: left; }
        .guide-kicker { margin: 0 0 5px; color: #5b8070; font-size: .63rem; font-weight: 900; letter-spacing: 1px; }
        .guide-progress { display: flex; gap: 6px; margin: 12px 0 16px; }
        .guide-progress i { display: block; width: 100%; height: 6px; background: #dfd3bb; border-radius: 8px; }
        .guide-progress i.done { background: #79b99a; }
        .guide-card { margin: 10px 0; padding: 11px; background: #f4ead5; border: 2px solid #fffdf5; border-radius: 14px 11px 13px 10px; box-shadow: 0 2px 0 rgba(93,117,133,.14); }
        .guide-card b { display: block; color: #4e6f64; font-size: .74rem; letter-spacing: .35px; }
        .guide-card span { display: block; margin-top: 3px; color: #607285; font-size: .75rem; line-height: 1.4; }
        .guide-note { margin: 12px 0 4px; color: #63768a; font-size: .76rem; line-height: 1.45; }
        .guide-skip { display: block; width: 100%; margin-top: 7px; padding: 8px; color: #65798e; background: transparent; border: 0; border-radius: 10px; font: 800 .68rem inherit; letter-spacing: .45px; cursor: pointer; }
        .guide-skip:hover { background: #f4ead5; }
        .opportunity-progress { margin: 12px 0; padding: 10px; background: #e8f4ed; border: 2px solid #c9e2cf; border-radius: 13px; }
        .opportunity-progress b { display: block; color: #4e6f64; font-size: .71rem; letter-spacing: .4px; }
        .opportunity-progress span { display: block; margin-top: 4px; color: #607285; font-size: .75rem; line-height: 1.4; }
        .opportunity-hold { width: 100%; min-height: 56px; margin-top: 4px; color: #fffaf0; background: #76ad87; border: 2px solid #fffdf5; border-radius: 13px 10px 14px 9px; box-shadow: 0 4px 0 #4e8162; font: 900 .77rem inherit; letter-spacing: .7px; cursor: pointer; touch-action: none; }
        .opportunity-hold:active { transform: translateY(4px); box-shadow: none; background: #5d9fc8; }
        .settings-grid { display: grid; gap: 9px; margin: 12px 0; }
        .settings-toggle { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 52px; padding: 10px 12px; color: var(--ink); background: #f4ead5; border: 2px solid #fffdf6; border-radius: 13px 10px 14px 9px; font: 800 .75rem inherit; text-align: left; cursor: pointer; }
        .settings-toggle span { color: #607285; font-size: .69rem; font-weight: 700; }
        .settings-toggle[aria-pressed="true"] { background: #dff0e4; border-color: #9bc9aa; }
        .data-box { margin: 10px 0; padding: 10px; color: #607285; background: #f4ead5; border: 2px dashed #b8a27e; border-radius: 12px; font-size: .72rem; line-height: 1.45; word-break: break-all; }
        body.high-contrast { --cream:#fffdf5; --paper:#fff7d9; --ink:#10233d; --muted-ink:#314e6e; }
        body.high-contrast .hud-box, body.high-contrast .stat-card, body.high-contrast .context-card, body.high-contrast .sheet, body.high-contrast .panel-menu { border-color:#10233d; box-shadow: 0 3px 0 #10233d; }
        body.large-text { font-size: 118%; }
        body.large-text .context-text, body.large-text .choice span, body.large-text .sheet p { font-size: .88rem; }
        .stat-card { width: 100%; font-family: inherit; text-align: left; cursor: pointer; }
        .stat-card:focus-visible { outline: 3px solid #5d9fc8; outline-offset: 3px; }
        .project-progress { margin-top: 9px; }
        .project-progress-label { display: flex; justify-content: space-between; gap: 8px; color: #607285; font-size: .68rem; font-weight: 800; }
        .project-progress-track { height: 9px; margin-top: 5px; overflow: hidden; background: #dbe8df; border-radius: 8px; }
        .project-progress-fill { height: 100%; min-width: 2px; background: linear-gradient(90deg, #79c5a0, #5d9fc8); border-radius: inherit; transition: width .35s ease; }
        #context-progress { display: none; }
        #context-progress.active { display: block; }
        .context-action { position: absolute; min-height: 44px; cursor: pointer; }
        .doom-wrap { position: absolute; pointer-events: auto; }
        .doom-track { overflow: hidden; }
        .doom-fill { width: 0; height: 100%; transition: width .35s ease; }
        .resource-row { display: flex; flex-wrap: wrap; }
        .world-age { margin-left: auto; color: #7b6c9f; }
        .world-age b { color: #5b4b82; font-family: Georgia, serif; font-size: .8rem; }
        .journey-map { display: grid; gap: 6px; margin: 12px 0; }
        .journey-era { display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: 8px; padding: 9px; border-radius: 10px; background: #f4ead5; color: #63768a; font-size: .72rem; }
        .journey-era.current { color: var(--ink); background: #dff0e4; outline: 2px solid #9bc9aa; }
        .journey-era.done { color: #496c5a; background: #edf6ed; }
        .tiny-meta { color: #75869a; font-size: .7rem; line-height: 1.45; }
        .screen.genesis-screen { z-index: 130; background: radial-gradient(circle at 50% 46%, rgba(61,87,130,.1), rgba(3,8,22,.88) 66%); backdrop-filter: none; overflow: hidden; }
        .genesis-screen .panel-menu { width: min(92%, 430px); margin-top: auto; margin-bottom: max(18px, env(safe-area-inset-bottom)); padding: 22px; }
        .cosmic-spark { position: absolute; left: 50%; top: 39%; width: 16px; height: 16px; border-radius: 50%; transform: translate(-50%,-50%); background: #fff8cf; box-shadow: 0 0 20px #fff, 0 0 60px #f6bd5a, 0 0 130px #8ad7f5; animation: breathe 2.4s ease-in-out infinite; }
        .genesis-screen.bang .cosmic-spark { animation: bigBang 1.8s cubic-bezier(.1,.7,.2,1) both; }
        .genesis-kicker { color: #8b7252; font-size: .68rem; font-weight: 900; letter-spacing: 1.5px; }
        .genesis-progress { display: flex; justify-content: center; gap: 7px; margin: 13px 0 2px; }
        .genesis-progress i { width: 9px; height: 9px; border: 2px solid #9bb1bd; border-radius: 50%; }
        .genesis-progress i.done { background: #76b99a; border-color: #76b99a; }
        @keyframes breathe { 50% { transform: translate(-50%,-50%) scale(1.3); opacity: .75; } }
        @keyframes bigBang { 0% { transform: translate(-50%,-50%) scale(.2); } 45% { transform: translate(-50%,-50%) scale(24); opacity: 1; } 100% { transform: translate(-50%,-50%) scale(70); opacity: 0; } }
        @media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; } }
        body.reduced-motion *, body.reduced-motion *::before, body.reduced-motion *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }

        /* Responsive */
        @media (max-width: 600px) {
            /* One compact top card, then dedicated layers for risk, stats, and thumb actions. */
            .overlay { padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom)); }
            .hud-header { display: block; }
            .planet-info { min-width: 0; width: 100%; min-height: 67px; padding: 8px 11px 9px; }
            /* Reserve a dedicated lane for Settings so long procedural world names never collide with it. */
            .planet-info h1 { font-size: .9rem; max-width: calc(100% - 73px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
            .header-settings { top: 6px; right: 7px; min-height: 30px; }
            .planet-info p { display: none; }
            .resource-row { margin-top: 5px; padding-top: 5px; gap: 7px; font-size: .52rem; }
            .world-age { margin-left: auto; }
            .timer-box { display: none; }
            /* This clears the tallest mobile header, including a wrapped resource row at larger text sizes. */
            .doom-wrap { top: 104px; right: 10px; width: 128px; }
            .doom-card { padding: 7px 7px 8px 30px; }
            .doom-card::before { left: 7px; top: 5px; font-size: 1rem; }
            .doom-label { font-size: .48rem; }
            /* Keep stats above the largest context-card state (project progress) instead of letting the two surfaces overlap. */
            .hud-sidebar { top: auto; bottom: calc(166px + env(safe-area-inset-bottom)); left: 10px; width: calc(100% - 20px); flex-direction: row; gap: 5px; transition: bottom .18s ease; }
            .stat-card { flex: 1; min-width: 0; padding: 6px 7px; }
            .stat-label { font-size: .48rem; margin-bottom: 4px; letter-spacing: .35px; }
            .stat-label .postcard-val { font-size: .58rem; }
            .hud-footer { width: calc(100% - 20px); gap: 6px; }
            .context-card { min-height: 66px; padding: 9px 91px 9px 11px; border-radius: 13px; }
            .context-title { max-width: calc(100% - 2px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .55rem; }
            .context-text { display: -webkit-box; max-height: 33px; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; font-size: .6rem; margin: 4px 0 0; }
            .context-action { right: 8px; bottom: 9px; padding: 7px; font-size: .49rem; }
            .tools-container { gap: 4px; padding: 5px; border-radius: 14px; }
            .tool-btn { width: 42px; height: 34px; border-radius: 9px; font-size: .95rem; }
        }
        @media (max-width: 360px) {
            .resource-row { gap: 5px; font-size: .49rem; }
            .planet-info h1 { max-width: calc(100% - 71px); }
            .doom-wrap { top: 104px; width: 112px; }
            .hud-sidebar { bottom: calc(174px + env(safe-area-inset-bottom)); }
            .context-card { padding-right: 84px; }
            .context-action { right: 6px; }
            .tool-btn { width: 38px; }
        }
        /* On short portrait phones, preserve a clean separation between the stats and thumb-zone action card. */
        @media (max-width: 600px) and (max-height: 700px) {
            .hud-sidebar { bottom: calc(172px + env(safe-area-inset-bottom)); }
            .context-card { min-height: 70px; }
        }
        body.large-text .hud-sidebar { bottom: calc(184px + env(safe-area-inset-bottom)); }
        @media (max-width: 600px) { body.large-text .planet-info { min-height: 76px; } body.large-text .doom-wrap { top: 116px; } body.large-text .context-card { min-height: 78px; } }
        /* JS measures the real footer after project-progress and text layout, then sets this exact clearance. */
        @media (max-width: 600px) { .hud-sidebar[data-measured="true"] { bottom: calc(var(--footer-clearance, 166px) + env(safe-area-inset-bottom)); } }
