:root {
  --bg: #06111b;
  --bg-panel: rgba(7, 15, 27, 0.86);
  --bg-panel-strong: rgba(5, 11, 20, 0.95);
  --line: rgba(161, 196, 255, 0.16);
  --line-strong: rgba(189, 220, 255, 0.28);
  --text: #e7eef9;
  --muted: #8ea4c6;
  --accent: #ffbf6b;
  --accent-soft: #83e3ff;
  --ok: #54ff7b;
  --warn: #ffb14b;
  --danger: #ff6161;
  --cut: #ff5959;
  --bruise: #d57d2a;
  --bite: #ff1d39;
  --infect: #b24fff;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  --radius: 16px;
  --hud-gap: 12px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at top, #183150 0%, #0a1625 38%, #02070c 100%);
  color: var(--text);
  font-family: var(--font);
}

body {
  display: flex;
  align-items: stretch;
  justify-content: stretch;
}

button, input, select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(6, 17, 27, 0.4), rgba(3, 8, 14, 0.65));
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #0a1b0f;
  cursor: none;
}

.hud {
  position: absolute;
  z-index: 5;
  pointer-events: none;
}

.hud.top-left {
  top: 20px;
  left: 24px;
  max-width: min(360px, 28vw);
}

.hud.top-center {
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  min-width: 300px;
}

.hud.top-right {
  top: 20px;
  right: 24px;
  text-align: right;
}

.metric {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.03em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

.metric.accent {
  color: var(--accent);
}

.subtle {
  color: var(--muted);
  font-size: 0.92rem;
}

.message-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.message {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 999px;
  width: fit-content;
  max-width: 100%;
  background: rgba(3, 7, 13, 0.76);
  border: 1px solid rgba(137, 223, 255, 0.18);
  box-shadow: 0 8px 22px rgba(0,0,0,0.22);
  color: var(--text);
}

.message::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  flex: 0 0 auto;
}

.mission-focus {
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(3, 7, 13, 0.68);
  border: 1px solid rgba(255, 191, 107, 0.2);
  display: inline-block;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(0,0,0,0.22);
}

#threatMeter {
  margin-top: 6px;
}

