:root {
  --bg: #07111f;
  --bg2: #0f1a2b;
  --panel: rgba(9, 20, 36, 0.92);
  --line: rgba(146, 182, 255, 0.22);
  --text: #edf4ff;
  --muted: #90a5c5;
  --accent: #4dd4ff;
  --danger: #ff6b6b;
  --ok: #7bf0ad;
  --pixel: #17263c;
  font-family: Inter, system-ui, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--text);
  background: radial-gradient(circle at top, #13264a 0%, var(--bg) 55%, #040810 100%);
  min-height: 100vh;
}
button, input, textarea, select { font: inherit; }
.hidden { display: none !important; }
.app-shell { min-height: 100vh; padding: 14px; }
.pixel-panel {
  border: 3px solid rgba(180, 208, 255, 0.18);
  background: var(--panel);
  box-shadow: 0 0 0 2px rgba(12, 26, 48, 0.95) inset, 0 18px 60px rgba(0, 0, 0, 0.33);
  border-radius: 18px;
}
.eyebrow { margin: 0 0 6px; text-transform: uppercase; letter-spacing: 0.16em; font-size: 11px; color: #88b8ff; }
.login-view { min-height: calc(100vh - 28px); display: grid; place-items: center; }
.login-card { width: min(100%, 520px); padding: 26px; }
.login-card h1 { margin: 0 0 12px; font-size: clamp(36px, 7vw, 56px); }
.login-copy { color: var(--muted); line-height: 1.5; }
.login-form { display: grid; gap: 12px; margin-top: 20px; }
input, textarea, select {
  width: 100%; border: 2px solid rgba(140, 182, 255, 0.2); background: #08131f; color: var(--text);
  border-radius: 14px; padding: 12px 14px;
}
textarea { min-height: 96px; resize: vertical; }
button {
  border: 0; border-radius: 14px; padding: 12px 14px; background: linear-gradient(180deg, #5ad8ff, #2298ff);
  color: #04111f; font-weight: 800; cursor: pointer;
}
button:hover { filter: brightness(1.06); }
.ghost-button { background: rgba(96, 124, 170, 0.18); color: var(--text); }
.danger-button { background: linear-gradient(180deg, #ff8888, #ff5a5a); }
.form-error { min-height: 1.2em; color: #ff9f9f; }
.world-view { display: grid; gap: 14px; }
.topbar { display: flex; justify-content: space-between; gap: 18px; padding: 18px 22px; align-items: center; }
.topbar h1, .stage-header h2, .side-header h2 { margin: 0; }
.topbar-stats { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.topbar-stats div { min-width: 72px; text-align: center; }
.topbar-stats span { display: block; font-size: 22px; font-weight: 800; }
.topbar-stats small { color: var(--muted); }
.layout { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(330px, 420px); gap: 14px; }
.ship-stage { padding: 16px; overflow: hidden; }
.stage-header { display: flex; justify-content: space-between; align-items: end; margin-bottom: 12px; }
.stage-time { color: var(--muted); font-size: 13px; }
.ship-map {
  position: relative; min-height: 68vh; border-radius: 24px; overflow: hidden;
  background:
    linear-gradient(transparent 96%, rgba(122,170,255,0.05) 96%),
    linear-gradient(90deg, transparent 96%, rgba(122,170,255,0.05) 96%),
    linear-gradient(180deg, rgba(53,90,136,0.35), rgba(10,18,31,0.8));
  background-size: 24px 24px, 24px 24px, auto;
}
.ambient-stars { position: absolute; inset: 0; background-image: radial-gradient(circle, rgba(255,255,255,0.8) 1px, transparent 1.5px); background-size: 80px 80px; opacity: 0.18; }
.zone {
  position: absolute; border: 3px solid rgba(157, 198, 255, 0.14); background: rgba(8, 18, 31, 0.55);
  border-radius: 22px; box-shadow: 0 0 40px rgba(0,0,0,0.2) inset;
}
.zone span { position: absolute; top: 10px; left: 12px; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: #99c1ff; }
.zone-bridge { left: 5%; top: 7%; width: 36%; height: 31%; }
.zone-archive { right: 5%; top: 9%; width: 31%; height: 27%; }
.zone-workshop { left: 7%; bottom: 8%; width: 34%; height: 28%; }
.zone-dock { right: 5%; bottom: 7%; width: 31%; height: 30%; }
.zone-nexus { left: 37%; top: 33%; width: 26%; height: 25%; }
.entity {
  position: absolute; transform: translate(-50%, -50%); width: 76px; text-align: center; z-index: 2;
  background: transparent; border: 0; color: var(--text); cursor: pointer;
}
.entity .halo { position: absolute; inset: 8px 10px 16px; border-radius: 50%; filter: blur(18px); opacity: 0.6; z-index: 0; }
.entity img { width: 56px; height: 56px; image-rendering: pixelated; position: relative; z-index: 2; }
.entity .name { display: block; margin-top: 6px; font-size: 11px; font-weight: 800; letter-spacing: 0.04em; }
.entity .task { display: block; font-size: 10px; color: var(--muted); line-height: 1.25; max-width: 130px; margin: 4px auto 0; }
.entity[data-state="error"] img { filter: drop-shadow(0 0 10px rgba(255, 106, 106, 0.7)); }
.entity[data-state="using-tool"] img, .entity[data-state="coding"] img { animation: bob 1s steps(2) infinite; }
.entity[data-state="researching"] img, .entity[data-state="talking"] img { animation: floaty 1.6s ease-in-out infinite; }
.entity[data-state="deploying"] img, .entity[data-state="background"] img { animation: pulse 1.8s ease-in-out infinite; }
.entity.active-target::after {
  content: ''; position: absolute; inset: -4px; border: 2px solid rgba(255,255,255,0.55); border-radius: 18px;
}
.legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.legend-item { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.legend-item i { width: 10px; height: 10px; border-radius: 999px; display: inline-block; }
.sidebar { display: grid; gap: 14px; }
.side-card { padding: 16px; }
.side-header { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.state-pill, .action-status { padding: 6px 10px; border-radius: 999px; background: rgba(86, 124, 185, 0.18); color: #d9ebff; font-size: 12px; }
.inspect-summary { color: var(--muted); line-height: 1.5; }
.inspect-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
.inspect-meta small { color: var(--muted); display: block; margin-bottom: 4px; }
.logs-box { min-height: 140px; max-height: 240px; overflow: auto; background: #07111d; border-radius: 14px; padding: 12px; color: #a7c3e9; white-space: pre-wrap; }
.tool-form { display: grid; gap: 8px; margin-top: 14px; }
.tool-form.compact { gap: 10px; }
.tool-form label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.14em; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes floaty { 0%,100% { transform: translateY(0) translateX(0); } 50% { transform: translateY(-6px) translateX(1px); } }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .ship-map { min-height: 56vh; }
}
@media (max-width: 680px) {
  .app-shell { padding: 10px; }
  .topbar, .side-card, .ship-stage { padding: 14px; }
  .topbar { align-items: start; }
  .ship-map { min-height: 74vh; }
  .entity { width: 68px; }
  .entity img { width: 48px; height: 48px; }
  .inspect-meta { grid-template-columns: 1fr; }
}
