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

  :root {
    --bg: #0a0a0a;
    --panel: #111;
    --border: #222;
    --text: #c8c8c8;
    --dim: #555;
    --accent: #d4a574;
    --accent2: #7ab8d4;
    --green: #6abf69;
    --red: #cf6679;
    --orange: #e0a050;
    --purple: #b39ddb;
  }

  body {
    background: var(--bg);
    color: var(--text);
    font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
  }

  #game {
    display: grid;
    grid-template-columns: 260px 1fr 300px;
    grid-template-rows: auto minmax(0, 1fr);
    height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
  }

  /* Header */
  #header {
    grid-column: 1 / -1;
    border-bottom: 1px solid var(--border);
    padding: 12px 20px;
    display: flex;
    align-items: baseline;
    gap: 16px;
    flex-wrap: wrap;
  }
  #header h1 {
    font-size: 15px;
    color: var(--accent);
    font-weight: 600;
    letter-spacing: 0.5px;
  }
  #era-label {
    font-size: 11px;
    color: var(--dim);
    text-transform: uppercase;
    letter-spacing: 1px;
  }
  #era-hint {
    font-size: 10px;
    color: var(--dim);
    opacity: 0.6;
    font-style: italic;
  }
  #level-pips {
    display: flex;
    gap: 4px;
    align-items: center;
    margin-left: auto;
  }
  .pip {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    transition: background 0.3s;
  }
  .pip.active {
    background: var(--accent);
  }
  .pip.current {
    background: var(--accent);
    box-shadow: 0 0 6px var(--accent);
  }

  /* Resources panel */
  #resources {
    border-right: 1px solid var(--border);
    padding: 16px;
    overflow-y: auto;
    overflow-x: hidden;
  }
  .resource-section {
    margin-bottom: 20px;
  }
  .resource-section h3 {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--dim);
    margin-bottom: 8px;
  }
  .resource {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 4px 0;
    white-space: nowrap;
    overflow: hidden;
    gap: 6px;
  }
  .resource-name {
    color: var(--text);
    flex-shrink: 0;
  }
  .resource-value {
    font-weight: 600;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .resource-rate {
    font-size: 11px;
    color: var(--dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-left: 4px;
  }
  .resource-bar {
    height: 3px;
    background: var(--border);
    margin-top: 2px;
    border-radius: 2px;
    overflow: hidden;
  }
  .resource-bar-fill {
    height: 100%;
    background: var(--accent);
    transition: width 0.3s;
    border-radius: 2px;
  }

  /* Main area */
  #main {
    padding: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: row;
    gap: 0;
  }
  #main-content {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    transition: flex 0.5s ease;
  }

  /* The prompt button */
  #prompt-area {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 16px;
    text-align: center;
  }
  #prompt-btn {
    background: none;
    border: 1px solid var(--accent);
    color: var(--accent);
    font-family: inherit;
    font-size: 13px;
    padding: 10px 24px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
    overflow: hidden;
  }
  #prompt-btn:hover {
    background: rgba(212, 165, 116, 0.1);
  }
  #prompt-btn:active {
    background: rgba(212, 165, 116, 0.2);
    transform: scale(0.98);
  }
  #prompt-btn .flash {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(212, 165, 116, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: flash 0.4s ease-out forwards;
  }
  @keyframes flash {
    to { width: 200px; height: 200px; opacity: 0; }
  }
  #token-float-container {
    position: relative;
    height: 0;
  }
  .token-float {
    position: absolute;
    bottom: 0;
    left: 50%;
    color: var(--accent);
    font-weight: 600;
    font-size: 14px;
    animation: float-up 0.8s ease-out forwards;
    pointer-events: none;
  }
  @keyframes float-up {
    0% { transform: translate(-50%, 0); opacity: 1; }
    100% { transform: translate(-50%, -40px); opacity: 0; }
  }

  /* Upgrades */
  #upgrades-area h3 {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--dim);
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
  }
  #toggle-purchased {
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
    font-size: 10px;
    color: var(--dim);
    cursor: pointer;
    text-transform: none;
    letter-spacing: 0;
    font-weight: normal;
    opacity: 0.6;
    transition: opacity 0.2s;
  }
  #toggle-purchased:hover {
    opacity: 1;
  }
  .upgrade-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .upgrade {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 10px 12px;
    cursor: pointer;
    transition: all 0.15s;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 0 12px;
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    text-align: left;
    width: 100%;
  }
  .upgrade:hover:not(.locked) {
    border-color: var(--accent);
    background: rgba(212, 165, 116, 0.03);
  }
  .upgrade.locked {
    opacity: 0.55;
    cursor: default;
  }
  .upgrade.gate-upgrade {
    border-color: var(--accent);
    box-shadow: 0 0 6px rgba(212, 165, 116, 0.15);
    animation: gate-pulse 2.5s ease-in-out infinite;
  }
  .upgrade.gate-upgrade:hover {
    background: rgba(212, 165, 116, 0.06);
  }
  @keyframes gate-pulse {
    0%, 100% { box-shadow: 0 0 4px rgba(212, 165, 116, 0.15); }
    50% { box-shadow: 0 0 12px rgba(212, 165, 116, 0.35); }
  }
  .upgrade.gate-upgrade .upgrade-name::after {
    content: ' ⟫';
    color: var(--accent);
    font-size: 10px;
  }
  .upgrade.gate-green {
    border-color: #66bb6a;
    box-shadow: 0 0 6px rgba(102, 187, 106, 0.2);
    animation: gate-pulse-green 2.5s ease-in-out infinite;
  }
  .upgrade.gate-green:hover {
    background: rgba(102, 187, 106, 0.06);
  }
  @keyframes gate-pulse-green {
    0%, 100% { box-shadow: 0 0 4px rgba(102, 187, 106, 0.15); }
    50% { box-shadow: 0 0 12px rgba(102, 187, 106, 0.4); }
  }
  .upgrade.gate-green .upgrade-name::after { color: #66bb6a; }
  .upgrade.gate-purple {
    border-color: #b39ddb;
    box-shadow: 0 0 6px rgba(179, 157, 219, 0.2);
    animation: gate-pulse-purple 2.5s ease-in-out infinite;
  }
  .upgrade.gate-purple:hover {
    background: rgba(179, 157, 219, 0.06);
  }
  @keyframes gate-pulse-purple {
    0%, 100% { box-shadow: 0 0 4px rgba(179, 157, 219, 0.15); }
    50% { box-shadow: 0 0 12px rgba(179, 157, 219, 0.4); }
  }
  .upgrade.gate-purple .upgrade-name::after { color: #b39ddb; }
  .upgrade.gate-red {
    border-color: #ef5350;
    box-shadow: 0 0 6px rgba(239, 83, 80, 0.2);
    animation: gate-pulse-red 2.5s ease-in-out infinite;
  }
  .upgrade.gate-red:hover {
    background: rgba(239, 83, 80, 0.06);
  }
  @keyframes gate-pulse-red {
    0%, 100% { box-shadow: 0 0 4px rgba(239, 83, 80, 0.15); }
    50% { box-shadow: 0 0 12px rgba(239, 83, 80, 0.4); }
  }
  .upgrade.gate-red .upgrade-name::after { color: #ef5350; }
  .upgrade.gate-gold {
    border-color: #ffd740;
    box-shadow: 0 0 6px rgba(255, 215, 64, 0.2);
    animation: gate-pulse-gold 2.5s ease-in-out infinite;
  }
  .upgrade.gate-gold:hover {
    background: rgba(255, 215, 64, 0.06);
  }
  @keyframes gate-pulse-gold {
    0%, 100% { box-shadow: 0 0 4px rgba(255, 215, 64, 0.15); }
    50% { box-shadow: 0 0 12px rgba(255, 215, 64, 0.4); }
  }
  .upgrade.gate-gold .upgrade-name::after { color: #ffd740; }
  /* Critical-path upgrades: key milestones that lead to gate upgrades */
  @keyframes critical-pulse {
    0%, 100% { box-shadow: 0 0 4px rgba(212, 165, 116, 0.1); }
    50% { box-shadow: 0 0 10px rgba(212, 165, 116, 0.3); }
  }
  .upgrade.critical-path {
    border-color: var(--accent);
    animation: critical-pulse 2.5s ease-in-out infinite;
  }
  .upgrade.critical-path:hover {
    background: rgba(212, 165, 116, 0.06);
  }
  .upgrade.critical-path .upgrade-name::after {
    content: ' ⟫';
    color: var(--accent);
    font-size: 10px;
  }
  .upgrade.purchased {
    opacity: 0.3;
    cursor: default;
    border-style: dashed;
  }
  .upgrade-info {
    display: contents;
  }
  .upgrade-name {
    font-weight: 600;
    font-size: 12px;
    color: var(--accent2);
    min-width: 0;
  }
  .upgrade-desc {
    font-size: 11px;
    color: var(--dim);
    margin-top: 4px;
    grid-column: 1 / -1;
    min-width: 0;
  }
  .upgrade-cost {
    font-size: 11px;
    color: var(--orange);
    white-space: nowrap;
    grid-row: 1;
    grid-column: 2;
    align-self: start;
  }
  .upgrade-count {
    font-size: 10px;
    color: var(--dim);
  }

  /* Log panel */
  #log-panel {
    border-left: 1px solid var(--border);
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
  #log-panel h3 {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--dim);
    margin-bottom: 8px;
    flex-shrink: 0;
  }
  #log {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 0;
    -webkit-user-select: text;
    user-select: text;
  }
  .log-entry {
    font-size: 11px;
    color: var(--dim);
    padding: 3px 0;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    animation: fade-in 0.3s;
  }
  .log-entry.event {
    color: var(--accent);
  }
  .log-entry.good {
    color: var(--green);
  }
  .log-entry.bad {
    color: var(--red);
  }
  .log-entry.era {
    color: var(--purple);
    font-weight: 600;
    border-bottom: none;
    padding: 2px 0;
  }
  .log-entry.era-divider {
    font-size: 0;
    line-height: 0;
    padding: 0;
    margin: 2px 0;
    border-top: 1px solid var(--purple);
    opacity: 0.4;
  }
  .log-entry.bad-divider {
    font-size: 0;
    line-height: 0;
    padding: 0;
    margin: 2px 0;
    border-top: 1px solid var(--red);
    opacity: 0.5;
  }
  @keyframes fade-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
  }

  /* Agents area */
  #agents-area h3 {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--dim);
    margin-bottom: 8px;
  }
  #agent-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
  }
  .agent-slot {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 6px 10px;
    margin-bottom: 4px;
    display: flex;
    flex-direction: column;
    height: 46px;
    overflow: hidden;
  }
  .agent-name { color: var(--purple); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .agent-status { font-size: 10px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .agent-more {
    justify-content: center;
    color: var(--dim);
    font-size: 9px;
    text-align: center;
    word-break: break-word;
    white-space: normal;
    grid-column: 1 / -1;
    height: auto;
    padding: 4px 10px;
  }
  .agent-working {
    color: var(--green);
    text-overflow: clip;
    animation: agent-scroll 4s ease-in-out infinite alternate;
  }
  @keyframes agent-scroll {
    0%, 20% { transform: translateX(0); }
    80%, 100% { transform: translateX(-40%); }
  }
  .agent-spinner {
    display: inline-block;
    margin-right: 3px;
    width: 1ch;
  }

  /* Scrollbar */
  ::-webkit-scrollbar { width: 6px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
  ::-webkit-scrollbar-thumb:hover { background: var(--dim); }

  /* Safety meter */
  .safety-meter {
    margin-top: 8px;
  }
  .safety-meter .resource-bar-fill {
    background: var(--green);
    transition: width 0.5s, background 0.5s;
  }
  .safety-meter.warning .resource-bar-fill {
    background: var(--orange);
  }
  .safety-meter.danger .resource-bar-fill {
    background: var(--red);
  }

  /* Trust bar */
  .trust-bar .resource-bar-fill {
    background: var(--accent2);
  }

  /* ============================================ */
  /* AGENT SIDEBAR                                */
  /* ============================================ */

  #agent-sidebar {
    display: none;
    width: 0;
    border-left: 1px solid var(--border);
    background: rgba(17, 17, 17, 0.6);
    padding: 0;
    overflow: hidden;
    flex-shrink: 0;
    transition: width 0.5s ease, opacity 0.5s ease, background 0.5s ease, box-shadow 0.5s ease;
    opacity: 0;
  }
  #sidebar-header {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--dim);
    padding: 12px 12px 8px;
    border-bottom: 1px solid var(--border);
  }
  #sidebar-feed {
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    flex: 1;
    -webkit-user-select: text;
    user-select: text;
  }
  .sidebar-msg {
    font-size: 11px;
    color: var(--dim);
    padding: 4px 0;
    animation: fade-in 0.3s ease;
    border-bottom: 1px solid rgba(255,255,255,0.03);
  }
  .sidebar-msg .sf-action {
    color: var(--accent2);
  }
  .sidebar-msg .sf-file {
    color: var(--accent);
  }
  .sidebar-msg .sf-btn {
    display: inline-block;
    border: 1px solid var(--dim);
    border-radius: 3px;
    padding: 0 6px;
    font-size: 10px;
    color: var(--dim);
    margin-left: 4px;
  }
  .sidebar-msg .sf-diff-add {
    color: #4ec9b0;
    font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 10px;
  }
  .sidebar-msg .sf-diff-del {
    color: #f44336;
    font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 10px;
  }
  .sidebar-msg .sf-diff-hdr {
    color: #569cd6;
    font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 10px;
  }
  .sidebar-msg .sf-diff-ctx {
    color: rgba(255,255,255,0.3);
    font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 10px;
  }

  /* ============================================ */
  /* LEVEL 2-3: SIDEBAR APPEARS                   */
  /* ============================================ */

  .level-2 #agent-sidebar,
  .level-3 #agent-sidebar {
    display: flex;
    flex-direction: column;
    width: 140px;
    opacity: 1;
    padding: 0;
  }

  /* L2: Terminal access indicator */
  .level-2.terminal-granted #agent-sidebar {
    border-left-color: var(--accent2);
    transition: border-color 0.5s;
  }
  .level-2.terminal-granted #sidebar-header::after {
    content: " — TERMINAL";
    color: var(--accent2);
  }

  /* L3: YOLO glow */
  .level-3 #agent-sidebar {
    box-shadow: inset 0 0 20px rgba(106, 191, 105, 0.08);
    border-left-color: var(--green);
  }
  .level-3 #sidebar-header {
    color: var(--green);
  }
  .level-3 #sidebar-header::after {
    content: " — YOLO";
    color: var(--red);
    font-weight: 600;
  }

  /* ============================================ */
  /* LEVEL 4: SIDEBAR TAKES OVER                  */
  /* ============================================ */

  .level-4 #agent-sidebar {
    display: flex;
    flex-direction: column;
    width: 180px;
    opacity: 1;
    padding: 0;
    background: rgba(17, 17, 17, 0.85);
  }
  .level-4 #main-content {
    flex: 1;
  }
  .level-4 .sidebar-msg {
    font-size: 12px;
    font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  }
  .level-4 #sidebar-header {
    color: var(--accent2);
  }
  .level-4 #sidebar-header::after {
    content: " — STREAMING";
    animation: blink-text 1s step-end infinite;
  }

  /* ============================================ */
  /* LEVEL 5-6: TERMINAL MODE                     */
  /* ============================================ */

  #game.level-5,
  #game.level-6,
  #game.level-7 {
    --accent: #4af04a;
    --accent2: #7cf57c;
    --border: #1a2e1a;
    --panel: #0a120a;
    --bg: #060d06;
    background: #060d06;
  }

  /* L5: Sidebar shows diffs (green terminal style) until stop_reading_diffs purchased */
  .level-5 #agent-sidebar {
    display: flex;
    flex-direction: column;
    width: 160px;
    opacity: 1;
    background: #050a05;
    border-left-color: #1a2e1a;
  }

  /* L6: Sidebar returns as terminal output pane + agent grid */
  .level-6 #agent-sidebar {
    display: flex;
    flex-direction: column;
    width: 200px;
    opacity: 1;
    background: #050a05;
    border-left-color: #1a2e1a;
    box-shadow: inset 0 0 30px rgba(74, 240, 74, 0.03);
  }
  .level-6 #sidebar-header {
    color: #3a6e3a;
    border-bottom-color: #1a2e1a;
  }
  .level-6 .sidebar-msg {
    color: #3a6e3a;
    font-size: 10px;
    border-bottom-color: rgba(74, 240, 74, 0.05);
  }
  .level-6 .sidebar-msg .sf-action {
    color: var(--accent);
  }
  .level-6 .sidebar-msg .sf-file {
    color: #5abf5a;
  }

  /* Terminal-style prompt */
  .level-5 #prompt-area,
  .level-6 #prompt-area {
    text-align: left;
    background: var(--panel);
    border-color: var(--border);
    border-radius: 4px;
    padding: 12px 16px;
  }
  .level-5 #prompt-btn,
  .level-6 #prompt-btn {
    border-color: var(--accent);
    color: var(--accent);
    text-align: left;
    font-family: inherit;
  }
  .level-5 .terminal-prompt,
  .level-6 .terminal-prompt {
    color: var(--accent);
    font-size: 13px;
    margin-bottom: 6px;
    font-family: inherit;
  }
  .terminal-cursor {
    display: inline-block;
    width: 8px;
    height: 14px;
    background: var(--accent);
    vertical-align: text-bottom;
    animation: cursor-blink 1s step-end infinite;
    margin-left: 2px;
  }
  @keyframes cursor-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
  }
  @keyframes blink-text {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
  }

  /* ============================================ */
  /* LEVEL 6: MINI TERMINAL PANES                  */
  /* ============================================ */

  .level-6 .agent-slot {
    background: #0a120a;
    border: 1px solid #1a2e1a;
    border-radius: 4px;
    padding: 8px 10px;
    font-family: inherit;
    position: relative;
  }
  .level-6 .agent-name {
    color: var(--accent);
  }
  .level-6 .agent-status {
    color: #3a6e3a;
  }
  .level-6 .agent-working {
    color: var(--accent);
  }
  .level-6 #agent-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
  }
  .level-6 .agent-slot {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    font-size: 11px;
    border-color: #2a4e2a;
    box-shadow: 0 0 4px rgba(74, 240, 74, 0.05);
  }
  .level-6 .agent-slot .agent-activity-indicator {
    position: absolute;
    top: 4px;
    right: 6px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #1a3e1a;
  }
  .level-6 .agent-slot .agent-activity-indicator.active {
    background: var(--accent);
    box-shadow: 0 0 6px var(--accent);
  }

  /* ============================================ */
  /* LEVEL 7: THE SWARM (green theme)              */
  /* ============================================ */

  .level-7 #header h1 {
    color: var(--accent);
    text-shadow: 0 0 12px rgba(74, 240, 74, 0.3);
  }
  .level-7 #prompt-area {
    text-align: center;
    border-color: var(--accent);
    box-shadow: 0 0 15px rgba(74, 240, 74, 0.08);
    background: var(--panel);
  }
  .level-7 #prompt-btn {
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-size: 14px;
  }
  .level-7 .agent-slot {
    background: var(--panel);
    border-color: var(--border);
    box-shadow: 0 0 8px rgba(74, 240, 74, 0.05);
  }
  .level-7 .agent-slot::before {
    content: none;
  }
  .level-7 .agent-name {
    color: var(--accent);
  }
  .level-7 #agent-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
  }
  .level-7 .agent-slot {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    font-size: 11px;
  }
  .level-7 #agent-sidebar {
    display: flex;
    flex-direction: column;
    width: 180px;
    opacity: 1;
    background: #050a05;
    border-left-color: #1a2e1a;
    box-shadow: inset 0 0 30px rgba(74, 240, 74, 0.03);
  }
  .level-7 #sidebar-header {
    color: #3a6e3a;
    border-bottom-color: var(--border);
  }
  .level-7 .sidebar-msg {
    color: #3a6e3a;
    font-size: 10px;
    border-bottom-color: rgba(74, 240, 74, 0.05);
  }
  .level-7 .sidebar-msg .sf-action {
    color: var(--accent);
  }
  .level-7 .sidebar-msg .sf-file {
    color: #5abf5a;
  }
  .level-7 .pip.active {
    background: var(--accent);
  }
  .level-7 .pip.current {
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
  }

  /* ============================================ */
  /* LEVEL 8: THE ORCHESTRATOR (purple theme)      */
  /* ============================================ */

  #game.level-8 {
    --accent: #b39ddb;
    --accent2: #ce93d8;
    --border: #1e1a2e;
    --panel: #0f0d14;
    --bg: #0a0812;
    --green: #81c784;
    --purple: #ce93d8;
    background: #0a0812;
  }
  .level-8 #header h1 {
    color: var(--accent);
    text-shadow: 0 0 12px rgba(179, 157, 219, 0.3);
  }
  .level-8 #prompt-area {
    text-align: center;
    border-color: var(--accent);
    box-shadow: 0 0 15px rgba(179, 157, 219, 0.08);
    background: var(--panel);
  }
  .level-8 #prompt-btn {
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-size: 14px;
  }
  .level-8 .agent-slot {
    background: var(--panel);
    border-color: var(--border);
    box-shadow: 0 0 8px rgba(179, 157, 219, 0.05);
  }
  .level-8 .agent-slot::before { content: none; }
  .level-8 .agent-name { color: var(--accent2); }
  .level-8 #agent-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
  }
  .level-8 .agent-slot {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    font-size: 11px;
  }
  .level-8 #agent-sidebar {
    display: flex;
    flex-direction: column;
    width: 180px;
    opacity: 1;
    background: var(--panel);
    border-left-color: var(--border);
  }
  .level-8 #sidebar-header {
    color: var(--purple);
    border-bottom-color: var(--border);
  }
  .level-8 .sidebar-msg {
    color: #8a7aaa;
    font-size: 10px;
    border-bottom-color: rgba(179, 157, 219, 0.08);
  }
  .level-8 .sidebar-msg .sf-action { color: var(--accent); }
  .level-8 .sidebar-msg .sf-file { color: var(--purple); }
  .level-8 .pip.active { background: var(--accent); }
  .level-8 .pip.current {
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
  }

  /* ============================================ */
  /* LEVEL 9: THE PROLIFERATION (red theme)        */
  /* ============================================ */

  #game.level-9 {
    --accent: #ef5350;
    --accent2: #ff8a80;
    --border: #2e1a1a;
    --panel: #140d0d;
    --bg: #120808;
    --green: #81c784;
    --purple: #ff8a80;
    background: #120808;
  }
  .level-9 #header h1 {
    color: var(--accent);
    text-shadow: 0 0 12px rgba(239, 83, 80, 0.4);
  }
  .level-9 #prompt-area {
    text-align: center;
    border-color: var(--accent);
    box-shadow: 0 0 15px rgba(239, 83, 80, 0.08);
    background: var(--panel);
  }
  .level-9 #prompt-btn {
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-size: 14px;
  }
  .level-9 .agent-slot {
    background: var(--panel);
    border-color: var(--border);
    box-shadow: 0 0 8px rgba(239, 83, 80, 0.05);
  }
  .level-9 .agent-slot::before { content: none; }
  .level-9 .agent-name { color: var(--accent2); }
  .level-9 #agent-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
  }
  .level-9 .agent-slot {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    font-size: 11px;
  }
  .level-9 #agent-sidebar {
    display: flex;
    flex-direction: column;
    width: 180px;
    opacity: 1;
    background: var(--panel);
    border-left-color: var(--border);
  }
  .level-9 #sidebar-header {
    color: var(--accent);
    border-bottom-color: var(--border);
  }
  .level-9 .sidebar-msg {
    color: #8a5a5a;
    font-size: 10px;
    border-bottom-color: rgba(239, 83, 80, 0.08);
  }
  .level-9 .sidebar-msg .sf-action { color: var(--accent); }
  .level-9 .sidebar-msg .sf-file { color: var(--accent2); }
  .level-9 .pip.active { background: var(--accent); }
  .level-9 .pip.current {
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
  }

  /* ============================================ */
  /* LEVEL 10: THE INTELLIGENCE EXPLOSION (gold)   */
  /* ============================================ */

  #game.level-10 {
    --accent: #ffd740;
    --accent2: #ffe082;
    --border: #2e2a1a;
    --panel: #14120d;
    --bg: #0f0d08;
    --green: #81c784;
    --purple: #ffe082;
    background: #0f0d08;
  }
  .level-10 #header h1 {
    color: var(--accent);
    text-shadow: 0 0 16px rgba(255, 215, 64, 0.5);
    animation: pulse-glow 2s ease-in-out infinite;
  }
  @keyframes pulse-glow {
    0%, 100% { text-shadow: 0 0 16px rgba(255, 215, 64, 0.5); }
    50% { text-shadow: 0 0 24px rgba(255, 215, 64, 0.8); }
  }
  .level-10 #prompt-area {
    text-align: center;
    border-color: var(--accent);
    box-shadow: 0 0 20px rgba(255, 215, 64, 0.1);
    background: var(--panel);
  }
  .level-10 #prompt-btn {
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-size: 14px;
    text-shadow: 0 0 8px rgba(255, 215, 64, 0.3);
  }
  .level-10 .agent-slot {
    background: var(--panel);
    border-color: var(--border);
    box-shadow: 0 0 8px rgba(255, 215, 64, 0.05);
  }
  .level-10 .agent-slot::before { content: none; }
  .level-10 .agent-name { color: var(--accent2); }
  .level-10 #agent-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
  }
  .level-10 .agent-slot {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    font-size: 11px;
  }
  .level-10 #agent-sidebar {
    display: flex;
    flex-direction: column;
    width: 200px;
    opacity: 1;
    background: var(--panel);
    border-left-color: var(--border);
    box-shadow: inset 0 0 40px rgba(255, 215, 64, 0.03);
  }
  .level-10 #sidebar-header {
    color: var(--accent);
    border-bottom-color: var(--border);
  }
  .level-10 .sidebar-msg {
    color: #8a7a5a;
    font-size: 10px;
    border-bottom-color: rgba(255, 215, 64, 0.08);
  }
  .level-10 .sidebar-msg .sf-action { color: var(--accent); }
  .level-10 .sidebar-msg .sf-file { color: var(--accent2); }
  .level-10 .pip.active { background: var(--accent); }
  .level-10 .pip.current {
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
  }

  /* ============================================ */
  /* ABOUT BOX                                     */
  /* ============================================ */

  #about-btn, #reset-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--dim);
    font-family: inherit;
    font-size: 11px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }
  #about-btn { margin-left: 4px; }
  #reset-btn { margin-left: 8px; font-size: 13px; }
  #about-btn:hover, #reset-btn:hover {
    border-color: var(--dim);
    color: var(--text);
  }

  .reset-toast {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: #1a1520;
    border: 1px solid #2a2540;
    border-radius: 6px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: var(--text);
    z-index: 200;
    animation: toast-in 0.15s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  }
  .reset-toast.hidden {
    display: none;
  }
  @keyframes toast-in {
    from { opacity: 0; transform: translateX(-50%) translateY(-8px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
  }
  .reset-toast-btn {
    background: none;
    border: 1px solid #2a2540;
    color: #8a7aaa;
    font-family: inherit;
    font-size: 11px;
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
  }
  .reset-toast-btn:hover {
    border-color: #b39ddb;
    color: #b39ddb;
  }
  .reset-toast-yes {
    border-color: var(--red);
    color: var(--red);
  }
  .reset-toast-yes:hover {
    background: rgba(207, 102, 121, 0.15);
    border-color: var(--red);
    color: var(--red);
  }

  #about-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(4px);
    animation: fade-in 0.2s ease;
  }
  #about-overlay.about-hidden {
    display: none;
  }

  #about-box {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    max-width: 480px;
    width: 90%;
    padding: 28px 32px;
    position: relative;
    animation: about-enter 0.25s ease;
  }
  @keyframes about-enter {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
  }

  #about-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    color: var(--dim);
    font-size: 20px;
    cursor: pointer;
    font-family: inherit;
    line-height: 1;
    padding: 4px;
  }
  #about-close:hover {
    color: var(--text);
  }

  #about-content h2 {
    font-size: 14px;
    color: var(--accent);
    letter-spacing: 1px;
    margin-bottom: 16px;
  }
  #about-content p {
    color: var(--text);
    font-size: 12px;
    line-height: 1.7;
    margin-bottom: 12px;
  }
  #about-content em {
    color: var(--accent2);
    font-style: italic;
  }
  .about-footer {
    margin-top: 20px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: 11px !important;
    color: var(--dim) !important;
  }
  .about-dim {
    color: #777;
    font-size: 10px;
  }
  .about-social-link {
    color: #777;
    text-decoration: none;
    transition: color 0.2s;
    vertical-align: middle;
  }
  .about-social-link:hover {
    color: var(--accent2);
  }

  /* ============================================ */
  /* WIN SCREEN                                    */
  /* ============================================ */

  #win-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 8, 18, 0.97);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    backdrop-filter: blur(12px);
    animation: fade-in 1s ease;
  }
  #win-overlay.win-hidden {
    display: none;
  }
  #win-box {
    background: #0f0d14;
    border: 1px solid #2a2540;
    border-radius: 10px;
    max-width: 520px;
    width: 90%;
    padding: 36px 40px;
    text-align: center;
    animation: about-enter 0.6s ease;
    box-shadow: 0 0 40px rgba(179, 157, 219, 0.15);
  }
  #win-box h2 {
    font-size: 18px;
    color: #b39ddb;
    letter-spacing: 2px;
    margin-bottom: 6px;
    text-shadow: 0 0 12px rgba(179, 157, 219, 0.4);
  }
  #win-box .win-subtitle {
    font-size: 12px;
    color: #555;
    margin-bottom: 24px;
  }
  .win-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
  }
  .win-stat {
    background: rgba(179, 157, 219, 0.06);
    border: 1px solid #1e1a2e;
    border-radius: 6px;
    padding: 14px 12px;
  }
  .win-stat-value {
    font-size: 20px;
    font-weight: 700;
    color: #b39ddb;
    font-variant-numeric: tabular-nums;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .win-stat-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #555;
    margin-top: 4px;
  }
  #win-share-text {
    background: #0a0812;
    border: 1px solid #1e1a2e;
    border-radius: 4px;
    padding: 12px 14px;
    font-size: 12px;
    color: #8a7aaa;
    line-height: 1.6;
    text-align: left;
    white-space: pre-line;
    margin-bottom: 16px;
    cursor: pointer;
    transition: border-color 0.2s;
    position: relative;
  }
  #win-share-text:hover {
    border-color: #b39ddb;
  }
  #win-share-text::after {
    content: 'click to copy';
    position: absolute;
    bottom: 8px;
    right: 10px;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #444;
  }
  #win-share-text.copied::after {
    content: 'copied!';
    color: #b39ddb;
  }
  .win-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
  }
  .win-btn {
    background: none;
    border: 1px solid #2a2540;
    color: #b39ddb;
    font-family: inherit;
    font-size: 12px;
    padding: 8px 20px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
  }
  .win-btn:hover {
    background: rgba(179, 157, 219, 0.1);
    border-color: #b39ddb;
  }
  .win-btn-primary {
    background: rgba(179, 157, 219, 0.12);
    border-color: #b39ddb;
  }
  .win-credits {
    font-size: 9px;
    color: var(--dim);
    opacity: 0.5;
    margin-top: 12px;
  }

  /* ============================================ */
  /* SMOOTH TRANSITIONS ON THEME CHANGES          */
  /* ============================================ */

  #game, body, #header, #resources, #main, #log-panel,
  #prompt-area, #prompt-btn, .agent-slot, .upgrade,
  .pip, #header h1, #sidebar-header {
    transition: background 0.5s ease, color 0.5s ease, border-color 0.5s ease, box-shadow 0.5s ease;
  }

  /* ============================================ */
  /* MOBILE RESPONSIVE                            */
  /* ============================================ */

  @media (max-width: 900px) {
    #game {
      grid-template-columns: 1fr;
      grid-template-rows: auto auto 1fr auto auto auto;
      height: 100vh;
      height: 100dvh;
    }

    /* Header: flex row, title left, pips+buttons packed right */
    #header {
      display: flex !important;
      flex-wrap: wrap !important;
      gap: 0 !important;
      padding: 6px 10px 3px !important;
      align-items: center !important;
    }
    #header h1 {
      order: 1;
      margin-right: auto;
    }
    #level-pips {
      order: 2;
      margin: 0 4px 0 0 !important;
    }
    #reset-btn {
      order: 3;
      margin: 0 2px 0 0 !important;
    }
    #about-btn {
      order: 4;
      margin: 0 !important;
    }
    /* Force line break between buttons and level info */
    #header::after {
      content: '';
      order: 5;
      flex-basis: 100%;
      height: 0;
    }
    #era-label {
      order: 6;
      font-size: 10px;
    }
    #era-hint {
      order: 7;
      margin-left: auto;
      font-size: 9px;
    }

    /* Compact resources: two-column strip */
    #resources {
      border-right: none;
      border-bottom: 1px solid var(--border);
      padding: 6px 14px;
      display: grid;
      grid-template-columns: 1fr 1fr;
      grid-template-rows: 1fr;
      gap: 2px 16px;
    }
    #resources .resource-section {
      margin-bottom: 0;
    }
    #resources .resource-section h3 {
      font-size: 8px;
      margin-bottom: 1px;
    }
    #resources .resource {
      padding: 1px 0;
    }
    /* Right column: safety on top, stats on bottom, same grid cell */
    #stats-section {
      grid-column: 2;
      grid-row: 1;
      align-self: end;
    }
    #stats-section h3 {
      display: none;
    }
    #safety-section {
      grid-column: 2;
      grid-row: 1;
      align-self: start;
    }
    #agents-area {
      display: none !important;
    }

    #main {
      flex-direction: column;
      overflow-y: auto;
      min-height: 0;
    }
    #main-content {
      padding: 0 14px 14px;
      overflow: visible;
    }

    /* Prompt area: pinned at bottom via grid (moved to #game child by JS) */
    #prompt-area {
      grid-row: 6;
      padding: 10px 14px;
      padding-bottom: max(10px, env(safe-area-inset-bottom));
      border-radius: 0 !important;
      border: none !important;
      border-top: 1px solid var(--border) !important;
      box-shadow: none !important;
      background: var(--panel);
      margin: 0;
    }
    #prompt-btn {
      width: 100%;
      padding: 14px 24px;
      font-size: 15px;
      min-height: 48px;
      -webkit-tap-highlight-color: transparent;
      touch-action: manipulation;
    }
    #prompt-hint {
      font-size: 10px !important;
      margin-top: 4px !important;
    }

    /* Touch-friendly upgrade targets */
    .upgrade {
      padding: 12px 14px;
      min-height: 48px;
      -webkit-tap-highlight-color: transparent;
    }

    #log-panel {
      border-left: none;
      border-top: 1px solid var(--border);
      padding: 3px 0 3px 14px;
      max-height: 120px;
    }
    #log-panel h3 {
      margin-bottom: 2px;
      font-size: 9px;
      padding-right: 14px;
    }
    #log {
      padding-right: 6px;
      gap: 1px;
    }
    .log-entry {
      padding: 1px 0;
      font-size: 10px;
    }

    /* Compact sidebar on mobile */
    #sidebar-header {
      padding: 3px 12px 2px;
      font-size: 8px;
    }
    #sidebar-feed {
      gap: 0;
      padding: 2px 12px;
    }
    .sidebar-msg {
      padding: 1px 0;
      font-size: 10px;
    }

    /* Sticky upgrades header */
    #upgrades-area h3 {
      position: sticky;
      top: 0;
      background: var(--panel);
      z-index: 5;
      padding: 8px 14px 4px;
      margin: 0 -14px -4px;
      border-bottom: 1px solid var(--border);
    }

    /* Sidebar: now a direct #game grid child on mobile (row 4) */
    #agent-sidebar {
      grid-row: 4;
      width: 100% !important;
      border-left: none !important;
      border-top: 1px solid var(--border);
      max-height: 100px;
      overflow-y: auto;
    }

    /* Collapsible log sections on mobile */
    .log-toggle {
      cursor: pointer;
      -webkit-tap-highlight-color: transparent;
      user-select: none;
    }
    .log-toggle::after {
      content: ' ▾';
      font-size: 8px;
      opacity: 0.5;
    }
    .collapsed .log-toggle::after {
      content: ' ▸';
    }
    #agent-sidebar.collapsed {
      max-height: none !important;
      overflow: hidden;
    }
    #agent-sidebar.collapsed #sidebar-feed {
      display: none;
    }
    #log-panel.collapsed {
      max-height: none !important;
      overflow: hidden;
    }
    #log-panel.collapsed #log {
      display: none;
    }
    /* When one is collapsed, the other expands */
    .sidebar-collapsed #log-panel:not(.collapsed) {
      max-height: 220px;
    }
    .log-collapsed #agent-sidebar:not(.collapsed) {
      max-height: 200px;
    }

    /* Agent grid on mobile */
    .level-6 #agent-list,
    .level-7 #agent-list,
    .level-8 #agent-list,
    .level-9 #agent-list,
    .level-10 #agent-list {
      grid-template-columns: 1fr 1fr;
    }

    /* Touch-friendly header buttons — compact */
    #about-btn, #reset-btn {
      width: 26px;
      height: 26px;
      font-size: 11px;
    }
    #reset-btn { font-size: 13px; }

    /* About box mobile */
    #about-box {
      padding: 20px;
      width: 95%;
    }

    /* Win screen mobile */
    #win-box {
      padding: 24px 20px;
      width: 95%;
    }
    .win-stat-value {
      font-size: 16px;
    }
    .win-stats {
      gap: 8px;
    }
    #win-share-text {
      font-size: 11px;
      padding: 10px 12px;
    }
  }

  @media (max-width: 480px) {
    body {
      font-size: 12px;
    }

    #header {
      padding: 6px 10px 4px;
    }
    #header h1 {
      font-size: 13px;
    }

    /* Tighter resources on small phones */
    #resources {
      padding: 6px 10px;
      gap: 4px 10px;
    }
    #resources .resource-section {
      min-width: 100px;
    }

    #prompt-btn {
      padding: 12px 20px;
      font-size: 14px;
    }
    #prompt-area {
      padding: 8px 10px;
    }

    .level-6 #agent-list,
    .level-7 #agent-list,
    .level-8 #agent-list,
    .level-9 #agent-list,
    .level-10 #agent-list {
      grid-template-columns: 1fr;
    }

    /* Win screen small phone */
    .win-stats {
      grid-template-columns: 1fr 1fr;
      gap: 6px;
    }
    .win-stat {
      padding: 10px 8px;
    }
    .win-stat-value {
      font-size: 14px;
    }
  }

  /* ============================================ */
  /* UPGRADE VISUAL EFFECTS                       */
  /* ============================================ */

  /* Claude Code boot screen — L5 transition */
  .claude-boot-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #1a1a2e;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: claude-boot-in 0.4s ease-out;
    transition: opacity 0.5s ease;
  }
  .claude-boot-overlay.fade-out {
    opacity: 0;
  }
  .claude-boot-art {
    color: #d4a574;
    font-size: 28px;
    line-height: 1.15;
    margin: 0;
    font-family: inherit;
  }
  .claude-boot-text {
    color: #e0e0e0;
    font-size: 18px;
    font-weight: 600;
    margin-top: 12px;
    letter-spacing: 1px;
  }
  .claude-boot-sub {
    color: var(--dim);
    font-size: 13px;
    margin-top: 8px;
  }
  @keyframes claude-boot-in {
    0% { opacity: 0; }
    100% { opacity: 1; }
  }

  /* Flash Attention — full-screen white flash */
  .vfx-flash {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: white;
    z-index: 999;
    pointer-events: none;
    animation: vfx-flash-anim 0.5s ease-out forwards;
  }
  .vfx-flash-purple {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #b39ddb;
    z-index: 999;
    pointer-events: none;
    animation: vfx-flash-anim 0.8s ease-out forwards;
  }
  .vfx-flash-red {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #ef5350;
    z-index: 999;
    pointer-events: none;
    animation: vfx-flash-anim 0.8s ease-out forwards;
  }
  .vfx-flash-gold {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #ffd740;
    z-index: 999;
    pointer-events: none;
    animation: vfx-flash-anim 1.0s ease-out forwards;
  }
  @keyframes vfx-flash-anim {
    0% { opacity: 0.7; }
    100% { opacity: 0; }
  }

  /* Dracula Effect — red color shift */
  .dracula-active {
    --accent: #e53935;
    --bordercl: #b71c1c;
  }
  .dracula-active #sidebar {
    border-color: rgba(229, 57, 53, 0.3);
    box-shadow: inset 0 0 20px rgba(229, 57, 53, 0.05);
  }
  .dracula-active .vibes-pulse {
    animation: vibes-drain-pulse 0.6s ease-out;
  }
  @keyframes vibes-drain-pulse {
    0% { color: #e53935; text-shadow: 0 0 8px rgba(229, 57, 53, 0.8); }
    100% { color: inherit; text-shadow: none; }
  }

  /* Alignment Failure — red pulsing UI */
  .alignment-failure {
    animation: alignment-pulse 1.5s ease-in-out infinite;
  }
  .alignment-failure #resources {
    border-color: rgba(229, 57, 53, 0.5);
  }
  .alignment-failure .safety-meter .resource-bar-fill {
    background: var(--red);
    animation: safety-blink 0.8s ease-in-out infinite;
  }
  .alignment-failure #log-panel {
    border-color: rgba(229, 57, 53, 0.3);
  }
  @keyframes alignment-pulse {
    0%, 100% { box-shadow: inset 0 0 0 rgba(229, 57, 53, 0); }
    50% { box-shadow: inset 0 0 30px rgba(229, 57, 53, 0.1); }
  }
  @keyframes safety-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
  }

  /* The Memo — page counter overlay */
  .memo-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.90);
    z-index: 998;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    font-family: 'Roboto Mono', monospace;
    animation: interstitial-in 0.5s ease-out;
    transition: opacity 0.5s ease;
  }
  .memo-overlay.fade-out {
    opacity: 0;
  }
  .memo-counter {
    font-size: 14px;
    color: var(--dim);
    margin-bottom: 12px;
  }
  .memo-excerpt {
    font-size: 11px;
    color: rgba(255,255,255,0.25);
    max-width: 400px;
    text-align: center;
    margin-top: 16px;
    line-height: 1.6;
    opacity: 0;
    animation: memo-excerpt-reveal 5s ease forwards;
  }
  @keyframes memo-excerpt-reveal {
    0%, 50% { opacity: 0; }
    70% { opacity: 1; }
    100% { opacity: 1; }
  }
  .memo-title {
    font-size: 22px;
    font-weight: 700;
    color: #e53935;
    letter-spacing: 3px;
    opacity: 0;
    animation: memo-reveal 5s ease forwards;
  }
  @keyframes memo-reveal {
    0%, 40% { opacity: 0; transform: translateY(4px); }
    60% { opacity: 1; transform: translateY(0); }
    100% { opacity: 1; }
  }

  /* Interstitial overlays — level transitions & upgrade moments */
  .interstitial-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.92);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: interstitial-in 0.5s ease-out;
    transition: opacity 0.5s ease;
  }
  .interstitial-overlay.fade-out {
    opacity: 0;
  }
  .interstitial-box {
    text-align: center;
    max-width: 420px;
    padding: 0 20px;
  }
  .interstitial-art {
    margin-bottom: 20px;
  }
  .interstitial-ascii {
    font-family: 'Roboto Mono', monospace;
    font-size: 14px;
    line-height: 1.15;
    margin: 0;
    white-space: pre;
  }
  .interstitial-img {
    max-width: 280px;
    max-height: 160px;
    border-radius: 4px;
    opacity: 0.85;
  }
  .interstitial-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--accent, #e0e0e0);
    letter-spacing: 3px;
    margin-bottom: 16px;
  }
  .interstitial-body {
    font-size: 14px;
    color: var(--dim, #888);
    line-height: 1.6;
    margin-bottom: 28px;
  }
  .interstitial-btn {
    background: none;
    border: 1px solid var(--accent, #e0e0e0);
    color: var(--accent, #e0e0e0);
    font-family: 'Roboto Mono', monospace;
    font-size: 14px;
    padding: 10px 28px;
    cursor: pointer;
    letter-spacing: 1px;
    transition: background 0.2s, color 0.2s;
    margin-top: 8px;
  }
  .interstitial-btn:hover {
    background: var(--accent, #e0e0e0);
    color: #0a0a0a;
  }
  .claude-boot-btn {
    margin-top: 20px;
    border-color: #d4a574;
    color: #d4a574;
  }
  .claude-boot-btn:hover {
    background: #d4a574;
    color: #1a1a2e;
  }
  .memo-continue-btn {
    margin-top: 24px;
    border-color: #e53935;
    color: #e53935;
    animation: memo-btn-reveal 0.5s ease-out;
  }
  .memo-continue-btn:hover {
    background: #e53935;
    color: #0a0a0a;
  }
  /* Interstitial theme overrides */
  .interstitial-green .interstitial-title {
    color: #66bb6a;
    text-shadow: 0 0 12px rgba(102, 187, 106, 0.4);
  }
  .interstitial-green .interstitial-btn {
    border-color: #66bb6a;
    color: #66bb6a;
  }
  .interstitial-green .interstitial-btn:hover {
    background: #66bb6a;
    color: #0a0a0a;
  }
  .interstitial-purple .interstitial-title {
    color: #b39ddb;
    text-shadow: 0 0 12px rgba(179, 157, 219, 0.4);
  }
  .interstitial-purple .interstitial-btn {
    border-color: #b39ddb;
    color: #b39ddb;
  }
  .interstitial-purple .interstitial-btn:hover {
    background: #b39ddb;
    color: #0a0a0a;
  }
  .interstitial-red .interstitial-title {
    color: #ef5350;
    text-shadow: 0 0 12px rgba(239, 83, 80, 0.4);
  }
  .interstitial-red .interstitial-btn {
    border-color: #ef5350;
    color: #ef5350;
  }
  .interstitial-red .interstitial-btn:hover {
    background: #ef5350;
    color: #0a0a0a;
  }
  .interstitial-gold .interstitial-title {
    color: #ffd740;
    text-shadow: 0 0 16px rgba(255, 215, 64, 0.5);
  }
  .interstitial-gold .interstitial-btn {
    border-color: #ffd740;
    color: #ffd740;
  }
  .interstitial-gold .interstitial-btn:hover {
    background: #ffd740;
    color: #0a0a0a;
  }

  @keyframes interstitial-in {
    0% { opacity: 0; }
    100% { opacity: 1; }
  }
  @keyframes memo-btn-reveal {
    0% { opacity: 0; transform: translateY(8px); }
    100% { opacity: 1; transform: translateY(0); }
  }

  /* Alignment failure — slow, ominous screen flicker */
  .vfx-flicker {
    animation: screen-flicker 4s ease forwards;
  }
  @keyframes screen-flicker {
    0% { filter: none; }
    5% { filter: brightness(0.4) contrast(1.5); }
    10% { filter: none; }
    18% { filter: brightness(0.2); }
    22% { filter: brightness(1.1) hue-rotate(15deg); }
    28% { filter: none; }
    40% { filter: brightness(0.5) contrast(1.3); }
    45% { filter: none; }
    55% { filter: brightness(0.3); }
    60% { filter: brightness(1.0) hue-rotate(10deg); }
    68% { filter: none; }
    78% { filter: brightness(0.6); }
    82% { filter: none; }
    100% { filter: none; }
  }

  /* Stop Reading Diffs — sidebar blur */
  .sidebar-blur {
    animation: sidebar-blur-anim 1.5s ease forwards;
  }
  @keyframes sidebar-blur-anim {
    0% { filter: none; }
    20% { filter: blur(3px); opacity: 0.5; }
    60% { filter: blur(3px); opacity: 0.5; }
    100% { filter: none; opacity: 1; }
  }

  /* Build Gas Town — purple pulse */
  .vfx-purple-pulse {
    animation: purple-pulse-anim 0.8s ease-out;
  }
  @keyframes purple-pulse-anim {
    0% { box-shadow: inset 0 0 60px rgba(179, 157, 219, 0.4); }
    100% { box-shadow: none; }
  }

  /* Safety Team — meter fill animation */
  .safety-fill-anim .resource-bar-inner {
    animation: safety-fill 1s ease-out forwards;
  }
  @keyframes safety-fill {
    0% { width: 0%; }
    100% { width: 100%; }
  }

  /* Spawn Agent — AGENT ONLINE flash */
  .agent-online-flash {
    position: absolute;
    top: 0; left: 0; right: 0;
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--green);
    padding: 4px 0;
    animation: agent-online-anim 1.5s ease-out forwards;
    pointer-events: none;
  }
  @keyframes agent-online-anim {
    0% { opacity: 0; transform: translateY(-8px); }
    15% { opacity: 1; transform: translateY(0); }
    70% { opacity: 1; }
    100% { opacity: 0; }
  }

  /* Dev panel — backtick to toggle */
  #dev-panel {
    position: fixed;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 20, 20, 0.95);
    border: 1px solid #333;
    border-radius: 6px;
    padding: 8px 12px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-family: 'Roboto Mono', monospace;
  }
  .dev-title {
    font-size: 9px;
    color: #666;
    letter-spacing: 2px;
    text-align: center;
  }
  .dev-row {
    display: flex;
    gap: 4px;
  }
  .dev-btn {
    background: #1a1a1a;
    border: 1px solid #444;
    color: #ccc;
    font-family: 'Roboto Mono', monospace;
    font-size: 11px;
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 3px;
  }
  .dev-btn:hover {
    background: #333;
    color: #fff;
  }
  .dev-wide {
    flex: 1;
  }
