:root {
  color-scheme: dark;
  --ink: #f4f0df;
  --muted: #b9c0a4;
  --panel: #17231b;
  --panel-2: #203222;
  --line: #3c5338;
  --field: #5fa447;
  --field-2: #6dbb51;
  --accent: #d8b35f;
  --danger: #c96b5f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: #101813;
  font-family: "Segoe UI", system-ui, sans-serif;
}

button,
input {
  font: inherit;
}

.app {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 18px;
  background: #18251b;
  border-bottom: 1px solid var(--line);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 26px;
  line-height: 1;
  letter-spacing: 0;
}

#versionBadge {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

h2 {
  margin-bottom: 12px;
  font-size: 18px;
  letter-spacing: 0;
}

p,
.stats,
.creature-row,
.log li {
  color: var(--muted);
}

.login {
  display: flex;
  gap: 8px;
}

input {
  width: 210px;
  min-height: 40px;
  padding: 0 12px;
  color: var(--ink);
  background: #0f1712;
  border: 1px solid var(--line);
  border-radius: 6px;
}

button {
  min-height: 40px;
  padding: 0 14px;
  color: #231b0c;
  font-weight: 700;
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 10px 18px;
  overflow-x: auto;
  background: #111b14;
  border-bottom: 1px solid var(--line);
}

.tab {
  min-width: 96px;
  color: var(--muted);
  background: #0f1712;
  border: 1px solid var(--line);
}

.tab.active {
  color: #231b0c;
  background: var(--accent);
  border-color: var(--accent);
}

.panel {
  display: none;
  min-height: 0;
  padding: 16px;
  overflow: auto;
  background: var(--panel);
}

.panel.active {
  display: block;
}

.map-panel.active {
  display: grid;
}

.map-wrap {
  display: grid;
  place-items: start center;
  min-height: 0;
}

canvas {
  width: min(100%, calc((100vh - 142px) * 1.5));
  max-height: calc(100vh - 142px);
  aspect-ratio: 3 / 2;
  image-rendering: pixelated;
  border: 1px solid #6f8c4d;
  background: var(--field);
}

.status,
.creatures,
.log {
  max-width: 1040px;
  width: 100%;
  margin: 0 auto;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(130px, 1fr));
  gap: 10px;
  font-size: 13px;
}

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

.section-head h2 {
  margin-bottom: 0;
}

.stats span,
.player-card,
.creature-row {
  padding: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.stats strong {
  display: block;
  color: var(--ink);
  font-size: 22px;
}

.player-card {
  margin-top: 12px;
  color: var(--muted);
}

.hidden {
  display: none;
}

.creature-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}

.creature-row {
  display: grid;
  gap: 6px;
  font-size: 13px;
}

.creature-row strong {
  color: var(--ink);
  text-transform: capitalize;
}

.creature-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  color: var(--ink);
  font-size: 12px;
}

.xp-line {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.creature-meta span {
  padding: 5px 6px;
  background: #101813;
  border-radius: 4px;
}

.meters {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 5px;
}

.meter {
  height: 7px;
  overflow: hidden;
  background: #0f1712;
  border-radius: 999px;
}

.meter span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.meter.health span {
  background: #85ca6f;
}

.meter.hunger span {
  background: #d8b35f;
}

.meter.rest span {
  background: #76a7d8;
}

.meter.xp span {
  background: #cf8ee8;
}

.log ol {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.log li {
  padding: 9px 10px;
  font-size: 13px;
  line-height: 1.35;
  background: #101813;
  border-left: 3px solid var(--accent);
  border-radius: 4px;
}

@media (max-width: 760px) {
  .topbar,
  .login {
    align-items: stretch;
    flex-direction: column;
  }

  input {
    width: 100%;
  }

  .tabs {
    padding: 8px;
  }

  .tab {
    min-width: 88px;
  }

  .panel {
    padding: 10px;
  }

  canvas {
    width: 100%;
    max-height: calc(100vh - 188px);
  }

  .stats {
    grid-template-columns: 1fr;
  }
}
