:root {
  color-scheme: dark;
  --bg: #17110c;
  --panel: #211811;
  --panel-2: #2d2116;
  --text: #f3ead8;
  --muted: #c6b697;
  --line: #5b432c;
  --wall: #3a2113;
  --floor: #c59b67;
  --floor-2: #d7b27c;
  --accent: #8fdc8f;
  --warn: #e1b35d;
  --bad: #d66a55;
  --max: 1180px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, rgba(197, 155, 103, 0.08), transparent 420px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 80px),
    var(--bg);
  color: var(--text);
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", Meiryo, system-ui, sans-serif;
  line-height: 1.65;
}

a {
  color: inherit;
}

button,
select,
input {
  font: inherit;
}

.sim-header,
main,
.sim-footer {
  width: min(var(--max), calc(100% - 32px));
  margin: 0 auto;
}

.sim-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-height: 72px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.brand,
.sim-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  font-weight: 700;
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--warn);
  background: rgba(45, 33, 22, 0.72);
  color: var(--warn);
  font-family: Consolas, "Courier New", monospace;
}

.brand strong,
.brand small,
.hero p span,
h2 span,
h2 small,
.notes-panel p span {
  display: block;
}

.brand small,
.sim-nav a,
.kicker,
.sim-stats,
button,
.sim-footer,
.event-log,
.hint {
  font-family: Consolas, "Courier New", monospace;
}

.brand small {
  color: var(--muted);
  font-size: 0.72rem;
}

.sim-nav {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.sim-nav a {
  color: var(--muted);
  font-size: 0.82rem;
  text-decoration: none;
}

.sim-nav a:hover,
.sim-footer a:hover {
  color: var(--warn);
}

.hero,
.sim-layout,
.log-panel,
.notes-panel {
  margin-top: 34px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 280px);
  gap: 24px;
  align-items: end;
  padding: clamp(36px, 7vw, 76px) 0 22px;
}

.kicker {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.78rem;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(3rem, 8vw, 6.6rem);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  font-size: clamp(1.5rem, 3vw, 2.45rem);
  line-height: 1.18;
}

h2 small,
.hero p span + span,
.notes-panel p span + span {
  margin-top: 6px;
  color: var(--warn);
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.95rem;
  font-weight: 500;
}

.hero p {
  max-width: 760px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 1.04rem;
}

.meter-card {
  display: grid;
  gap: 8px;
}

.meter-card span {
  border-left: 3px solid var(--warn);
  background: rgba(45, 33, 22, 0.8);
  padding: 8px 10px;
  color: var(--text);
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.82rem;
}

.sim-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  gap: 16px;
  align-items: start;
}

.map-panel,
.panel,
.log-panel,
.notes-panel {
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(143, 220, 143, 0.035), transparent 42%),
    rgba(33, 24, 17, 0.92);
}

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

.panel-head,
.sim-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.panel-head {
  justify-content: space-between;
  margin-bottom: 16px;
}

.sim-stats span {
  border: 1px solid rgba(197, 155, 103, 0.38);
  padding: 4px 8px;
  color: var(--warn);
  font-size: 0.78rem;
}

.canvas-shell {
  overflow: auto;
  border: 1px solid rgba(225, 179, 93, 0.34);
  background: #0e0b08;
  padding: 10px;
}

#shelterCanvas {
  display: block;
  width: min(100%, 960px);
  aspect-ratio: 10 / 7;
  image-rendering: pixelated;
  cursor: crosshair;
  touch-action: none;
}

.control-stack {
  display: grid;
  gap: 16px;
}

.mode-row,
.room-palette,
.button-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.mode-row {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 10px;
}

button {
  display: inline-grid;
  place-items: center;
  gap: 2px;
  min-height: 40px;
  border: 1px solid rgba(243, 234, 216, 0.22);
  background: rgba(23, 17, 12, 0.72);
  color: var(--text);
  padding: 8px 10px;
  font-weight: 700;
  cursor: pointer;
}

button span,
button small {
  display: block;
  line-height: 1.15;
}

button small {
  color: var(--muted);
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", Meiryo, system-ui, sans-serif;
  font-size: 0.7rem;
  font-weight: 500;
}

button:hover,
button.is-active {
  border-color: var(--accent);
  color: var(--accent);
}

button[data-mode="delete"].is-active {
  border-color: var(--bad);
  color: var(--bad);
}

button[data-mode="select"].is-active {
  border-color: var(--warn);
  color: var(--warn);
}

.hint {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.78rem;
}

.inspector-panel h3 {
  margin: 0 0 12px;
  color: var(--warn);
  font-family: Consolas, "Courier New", monospace;
  font-size: 1.05rem;
}

.inspect-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.inspect-list > div {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 10px;
  border-bottom: 1px solid rgba(91, 67, 44, 0.62);
  padding-bottom: 7px;
}

.inspect-list dt,
.inspect-list dd {
  margin: 0;
}

.inspect-list dt {
  color: var(--muted);
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.76rem;
  text-transform: uppercase;
}

.inspect-list dd {
  color: var(--text);
  overflow-wrap: anywhere;
}

.priority-row {
  align-items: center;
}

.priority-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.priority-controls button {
  min-height: 34px;
  padding: 6px;
  font-size: 0.72rem;
}

.resource-list {
  display: grid;
  gap: 12px;
}

.resource-list label {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr) 38px;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.84rem;
}

meter {
  width: 100%;
  height: 16px;
}

#threatMeter::-webkit-meter-optimum-value {
  background: var(--bad);
}

.section-head {
  margin-bottom: 16px;
}

.event-log {
  display: grid;
  gap: 8px;
  max-height: 300px;
  overflow: auto;
  padding: 0;
  margin: 0;
  list-style: none;
}

.event-log li {
  border-bottom: 1px solid rgba(91, 67, 44, 0.7);
  padding: 8px 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.notes-panel {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 24px;
}

.notes-panel p {
  color: var(--muted);
}

.sim-footer {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 26px 0 40px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.sim-footer a {
  color: var(--muted);
  text-decoration: none;
}

@media (max-width: 900px) {
  .sim-header,
  .hero,
  .sim-layout,
  .notes-panel {
    grid-template-columns: 1fr;
  }

  .sim-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .sim-nav {
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  .sim-header,
  main,
  .sim-footer {
    width: min(100% - 20px, var(--max));
  }

  h1 {
    font-size: clamp(2.7rem, 15vw, 4rem);
  }

  .room-palette,
  .mode-row,
  .button-grid {
    grid-template-columns: 1fr;
  }

  .sim-footer {
    flex-direction: column;
  }
}
