:root {
  --bg: #05041a;
  --ink: #f2f3ff;
  --muted: #9aa0c8;
  --dim: #6b7099;
  --line: rgba(255, 255, 255, 0.1);
  --glass: rgba(9, 9, 28, 0.55);
  --glass-2: rgba(16, 16, 44, 0.72);
  --acc: #8fdcff;
  --energy: #7ff3ff;
  --alloy: #ffd36e;
  --crystal: #ff7ae6;
  --relic: #ffe9a8;
  --hull: #ff6b8a;
  --good: #7dffb0;
  --warn: #ffb35c;
  --danger: #ff5a6e;
  --grad: linear-gradient(120deg, #7fe7ff 0%, #8b7bff 45%, #ff7ae6 100%);
  --sab: env(safe-area-inset-bottom, 0px);
  --sat: env(safe-area-inset-top, 0px);
  --font-d: "Unbounded", "Space Grotesk", system-ui, sans-serif;
  --font: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; }
.mono { font-family: var(--mono); }
.hidden { display: none !important; }

#gl, #fx {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: block;
}
#gl { z-index: 0; }
#fx { z-index: 1; cursor: crosshair; }
#sab { position: fixed; bottom: 0; left: 0; height: env(safe-area-inset-bottom, 0px); width: 1px; pointer-events: none; visibility: hidden; }

/* ═══════════ HUD ═══════════ */
#hud {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  font-size: 13px;
}
.hud-top {
  position: absolute;
  top: calc(12px + var(--sat));
  left: 14px;
  right: 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.depth-badge {
  position: relative;
  width: 52px;
  height: 52px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--glass);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 0 0 1px var(--line), 0 0 24px -6px var(--acc);
}
.depth-badge svg { position: absolute; inset: 2px; width: 48px; height: 48px; transform: rotate(-90deg); }
.depth-badge .ring-bg { fill: none; stroke: rgba(255, 255, 255, 0.08); stroke-width: 3; }
.depth-badge .ring { fill: none; stroke: var(--acc); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 132 132; transition: stroke 0.4s; }
.depth-badge.unstable .ring { stroke: var(--warn); }
.depth-badge.collapse .ring { stroke: var(--danger); animation: blink 0.5s steps(2) infinite; }
.depth-badge span { font-family: var(--font-d); font-weight: 800; font-size: 20px; color: var(--ink); }
.layer-info { min-width: 0; padding-top: 2px; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9), 0 0 10px rgba(0, 0, 0, 0.7); }
.layer-name {
  font-family: var(--font-d);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.14em;
  color: var(--acc);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.95), 0 0 16px rgba(0, 0, 0, 0.8);
  white-space: nowrap;
}
.coord { font-size: 11px; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }
.contract {
  margin-top: 7px;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--glass);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 11px;
  font-weight: 600;
  color: var(--ink);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.contract .c-name::before { content: "◇ "; color: var(--acc); }
.contract.done { box-shadow: inset 0 0 0 1px var(--good); }
.contract.done .c-name::before { content: "◆ "; color: var(--good); }
.contract .c-prog { color: var(--muted); }
.hud-right { margin-left: auto; display: flex; gap: 10px; align-items: flex-start; }
.hud-btns { display: flex; flex-direction: column; gap: 8px; }
.hbtn {
  pointer-events: auto;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 0;
  background: var(--glass);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 0.15s, transform 0.1s;
}
.hbtn:hover { background: var(--glass-2); }
.hbtn:active { transform: scale(0.94); }
.hbtn svg { width: 19px; height: 19px; }
#minimap {
  pointer-events: auto;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: rgba(4, 4, 16, 0.6);
  box-shadow: 0 0 0 1px var(--line), 0 0 0 4px rgba(255, 255, 255, 0.03), 0 10px 30px -10px #000;
  cursor: pointer;
}

