:root {
  color-scheme: dark;
  --bg: #05090b;
  --panel: rgba(7, 16, 19, 0.96);
  --line: #d6ded9;
  --dim: #71807b;
  --amber: #e0a84d;
  --cyan: #8ed6d2;
  --danger: #e56e4b;
  --water: #8dbbd0;
  --soil: #b89563;
  --green: #b7cc73;
  font-family: "Courier New", Courier, monospace;
}

* { box-sizing: border-box; }

html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--bg); color: var(--line); }
body { touch-action: none; }
button, a { font: inherit; }
button { color: var(--line); }

#app { width: 100%; height: 100%; display: grid; grid-template-rows: auto 1fr; background: var(--bg); }

.hud {
  min-height: 54px;
  display: grid;
  grid-template-columns: minmax(230px, 1fr) auto minmax(90px, 1fr);
  align-items: center;
  gap: 18px;
  padding: 8px 16px;
  border-bottom: 1px solid #35413d;
  background: #071013;
  letter-spacing: .08em;
  font-size: 12px;
  z-index: 20;
}

.brand { color: var(--dim); text-decoration: none; white-space: nowrap; }
.brand:hover, .brand:focus-visible { color: var(--line); }
.brand span { color: var(--amber); font-size: 18px; vertical-align: -1px; }
.readouts { display: flex; justify-content: center; gap: clamp(10px, 2vw, 32px); white-space: nowrap; }
.readouts span { color: var(--dim); }
.readouts b { color: var(--line); font-weight: 400; }
.supply-readout b { color: var(--cyan); }
.hud-actions { justify-self: end; display: flex; gap: 6px; }
.icon-btn { width: 32px; height: 30px; border: 1px solid #52605b; background: transparent; cursor: pointer; }
.icon-btn.active { color: var(--amber); border-color: var(--amber); }

#viewport { position: relative; min-height: 0; overflow: hidden; background: radial-gradient(circle at 50% 50%, #0a1215 0, var(--bg) 70%); touch-action: none; }
#world { display: block; width: 100%; height: 100%; }

.asteroid-outline { fill: #091013; stroke: #9ca8a3; stroke-width: 2; vector-effect: non-scaling-stroke; }
.asteroid.rich .asteroid-outline { stroke: #c9d6cf; }
.asteroid.depleted { opacity: .48; }
.asteroid.warning .asteroid-outline { stroke: var(--danger); }
.asteroid.water .asteroid-outline { stroke: var(--water); fill: #091217; }
.asteroid.soil .asteroid-outline { stroke: var(--soil); fill: #12100c; }
.asteroid.source-empty { opacity: .12; }
.source-mark { fill: none; stroke-width: 1.4; opacity: .72; vector-effect: non-scaling-stroke; }
.seam { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; opacity: .7; }
.crater { fill: none; stroke: #586460; stroke-width: 1.2; vector-effect: non-scaling-stroke; }
.monster-face { stroke: var(--danger); fill: none; stroke-width: 3; }
.monster-eye { fill: var(--danger); stroke: none; }
.monster.warning, .monster.feeding, .monster.flyby { animation: warning-shake .12s steps(2) infinite; transform-box: fill-box; transform-origin: center; }
@keyframes warning-shake { 0% { translate: -2px 0; } 100% { translate: 2px 1px; } }

.laser { stroke: var(--amber); stroke-width: 1.5; opacity: .95; filter: drop-shadow(0 0 3px var(--amber)); }
.target-ring { fill: none; stroke: var(--amber); stroke-width: 1; stroke-dasharray: 5 8; opacity: .75; }
.thrust-flame { fill: none; stroke: var(--amber); stroke-width: 2; }
.ore-image.exotic { filter: drop-shadow(0 0 4px var(--amber)); }
.logistics-trail { stroke: var(--cyan); stroke-width: 1; stroke-dasharray: 2 6; opacity: .32; }
.sentinel-image { filter: drop-shadow(0 0 3px rgba(142, 214, 210, .35)); }
.pirate-image { filter: drop-shadow(0 0 4px rgba(229, 110, 75, .45)); }
.supply-trail { stroke: var(--soil); }
.farm-trail { stroke: var(--green); }
.resource-water { filter: drop-shadow(0 0 4px rgba(141, 187, 208, .45)); }
.carried-supply { opacity: .9; pointer-events: none; }
.farm-stock { opacity: .72; pointer-events: none; }
.resource-seed, .produce-grain { filter: drop-shadow(0 0 3px rgba(183, 204, 115, .38)); }
.produce-mushroom { filter: drop-shadow(0 0 3px rgba(201, 155, 201, .38)); }
.produce-fruit { filter: drop-shadow(0 0 3px rgba(223, 139, 98, .4)); }
.plant { transform-box: fill-box; transform-origin: center bottom; }
.plant.mature { filter: drop-shadow(0 0 3px currentColor); }
.plant.decorative { opacity: .72; }
.planting-beam { stroke: var(--green); stroke-width: 1.5; opacity: .9; }
.warden-pulse { fill: none; stroke: var(--cyan); stroke-width: 1.5; opacity: .75; }
.locust { fill: none; stroke: #d5c67e; stroke-width: 1.3; }

#distance-strip { position: absolute; left: 16px; top: 14px; color: var(--dim); font-size: 10px; letter-spacing: .1em; pointer-events: none; }
#distance-strip i { display: inline-block; width: 42px; height: 1px; margin: 0 8px 3px; background: #44514d; }
#distance-strip b { color: var(--amber); font-weight: 400; }

#tutorial { position: absolute; top: 10%; left: 50%; translate: -50% 0; color: var(--amber); font-size: 12px; letter-spacing: .18em; text-align: center; pointer-events: none; animation: breathe 2s ease-in-out infinite; }
#site-status { position: absolute; top: 14px; right: 16px; max-width: 270px; color: var(--dim); font-size: 10px; line-height: 1.5; letter-spacing: .11em; text-align: right; pointer-events: none; white-space: pre-line; }
@keyframes breathe { 50% { opacity: .45; } }

#toast { position: absolute; top: 18%; left: 50%; translate: -50% 0; min-width: 160px; text-align: center; color: var(--line); font-size: 13px; letter-spacing: .12em; opacity: 0; transition: opacity .2s; pointer-events: none; }
#toast.visible { opacity: 1; }

#context-actions { position: absolute; left: 50%; bottom: 30px; translate: -50% 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; z-index: 8; }
button { min-height: 42px; padding: 0 18px; border: 1px solid var(--line); background: rgba(7,16,19,.9); letter-spacing: .09em; font-size: 12px; cursor: pointer; }
button:hover, button:focus-visible { color: #071013; background: var(--line); outline: none; }
button:disabled { border-color: #35413d; color: #596560; cursor: not-allowed; background: transparent; }
.mobile-note { display: none; position: absolute; left: 50%; bottom: 86px; translate: -50%; color: #65736e; font-size: 9px; letter-spacing: .14em; pointer-events: none; }

.panel { position: absolute; z-index: 30; inset: 50% auto auto 50%; translate: -50% -50%; width: min(760px, calc(100% - 28px)); max-height: calc(100% - 28px); overflow: auto; padding: 24px; border: 1px solid var(--line); background: var(--panel); box-shadow: 10px 10px 0 rgba(0,0,0,.35); }
.panel[hidden] { display: none; }
.panel::before { content: ""; position: absolute; inset: 5px; border: 1px solid #293532; pointer-events: none; }
.panel-head { position: relative; display: flex; justify-content: space-between; gap: 20px; align-items: end; padding-bottom: 16px; border-bottom: 1px solid #35413d; }
.panel small { color: var(--amber); letter-spacing: .14em; }
.panel h1 { margin: 5px 0 0; font-size: clamp(20px, 4vw, 30px); font-weight: 400; letter-spacing: .1em; }
.shop-credit { color: var(--dim); white-space: nowrap; }
.shop-credit b { color: var(--line); font-weight: 400; }
.sale-message { position: relative; height: 26px; padding-top: 8px; color: var(--cyan); font-size: 12px; }
.depot-panel { position: relative; display: flex; align-items: center; gap: 18px; margin-bottom: 10px; padding: 9px 12px; border: 1px solid #35413d; color: var(--dim); font-size: 10px; letter-spacing: .1em; }
.depot-panel span { margin-right: auto; color: var(--cyan); }
.depot-panel b { font-weight: 400; }
.depot-panel i { color: var(--line); font-style: normal; font-weight: 400; }
.shop-list { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.shop-item { display: grid; grid-template-columns: 1fr auto; gap: 5px 12px; min-height: 66px; padding: 10px 12px; border: 1px solid #35413d; text-align: left; }
.shop-item:hover:not(:disabled), .shop-item:focus-visible:not(:disabled) { border-color: var(--amber); background: rgba(224,168,77,.07); color: var(--line); }
.shop-item strong { font-size: 12px; font-weight: 400; }
.shop-item .price { color: var(--amber); }
.shop-item small { grid-column: 1 / -1; color: var(--dim); letter-spacing: .04em; font-size: 10px; }
.panel-actions { position: relative; display: flex; justify-content: space-between; margin-top: 16px; }
.danger { color: var(--danger); border-color: #704537; }
.compact { width: min(520px, calc(100% - 28px)); text-align: center; }
.compact p { color: #a8b4af; line-height: 1.65; }
.compact b { color: var(--line); }
.compact button { margin-top: 8px; }
.completion-ring { width: 112px; height: 112px; margin: 22px auto; display: grid; place-items: center; border: 1px solid var(--amber); border-radius: 50%; color: var(--amber); font-size: 24px; box-shadow: inset 0 0 0 7px var(--panel), inset 0 0 0 8px #755e36; }

@media (max-width: 760px) {
  .hud { grid-template-columns: 1fr auto; gap: 7px; padding: 7px 10px; }
  .brand { font-size: 9px; }
  .readouts { grid-row: 2; grid-column: 1 / -1; justify-content: space-between; gap: 4px; font-size: 8px; letter-spacing: 0; border-top: 1px solid #27322f; padding-top: 6px; }
  .readouts span:nth-of-type(5), .readouts span:nth-of-type(6) { display: none; }
  .readouts span { white-space: nowrap; }
  .hud-actions { grid-column: 2; grid-row: 1; }
  .shop-list { grid-template-columns: 1fr; }
  .panel { padding: 18px; }
  .depot-panel { gap: 9px; font-size: 8px; }
  #site-status { top: 8px; right: 10px; max-width: 210px; font-size: 8px; }
  .shop-item { min-height: 58px; }
  #context-actions { bottom: 24px; width: calc(100% - 24px); justify-content: center; }
  #context-actions button { flex: 1 1 42%; max-width: 220px; padding: 0 8px; }
  .mobile-note { display: block; }
}

@media (max-height: 560px) {
  .hud { min-height: 44px; }
  .panel { padding: 14px 18px; }
  .shop-item { min-height: 48px; padding: 7px 10px; }
  .panel-actions { margin-top: 9px; }
  .sale-message { height: 20px; padding-top: 4px; }
}

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