:root {
  --bg: #0d1016;
  --panel: #111725;
  --panel-border: #2a3448;
  --text: #d9e2f1;
  --muted: #91a0bb;
  --command-green: #58dd96;
  --item-green: #6fbe79;
  --health-green: #45f06c;
  --accent: var(--command-green);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at top, #1c2233, var(--bg) 45%);
  color: var(--text);
  font-family: Consolas, "Courier New", monospace;
  min-height: 100vh;
  transition: background 220ms ease;
}

body.combat-active {
  background: radial-gradient(circle at top, #2b1a1f, #151018 48%);
}

body.combat-active .terminal-shell,
body.combat-active .status-shell,
body.combat-active .art-shell,
body.combat-active .actions-shell,
body.combat-active .inventory-shell,
body.combat-active .location-shell,
body.combat-active .kills-shell {
  border-color: rgba(168, 78, 88, 0.8);
  box-shadow: 0 18px 36px rgba(120, 20, 35, 0.35);
}

.layout {
  max-width: 1560px;
  margin: 0 auto;
  padding: 24px clamp(22px, 3vw, 40px) 30px;
}

.header {
  margin-bottom: 12px;
}

.header h1 {
  margin: 0;
  font-size: 1.6rem;
}

.header p {
  margin: 2px 0 0;
  color: var(--muted);
}

.terminal-layout {
  display: grid;
  gap: 14px;
  align-items: start;
}

.top-layout {
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) minmax(280px, 1.15fr) minmax(280px, 1.15fr);
  gap: 14px;
  align-items: start;
}

.left-pane {
  min-width: 0;
}

.middle-pane,
.right-pane {
  display: grid;
  gap: 12px;
  align-items: start;
  min-height: 0;
}