.hud-bottom {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: calc(14px + var(--sab));
  display: flex;
  align-items: flex-end;
  gap: 14px;
}
.bars {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 16px;
  background: var(--glass);
  box-shadow: inset 0 0 0 1px var(--line);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  width: min(340px, 44vw);
}
.bar { display: grid; grid-template-columns: 58px 1fr 34px; align-items: center; gap: 8px; }
.bar .lbl { font-size: 10px; font-weight: 700; letter-spacing: 0.14em; color: var(--muted); }
.bar .val { font-size: 12px; text-align: right; color: var(--ink); }
.track { position: relative; height: 8px; border-radius: 99px; background: rgba(255, 255, 255, 0.07); overflow: visible; }
.fill { position: absolute; inset: 0 auto 0 0; border-radius: 99px; width: 100%; transition: width 0.12s linear; }
.hull .fill { background: linear-gradient(90deg, #ff4f7b, #ff9a8a); box-shadow: 0 0 12px -2px #ff4f7b; }
.energy .fill { background: linear-gradient(90deg, #2fb8ff, #7ff3ff); box-shadow: 0 0 12px -2px #2fb8ff; }
.bar.low .fill { animation: pulse 0.6s ease-in-out infinite alternate; }
.ret {
  position: absolute;
  top: -5px;
  bottom: -5px;
  width: 2px;
  background: #fff;
  border-radius: 2px;
  box-shadow: 0 0 6px #fff;
  transition: left 0.3s ease;
}
.ret i {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  font-style: normal;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #fff;
  opacity: 0.8;
  white-space: nowrap;
  padding-bottom: 1px;
}
.energy.below .ret { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.energy.below .ret i { color: var(--warn); opacity: 1; }

.cargo {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 16px;
  background: var(--glass);
  box-shadow: inset 0 0 0 1px var(--line);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.cg { display: flex; align-items: center; gap: 6px; padding: 2px 6px; font-family: var(--mono); font-weight: 600; font-size: 14px; }
.cg i { width: 11px; height: 11px; transform: rotate(45deg); border-radius: 2px; }
.cg.alloy i { background: var(--alloy); box-shadow: 0 0 10px var(--alloy); }
.cg.crystal i { background: var(--crystal); box-shadow: 0 0 10px var(--crystal); clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); transform: none; }
.cg.relic i { background: var(--relic); box-shadow: 0 0 10px var(--relic); border-radius: 50%; transform: none; }
.cg.bump { animation: bump 0.35s ease; }
.abilities { margin-left: auto; display: flex; gap: 8px; }
.ab {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 11px;
  border-radius: 13px;
  background: var(--glass);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.ab kbd {
  font-family: var(--mono);
  font-size: 10px;
  min-width: 20px;
  text-align: center;
  padding: 2px 5px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--acc);
}
.ab .cd { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--acc); width: 0; }
.ab.off { opacity: 0.45; }

.prompt {
  position: absolute;
  left: 50%;
  bottom: calc(104px + var(--sab));
  transform: translateX(-50%) translateY(8px);
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(8, 8, 26, 0.75);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--acc) 50%, transparent), 0 0 30px -8px var(--acc);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.06em;
  opacity: 0;
  transition: opacity 0.18s, transform 0.18s;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.prompt.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.prompt kbd { font-family: var(--mono); color: var(--acc); margin-right: 6px; }
.prompt.locked { box-shadow: inset 0 0 0 1px var(--danger); color: #ffb3bd; }

#toasts {
  position: absolute;
  top: calc(84px + var(--sat));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: min(560px, 92vw);
}
.toast {
  padding: 8px 14px;
  border-radius: 12px;
  background: rgba(8, 8, 26, 0.78);
  box-shadow: inset 0 0 0 1px var(--line);
  font-weight: 600;
  font-size: 13px;
  text-align: center;
  animation: toastIn 0.25s ease, toastOut 0.4s ease forwards;
  animation-delay: 0s, var(--life, 3.2s);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.toast.good { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--good) 60%, transparent); color: #d4ffe6; }
.toast.warn { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warn) 70%, transparent); color: #ffe2bf; }
.toast.danger { box-shadow: inset 0 0 0 1px var(--danger), 0 0 24px -6px var(--danger); color: #ffd0d6; }
.toast.layer { font-family: var(--font-d); font-size: 15px; letter-spacing: 0.08em; padding: 10px 20px; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--acc) 60%, transparent), 0 0 40px -10px var(--acc); }
.toast.contract { color: var(--ink); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--acc) 50%, transparent); }

