@import url('https://fonts.googleapis.com/css2?family=Archivo+Black&family=IBM+Plex+Mono:wght@400;500;600&family=Share+Tech+Mono&display=swap');

:root {
  --ink: #171713;
  --soot: #22221d;
  --panel: #2a2a24;
  --panel-hi: #34342c;
  --bone: #c8c1a6;
  --paper: #dfd8ba;
  --muted: #9b9682;
  --phosphor: #76d6a0;
  --amber: #e5a63d;
  --blood: #a81725;
  --blood-hi: #e23939;
  --line: #555144;
  --display: 'Archivo Black', Impact, sans-serif;
  --mono: 'IBM Plex Mono', Consolas, monospace;
  --terminal: 'Share Tech Mono', Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--bone);
  background:
    radial-gradient(circle at 50% -20%, #464238 0, transparent 45%),
    var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  overflow-x: hidden;
}

button { font: inherit; }

button:focus-visible {
  outline: 2px solid var(--phosphor);
  outline-offset: 3px;
}

.noise {
  position: fixed;
  inset: 0;
  opacity: .08;
  pointer-events: none;
  z-index: 20;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
}

.masthead {
  min-height: 72px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: #1d1d19;
  box-shadow: inset 0 -3px 0 #0f0f0d;
}

.wordmark {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(22px, 2vw, 34px);
  letter-spacing: -1.5px;
  color: var(--paper);
}

.wordmark__prompt { color: var(--blood-hi); font-family: var(--terminal); margin-right: 6px; }
.cursor { color: var(--phosphor); animation: blink 1s steps(1) infinite; }

.masthead__status {
  margin: 0;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 10px;
}

.status-led {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
  background: var(--phosphor);
  box-shadow: 0 0 10px var(--phosphor);
}

