:root {
  color-scheme: dark;
  --bg: #101016;
  --panel: #222431;
  --panel2: #2d3040;
  --line: #464958;
  --text: #f5f1e8;
  --muted: #b9b4a8;
  --gold: #e5b857;
  --mint: #8bd5b4;
  --red: #e66f5c;
  --blue: #73a8e8;
  --shadow: rgba(0, 0, 0, .34);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background:
    linear-gradient(180deg, rgba(115,168,232,.12), transparent 34%),
    linear-gradient(120deg, rgba(229,184,87,.10), transparent 42%),
    var(--bg);
  color: var(--text);
}

button, select { font: inherit; }
input { accent-color: var(--gold); }
select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #171922;
  color: var(--text);
  padding: 0 8px;
}
button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #343747;
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 2px 0 var(--shadow);
}

.button-link {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #343747;
  color: var(--text);
  padding: 0 14px;
  text-decoration: none;
  font-weight: 800;
  box-shadow: 0 2px 0 var(--shadow);
}
button:hover { border-color: var(--gold); }
button:disabled { cursor: not-allowed; opacity: .45; }

.app-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 14px;
}

.prototype-links {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 10px 14px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.prototype-links a {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #343747;
  color: var(--text);
  padding: 0 10px;
  text-decoration: none;
  font-weight: 800;
}

.prototype-links .brand-mark {
  gap: 10px;
}

.brand-mark img {
  width: 38px;
  height: 38px;
  object-fit: contain;
}

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

.brand h1 {
  margin: 0;
  font-size: clamp(1.55rem, 6vw, 2.4rem);
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--gold);
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(34,36,49,.86);
  padding: 8px;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
}
.stat strong { display: block; margin-top: 2px; font-size: 1.1rem; }

.screen-grid, .combat-grid {
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  gap: 12px;
}

.combat-grid { grid-template-columns: .9fr 1.1fr; }

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(34, 36, 49, .94);
  box-shadow: 0 10px 24px var(--shadow);
  overflow: hidden;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(45,48,64,.94);
}
.panel-header h2, .panel-header h3 { margin: 0; }
.panel-body { padding: 12px; }
.copy { margin: 0; color: var(--muted); line-height: 1.45; }

.choice-grid, .action-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.choice, .node, .shop-item, .card, .log-entry {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel2);
  padding: 10px;
}

.choice.selected {
  border-color: var(--gold);
  outline: 2px solid rgba(229,184,87,.28);
}
.choice h3, .shop-item h3 { margin: 0 0 5px; font-size: 1rem; }
.choice p, .shop-item p, .node p {
  margin: 0;
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.35;
}

.stat-builder {
  display: grid;
  gap: 8px;
}

.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel2);
  padding: 10px;
}

.stat-row strong,
.stat-row span {
  display: block;
}

.stat-row span {
  color: var(--gold);
  font-weight: 900;
}

.stat-row .small-actions {
  flex-wrap: nowrap;
}

.stat-row button {
  width: 42px;
}

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

.starter-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.starter-preview span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #171922;
  color: var(--muted);
  padding: 5px 8px;
  font-size: .78rem;
  font-weight: 800;
}

.generator-controls label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 800;
}

.generator-actions {
  margin: 10px 0;
}

.mock-spell {
  margin-bottom: 12px;
}

.start-button {
  width: 100%;
  margin-top: 12px;
  background: #66512a;
  border-color: var(--gold);
}

.city-art {
  min-height: 210px;
  display: grid;
  place-items: end center;
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(115,168,232,.22), rgba(16,16,22,.18)),
    repeating-linear-gradient(90deg, rgba(255,255,255,.04) 0 2px, transparent 2px 16px);
}

