:root {
  --bg: #0d0f0e;
  --bg-soft: #14171a;
  --panel: #1a1d20;
  --line: #262a2f;
  --text: #c8cdd1;
  --dim: #6b7178;
  --accent: #7dd3a0;
  --warn: #e0b66d;
  --bad: #d97462;
  --good: #7dd3a0;
  --hl: #f4e4b8;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-size: 14px;
  line-height: 1.55;
  overflow: hidden;
}
body {
  background:
    radial-gradient(ellipse at top, #14191a 0%, var(--bg) 60%),
    var(--bg);
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100vh;
}

/* шапка */
.topbar {
  border-bottom: 1px solid var(--line);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: linear-gradient(180deg, #11151700 0%, #0d0f0e 100%);
}
.brand {
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.12em;
  font-size: 12px;
}
.brand .dot {
  display: inline-block;
  width: 7px; height: 7px;
  background: var(--accent);
  border-radius: 50%;
  margin-right: 8px;
  box-shadow: 0 0 8px var(--accent);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.meta {
  color: var(--dim);
  font-size: 11px;
  letter-spacing: 0.08em;
}
.meta b { color: var(--warn); font-weight: 500; }

/* основная сетка */
.app {
  display: grid;
  grid-template-columns: 1fr 260px;
  overflow: hidden;
  min-height: 0;
}

/* вкладки */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
  padding: 0 16px;
  gap: 2px;
}
.tab {
  background: transparent;
  border: none;
  color: var(--dim);
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tab .key {
  color: var(--dim);
  font-size: 10px;
  margin-left: 6px;
}
.tab.active .key { color: var(--warn); }

/* основная колонка с вкладками */
.main-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
}
.pane {
  display: none;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.pane.active {
  display: flex;
  flex-direction: column;
}

/* терминал */
.scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  scroll-behavior: smooth;
}
.scroll::-webkit-scrollbar { width: 8px; }
.scroll::-webkit-scrollbar-track { background: transparent; }
.scroll::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
.scroll::-webkit-scrollbar-thumb:hover { background: #353a40; }

.line { white-space: pre-wrap; word-break: break-word; }
.line + .line { margin-top: 2px; }
.blk { margin: 10px 0; }

.echo { color: var(--dim); }
.echo::before { content: "› "; color: var(--accent); }
.sys  { color: var(--dim); font-style: italic; }
.ok   { color: var(--good); }
.warn { color: var(--warn); }
.bad  { color: var(--bad); }
.hl   { color: var(--hl); }
.head { color: var(--accent); font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; font-size: 12px; margin-bottom: 4px; }
.loc  { color: var(--warn); font-weight: 700; letter-spacing: 0.15em; text-transform: uppercase; font-size: 12px; margin-bottom: 4px; }
.desc { color: #a8aeb3; }
.hint { color: var(--dim); font-style: italic; font-size: 12px; }
.npc  { color: var(--hl); }
.item { color: #9ab3d4; }
.exit { color: var(--accent); }
.br   { height: 8px; }
.sep  {
  border-top: 1px dashed var(--line);
  margin: 10px 0;
  height: 0;
}
.dmg  { color: var(--bad); font-weight: 700; }
.heal { color: var(--good); font-weight: 700; }

/* строка ввода */
.input-row {
  border-top: 1px solid var(--line);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-soft);
}
.prompt {
  color: var(--accent);
  font-weight: 700;
  user-select: none;
}
.prompt::after { content: " "; }
#cmd {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--hl);
  font-family: inherit;
  font-size: 14px;
  caret-color: var(--accent);
}
#cmd::placeholder { color: var(--dim); }

/* боковая панель */
.side {
  overflow-y: auto;
  padding: 16px;
  background: var(--bg-soft);
  display: flex;
  flex-direction: column;
  gap: 18px;
  font-size: 12px;
}
.side::-webkit-scrollbar { width: 6px; }
.side::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

.panel {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 12px;
  border-radius: 2px;
}
.panel h3 {
  margin: 0 0 10px 0;
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
}
.stat {
  display: flex;
  justify-content: space-between;
  margin: 4px 0;
  color: var(--text);
}
.stat .lbl { color: var(--dim); }
.bar {
  height: 6px;
  background: #0a0b0c;
  border: 1px solid var(--line);
  margin: 4px 0 10px;
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  transition: width 0.3s ease;
}
.bar.hp > i  { background: linear-gradient(90deg, var(--bad), #e89a8b); }
.bar.exp > i { background: linear-gradient(90deg, var(--accent), #c5f3d6); }
.bar.hunger > i { background: linear-gradient(90deg, var(--warn), #f4d59a); }
.bar.rad > i { background: linear-gradient(90deg, #b58cd9, #d9b3ff); }

.inv-list {
  list-style: none;
  margin: 0; padding: 0;
  max-height: 180px;
  overflow-y: auto;
}
.inv-list li {
  padding: 3px 0;
  color: #9ab3d4;
  border-bottom: 1px dotted var(--line);
  display: flex;
  justify-content: space-between;
}
.inv-list li:last-child { border: none; }
.inv-list .empty { color: var(--dim); font-style: italic; }
.inv-list .q { color: var(--dim); }

/* карта */
.map-wrap {
  flex: 1;
  overflow: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.map-wrap::-webkit-scrollbar { width: 8px; }
.map-wrap::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

.map-head {
  width: 100%;
  max-width: 720px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}
.map-head .title {
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  font-size: 12px;
}
.map-head .sub {
  color: var(--dim);
  font-size: 11px;
  letter-spacing: 0.08em;
}
.map-grid {
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  color: var(--dim);
  white-space: pre;
  letter-spacing: 0.02em;
  user-select: none;
}
.map-grid .node {
  display: inline-block;
  padding: 0 4px;
  border-radius: 2px;
  color: var(--dim);
}
.map-grid .node.visited { color: var(--text); }
.map-grid .node.here {
  color: var(--bg);
  background: var(--accent);
  box-shadow: 0 0 10px rgba(125, 211, 160, 0.5);
  animation: heretick 1.4s infinite;
}
.map-grid .node.locked { color: var(--warn); }
.map-grid .node.unknown { color: var(--line); }
@keyframes heretick {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}
.map-grid .edge { color: var(--line); }

.map-legend {
  width: 100%;
  max-width: 720px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px 16px;
  font-size: 11px;
  color: var(--dim);
}
.map-legend .lg {
  display: flex; align-items: center; gap: 8px;
}
.map-legend .sq {
  width: 10px; height: 10px;
  background: var(--line);
  display: inline-block;
}
.map-legend .sq.here { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.map-legend .sq.visited { background: var(--text); }
.map-legend .sq.locked { background: var(--warn); }
.map-legend .sq.unknown { background: var(--line); border: 1px dashed var(--dim); }

.map-current {
  width: 100%;
  max-width: 720px;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 14px 16px;
  border-radius: 2px;
}
.map-current .lname {
  color: var(--warn);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
}
.map-current .ldesc {
  color: #a8aeb3;
  font-size: 13px;
}
.map-current .lex {
  color: var(--dim);
  font-size: 11px;
  margin-top: 8px;
}
.map-current .lex b { color: var(--accent); font-weight: 500; }

/* мобильный */
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .side {
    border-top: 1px solid var(--line);
    max-height: 200px;
  }
  .scroll, .map-wrap { padding: 14px; }
  .input-row { padding: 10px 14px; }
  .map-grid { font-size: 11px; }
}
