:root {
  --bg: #111417;
  --bg-soft: #1b2127;
  --panel: rgba(14, 19, 24, 0.9);
  --panel-border: rgba(140, 179, 156, 0.24);
  --text: #edf3ec;
  --muted: #9eb0a2;
  --accent: #d0ff72;
  --accent-soft: #4c6e1f;
  --danger: #ff7a7a;
  --warn: #ffc96a;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "SFMono-Regular", "Cascadia Code", "Liberation Mono", monospace;
  background:
    radial-gradient(circle at top left, rgba(208, 255, 114, 0.16), transparent 30%),
    radial-gradient(circle at top right, rgba(255, 201, 106, 0.12), transparent 28%),
    linear-gradient(180deg, #161b21 0%, #0c0f13 100%);
  color: var(--text);
}

button,
kbd {
  font: inherit;
}

.app-shell {
  width: min(1380px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.hidden {
  display: none !important;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  padding: 24px 28px;
  margin-bottom: 20px;
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(27, 33, 39, 0.94), rgba(10, 13, 17, 0.94));
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.78rem;
}

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

.summary {
  margin: 12px 0 0;
  max-width: 56ch;
  color: var(--muted);
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

button {
  border: 1px solid rgba(208, 255, 114, 0.4);
  border-radius: 12px;
  padding: 12px 16px;
  background: rgba(208, 255, 114, 0.08);
  color: var(--text);
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

button:hover,
button:focus-visible {
  transform: translateY(-1px);
  background: rgba(208, 255, 114, 0.16);
  border-color: rgba(208, 255, 114, 0.72);
}

.text-button {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.14);
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.status-rail {
  display: grid;
  gap: 18px;
  align-content: start;
}

.play-area {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 20px;
  align-items: start;
}

.map-card,
.panel,
#inventory-dialog,
#help-dialog {
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.map-card,
.panel {
  padding: 18px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 14px;
}

.panel-head h2 {
  margin: 0;
  font-size: 1rem;
}

.panel-head span {
  color: var(--muted);
  font-size: 0.84rem;
}

#game-map {
  margin: 0;
  min-height: 640px;
  padding: 22px;
  overflow: auto;
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(208, 255, 114, 0.03), transparent 12%),
    #0a0d10;
  color: var(--text);
  font-family: "SFMono-Regular", "Cascadia Code", "Liberation Mono", monospace;
  white-space: pre;
  line-height: 1.14;
  font-size: clamp(0.7rem, 1.15vw, 1rem);
}

.map-cell {
  display: inline;
}

.glyph-player {
  color: #78f0ff;
}

.glyph-enemy {
  color: #7ae87a;
}

.glyph-wall {
  color: #d8dfe4;
}

.sidebar {
  display: grid;
  gap: 18px;
  align-content: start;
}

.hud-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 18px;
  margin: 0;
}

.encounter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 18px;
  margin: 0;
}

.hud-grid dt {
  color: var(--muted);
}

.hud-grid dd,
.encounter-grid dd {
  margin: 4px 0 0;
  font-weight: 700;
}

.encounter-grid dt {
  color: var(--muted);
}

.character-art {
  display: block;
  margin: 0;
  padding: 18px;
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(208, 255, 114, 0.04), transparent 16%),
    #0a0d10;
  color: var(--accent);
  font-family: "SFMono-Regular", "Cascadia Code", "Liberation Mono", monospace;
  white-space: pre;
  line-height: 1.08;
  font-size: 0.94rem;
  overflow-x: auto;
  overflow-y: hidden;
}

.character-loadout {
  margin: 14px 0 0;
  color: var(--muted);
  min-height: 2.6em;
}

.inventory-list,
.message-log,
.controls-list,
.inventory-dialog-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.inventory-list li,
.message-log li,
.controls-list li,
.inventory-dialog-list li {
  padding: 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.inventory-list li:first-child,
.message-log li:first-child,
.controls-list li:first-child,
.inventory-dialog-list li:first-child {
  border-top: 0;
  padding-top: 0;
}

.inventory-action {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: 8px;
}

.inventory-action:hover,
.inventory-action:focus-visible {
  transform: none;
  background: rgba(208, 255, 114, 0.08);
  outline: none;
}

.message-log {
  max-height: 220px;
  overflow: auto;
}

.message-log li {
  color: var(--muted);
  font-size: 0.92rem;
}

.controls-list li {
  color: var(--muted);
}

kbd {
  display: inline-block;
  min-width: 1.8em;
  padding: 0.16em 0.42em;
  border-radius: 6px;
  background: rgba(208, 255, 114, 0.1);
  border: 1px solid rgba(208, 255, 114, 0.24);
  color: var(--accent);
  text-align: center;
}

#inventory-dialog,
#help-dialog {
  width: min(520px, calc(100vw - 24px));
  padding: 22px;
  color: var(--text);
}

#inventory-dialog::backdrop,
#help-dialog::backdrop {
  background: rgba(0, 0, 0, 0.58);
}

.log-panel {
  margin-top: 20px;
}

.dungeon-loading-panel {
  margin-top: 16px;
  padding: 20px;
  border-radius: 14px;
  background:
    radial-gradient(circle at top, rgba(208, 255, 114, 0.08), transparent 35%),
    #05080a;
}

.dungeon-loading-panel h3 {
  margin: 0 0 14px;
}

.floor-loading-art {
  margin: 0;
  padding: 18px;
  border-radius: 12px;
  background: #0a0d10;
  color: var(--accent);
  white-space: pre;
  line-height: 1.1;
  overflow: auto;
}

.loading-progress-label {
  margin: 14px 0 0;
  color: var(--accent);
  font-weight: 700;
  white-space: pre;
}

.floor-loading-text {
  margin: 14px 0 0;
  color: var(--muted);
}

#inventory-hint {
  margin: 0 0 14px;
  color: var(--muted);
}

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

.danger {
  color: var(--danger);
}

.warn {
  color: var(--warn);
}

@media (max-width: 980px) {
  .app-shell {
    width: min(100vw - 20px, 1380px);
    padding-top: 10px;
  }

  .hero,
  .game-layout {
    grid-template-columns: 1fr;
    display: grid;
  }

  .play-area {
    grid-template-columns: 1fr;
  }

  .hero {
    align-items: start;
  }

  #game-map {
    min-height: 420px;
    font-size: 0.78rem;
  }
}
