:root {
  color-scheme: dark;
  font-family: "Courier New", ui-monospace, monospace;
  background: #050806;
  color: #f3ead0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 15%, rgba(62, 104, 82, 0.28), transparent 42%),
    linear-gradient(180deg, #07130d 0%, #030504 100%);
}

#app {
  position: relative;
  width: min(100vw, 960px);
  aspect-ratio: 16 / 10;
  max-height: 100vh;
  overflow: hidden;
  background: #07130d;
  border: 1px solid #2a3d2e;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#hud {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 10px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

#topActions {
  position: absolute;
  top: 46px;
  right: 12px;
  display: flex;
  gap: 8px;
  z-index: 30;
}

#topActions button {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 11px;
}

.title-mode #hud,
.title-mode #topActions,
.title-mode #musicToggle,
.hide-game-ui #hud,
.hide-game-ui #topActions,
.hide-game-ui #musicToggle {
  display: none;
}

.hide-html-overlays #panel,
.hide-html-overlays #battle,
.hide-html-overlays #inventory,
.hide-html-overlays #skilltree {
  display: none;
}

.party,
.status {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.hero-pill,
.status span {
  min-height: 28px;
  padding: 6px 9px;
  background: rgba(7, 18, 12, 0.82);
  border: 1px solid rgba(217, 196, 132, 0.28);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
  color: #eadcae;
  font-size: 11px;
  line-height: 1.25;
  white-space: nowrap;
}

.hero-pill b {
  color: #fff8cf;
}

.panel,
.battle,
.inventory,
.skilltree {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  background: rgba(6, 12, 9, 0.93);
  border: 1px solid rgba(230, 210, 140, 0.42);
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.panel {
  min-height: 132px;
  padding: 18px 20px;
  font-size: 16px;
  line-height: 1.45;
  color: #11140f;
  background: rgba(214, 214, 208, 0.72);
  border-color: rgba(40, 44, 36, 0.38);
}

.panel h1,
.panel h2,
.skilltree h2 {
  margin: 0 0 8px;
  font-size: 18px;
  letter-spacing: 0;
}

.panel h1,
.panel h2 {
  color: #11140f;
}

.skilltree h2 {
  color: #fff0b8;
}

.panel p {
  margin: 5px 0;
  max-width: 78ch;
  color: #11140f;
}

.dialogue-layout {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.dialogue-portrait {
  width: 104px;
  height: 104px;
  object-fit: cover;
  image-rendering: pixelated;
  border: 1px solid rgba(230, 210, 140, 0.42);
  background: rgba(16, 29, 20, 0.8);
}

.dialogue-copy {
  min-width: 0;
  color: #11140f;
}

.tutorial-list {
  margin: 7px 0 0;
  padding-left: 22px;
  max-width: 82ch;
}

.tutorial-list li {
  margin: 5px 0;
}

.credits-scene {
  display: grid;
  place-items: center;
}

.credits-scene img {
  display: block;
  width: min(100%, 812px);
  max-height: 430px;
  object-fit: contain;
  border: 1px solid rgba(230, 210, 140, 0.42);
  background: #050806;
}

.muted {
  color: #a9b18e;
  font-size: 12px;
}

.panel .muted {
  color: #34382f;
}

.panel button {
  color: #11140f;
  background: rgba(232, 232, 224, 0.82);
  border-color: rgba(56, 61, 48, 0.55);
}

.panel button:hover,
.panel button:focus-visible {
  background: rgba(246, 246, 238, 0.94);
  outline-color: #11140f;
}

button {
  font: inherit;
  color: #fff5c7;
  background: #173421;
  border: 1px solid #c9a84f;
  box-shadow: 0 3px 0 #070a08;
  min-height: 34px;
  padding: 7px 11px;
  cursor: pointer;
}

button:hover,
button:focus-visible {
  background: #22502f;
  outline: 1px solid #ffe58a;
}

button:disabled {
  color: #68705d;
  border-color: #384235;
  background: #101812;
  cursor: default;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

.battle {
  top: 10px;
  bottom: auto;
  padding: 8px;
  min-height: 0;
  z-index: 35;
}

.battle-top-grid {
  display: grid;
  grid-template-columns: minmax(160px, 0.9fr) minmax(360px, 1.7fr) minmax(170px, 0.95fr);
  gap: 8px;
  align-items: start;
}

.battle-party-bars {
  display: grid;
  gap: 5px;
}

.battle-party-row {
  background: rgba(7, 18, 12, 0.86);
  border: 1px solid rgba(217, 196, 132, 0.28);
  padding: 5px 6px;
  color: #eadcae;
  font-size: 11px;
}

.battle-party-row b,
.battle-party-row span {
  display: block;
  margin-right: 0;
}

.battle-actions {
  min-width: 0;
}

.battle-actions h3 {
  margin: 0 0 3px;
  font-size: 14px;
  color: #fff0b8;
}

.battle-actions .row {
  margin-top: 5px;
  gap: 6px;
}

.battle-actions button {
  min-height: 26px;
  padding: 4px 7px;
  font-size: 11px;
}

.battle-meta {
  color: #c8d0ac;
  font-size: 11px;
}

.battle-wait {
  min-height: 26px;
  padding: 5px 7px;
  color: #ffd66f;
  background: rgba(72, 49, 18, 0.72);
  border: 1px solid rgba(255, 214, 111, 0.42);
  font-size: 11px;
}

.battle-side {
  display: grid;
  gap: 6px;
}

.battle-enemy,
.turn-order {
  background: rgba(7, 18, 12, 0.86);
  border: 1px solid rgba(217, 196, 132, 0.28);
  padding: 5px 6px;
  color: #eadcae;
  font-size: 11px;
}

.battle-enemy b,
.battle-enemy span,
.turn-order b,
.turn-order span {
  display: block;
}

.turn-order {
  max-height: 92px;
  overflow: hidden;
}

.battle-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.card {
  background: rgba(16, 29, 20, 0.8);
  border: 1px solid rgba(229, 203, 125, 0.22);
  padding: 9px;
}

.card h3 {
  margin: 0 0 7px;
  font-size: 14px;
  color: #fff0b8;
}

.hp {
  height: 6px;
  background: #1b201b;
  border: 1px solid #344332;
  margin: 4px 0 2px;
}

.hp i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #67c464, #d8dd5c);
}

.log {
  min-height: 28px;
  margin: 5px 0 0;
  color: #d7dec0;
  font-size: 12px;
}

.hidden {
  display: none;
}

.skilltree {
  top: 64px;
  bottom: 14px;
  padding: 14px;
  overflow: auto;
}

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

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

.skill-card {
  min-height: 120px;
}

.skill-card p {
  margin: 5px 0 10px;
  color: #bfc8a4;
  font-size: 12px;
  line-height: 1.35;
}

.ultimate-skill {
  background: #4b3514;
  border-color: #ffd66f;
  color: #fff3bf;
}

.ultimate-text {
  padding: 7px;
  background: rgba(126, 83, 20, 0.35);
  border-left: 3px solid #ffd66f;
  color: #ffe6a3;
}

.quest-list {
  display: grid;
  gap: 8px;
}

.quest-entry {
  padding: 9px;
  background: rgba(16, 29, 20, 0.8);
  border: 1px solid rgba(229, 203, 125, 0.22);
}

.quest-entry b {
  color: #ffe36f;
}

.quest-entry p {
  margin: 5px 0 0;
  font-size: 13px;
  color: #ffe36f;
}

.quest-entry.done {
  border-color: rgba(103, 196, 100, 0.55);
}

#musicToggle {
  position: absolute;
  right: 12px;
  bottom: 122px;
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 0;
}

@media (max-width: 700px) {
  #hud {
    left: 8px;
    right: 8px;
    top: 8px;
    align-items: flex-start;
  }

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

  .status {
    flex-direction: column;
    align-items: flex-end;
  }

  .hero-pill,
  .status span {
    font-size: 10px;
    padding: 5px 7px;
  }

  .panel {
    font-size: 12px;
  }

  .battle-grid,
  .battle-top-grid,
  .skill-grid {
    grid-template-columns: 1fr;
  }

  .battle {
    left: 8px;
    right: 8px;
  }
}