.masthead__actions { display: flex; justify-content: flex-end; gap: 18px; }
.text-button { min-height: 32px; border: 0; padding: 6px; color: var(--bone); background: transparent; cursor: pointer; font-size: 11px; }
.masthead .text-button { min-width: 44px; min-height: 44px; }
.text-button:hover { color: var(--phosphor); }
.danger-text { color: #c05252; }

.console-shell {
  display: grid;
  grid-template-columns: 240px minmax(420px, 1fr) 290px;
  min-height: calc(100vh - 105px);
  max-width: 1800px;
  margin: 0 auto;
}

.rail { background: #20201b; }
.rail--left { border-right: 1px solid var(--line); }
.rail--right { border-left: 1px solid var(--line); }

.panel { padding: 20px; border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 12px; color: var(--amber); font-size: 9px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; }

.incident-number { display: flex; align-items: flex-start; line-height: 1; }
.incident-number span { color: var(--blood-hi); font-family: var(--display); font-size: 22px; }
.incident-number strong { color: var(--paper); font-family: var(--display); font-size: 45px; letter-spacing: -3px; }
.level-name { margin: 5px 0 20px; color: var(--muted); text-transform: uppercase; }

.sla { border-top: 1px dashed var(--line); padding-top: 14px; display: flex; justify-content: space-between; gap: 8px; font-size: 10px; }
.sla strong { color: var(--blood-hi); }

.operator-panel { background: linear-gradient(135deg, rgba(118,214,160,.06), transparent 70%); }
.operator-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.operator-heading span { color: var(--phosphor); font-size: 8px; letter-spacing: .12em; }
.operator-rank { display: flex; align-items: flex-start; gap: 4px; line-height: 1; }
.operator-rank span { margin-top: 5px; color: var(--phosphor); font-family: var(--terminal); }
.operator-rank strong { color: var(--paper); font-family: var(--display); font-size: 34px; letter-spacing: -2px; }
.meter--xp { margin-top: 9px; }
.meter--xp i { width: 0; background: var(--amber); box-shadow: 0 0 8px rgba(229,166,61,.45); }
.xp-label { display: flex; justify-content: space-between; gap: 8px; margin-top: 5px; color: var(--muted); font-size: 8px; }
.xp-label span:last-child { color: var(--phosphor); }
.next-unlock { margin: 12px 0 0; padding-top: 9px; color: var(--muted); border-top: 1px dotted var(--line); font-size: 9px; line-height: 1.4; text-transform: uppercase; }

.resource { margin: 0 0 22px; }
.resource:last-child { margin-bottom: 0; }
.resource__label { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.resource__label span { font-family: var(--terminal); font-size: 15px; }
.resource__label strong { color: var(--phosphor); font-weight: 500; }
.resource--blood strong { color: var(--blood-hi); }
.resource--credential strong { color: var(--amber); }
.resource small { display: block; margin-top: 5px; color: var(--muted); font-size: 9px; }

.meter { height: 5px; margin-top: 8px; overflow: hidden; background: #11110f; box-shadow: inset 0 0 0 1px #080807; }
.meter i { width: 100%; height: 100%; display: block; background: var(--phosphor); box-shadow: 0 0 8px rgba(118,214,160,.5); transition: width .15s linear; }

.daemon-panel dl { margin: 0; }
.daemon-panel dl div { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dotted #464238; }
.daemon-panel dt { color: var(--muted); font-size: 10px; }
.daemon-panel dd { margin: 0; color: var(--paper); }

.rail-stamp { margin: 32px auto; width: 130px; padding: 8px; transform: rotate(-4deg); color: #6e3030; border: 3px double #6e3030; text-align: center; font-weight: 600; opacity: .7; }

.battlefield-wrap { position: relative; min-width: 0; overflow: hidden; background: #10110e; }
.battlefield-topline { height: 30px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; color: #706d5d; background: #181914; border-bottom: 1px solid #3c3a31; font-size: 9px; letter-spacing: .08em; }
#threatReadout { color: var(--amber); }
#gameCanvas { width: 100%; height: calc(100vh - 135px); min-height: 500px; display: block; cursor: crosshair; background: #262920; touch-action: none; }
#gameCanvas:focus-visible { outline: 2px solid var(--phosphor); outline-offset: -4px; }

.scanlines { position: absolute; inset: 30px 0 0; pointer-events: none; background: repeating-linear-gradient(0deg, rgba(0,0,0,.1) 0 1px, transparent 1px 3px); mix-blend-mode: multiply; }

.deploy-hint { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; align-items: center; gap: 9px; padding: 7px 12px; color: #aaa48e; background: rgba(17,17,14,.82); border: 1px solid #4b493e; font-size: 9px; letter-spacing: .1em; pointer-events: none; transition: opacity .4s; }
.deploy-hint.is-hidden { opacity: 0; }
.mouse-icon { width: 11px; height: 15px; display: inline-block; border: 1px solid var(--bone); border-radius: 6px; position: relative; }
.mouse-icon::before { content: ''; position: absolute; width: 1px; height: 4px; left: 4px; top: 2px; background: var(--blood-hi); }

.event-feed { position: absolute; left: 12px; top: 43px; display: flex; flex-direction: column; gap: 4px; pointer-events: none; }
.event-line { width: fit-content; padding: 4px 6px; color: #d5cdb0; background: rgba(15,16,13,.76); border-left: 2px solid var(--blood-hi); font-family: var(--terminal); font-size: 11px; animation: feedIn .2s ease-out; }

.level-banner { position: absolute; inset: 30px 0 0; z-index: 6; place-content: center; text-align: center; background: rgba(18,14,12,.86); backdrop-filter: blur(4px); }
.level-banner:not([hidden]) { display: grid; }
.level-banner p { margin: 0 0 8px; color: var(--blood-hi); font-family: var(--display); font-size: clamp(28px, 4vw, 58px); letter-spacing: -2px; }
.level-banner strong { margin-bottom: 26px; color: var(--bone); font-weight: 400; }

.shop-heading { display: flex; justify-content: space-between; gap: 12px; }
.shop-heading h2 { margin: 0; color: var(--paper); font-family: var(--display); font-size: 25px; line-height: .95; letter-spacing: -1.2px; }
.approval { padding: 4px 7px; align-self: flex-start; transform: rotate(5deg); color: var(--blood-hi); border: 2px solid var(--blood); font-size: 8px; font-weight: 600; text-align: center; }
.shop-intro { margin: 15px 0 18px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.shop-list { display: grid; gap: 8px; }

.upgrade { width: 100%; padding: 10px; display: grid; grid-template-columns: 30px 1fr auto; gap: 9px; align-items: center; color: var(--bone); background: #24241f; border: 1px solid #464339; text-align: left; cursor: pointer; transition: background .12s, border-color .12s, transform .12s; }
.upgrade:hover:not(:disabled) { transform: translateX(-3px); background: #303028; border-color: var(--amber); }
.upgrade:disabled { cursor: not-allowed; opacity: .48; }
.upgrade__icon { font-family: var(--terminal); font-size: 20px; color: var(--phosphor); text-align: center; }
.upgrade__body strong { display: block; color: var(--paper); font-size: 11px; }
.upgrade__body small { display: block; margin-top: 3px; color: var(--muted); font-size: 8px; line-height: 1.35; }
.upgrade__price { text-align: right; }
.upgrade__price strong { display: block; color: var(--amber); font-size: 10px; }
.upgrade__price small { color: var(--muted); font-size: 8px; }

.outage-button { width: 100%; padding: 12px 10px; color: #e6d8ba; background: #61121b; border: 1px solid #b02c36; box-shadow: inset 0 0 18px rgba(0,0,0,.4); cursor: pointer; }
.outage-button:hover:not(:disabled) { background: #8d1824; }
.outage-button:disabled { opacity: .4; cursor: not-allowed; }
.outage-button span { display: block; font-family: var(--terminal); }
.outage-button small { display: block; margin-top: 4px; color: #c98b8b; font-size: 8px; }

.root-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.root-heading h2 { margin: 0; color: var(--paper); font-family: var(--display); font-size: 18px; line-height: 1; }
.root-heading > strong { min-width: 42px; color: var(--amber); font-family: var(--display); font-size: 32px; text-align: right; }
.root-shop { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin-bottom: 10px; }
.root-upgrade { min-height: 60px; padding: 7px 4px; color: var(--bone); background: #24241f; border: 1px solid #464339; cursor: pointer; text-align: center; }
.root-upgrade:hover:not(:disabled) { border-color: var(--amber); background: #302e25; }
.root-upgrade:disabled { opacity: .42; cursor: not-allowed; }
.root-upgrade strong { display: block; color: var(--phosphor); font-family: var(--terminal); font-size: 14px; }
.root-upgrade span { display: block; margin-top: 3px; font-size: 8px; line-height: 1.2; text-transform: uppercase; }
.root-upgrade small { display: block; margin-top: 4px; color: var(--amber); font-size: 8px; }
.automation-button, .prestige-button { width: 100%; min-height: 48px; padding: 9px; color: var(--bone); background: #292923; border: 1px solid #595546; cursor: pointer; }
.automation-button { margin-bottom: 7px; }
.automation-button[aria-pressed="true"] { color: var(--ink); background: var(--phosphor); border-color: var(--phosphor); }
.automation-button:disabled, .prestige-button:disabled { opacity: .4; cursor: not-allowed; }
.automation-button span, .prestige-button span { display: block; font-family: var(--terminal); }
.automation-button small, .prestige-button small { display: block; margin-top: 3px; color: var(--muted); font-size: 8px; }
.automation-button[aria-pressed="true"] small { color: #315744; }
.prestige-button { color: #e7c5a0; background: #4b2118; border-color: #8e4c32; }
.prestige-button:not(:disabled):hover { background: #6c2b1e; }

.offline-loot { display: grid; grid-template-columns: 1fr 1fr; margin: 22px 0; border: 1px solid var(--line); }
.offline-loot div { padding: 16px; }
.offline-loot div + div { border-left: 1px solid var(--line); }
.offline-loot span { display: block; color: var(--muted); font-size: 9px; }
.offline-loot strong { display: block; margin-top: 7px; color: var(--blood-hi); font-family: var(--terminal); font-size: 25px; }
.offline-loot div:last-child strong { color: var(--amber); }

.footer-bar { min-height: 33px; padding: 0 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; color: #706d5d; background: #141411; border-top: 1px solid #3c3a31; font-size: 9px; }

.primary-button { justify-self: center; padding: 12px 18px; color: var(--ink); background: var(--amber); border: 0; box-shadow: 4px 4px 0 #6c3e13; font-weight: 600; cursor: pointer; text-transform: uppercase; }
.primary-button:hover { transform: translate(2px,2px); box-shadow: 2px 2px 0 #6c3e13; }

.boot-dialog { width: min(680px, calc(100vw - 30px)); padding: 0; color: var(--bone); background: #24241f; border: 1px solid #85806d; box-shadow: 14px 14px 0 rgba(0,0,0,.55); }
.boot-dialog::backdrop { background: rgba(7,7,6,.88); backdrop-filter: blur(3px); }
.boot-dialog__top { padding: 7px 10px; color: var(--ink); background: var(--bone); font-size: 10px; font-weight: 600; }
.boot-dialog__content { padding: clamp(24px, 5vw, 50px); }
.boot-dialog h2 { margin: 0 0 16px; color: var(--paper); font-family: var(--display); font-size: clamp(29px, 5vw, 48px); line-height: .95; letter-spacing: -2px; }
.boot-dialog h2 em { color: var(--blood-hi); font-style: normal; }
.boot-dialog p:not(.eyebrow) { color: #aaa58f; line-height: 1.65; }
.boot-dialog ol { padding: 0; margin: 25px 0; list-style: none; }
.boot-dialog li { display: grid; grid-template-columns: 34px 1fr; padding: 8px 0; border-top: 1px solid #454239; color: #c5bea3; font-size: 11px; line-height: 1.45; }
.boot-dialog li span { color: var(--amber); font-family: var(--terminal); }
.boot-button { margin-top: 4px; }
.boot-warning { display: block; margin-top: 14px; color: #736f60; font-size: 8px; }

.toast { position: fixed; z-index: 30; left: 50%; top: 82px; transform: translate(-50%, -15px); padding: 8px 12px; color: var(--ink); background: var(--phosphor); font-size: 10px; font-weight: 600; opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@keyframes blink { 50% { opacity: 0; } }
@keyframes feedIn { from { opacity: 0; transform: translateX(-8px); } }

@media (max-width: 1050px) {
  .console-shell { grid-template-columns: 190px minmax(390px, 1fr); }
  .rail--right { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 260px; border-left: 0; border-top: 1px solid var(--line); }
  .shop-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #gameCanvas { height: 600px; }
}

@media (max-width: 720px) {
  body { overflow-x: auto; }
  .masthead { grid-template-columns: 1fr auto; }
  .masthead__status { display: none; }
  .console-shell { display: flex; flex-direction: column; min-width: 360px; }
  .rail--left { display: grid; grid-template-columns: 1fr 1.2fr; border-right: 0; }
  .rail--left .resource-panel { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px; }
  .rail--left .resource-panel > .eyebrow,
  .rail--left .resource-panel > .resource:first-of-type { grid-column: 1 / -1; }
  .rail--left .resource-panel .resource { margin-bottom: 0; }
  .daemon-panel, .rail-stamp { display: none; }
  .panel { padding: 14px; }
  .incident-number strong { font-size: 34px; }
  .resource { margin-bottom: 12px; }
  .battlefield-wrap { order: 2; }
  #gameCanvas { height: 58vh; min-height: 400px; }
  .rail--right { order: 3; display: block; }
  .shop-list { grid-template-columns: 1fr; }
  .footer-bar span:nth-child(2) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
