/* The Pit UI — ice & deep-blue CRT */

:root {
  --bg: #0a1018;
  --bg-panel: #0e1622;
  --bg-panel-2: #0a121c;
  --line: #2a4560;
  --phosphor: #7ec8f0;
  --phosphor-dim: #3a7aa8;
  --phosphor-hot: #c8ecff;
  --accent: #3d8bfd;
  --accent-dim: #1e4a8c;
  --steel: #5eb0e0;
  --danger: #ff6b5a;
  --warn: #ffd060;
  --good: #5ad49a;
  --muted: #4a6880;
  --font: "Share Tech Mono", ui-monospace, monospace;
  --display: "Staatliches", Impact, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(ellipse 100% 70% at 50% -10%, #1a3050 0%, transparent 50%),
    radial-gradient(ellipse 80% 50% at 80% 100%, #0c1830 0%, transparent 45%),
    linear-gradient(180deg, #060a10 0%, #0a1018 45%, #081018 100%);
  color: var(--phosphor);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
}

body {
  overflow-x: hidden;
}

.scanlines {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 2px,
    rgba(0, 0, 0, 0.14) 2px,
    rgba(0, 0, 0, 0.14) 4px
  );
  opacity: 0.3;
}

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

.hidden {
  display: none !important;
}

.screen {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

.boot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  gap: 1.5rem;
  animation: fadeIn 0.8s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.boot-art {
  margin: 0;
  color: var(--accent);
  font-size: clamp(7px, 1.5vw, 11px);
  line-height: 1.15;
  text-shadow: 0 0 16px rgba(61, 139, 253, 0.45);
  white-space: pre;
  overflow-x: auto;
  max-width: 100%;
}

.boot-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: end;
  justify-content: center;
}

.boot-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  color: var(--steel);
  font-size: 0.85rem;
}

.boot-form input {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  color: var(--phosphor-hot);
  padding: 0.55rem 0.75rem;
  font-family: var(--font);
  font-size: 1rem;
  min-width: 12rem;
  outline: none;
}

.boot-form input:focus {
  border-color: var(--phosphor);
  box-shadow: 0 0 0 1px var(--phosphor-dim);
}

.boot-form button,
.btn {
  background: transparent;
  border: 1px solid var(--accent-dim);
  color: var(--phosphor);
  font-family: var(--font);
  font-weight: 600;
  padding: 0.55rem 1rem;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.boot-form button:hover,
.btn:hover {
  background: rgba(61, 139, 253, 0.14);
  border-color: var(--accent);
  color: var(--phosphor-hot);
}

.boot-form button:disabled,
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn.primary {
  border-color: var(--steel);
  color: var(--steel);
}

.btn.primary:hover {
  background: rgba(94, 176, 224, 0.15);
  color: var(--phosphor-hot);
}

.boot-hint {
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
  max-width: 36rem;
}

.boot-links {
  margin: 0;
  font-size: 0.85rem;
}

.boot-links a,
.help-link {
  color: var(--steel);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.boot-links a:hover,
.help-link:hover {
  color: var(--phosphor-hot);
}

.top-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.45rem;
}

.help-link {
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
}

.top {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: flex-end;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.85rem;
  margin-bottom: 1rem;
  animation: slideDown 0.5s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: none; }
}

.brand-mark {
  display: block;
  font-family: var(--display);
  font-size: clamp(1.4rem, 4vw, 2rem);
  color: var(--accent);
  letter-spacing: 0.08em;
  line-height: 1;
  text-shadow: 0 0 22px rgba(61, 139, 253, 0.5);
}

.brand-sub {
  color: var(--muted);
  font-size: 0.8rem;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  font-size: 0.82rem;
}

.stats .stat strong {
  color: var(--phosphor-hot);
  font-weight: 600;
}

.stats .stat .label {
  color: var(--muted);
  margin-right: 0.35rem;
}

.layout {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  grid-template-areas:
    "terminal menu"
    "gear location"
    "shop shop";
  gap: 0.75rem;
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "terminal"
      "menu"
      "location"
      "gear"
      "shop";
  }
}

.panel {
  background: linear-gradient(165deg, var(--bg-panel) 0%, var(--bg-panel-2) 100%);
  border: 1px solid var(--line);
  min-height: 0;
  animation: panelIn 0.55s ease backwards;
}

.terminal { grid-area: terminal; animation-delay: 0.05s; }
.menu { grid-area: menu; animation-delay: 0.1s; }
.gear { grid-area: gear; animation-delay: 0.15s; }
.location { grid-area: location; animation-delay: 0.2s; }
.shop { grid-area: shop; animation-delay: 0.25s; }

@keyframes panelIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: none; }
}

.panel-head {
  background: rgba(42, 69, 96, 0.35);
  border-bottom: 1px solid var(--line);
  padding: 0.4rem 0.65rem;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: var(--steel);
  text-transform: uppercase;
}

.log {
  height: 240px;
  overflow-y: auto;
  padding: 0.55rem 0.65rem;
  font-size: 0.8rem;
}