.hint {
  position: absolute;
  left: 50%;
  bottom: calc(150px + var(--sab));
  transform: translateX(-50%) translateY(10px);
  max-width: min(520px, 90vw);
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 11px 16px;
  border-radius: 14px;
  background: rgba(10, 10, 32, 0.82);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--acc) 35%, transparent);
  font-size: 13px;
  line-height: 1.45;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.hint.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.hint b { font-size: 10px; letter-spacing: 0.16em; color: var(--acc); flex: none; }

.boss-bar {
  position: absolute;
  top: calc(80px + var(--sat));
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
}
.bb-name { font-family: var(--font-d); font-size: 12px; letter-spacing: 0.24em; color: #ffb6f6; text-shadow: 0 0 20px #ff6ff0; }
.bb-nodes { display: flex; gap: 8px; justify-content: center; margin-top: 6px; }
.bb-nodes i { width: 14px; height: 14px; border-radius: 50%; background: #ffe1fb; box-shadow: 0 0 12px #ff6ff0; }
.bb-nodes i.dead { background: #3b1838; box-shadow: none; }
.bb-nodes i.hurt { background: #fff; }

.tune-inset {
  position: absolute;
  right: 14px;
  top: calc(176px + var(--sat));
  padding: 8px;
  border-radius: 14px;
  background: var(--glass);
  box-shadow: inset 0 0 0 1px var(--line);
  text-align: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.tune-inset canvas { width: 120px; height: 120px; border-radius: 10px; display: block; }
.ti-label { font-size: 10px; color: var(--muted); margin-top: 5px; }

.charting {
  position: absolute;
  left: 50%;
  top: 58%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--muted);
}
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.15); border-top-color: var(--acc); animation: spin 0.8s linear infinite; }

/* ═══════════ TOUCH ═══════════ */
#touch { position: fixed; inset: 0; z-index: 6; pointer-events: none; }
.stick {
  position: absolute;
  width: 112px;
  height: 112px;
  margin: -56px 0 0 -56px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.18);
  background: radial-gradient(circle, rgba(255, 255, 255, 0.06), transparent 70%);
  opacity: 0;
  transition: opacity 0.15s;
}
.stick.on { opacity: 1; }
.stick .nub { position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; background: rgba(255, 255, 255, 0.28); box-shadow: 0 0 20px rgba(127, 231, 255, 0.4); }
.tpad {
  position: absolute;
  right: calc(12px + env(safe-area-inset-right, 0px));
  bottom: calc(96px + var(--sab));
  display: grid;
  grid-template-columns: repeat(2, 64px);
  gap: 10px;
  justify-items: center;
}
.tbtn {
  pointer-events: auto;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 0;
  background: rgba(10, 10, 30, 0.6);
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.18);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--ink);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  touch-action: none;
}
.tbtn:active, .tbtn.on { background: rgba(127, 231, 255, 0.25); }
.tbtn.action { grid-column: span 2; width: 138px; height: 52px; border-radius: 26px; box-shadow: inset 0 0 0 1.5px var(--acc), 0 0 24px -6px var(--acc); font-size: 11px; }
.tbtn.action.idle { opacity: 0.35; box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.18); }
.tbtn.dash { box-shadow: inset 0 0 0 1.5px #9feaff; }

/* ═══════════ SCREENS ═══════════ */
.screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: max(20px, var(--sat)) 18px max(20px, var(--sab));
  overflow-y: auto;
  touch-action: pan-y;
  -webkit-user-select: none;
}
.screen.dim { background: rgba(3, 3, 14, 0.6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
#title { place-items: center start; padding-left: clamp(22px, 7vw, 110px); background: linear-gradient(90deg, rgba(3, 3, 14, 0.72) 0%, rgba(3, 3, 14, 0.3) 48%, transparent 75%); }
.title-wrap { max-width: 600px; animation: rise 0.9s cubic-bezier(.2, .8, .2, 1); }
.kicker, .card-kicker { font-size: 11px; font-weight: 700; letter-spacing: 0.24em; color: var(--acc); opacity: 0.9; }
.logo {
  margin: 12px 0 0;
  font-family: var(--font-d);
  font-weight: 800;
  font-size: clamp(42px, 8.4vw, 96px);
  line-height: 0.92;
  letter-spacing: -0.02em;
  display: flex;
  flex-direction: column;
}
.logo span {
  background: linear-gradient(100deg, #e8fbff 0%, #8fdcff 25%, #a28bff 55%, #ff8cf2 80%, #ffe6a8 100%);
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 9s ease-in-out infinite alternate;
  filter: drop-shadow(0 6px 30px rgba(120, 140, 255, 0.35));
}
.logo span + span { animation-delay: -2s; }
.tagline { margin: 18px 0 0; max-width: 46ch; color: #c9cdf0; font-size: 16px; line-height: 1.55; }
.menu { margin-top: 30px; display: flex; flex-direction: column; gap: 10px; width: min(420px, 100%); }
.menu-row { display: flex; gap: 8px; }
.menu-row .btn { flex: 1; }
.btn {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  padding: 13px 18px;
  border: 0;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.2s, box-shadow 0.2s;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  text-align: left;
}
.btn small { font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: 0.02em; }
.btn:hover { background: rgba(255, 255, 255, 0.11); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22); }
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--grad); color: #0a0820; box-shadow: 0 14px 40px -14px #8b7bff, inset 0 0 0 1px rgba(255, 255, 255, 0.35); }
.btn.primary small { color: rgba(10, 8, 32, 0.7); }
.btn.primary:hover { filter: brightness(1.08); box-shadow: 0 18px 48px -14px #ff7ae6, inset 0 0 0 1px rgba(255, 255, 255, 0.5); }
.btn.ghost { background: rgba(255, 255, 255, 0.03); align-items: center; }
.btn.danger { background: rgba(255, 90, 110, 0.1); box-shadow: inset 0 0 0 1px rgba(255, 90, 110, 0.4); color: #ffc2cb; align-items: center; }
.btn.small { padding: 9px 14px; font-size: 13px; border-radius: 12px; align-items: center; }
.btn:disabled { opacity: 0.4; cursor: default; transform: none; }
.title-foot { margin-top: 28px; display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: center; justify-content: space-between; width: min(420px, 100%); }
.bank { display: flex; gap: 14px; font-family: var(--mono); font-weight: 600; font-size: 14px; }
.bank span { display: inline-flex; align-items: center; gap: 6px; }
.bank i { width: 10px; height: 10px; display: inline-block; }
.bank .a i { background: var(--alloy); transform: rotate(45deg); box-shadow: 0 0 10px var(--alloy); }
.bank .c i { background: var(--crystal); clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); box-shadow: 0 0 10px var(--crystal); }
.bank.big { font-size: 18px; }
.title-links { display: flex; gap: 16px; }
.link { background: none; border: 0; color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none; padding: 0; }
.link:hover { color: var(--ink); }
.visit-banner {
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 122, 230, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 122, 230, 0.4);
  font-size: 13px;
  line-height: 1.5;
  max-width: 420px;
}
.visit-banner b { color: #ffc3f3; }
.visit-banner .btn { margin-top: 8px; }

.card {
  width: min(560px, 100%);
  padding: 26px 26px 22px;
  border-radius: 24px;
  background: linear-gradient(160deg, rgba(22, 20, 58, 0.82), rgba(8, 8, 26, 0.86));
  box-shadow: inset 0 0 0 1px var(--line), 0 30px 80px -30px rgba(0, 0, 0, 0.8), 0 0 80px -40px var(--acc);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  animation: rise 0.45s cubic-bezier(.2, .8, .2, 1);
}
.card h2, .panel-head h2 { margin: 6px 0 0; font-family: var(--font-d); font-weight: 800; font-size: clamp(24px, 4.4vw, 34px); letter-spacing: -0.01em; }
.card-actions { margin-top: 22px; display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.card-actions.col { flex-direction: column; align-items: stretch; }
.card-actions.col .btn { align-items: center; }
.card-actions .btn.primary { align-items: center; min-width: 150px; }

.brief-coord { margin-top: 8px; font-size: 12px; color: var(--muted); word-break: break-all; }
.brief-grid { margin-top: 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.bg-cell { padding: 14px; border-radius: 16px; background: rgba(255, 255, 255, 0.04); box-shadow: inset 0 0 0 1px var(--line); font-size: 14px; line-height: 1.5; }
.bg-cell label { display: block; font-size: 10px; font-weight: 700; letter-spacing: 0.18em; color: var(--muted); margin-bottom: 6px; }
.bg-cell .cn { font-weight: 700; color: var(--acc); }
.loadout { display: grid; grid-template-columns: auto auto; gap: 2px 12px; font-size: 12px; color: #c9cdf0; }
.loadout b { color: var(--ink); font-family: var(--mono); font-weight: 600; text-align: right; }

.board { margin-top: 14px; border-radius: 14px; background: rgba(255, 255, 255, 0.03); box-shadow: inset 0 0 0 1px var(--line); padding: 8px 12px; font-size: 13px; }
.board .row { display: grid; grid-template-columns: 26px 1fr auto auto; gap: 10px; padding: 5px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.05); align-items: center; }
.board .row:last-child { border-bottom: 0; }
.board .row .rk { color: var(--muted); font-family: var(--mono); }
.board .row .sc { font-family: var(--mono); font-weight: 600; }
.board .row .dp { font-size: 11px; color: var(--muted); }
.board .row.me { color: var(--acc); }
.board .empty { color: var(--muted); padding: 6px 0; text-align: center; }
.board h4 { margin: 2px 0 6px; font-size: 10px; letter-spacing: 0.18em; color: var(--muted); }

.panel-wrap { width: min(1080px, 100%); padding: 6px 0; animation: rise 0.45s cubic-bezier(.2, .8, .2, 1); }
.panel-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.panel-foot { margin-top: 18px; display: flex; gap: 10px; justify-content: flex-end; }
.panel-foot .btn.primary { align-items: center; }
.up-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.up {
  position: relative;
  padding: 18px 18px 16px;
  border-radius: 20px;
  background: linear-gradient(160deg, rgba(22, 20, 58, 0.78), rgba(8, 8, 26, 0.82));
  box-shadow: inset 0 0 0 1px var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.up-top { display: flex; gap: 12px; align-items: center; }
.up-ico { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: rgba(143, 220, 255, 0.1); box-shadow: inset 0 0 0 1px rgba(143, 220, 255, 0.3); flex: none; }
.up-ico svg { width: 26px; height: 26px; color: var(--acc); }
.up h3 { margin: 0; font-size: 16px; font-weight: 700; }
.pips { display: flex; gap: 4px; margin-top: 5px; }
.pips i { width: 18px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.12); }
.pips i.on { background: var(--grad); box-shadow: 0 0 8px rgba(143, 220, 255, 0.6); }
.up p { margin: 0; font-size: 13px; line-height: 1.5; color: #b9bee6; }
.up .now { font-size: 12px; color: var(--muted); }
.up .now b { color: var(--ink); }
.up .next { font-size: 12px; color: var(--acc); }
.up .buy { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.up .cost { font-family: var(--mono); font-size: 13px; display: flex; gap: 10px; }
.up .cost .short { color: var(--danger); }
.up.locked { opacity: 0.6; }
.up.max .buy .btn { opacity: 0.6; }

.results-card { width: min(620px, 100%); }
.res-sub { margin: 8px 0 0; color: #c9cdf0; line-height: 1.5; }
#results.lost h2 { color: #ffb3bd; }
#results.won h2 { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.res-stats { margin-top: 18px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.rs { padding: 12px; border-radius: 14px; background: rgba(255, 255, 255, 0.04); box-shadow: inset 0 0 0 1px var(--line); }
.rs label { display: block; font-size: 9.5px; letter-spacing: 0.16em; font-weight: 700; color: var(--muted); }
.rs b { display: block; margin-top: 4px; font-family: var(--mono); font-size: 18px; font-weight: 600; }
.res-bank { margin-top: 14px; padding: 14px; border-radius: 14px; background: rgba(125, 255, 176, 0.06); box-shadow: inset 0 0 0 1px rgba(125, 255, 176, 0.25); font-size: 14px; line-height: 1.6; }
#results.lost .res-bank { background: rgba(255, 90, 110, 0.06); box-shadow: inset 0 0 0 1px rgba(255, 90, 110, 0.25); }
.res-bank .line { display: flex; justify-content: space-between; gap: 10px; }
.res-bank .line span:last-child { font-family: var(--mono); }
.res-bank .tot { margin-top: 6px; padding-top: 6px; border-top: 1px solid rgba(255, 255, 255, 0.08); font-weight: 700; }
.res-disc { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.res-disc .chip { padding: 5px 10px; border-radius: 99px; font-size: 12px; background: rgba(255, 233, 168, 0.08); box-shadow: inset 0 0 0 1px rgba(255, 233, 168, 0.3); color: #fff1c9; }
.daily-submit { margin-top: 14px; }
.daily-submit label { font-size: 10px; letter-spacing: 0.18em; font-weight: 700; color: var(--muted); }
.ds-row { margin-top: 6px; display: flex; gap: 8px; }
input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 12px;
  border: 0;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink);
  font: 600 14px var(--font);
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}
input:focus { box-shadow: inset 0 0 0 1px var(--acc); }

.atlas-count { color: var(--muted); font-size: 13px; }
.atlas-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.at {
  border-radius: 16px;
  overflow: hidden;
  background: rgba(10, 10, 30, 0.7);
  box-shadow: inset 0 0 0 1px var(--line);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s;
  text-align: left;
  padding: 0;
  border: 0;
}
.at:hover { transform: translateY(-3px); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25), 0 16px 30px -16px #000; }
.at .th { aspect-ratio: 16 / 10; background: #0a0a20 center / cover no-repeat; position: relative; }
.at .th .tag { position: absolute; left: 8px; top: 8px; font-size: 9px; letter-spacing: 0.14em; font-weight: 700; padding: 3px 7px; border-radius: 99px; background: rgba(0, 0, 0, 0.55); }
.at .meta { padding: 10px 12px; }
.at .meta b { display: block; font-size: 13px; }
.at .meta span { font-size: 11px; color: var(--muted); }
.atlas-empty { grid-column: 1 / -1; padding: 40px; text-align: center; color: var(--muted); border-radius: 18px; box-shadow: inset 0 0 0 1px var(--line); }
.visit-box { margin-top: 16px; display: flex; gap: 8px; max-width: 560px; }

.how-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.how { padding: 16px; border-radius: 18px; background: linear-gradient(160deg, rgba(22, 20, 58, 0.78), rgba(8, 8, 26, 0.82)); box-shadow: inset 0 0 0 1px var(--line); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.how h3 { margin: 10px 0 6px; font-size: 15px; }
.how p { margin: 0; font-size: 13px; line-height: 1.55; color: #b9bee6; }
.how b { color: var(--ink); }
.how .c-e { color: var(--energy); } .how .c-a { color: var(--alloy); } .how .c-c { color: var(--crystal); }
.hi { width: 40px; height: 40px; border-radius: 12px; background: rgba(255, 255, 255, 0.05); box-shadow: inset 0 0 0 1px var(--line); position: relative; overflow: hidden; }
.hi::after { content: ""; position: absolute; inset: 9px; border-radius: 50%; }
.i-fly::after { inset: 11px 9px; border-radius: 0; background: #fff; clip-path: polygon(100% 50%, 0 0, 25% 50%, 0 100%); }
.i-mass::after { background: radial-gradient(circle at 60% 50%, #2a0f35 55%, #ff9bd9 58%, transparent 66%); inset: 4px; }
.i-res::after { background: radial-gradient(circle, var(--energy) 20%, transparent 22%) 0 0 / 50% 50%, radial-gradient(circle, var(--alloy) 20%, transparent 22%) 100% 100% / 50% 50%, radial-gradient(circle, var(--crystal) 25%, transparent 27%) 100% 0 / 50% 50%; background-repeat: no-repeat; inset: 6px; border-radius: 0; }
.i-dive::after { border: 2px dashed var(--acc); animation: spin 6s linear infinite; }
.i-scan::after { border: 2px solid var(--acc); animation: ping 1.8s ease-out infinite; }
.i-ret::after { inset: 10px; border-radius: 0; background: #fff; clip-path: polygon(50% 0, 100% 70%, 70% 70%, 70% 100%, 30% 100%, 30% 70%, 0 70%); }
.i-unst::after { background: radial-gradient(circle, #ffb070, transparent 70%); animation: pulse 0.9s ease-in-out infinite alternate; }
.i-echo::after { border: 2px solid #ecc985; inset: 8px; box-shadow: 0 0 0 4px rgba(255, 111, 240, 0.25); }

.pause-card { width: min(420px, 100%); }
.settings { margin-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; font-weight: 600; }
.set-row input[type="range"] { flex: none; width: 170px; accent-color: #8fdcff; padding: 0; box-shadow: none; background: none; }
.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: rgba(255, 255, 255, 0.05); box-shadow: inset 0 0 0 1px var(--line); }
.seg button { border: 0; background: none; padding: 6px 10px; border-radius: 9px; font-size: 12px; font-weight: 700; cursor: pointer; color: var(--muted); }
.seg button.on { background: rgba(143, 220, 255, 0.18); color: var(--ink); }

.dock-card { width: min(480px, 100%); }
.dock-sub { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.trade-list { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.trade { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 14px; background: rgba(255, 255, 255, 0.04); box-shadow: inset 0 0 0 1px var(--line); }
.trade b { display: block; font-size: 14px; }
.trade span { font-size: 12px; color: var(--muted); }
.trade .btn { flex: none; }

.screen.map { place-items: start stretch; background: linear-gradient(180deg, rgba(3, 3, 14, 0.7), transparent 30%, transparent 80%, rgba(3, 3, 14, 0.6)); pointer-events: none; }
.map-head { pointer-events: auto; display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; padding: 4px 6px; }
.map-head h2 { margin: 4px 0 0; font-family: var(--font-d); font-size: 26px; }
.map-coord { font-size: 11px; color: var(--muted); margin-top: 4px; max-width: 70vw; word-break: break-all; }
.map-actions { display: flex; gap: 8px; }
.map-legend { position: fixed; bottom: calc(18px + var(--sab)); left: 50%; transform: translateX(-50%); display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; font-size: 12px; color: var(--muted); }
.map-legend span { display: inline-flex; gap: 6px; align-items: center; }
.lg { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.lg.e { background: var(--energy); } .lg.a { background: var(--alloy); } .lg.c { background: var(--crystal); }
.lg.s { box-shadow: inset 0 0 0 2px #c9d6ff; } .lg.r { background: #fff; }

.screen.photo { place-items: end center; pointer-events: none; }
.photo-bar { pointer-events: auto; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: center; padding: 10px 14px; border-radius: 18px; background: rgba(8, 8, 26, 0.7); box-shadow: inset 0 0 0 1px var(--line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); margin-bottom: 8px; }
.photo-bar .mono { font-size: 11px; color: var(--muted); }
.photo-actions { display: flex; gap: 8px; }

.modal-card { width: min(560px, 100%); }
.modal-card .shot { width: 100%; aspect-ratio: 16 / 10; border-radius: 14px; background: #0a0a20 center / cover no-repeat; margin-top: 14px; box-shadow: inset 0 0 0 1px var(--line); }
.modal-card .code { margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.04); box-shadow: inset 0 0 0 1px var(--line); font-family: var(--mono); font-size: 11px; word-break: break-all; color: #c9cdf0; -webkit-user-select: text; user-select: text; }

/* ═══════════ animation ═══════════ */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes shimmer { from { background-position: 0% 50%; } to { background-position: 100% 50%; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes ping { 0% { transform: scale(0.3); opacity: 1; } 100% { transform: scale(1.4); opacity: 0; } }
@keyframes pulse { from { opacity: 0.55; } to { opacity: 1; } }
@keyframes blink { 50% { opacity: 0.3; } }
@keyframes bump { 40% { transform: scale(1.25); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px) scale(0.97); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-6px); } }

/* ═══════════ small screens ═══════════ */
@media (max-width: 720px) {
  #title { place-items: center; padding-left: 18px; background: radial-gradient(ellipse at 50% 45%, rgba(3, 3, 14, 0.75), rgba(3, 3, 14, 0.35) 75%); }
  .title-wrap { text-align: center; display: flex; flex-direction: column; align-items: center; }
  .tagline { font-size: 14px; }
  .menu { margin-top: 22px; }
  .btn { align-items: center; text-align: center; }
  .title-foot { justify-content: center; }
  .brief-grid { grid-template-columns: 1fr; }
  .res-stats { grid-template-columns: repeat(2, 1fr); }
  .card { padding: 20px 18px 18px; border-radius: 20px; }
  #minimap { width: 96px; height: 96px; }
  .hud-top { gap: 9px; left: 10px; right: 10px; }
  .depth-badge { width: 44px; height: 44px; }
  .depth-badge svg { width: 40px; height: 40px; }
  .depth-badge span { font-size: 17px; }
  .layer-name { font-size: 11px; }
  .coord { max-width: 40vw; font-size: 10px; }
  .contract { font-size: 10px; padding: 3px 8px; }
  .hbtn { width: 34px; height: 34px; border-radius: 10px; }
  .hud-bottom { left: 10px; right: 10px; gap: 8px; flex-wrap: wrap; }
  .bars { width: min(260px, 62vw); padding: 8px 10px; gap: 6px; }
  .bar { grid-template-columns: 48px 1fr 28px; }
  .bar .lbl { font-size: 9px; }
  .cargo { padding: 6px 8px; }
  .cg { font-size: 12px; padding: 2px 4px; }
  .touch .abilities { display: none; }
  .prompt { bottom: calc(118px + var(--sab)); font-size: 12px; }
  .hint { bottom: calc(240px + var(--sab)); font-size: 12px; }
  .tune-inset { top: calc(122px + var(--sat)); }
  .tune-inset canvas { width: 90px; height: 90px; }
  #toasts { top: calc(110px + var(--sat)); }
}
.touch .abilities { display: none; }
.touch .prompt { display: none; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001s !important; transition-duration: 0.001s !important; }
}