.panel {
  position: absolute;
  z-index: 7;
  background: linear-gradient(180deg, rgba(9, 18, 31, 0.9), rgba(5, 12, 21, 0.92));
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.left-panel {
  left: 28px;
  top: 24%;
  width: 320px;
  padding: 16px 16px 18px;
}

.right-panel {
  right: 24px;
  top: 90px;
  width: min(420px, 34vw);
  max-height: calc(100vh - 180px);
  display: flex;
  flex-direction: column;
}

.overlay-panel {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(580px, calc(100vw - 60px));
  max-height: calc(100vh - 80px);
  overflow: auto;
  padding: 22px;
}

.hidden {
  display: none !important;
}

.panel-section + .panel-section {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.panel-section h2,
.utility-header h2 {
  margin: 0 0 10px;
  font-size: 1.05rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #ffd39c;
}

.legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  border: 1px solid rgba(255,255,255,0.08);
  color: #081114;
}

.chip-ok { background: var(--ok); }
.chip-cut { background: var(--cut); }
.chip-bruise { background: var(--bruise); }
.chip-bite { background: var(--bite); color: #fff; }
.chip-infect { background: var(--infect); color: #fff; }

.body-figure {
  position: relative;
  width: 230px;
  height: 300px;
  margin: 14px auto 2px;
}

.body-part {
  position: absolute;
  border: 1px solid rgba(7, 20, 8, 0.34);
  background: linear-gradient(180deg, rgba(112, 255, 145, 0.95), rgba(54, 219, 102, 0.9));
  color: #0f2014;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 10px;
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

.body-part:hover,
.body-part.active {
  transform: translateY(-1px);
  box-shadow: 0 0 0 2px rgba(131, 227, 255, 0.45), 0 8px 22px rgba(0,0,0,0.28);
}

.body-part.head {
  left: 87px;
  top: 0;
  width: 56px;
  height: 56px;
  border-radius: 999px;
}

.body-part.torso {
  left: 64px;
  top: 70px;
  width: 102px;
  height: 100px;
}

.body-part.left-arm {
  left: 18px;
  top: 74px;
  width: 52px;
  height: 96px;
}

.body-part.right-arm {
  left: 160px;
  top: 74px;
  width: 52px;
  height: 96px;
}

.body-part.left-leg {
  left: 72px;
  top: 184px;
  width: 44px;
  height: 106px;
}

.body-part.right-leg {
  left: 118px;
  top: 184px;
  width: 44px;
  height: 106px;
}

.equipped-list,
.stat-list,
.inventory-list,
.recipe-list,
.perk-list,
.mission-list,
.storage-list {
  display: grid;
  gap: 8px;
}

.equipped-row,
.inventory-item,
.recipe-item,
.perk-item,
.mission-item,
.storage-item,
.note-card,
.log-card,
.stat-card {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(13, 25, 41, 0.72);
  border: 1px solid rgba(164, 198, 255, 0.1);
}

.row-title {
  font-weight: 700;
}

.row-value,
.row-subtitle {
  color: var(--muted);
  font-size: 0.92rem;
}

.injury-detail {
  min-height: 160px;
}

.utility-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.utility-body {
  overflow: auto;
  padding: 16px 18px 18px;
}

.ghost-button,
.speed-button,
.command-button,
.icon-button,
.primary-button,
.secondary-button,
.tab-button,
.inline-button,
.card-button {
  appearance: none;
  border: 1px solid rgba(169, 207, 255, 0.18);
  background: rgba(11, 22, 36, 0.82);
  color: var(--text);
  border-radius: 12px;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.ghost-button:hover,
.speed-button:hover,
.command-button:hover,
.icon-button:hover,
.primary-button:hover,
.secondary-button:hover,
.tab-button:hover,
.inline-button:hover,
.card-button:hover {
  transform: translateY(-1px);
  background: rgba(19, 33, 53, 0.9);
  border-color: rgba(201, 227, 255, 0.32);
}

.ghost-button {
  padding: 10px 12px;
  min-width: 42px;
}

.primary-button,
.secondary-button,
.inline-button,
.card-button {
  padding: 9px 12px;
}

.primary-button {
  background: linear-gradient(180deg, rgba(37, 129, 255, 0.28), rgba(11, 22, 36, 0.9));
  border-color: rgba(131, 227, 255, 0.34);
}

.secondary-button {
  background: linear-gradient(180deg, rgba(255, 191, 107, 0.18), rgba(11, 22, 36, 0.9));
}

.inline-actions,
.card-actions,
.button-row,
.tab-row,
.inventory-actions,
.inventory-filter-row,
.mission-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tab-row {
  margin-bottom: 14px;
}

.tab-button.active,
.speed-button.active,
.command-button.active {
  border-color: rgba(131, 227, 255, 0.52);
  box-shadow: inset 0 0 0 1px rgba(131, 227, 255, 0.18), 0 0 0 1px rgba(131, 227, 255, 0.18);
  background: rgba(25, 44, 68, 0.9);
}

.inventory-item,
.recipe-item,
.perk-item,
.mission-item,
.storage-item {
  display: grid;
  gap: 8px;
}

.inventory-item.selected,
.recipe-item.selected,
.perk-item.selected,
.mission-item.selected,
.storage-item.selected {
  border-color: rgba(131, 227, 255, 0.32);
  box-shadow: inset 0 0 0 1px rgba(131, 227, 255, 0.16);
}

.inventory-meta,
.recipe-meta,
.perk-meta,
.mission-meta,
.storage-meta,
.kv-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 0.88rem;
}

.kv-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.kv-card {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(13, 25, 41, 0.72);
  border: 1px solid rgba(164, 198, 255, 0.1);
}

.map-card,
.big-card {
  padding: 12px;
  border-radius: 16px;
  border: 1px solid rgba(164, 198, 255, 0.1);
  background: rgba(13, 25, 41, 0.72);
}

.map-canvas {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(175, 211, 255, 0.18);
  background: rgba(4, 8, 13, 0.9);
}

.center-prompt,
.center-banner {
  position: absolute;
  z-index: 8;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
}

.center-prompt {
  bottom: 106px;
  padding: 12px 16px;
  border-radius: 999px;
  background: rgba(3, 7, 13, 0.82);
  border: 1px solid rgba(255, 191, 107, 0.22);
  box-shadow: 0 10px 26px rgba(0,0,0,0.25);
}

.center-banner {
  top: 94px;
  padding: 12px 18px;
  border-radius: 999px;
  background: rgba(12, 28, 48, 0.86);
  border: 1px solid rgba(131, 227, 255, 0.22);
  box-shadow: 0 14px 32px rgba(0,0,0,0.28);
}

.bottom-bar {
  left: 0;
  right: 0;
  bottom: 0;
  height: 80px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: stretch;
  background: linear-gradient(180deg, rgba(5, 12, 20, 0.34), rgba(3, 8, 14, 0.92));
  border-top: 1px solid rgba(181, 218, 255, 0.18);
  pointer-events: auto;
  z-index: 9;
}

.command-group,
.time-controls {
  display: flex;
  align-items: stretch;
}

.command-button,
.speed-button,
.icon-button {
  pointer-events: auto;
}

.command-button {
  min-width: 86px;
  border-radius: 0;
  border-top: none;
  border-bottom: none;
  border-left: none;
  padding: 0 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
}

.command-button .key {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 700;
}

.command-button .label {
  font-size: 0.8rem;
  color: var(--muted);
}

.action-status {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.12rem;
  font-weight: 700;
  color: #e8eef7;
  border-left: 1px solid rgba(181, 218, 255, 0.12);
  border-right: 1px solid rgba(181, 218, 255, 0.12);
}

.time-controls {
  justify-content: flex-end;
}

.icon-button,
.speed-button {
  border-radius: 0;
  border-top: none;
  border-bottom: none;
  border-left: 1px solid rgba(181, 218, 255, 0.12);
  padding: 0 18px;
  min-width: 72px;
}

.icon-button {
  min-width: 78px;
}

.start-screen,
.modal-screen,
.game-over-screen {
  display: grid;
  gap: 18px;
}

.hero-title {
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
}

.hero-title h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 0.95;
}

.hero-title p,
.note-text,
.card-text {
  color: var(--muted);
  line-height: 1.55;
}

.callout {
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 191, 107, 0.08);
  border: 1px solid rgba(255, 191, 107, 0.14);
}

.controls-grid,
.recipe-grid,
.perk-grid,
.stat-grid,
.mission-grid,
.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.controls-card {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(13, 25, 41, 0.72);
  border: 1px solid rgba(164, 198, 255, 0.1);
}

.controls-card strong {
  display: block;
  margin-bottom: 4px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(131, 227, 255, 0.12);
  border: 1px solid rgba(131, 227, 255, 0.24);
  color: #d8f6ff;
  width: fit-content;
  font-size: 0.84rem;
  font-weight: 700;
}

.health-bar,
.progress-bar {
  position: relative;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.08);
}

.health-fill,
.progress-fill {
  position: absolute;
  inset: 0;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(84,255,123,0.92), rgba(255,177,75,0.92));
}