.log .line {
  margin: 0 0 0.25rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.log .line.good { color: var(--good); }
.log .line.bad { color: var(--danger); }
.log .line.warn { color: var(--warn); }
.log .line.system { color: var(--steel); }
.log .line.info { color: var(--phosphor-dim); }

.menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  padding: 0.55rem;
  max-height: 280px;
  overflow-y: auto;
}

.menu-grid button {
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-bottom-color: rgba(42, 69, 96, 0.6);
  color: var(--phosphor);
  font-family: var(--font);
  font-size: 0.78rem;
  padding: 0.45rem 0.5rem;
  cursor: pointer;
}

.menu-grid button:hover,
.menu-grid button:focus-visible {
  border-color: var(--accent-dim);
  background: rgba(61, 139, 253, 0.1);
  color: var(--phosphor-hot);
  outline: none;
}

.menu-grid button .key {
  color: var(--steel);
  margin-right: 0.4rem;
  font-weight: 700;
}

.extra {
  border-top: 1px solid var(--line);
  padding: 0.55rem;
  font-size: 0.8rem;
}

.gear-body,
.location-body,
.shop-list {
  padding: 0.55rem 0.65rem;
  font-size: 0.8rem;
  max-height: 320px;
  overflow-y: auto;
}

.gear-body .row,
.location-body .row,
.shop-list .row,
.shop-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid rgba(42, 69, 96, 0.4);
}

.gear-body .row span,
.location-body .row span,
.shop-list .row span {
  color: var(--muted);
  margin-right: 0.5rem;
}

.gear-body .meta,
.location-body .meta,
.shop-list .meta,
.shop-row .meta {
  color: var(--muted);
  font-size: 0.72rem;
}

.shop-row button {
  font-family: var(--font);
  font-size: 0.65rem;
  padding: 0.2rem 0.4rem;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--phosphor-dim);
  cursor: pointer;
}

.shop-row button:hover {
  color: var(--phosphor-hot);
  border-color: var(--accent-dim);
}

.hp-bar {
  margin-top: 0.5rem;
  height: 8px;
  background: rgba(42, 69, 96, 0.5);
  border: 1px solid var(--line);
}

.hp-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--phosphor-dim), var(--phosphor));
  width: 0%;
  transition: width 0.35s ease;
}

.hp-bar.enemy > span {
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
}

.arena-grid {
  display: grid;
  gap: 1px;
  background: #122030;
  border: 1px solid var(--line);
  padding: 4px;
  margin-top: 0.5rem;
  font-family: var(--font);
  line-height: 1;
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
}

.arena-cell {
  width: 1.15rem;
  height: 1.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  background: #0c1520;
  color: var(--phosphor-dim);
}

.arena-cell.wall { color: var(--muted); background: #080e16; }
.arena-cell.door { color: var(--steel); font-weight: 700; }
.arena-cell.player {
  color: var(--phosphor-hot);
  background: rgba(94, 176, 224, 0.25);
  text-shadow: 0 0 8px rgba(126, 200, 240, 0.55);
  animation: pulse 1.2s ease infinite;
}
.arena-cell.foe {
  color: var(--danger);
  background: rgba(61, 139, 253, 0.18);
  animation: pulse 0.9s ease infinite reverse;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(4, 8, 14, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}

.modal-card {
  width: min(420px, 100%);
  background: var(--bg-panel);
  border: 1px solid var(--accent-dim);
  box-shadow: 0 0 40px rgba(61, 139, 253, 0.12);
}

.modal-card.end {
  text-align: center;
  padding-bottom: 1rem;
}

.modal-card.end p {
  padding: 1rem;
  color: var(--phosphor-hot);
}

#modal-body {
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

#modal-body label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  color: var(--muted);
  font-size: 0.8rem;
}

#modal-body input,
#modal-body select {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--phosphor-hot);
  font-family: var(--font);
  padding: 0.45rem 0.55rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0 0.85rem 0.85rem;
}

.help-card {
  width: min(560px, 100%);
  max-height: min(88vh, 720px);
  display: flex;
  flex-direction: column;
}

.help-body {
  padding: 0.85rem 1rem;
  overflow-y: auto;
  font-size: 0.82rem;
  color: var(--phosphor-dim);
  line-height: 1.5;
}

.help-body h3 {
  margin: 1rem 0 0.4rem;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  color: var(--steel);
  text-transform: uppercase;
}

.help-body h3:first-of-type {
  margin-top: 0.35rem;
}

.help-body p {
  margin: 0 0 0.65rem;
}

.help-body strong {
  color: var(--phosphor-hot);
  font-weight: 600;
}

.help-body ul {
  margin: 0 0 0.5rem;
  padding-left: 1.15rem;
}

.help-body li {
  margin-bottom: 0.35rem;
}

.help-foot {
  margin-top: 0.75rem !important;
  color: var(--muted);
  font-size: 0.75rem;
}

::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-thumb {
  background: var(--line);
}
