:root {
  color-scheme: dark;
  --bg: #0f1110;
  --stone: #181c1b;
  --panel: #1e2321;
  --panel-2: #252a27;
  --line: #384039;
  --text: #f6f0e4;
  --muted: #b9b09f;
  --dim: #7f887f;
  --green: #81c784;
  --teal: #6ec6c4;
  --gold: #e3b35f;
  --red: #df735e;
  --blue: #86a7d7;
  --shadow: rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(129, 199, 132, 0.12), transparent 28rem),
    linear-gradient(180deg, #101110 0%, #151816 45%, #0d0f0e 100%);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button {
  min-height: 2.5rem;
  border: 1px solid rgba(246, 240, 228, 0.14);
  border-radius: 8px;
  background: #30362f;
  color: var(--text);
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: rgba(227, 179, 95, 0.65);
  background: #3a4138;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.game-shell {
  height: 100svh;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(420px, 0.95fr) minmax(300px, 380px);
  gap: 1rem;
  padding: 1rem;
}

.dungeon-stage,
.control-board,
.side-panel {
  min-width: 0;
  min-height: 0;
  border: 1px solid rgba(246, 240, 228, 0.11);
  border-radius: 8px;
  background: rgba(24, 28, 27, 0.92);
  box-shadow: 0 20px 70px var(--shadow);
}

.dungeon-stage {
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid rgba(246, 240, 228, 0.1);
}

.eyebrow,
.label {
  margin: 0;
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 2.2rem;
  line-height: 1;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
}

h3 {
  margin-bottom: 0.35rem;
  font-size: 1rem;
}

p {
  color: var(--muted);
  line-height: 1.45;
}

.run-clock {
  min-width: 6.5rem;
  text-align: right;
}

.run-clock span {
  display: block;
  font-variant-numeric: tabular-nums;
  font-size: 1.4rem;
  font-weight: 850;
}

.run-clock small {
  color: var(--muted);
}

.scene-wrap {
  display: grid;
  grid-template-rows: minmax(20rem, 1fr) auto;
}

.dungeon-scene {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(15, 17, 16, 0.9), transparent 25%, transparent 75%, rgba(15, 17, 16, 0.9)),
    repeating-linear-gradient(90deg, #202521 0 2rem, #1a1e1b 2rem 4rem);
}

.arch {
  position: absolute;
  left: 50%;
  bottom: -6rem;
  transform: translateX(-50%);
  border: 1.2rem solid rgba(87, 96, 86, 0.36);
  border-bottom: 0;
  border-radius: 50% 50% 0 0;
}

.arch-back {
  width: 78%;
  height: 76%;
  opacity: 0.45;
}

.arch-mid {
  width: 58%;
  height: 58%;
  opacity: 0.65;
}

.arch-front {
  width: 36%;
  height: 40%;
  opacity: 0.9;
}

.floor-glow {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 4rem;
  height: 4rem;
  background: linear-gradient(90deg, transparent, rgba(227, 179, 95, 0.35), transparent);
  filter: blur(0.6rem);
}

.lantern {
  position: absolute;
  left: 48%;
  bottom: 5.4rem;
  width: 1.2rem;
  height: 2rem;
  border: 2px solid #e3b35f;
  border-radius: 0.4rem;
  background: rgba(227, 179, 95, 0.28);
  box-shadow: 0 0 2rem rgba(227, 179, 95, 0.8);
}

.safe-room {
  position: absolute;
  left: 12%;
  bottom: 5.2rem;
  width: 5rem;
  height: 6rem;
  border: 0.45rem solid #4c554d;
  border-radius: 8px 8px 2px 2px;
  background: #171a18;
  opacity: 0.38;
}

.safe-room.restored {
  border-color: var(--teal);
  background: rgba(110, 198, 196, 0.16);
  box-shadow: 0 0 2rem rgba(110, 198, 196, 0.28);
  opacity: 1;
}

.maw {
  position: absolute;
  right: 13%;
  bottom: 5rem;
  width: 5.5rem;
  height: 4rem;
  border-radius: 48% 48% 42% 42%;
  background: #2c2421;
  border: 0.25rem solid #5b3930;
  opacity: 0;
  transform: scale(0.85);
  transition: 180ms ease;
}

.maw.visible {
  opacity: 1;
  transform: scale(1);
}

.maw.defeated {
  opacity: 0.45;
  filter: grayscale(0.65);
}