.bottom-layout {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.terminal-shell,
.status-shell,
.art-shell,
.actions-shell,
.inventory-shell,
.location-shell,
.kills-shell {
  border: 1px solid var(--panel-border);
  background: linear-gradient(180deg, #0e1420, var(--panel));
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 18px 32px rgba(0, 0, 0, 0.35);
}

.terminal {
  margin: 0;
  min-height: 62vh;
  max-height: none;
  overflow: visible;
  padding: 16px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.35;
  font-size: 0.97rem;
}

.status-title,
.art-title,
.summary-title {
  margin: 0;
  padding: 12px 14px;
  border-bottom: 1px solid var(--panel-border);
  font-size: 1rem;
  color: var(--text);
}

.status-panel {
  padding: 10px 12px;
  min-height: 270px;
  max-height: none;
  overflow: hidden;
  display: grid;
  gap: 10px;
}

.status-section {
  border: 1px solid rgba(145, 160, 187, 0.2);
  border-radius: 8px;
  padding: 8px 9px;
  background: rgba(8, 12, 20, 0.85);
}

.status-label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.status-value {
  margin: 0;
  color: var(--text);
  line-height: 1.35;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.status-list {
  margin: 0;
  padding-left: 14px;
  display: grid;
  gap: 4px;
}

.status-list li {
  color: var(--text);
  font-size: 0.86rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.status-empty,
.summary-empty,
.actions-empty {
  margin: 0;
  padding: 10px 12px 12px;
  color: var(--muted);
}

.art-panel {
  margin: 0;
  padding: 8px;
  min-height: 182px;
  max-height: 252px;
  overflow: hidden;
  white-space: pre;
  line-height: 0.42rem;
  font-size: 0.42rem;
  text-align: center;
  color: #cbd6ed;
  letter-spacing: 0;
  background: rgba(8, 12, 20, 0.85);
}

.art-panel[hidden] {
  display: none;
}

.art-image {
  display: block;
  width: 100%;
  min-height: 182px;
  max-height: 252px;
  object-fit: contain;
  object-position: center;
  background: rgba(8, 12, 20, 0.85);
}

.art-image[hidden] {
  display: none;
}

.actions-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--panel-border);
}

.actions-title {
  margin: 0;
  padding: 12px 14px;
  font-size: 1rem;
  color: var(--text);
}

.hints-toggle {
  padding: 8px 10px;
  margin-right: 12px;
  font-size: 0.82rem;
  min-width: 86px;
}

.actions-shell {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.actions-list {
  margin: 0;
  min-height: 220px;
  max-height: 72vh;
  flex: 1 1 auto;
  overflow: auto;
  padding: 8px 14px 10px;
}

.actions-group {
  margin: 0 0 12px;
}

.actions-group:last-child {
  margin-bottom: 0;
}

.actions-group-title {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.actions-group-list {
  display: grid;
  gap: 8px;
}

.actions-group-hint {
  color: var(--accent);
}

.actions-item {
  border: 1px solid rgba(145, 160, 187, 0.2);
  border-radius: 8px;
  overflow: hidden;
}

.action-button {
  width: 100%;
  border: 0;
  background: rgba(8, 12, 20, 0.85);
  color: var(--text);
  border-radius: 0;
  text-align: left;
  padding: 10px 11px;
  cursor: pointer;
}

.action-button:hover:not(:disabled) {
  filter: brightness(1.08);
}

.action-command {
  display: block;
  line-height: 1.3;
  margin-bottom: 5px;
}

.action-verb {
  color: var(--command-green);
  font-weight: 700;
}

.action-argument {
  font-weight: 700;
}

.action-description {
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
  font-size: 0.9rem;
}

.action-hint-reason {
  margin-top: 6px;
  color: var(--accent);
  font-size: 0.82rem;
  line-height: 1.3;
}

.summary-panel {
  padding: 10px 12px 12px;
  min-height: 210px;
  max-height: none;
  overflow: hidden;
  display: grid;
  gap: 8px;
  background: rgba(8, 12, 20, 0.85);
}

.summary-line {
  margin: 0;
  color: var(--text);
  line-height: 1.3;
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

.summary-subsection {
  border: 1px solid rgba(145, 160, 187, 0.2);
  border-radius: 8px;
  padding: 8px 9px;
  background: rgba(10, 14, 24, 0.9);
}

.summary-subtitle {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.summary-list {
  margin: 0;
  padding-left: 14px;
  display: grid;
  gap: 4px;
}

.summary-list li {
  color: var(--text);
  font-size: 0.86rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.command-row {
  margin-top: 14px;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 8px;
  align-items: center;
}

.prompt {
  color: var(--accent);
  font-weight: 700;
  font-size: 1.05rem;
}

#command-input {
  width: 100%;
  border: 1px solid var(--panel-border);
  background: #090d17;
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
}

button {
  border: 1px solid var(--panel-border);
  background: #1a2334;
  color: var(--text);
  border-radius: 8px;
  padding: 10px 14px;
  font: inherit;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.08);
}

button:disabled,
input:disabled {
  opacity: 0.7;
  cursor: default;
}

.status-line {
  margin: 10px 2px 0;
  color: var(--muted);
  min-height: 1.2em;
}

.status-line.over {
  color: #ff9f9f;
}

.ansi-blue {
  color: #52a8ff;
}

.ansi-yellow {
  color: #f6db5b;
}

.ansi-orange {
  color: #ffad5d;
}

.ansi-red {
  color: #ff7b7b;
}

.ansi-health-green {
  color: var(--health-green);
}

.ansi-item-green {
  color: var(--item-green);
}

.ansi-green {
  color: var(--item-green);
}

.ansi-purple {
  color: #cd8dff;
}

.ansi-pink {
  color: #ff95da;
}

@media (max-width: 1100px) {
  .top-layout {
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  }

  .right-pane {
    grid-column: 1 / -1;
    grid-template-columns: minmax(0, 1fr);
  }

  .terminal {
    min-height: 56vh;
    max-height: none;
  }

  .actions-list {
    min-height: 34vh;
    max-height: 62vh;
  }
}

@media (max-width: 760px) {
  .layout {
    padding: 18px 14px 24px;
  }

  .top-layout,
  .right-pane,
  .bottom-layout {
    grid-template-columns: 1fr;
  }

  .terminal {
    min-height: 50vh;
    max-height: none;
    font-size: 0.9rem;
  }

  .status-panel,
  .actions-list,
  .summary-panel {
    min-height: 42vh;
    max-height: none;
  }

  .art-panel {
    min-height: 140px;
    max-height: 190px;
  }

  .art-image {
    min-height: 140px;
    max-height: 190px;
  }

  .command-row {
    grid-template-columns: auto 1fr;
  }

  .command-row button {
    width: 100%;
  }
}
