@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=VT323&display=swap');

:root {
  --ink: #17162a;
  --night: #24213d;
  --panel: #302b4c;
  --paper: #f4e9cf;
  --paper-dark: #d9c99f;
  --red: #e0544e;
  --blue: #4d78c7;
  --green: #62a96b;
  --gold: #e4b94f;
  --line: #11101e;
  font-family: "VT323", monospace;
  color: var(--paper);
  background: var(--ink);
  letter-spacing: 0;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; background: var(--ink); }
body { min-height: 100vh; overflow-x: hidden; }
button, input { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }

.app { min-height: 100vh; }
.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(300px, 540px) minmax(320px, 560px);
  place-content: center;
  gap: 64px;
  padding: 48px;
  background: linear-gradient(#24213d 0 68%, #465a47 68% 73%, #29283b 73%);
  image-rendering: pixelated;
}
.login-building {
  align-self: end;
  height: 420px;
  border: 8px solid var(--line);
  background: #9d5c55;
  box-shadow: inset -22px 0 #754541, 14px 14px 0 #11101e66;
  position: relative;
}
.login-building::before {
  content: "";
  position: absolute;
  left: -20px; right: -20px; top: -32px;
  height: 28px;
  background: #d7c08d;
  border: 8px solid var(--line);
}
.login-sign {
  position: absolute; left: 50%; top: 36px; transform: translateX(-50%);
  width: 112px; height: 70px; display: grid; place-items: center;
  font: 26px "Press Start 2P", monospace; color: var(--ink); background: var(--paper);
  border: 7px solid var(--line); box-shadow: 8px 8px 0 #11101e55;
}
.login-windows {
  position: absolute; inset: 138px 46px 88px;
  background: repeating-linear-gradient(90deg, #6fb1bd 0 66px, #17162a 66px 82px);
  border: 7px solid var(--line); box-shadow: inset 0 16px #b9dde0aa;
}
.login-door {
  position: absolute; bottom: 0; left: calc(50% - 42px); width: 84px; height: 94px;
  background: #28374a; border: 7px solid var(--line); border-bottom: 0;
}
.login-copy { align-self: center; max-width: 560px; }
.eyebrow, .panel-label { font: 10px "Press Start 2P", monospace; color: var(--gold); }
h1 { font: 34px/1.35 "Press Start 2P", monospace; margin: 16px 0 22px; color: #fff4d8; }
.login-copy > p:not(.eyebrow) { font-size: 27px; line-height: 1.1; color: #c7c1d9; max-width: 480px; }
form { margin-top: 38px; }
label { display: block; margin-bottom: 10px; font: 10px "Press Start 2P", monospace; color: var(--paper-dark); }
.password-row { display: grid; grid-template-columns: 1fr auto; }
input { min-width: 0; border: 5px solid var(--line); background: var(--paper); color: var(--ink); padding: 12px 16px; font-size: 25px; outline: none; border-radius: 0; }
input:focus { box-shadow: inset 0 0 0 4px var(--gold); }
.password-row button, .icon-button { border: 5px solid var(--line); border-left: 0; background: var(--red); color: white; padding: 0 20px; font: 10px "Press Start 2P", monospace; border-radius: 0; }
.password-row button:hover, .password-row button:focus-visible { background: #ef716c; }
.form-error { min-height: 24px; color: #ff8b85; font-size: 20px; }

.city-shell { min-height: 100vh; background: var(--ink); }
.topbar { min-height: 72px; display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 24px; padding: 10px 18px; background: #201d35; border-bottom: 5px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { display: grid; place-items: center; width: 46px; height: 46px; background: var(--paper); color: var(--ink); border: 4px solid var(--line); font: 13px "Press Start 2P", monospace; }
.brand strong { display: block; font: 12px "Press Start 2P", monospace; }
.brand small { display: block; margin-top: 5px; color: #8f89a8; font-size: 16px; }
.city-stats { display: flex; align-items: center; gap: 18px; font-size: 19px; color: #c7c1d9; }
.city-stats b { color: white; }
.connection { color: var(--gold); }
.connection.online { color: #83d78b; }
.icon-button { border: 4px solid var(--line); padding: 11px 12px; }
.department-tabs { display: flex; gap: 0; overflow-x: auto; background: #292541; border-bottom: 5px solid var(--line); }
.department-tabs button { flex: 1 0 auto; min-height: 48px; padding: 0 18px; border: 0; border-right: 3px solid var(--line); background: transparent; color: #a7a0bb; font: 9px "Press Start 2P", monospace; }
.department-tabs button:hover, .department-tabs button.active { color: white; background: #3d375e; box-shadow: inset 0 -5px var(--gold); }
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; min-height: calc(100vh - 125px); }
.viewport { position: relative; min-height: 620px; background: #1d1a30; overflow: hidden; }
canvas { display: block; width: 100%; height: 100%; min-height: 620px; object-fit: contain; image-rendering: pixelated; cursor: crosshair; }
.canvas-help { position: absolute; left: 14px; bottom: 12px; padding: 8px 10px; background: #17162add; border: 3px solid #0e0d18; color: #bcb5ce; font: 8px "Press Start 2P", monospace; pointer-events: none; }
.side-panel { display: grid; grid-template-rows: auto 1fr; background: #28243f; border-left: 5px solid var(--line); min-width: 0; }
.worker-panel, .feed-panel { padding: 18px; }
.worker-panel { min-height: 210px; border-bottom: 5px solid var(--line); }
.worker-detail h2 { margin: 14px 0 6px; font: 16px "Press Start 2P", monospace; color: white; }
.worker-detail .role { margin: 0; color: #bcb5ce; font-size: 21px; }
.status-line { display: flex; align-items: center; gap: 8px; margin: 18px 0 10px; font-size: 20px; text-transform: uppercase; }
.status-dot { width: 12px; height: 12px; background: var(--green); border: 3px solid var(--line); }
.status-dot.running { background: var(--gold); animation: blink 0.8s steps(2) infinite; }
.status-dot.failed { background: var(--red); }
.task-box { padding: 11px; color: var(--ink); background: var(--paper); border: 4px solid var(--line); font-size: 19px; line-height: 1.05; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; }
#city-time { color: #8f89a8; font-size: 19px; }
.event-feed { list-style: none; margin: 14px 0 0; padding: 0; max-height: calc(100vh - 405px); overflow-y: auto; }
.event-feed li { padding: 11px 0; border-top: 2px solid #423c5c; }
.event-feed time { color: #8f89a8; font-size: 16px; }
.event-feed strong { display: block; margin: 3px 0; color: #fff4d8; font-size: 19px; font-weight: normal; }
.event-feed span { color: #aaa4bb; font-size: 17px; }
.empty-feed { color: #8f89a8; }

@keyframes blink { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; } }
@media (max-width: 900px) {
  .login-screen { grid-template-columns: 1fr; padding: 28px; gap: 28px; }
  .login-building { display: none; }
  h1 { font-size: 25px; }
  .topbar { grid-template-columns: 1fr auto; }
  .city-stats { grid-column: 1 / -1; grid-row: 2; justify-content: space-between; }
  .game-layout { grid-template-columns: 1fr; }
  .viewport, canvas { min-height: 56vh; }
  .side-panel { border-left: 0; border-top: 5px solid var(--line); grid-template-columns: 1fr 1fr; grid-template-rows: auto; }
  .worker-panel { border-bottom: 0; border-right: 5px solid var(--line); }
  .event-feed { max-height: 300px; }
}
@media (max-width: 560px) {
  .login-screen { padding: 22px; }
  .password-row { grid-template-columns: 1fr; }
  .password-row button { min-height: 52px; border: 5px solid var(--line); border-top: 0; }
  .brand strong { font-size: 9px; }
  .city-stats { gap: 8px; font-size: 15px; }
  .game-layout { display: block; }
  .viewport, canvas { min-height: 430px; }
  .side-panel { display: block; }
  .worker-panel { border-right: 0; border-bottom: 5px solid var(--line); }
}