.progress-fill.danger {
  background: linear-gradient(90deg, rgba(255,97,97,0.92), rgba(255,29,57,0.92));
}

.treatment-grid,
.quick-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.quick-stat {
  padding: 12px;
  border-radius: 14px;
  background: rgba(13, 25, 41, 0.72);
  border: 1px solid rgba(164, 198, 255, 0.1);
}

.quick-stat .value {
  font-size: 1.25rem;
  font-weight: 800;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.08);
  font-size: 0.82rem;
  font-weight: 700;
}

.status-pill.good {
  color: #baffcb;
}

.status-pill.warn {
  color: #ffd49b;
}

.status-pill.bad {
  color: #ffb2b2;
}

hr.soft-line {
  border: none;
  border-top: 1px solid rgba(161, 196, 255, 0.12);
  margin: 14px 0;
}

@media (max-width: 1360px) {
  .left-panel {
    transform: scale(0.92);
    transform-origin: left center;
  }
  .right-panel {
    width: min(390px, 38vw);
  }
  .command-button {
    min-width: 74px;
    padding: 0 10px;
  }
}

@media (max-width: 1120px) {
  .left-panel {
    width: 286px;
    left: 18px;
  }
  .right-panel {
    right: 18px;
    width: min(360px, 40vw);
  }
  .hud.top-left,
  .hud.top-right {
    top: 14px;
  }
  .hud.top-left { left: 18px; }
  .hud.top-right { right: 18px; }
}

@media (max-width: 960px) {
  .left-panel {
    display: none;
  }
  .right-panel {
    width: min(420px, calc(100vw - 36px));
  }
  .controls-grid,
  .recipe-grid,
  .perk-grid,
  .stat-grid,
  .mission-grid,
  .two-col,
  .treatment-grid,
  .quick-stats,
  .kv-grid {
    grid-template-columns: 1fr;
  }
}