.maw span {
  position: absolute;
  left: 18%;
  right: 18%;
  top: 42%;
  height: 0.5rem;
  border-radius: 999px;
  background: var(--red);
  box-shadow: 0 0 1rem rgba(223, 115, 94, 0.42);
}

.floor-readout {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr 1fr;
  gap: 0.75rem;
  align-items: center;
  padding: 1rem;
  background: rgba(15, 17, 16, 0.62);
  border-top: 1px solid rgba(246, 240, 228, 0.1);
}

.meter,
.action-meter {
  height: 0.75rem;
  overflow: hidden;
  border: 1px solid rgba(246, 240, 228, 0.12);
  border-radius: 999px;
  background: #111411;
}

.meter span,
.action-meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--gold));
  transition: width 160ms linear;
}

.control-board {
  display: grid;
  grid-template-rows: auto auto 1fr;
  min-height: 42rem;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.35rem;
  padding: 0.75rem;
  border-bottom: 1px solid rgba(246, 240, 228, 0.1);
}

.tab {
  min-width: 0;
  padding-inline: 0.5rem;
  background: #202620;
  color: var(--muted);
}

.tab.active {
  color: var(--text);
  border-color: rgba(110, 198, 196, 0.65);
  background: #28332f;
}

.status-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(8rem, 14rem);
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(246, 240, 228, 0.1);
}

.tab-panel {
  display: none;
  padding: 1rem;
  overflow: auto;
}

.tab-panel.active {
  display: block;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
  margin-bottom: 1rem;
}

.section-heading p {
  max-width: 30rem;
  margin-bottom: 0;
  font-size: 0.9rem;
}

.section-heading.compact {
  align-items: center;
  margin-bottom: 0.65rem;
}

.action-grid {
  display: grid;
  gap: 0.75rem;
}

.action-card,
.project-card,
.boss-box,
.guild-card {
  display: grid;
  gap: 0.75rem;
  padding: 0.9rem;
  border: 1px solid rgba(246, 240, 228, 0.1);
  border-radius: 8px;
  background: rgba(37, 42, 39, 0.72);
}

.action-card p,
.guild-card p,
.project-card p {
  margin-bottom: 0;
  font-size: 0.9rem;
}

.reward-line {
  color: var(--dim);
  font-size: 0.82rem;
}

.cost-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.cost-list li {
  color: var(--muted);
  font-size: 0.85rem;
}

.cost-list .met {
  color: var(--green);
}

.boss-actions {
  display: grid;
  gap: 0.6rem;
}

.side-panel {
  display: grid;
  grid-template-rows: auto auto auto minmax(14rem, 1fr);
  gap: 0;
  overflow: hidden;
}

.panel-section {
  padding: 1rem;
  border-bottom: 1px solid rgba(246, 240, 228, 0.1);
}

.log-section {
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
}

.item-chip,
.skill-row,
.dossier-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  background: rgba(15, 17, 16, 0.56);
  color: var(--muted);
  font-size: 0.85rem;
}

.item-chip strong,
.skill-row strong,
.dossier-row strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.skills-list,
.dossier {
  display: grid;
  gap: 0.4rem;
}

.event-log {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 0.5rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.event-log li {
  padding: 0.55rem 0.65rem;
  border-left: 3px solid rgba(227, 179, 95, 0.7);
  border-radius: 0 6px 6px 0;
  background: rgba(15, 17, 16, 0.56);
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.event-log strong {
  color: var(--text);
}

.quiet-button {
  min-height: 2rem;
  padding-inline: 0.7rem;
  background: transparent;
  color: var(--muted);
}

.resolved-banner {
  padding: 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(129, 199, 132, 0.42);
  background: rgba(129, 199, 132, 0.11);
  color: var(--text);
}

@media (max-width: 1160px) {
  .game-shell {
    grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  }

  .dungeon-stage {
    grid-column: 1 / -1;
  }
}

@media (max-width: 780px) {
  body {
    overflow: auto;
  }

  .game-shell {
    height: auto;
    overflow: visible;
    grid-template-columns: 1fr;
    padding: 0.6rem;
  }

  .floor-readout,
  .status-strip,
  .section-heading {
    grid-template-columns: 1fr;
    display: grid;
  }

  .tabs {
    grid-template-columns: repeat(3, 1fr);
  }

  .inventory-grid,
  .cost-list {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 1.7rem;
  }
}