.pixel-city {
  width: min(440px, 100%);
  height: 150px;
  image-rendering: pixelated;
  position: relative;
}
.pixel-city span {
  position: absolute;
  bottom: 0;
  width: 16%;
  border: 4px solid #0b0b0f;
  background: #686b78;
}
.pixel-city span:nth-child(1) { left: 2%; height: 62%; background: #7d7a69; }
.pixel-city span:nth-child(2) { left: 18%; height: 84%; background: #596b75; }
.pixel-city span:nth-child(3) { left: 34%; height: 55%; background: #8a664c; }
.pixel-city span:nth-child(4) { left: 50%; height: 96%; background: #4e6774; }
.pixel-city span:nth-child(5) { left: 66%; height: 68%; background: #77656e; }
.pixel-city span:nth-child(6) { left: 82%; height: 45%; background: #766f55; }
.pixel-city span::before {
  content: "";
  position: absolute;
  left: 18%;
  right: 18%;
  top: 14px;
  height: 10px;
  background: var(--gold);
  box-shadow: 0 24px 0 var(--gold), 0 48px 0 var(--gold);
}

.map {
  min-height: 360px;
  position: relative;
  background:
    linear-gradient(90deg, transparent 49%, rgba(229,184,87,.15) 49% 51%, transparent 51%),
    linear-gradient(20deg, transparent 42%, rgba(115,168,232,.13) 42% 45%, transparent 45%),
    #191b24;
}
.node { position: absolute; width: 150px; }
.node.current { border-color: var(--mint); }
.node h3 { margin: 0 0 4px; font-size: 1rem; }
.node button { width: 100%; margin-top: 8px; }
.node-city { left: 4%; top: 34%; }
.node-dungeon { left: 42%; top: 6%; }
.node-lair { right: 4%; top: 38%; }
.node-temp { left: 42%; bottom: 5%; }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 900;
}

.enemy-stage { display: grid; gap: 10px; }
.sprite {
  height: 132px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #171922;
  position: relative;
  overflow: hidden;
}
.sprite::before {
  content: "";
  width: 82px;
  height: 82px;
  background: var(--red);
  box-shadow: 16px -16px 0 #7d3b40, -16px 16px 0 #a84d43, 0 44px 0 #2f2f36;
  image-rendering: pixelated;
}
.sprite.dragon::before {
  width: 110px;
  height: 78px;
  background: #906241;
  box-shadow: 34px -18px 0 #c69a54, -34px -10px 0 #574158, -52px 18px 0 #574158, 0 38px 0 #2f2f36;
}

.bars { display: grid; gap: 7px; }
.bar {
  height: 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #11131a;
  overflow: hidden;
}
.bar-fill { height: 100%; background: var(--red); }
.bar-fill.player { background: var(--mint); }

.hand {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.generated-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 9px;
}

.generated-card {
  min-height: 170px;
}

.featured-card {
  border-color: var(--gold);
}

.mini-json {
  max-height: 180px;
  overflow: auto;
  margin: 4px 0 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #11131a;
  color: var(--muted);
  padding: 8px;
  font-size: .72rem;
  line-height: 1.35;
  white-space: pre-wrap;
}

.json-output {
  max-height: 680px;
  overflow: auto;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #11131a;
  color: var(--muted);
  padding: 10px;
  font-size: .78rem;
  line-height: 1.45;
  white-space: pre-wrap;
}
.card {
  min-height: 142px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.card h3 { margin: 0; font-size: .98rem; }
.card p { margin: 0; color: var(--muted); font-size: .86rem; line-height: 1.3; }
.card button { margin-top: auto; }

.mana-row, .resource-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.roll-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.roll-controls label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 800;
}
.die {
  min-width: 62px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px;
  background: #171922;
  text-align: center;
}
.die strong { display: block; font-size: 1.35rem; }
.die.spent { opacity: .45; }
.die.crit {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(229, 184, 87, .22);
}

.die em {
  display: inline-flex;
  margin-top: 2px;
  color: var(--gold);
  font-style: normal;
  font-size: .68rem;
  font-weight: 950;
  letter-spacing: .08em;
}

.die button {
  width: 100%;
  min-height: 30px;
  margin-top: 6px;
  font-size: .78rem;
}

.adept-card {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #171922;
  padding: 10px;
}

.equipment-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.slot {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px;
  background: var(--panel2);
}

.slot span {
  display: block;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.slot strong {
  display: block;
  margin-top: 3px;
  font-size: .9rem;
}

.log {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
}
.log-entry { color: var(--muted); font-size: .9rem; }
.small-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.small-actions button { padding: 0 10px; }

@media (max-width: 820px) {
  .status-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .screen-grid, .combat-grid { grid-template-columns: 1fr; }
  .choice-grid, .action-grid { grid-template-columns: 1fr; }
  .map {
    display: grid;
    gap: 10px;
    min-height: 0;
    padding: 12px;
  }
  .node { position: static; width: 100%; }
  .hand { grid-template-columns: 1fr; }
  .roll-controls,
  .equipment-grid { grid-template-columns: 1fr; }
}
