:root {
  color-scheme: dark;
  font-family:
    "Trebuchet MS",
    "Segoe UI",
    system-ui,
    sans-serif;
  background: #15100d;
  color: #f8efe1;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  height: 100dvh;
  overflow: hidden;
  display: grid;
  place-items: center;
  background:
    linear-gradient(180deg, rgba(19, 15, 12, 0.86), rgba(19, 15, 12, 0.96)),
    #15100d;
}

#game-shell {
  width: min(100vw, 1280px);
  height: 100dvh;
  max-height: 100dvh;
  padding: 18px;
  display: grid;
  place-items: center;
}

#game-wrap {
  position: relative;
  width: min(100%, 1180px, calc((100dvh - 36px) * 4 / 3));
  aspect-ratio: 4 / 3;
  margin: 0 auto;
  border: 1px solid rgba(255, 238, 204, 0.2);
  background: #0c0a09;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.48);
  overflow: hidden;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: auto;
}

.hud {
  position: absolute;
  left: 18px;
  top: 14px;
  z-index: 5;
  width: min(320px, calc(100% - 36px));
  pointer-events: none;
}

.quest,
.prompt,
.dialogue,
.battle-hud,
.reward-panel,
.system-panel,
.map-panel {
  border: 1px solid rgba(72, 46, 24, 0.76);
  background: rgba(32, 22, 15, 0.86);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.32);
}

.quest {
  width: 100%;
  padding: 10px 12px;
  background: rgba(28, 20, 14, 0.76);
}

.quest .label {
  display: block;
  color: #d3a35d;
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

#quest-text {
  display: block;
  margin-top: 2px;
  font-size: 17px;
  line-height: 1.25;
}

.prompt {
  position: absolute;
  left: 50%;
  bottom: 226px;
  transform: translateX(-50%);
  z-index: 6;
  max-width: min(260px, calc(100% - 20px));
  padding: 8px 13px;
  color: #fff3d1;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  overflow-wrap: anywhere;
  border-radius: 2px;
  pointer-events: none;
}

.location-banner {
  position: absolute;
  left: 50%;
  top: 18px;
  z-index: 7;
  min-width: 260px;
  transform: translateX(-50%);
  padding: 9px 18px;
  color: #fff4df;
  font-size: 18px;
  font-weight: 900;
  text-align: center;
  background: rgba(22, 15, 10, 0.86);
  border-top: 1px solid rgba(255, 241, 197, 0.48);
  border-bottom: 1px solid rgba(255, 241, 197, 0.48);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.34);
}

.location-banner.leaving {
  opacity: 0;
  transform: translate(-50%, -8px);
  transition:
    opacity 0.45s ease,
    transform 0.45s ease;
}

.battle-hud {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 20px;
  z-index: 6;
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 12px;
  padding: 12px;
}

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

.party-card {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 8px;
  align-items: center;
  padding: 8px;
  background: rgba(15, 12, 10, 0.58);
  border: 1px solid rgba(237, 204, 142, 0.28);
}

.party-name {
  color: #fff3d1;
  font-weight: 800;
  line-height: 1.1;
}

.party-level {
  display: block;
  color: #9ed3cf;
  font-size: 12px;
  font-weight: 700;
}

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

.battle-bar {
  height: 10px;
  overflow: hidden;
  background: #24170f;
  border: 1px solid rgba(255, 238, 204, 0.2);
}

.battle-bar span {
  display: block;
  height: 100%;
  width: 0%;
  transition: width 0.18s ease;
}

.hp-bar span {
  background: linear-gradient(90deg, #be4d35, #ec9564);
}

.atb-bar span {
  background: linear-gradient(90deg, #3b8580, #b9efe0);
}

.xp-bar span {
  background: linear-gradient(90deg, #7865bd, #d1c1ff);
}

.battle-console {
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 8px;
  min-width: 0;
}

.battle-status {
  min-height: 25px;
  padding: 4px 8px;
  color: #9ed3cf;
  font-size: 14px;
  font-weight: 800;
  background: rgba(8, 7, 6, 0.34);
  border: 1px solid rgba(134, 203, 195, 0.22);
}

.battle-log {
  min-height: 74px;
  padding: 10px 12px;
  color: #fff4df;
  font-size: 16px;
  line-height: 1.32;
  background: rgba(8, 7, 6, 0.5);
  border: 1px solid rgba(237, 204, 142, 0.22);
}

.battle-targets,
.battle-commands {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.battle-targets button,
.battle-commands button {
  min-height: 38px;
  padding: 8px 12px;
  color: #f8efe1;
  font: inherit;
  font-size: 15px;
  font-weight: 800;
  background: #263b3a;
  border: 1px solid rgba(134, 203, 195, 0.48);
  cursor: pointer;
}

.battle-targets button {
  display: grid;
  gap: 2px;
  max-width: 230px;
  text-align: left;
}

.battle-targets button span {
  color: #cbb79a;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}

.battle-targets button:disabled,
.battle-commands button:disabled {
  opacity: 0.42;
  cursor: default;
}

.battle-targets button:not(:disabled):hover,
.battle-commands button:not(:disabled):hover,
.battle-targets button:not(:disabled):focus-visible,
.battle-commands button:not(:disabled):focus-visible {
  background: #365754;
  outline: 2px solid rgba(255, 244, 223, 0.75);
  outline-offset: 1px;
}

.battle-commands button.active {
  background: #8a3d27;
  border-color: #fff1c5;
}

.reward-screen,
.system-screen,
.valve-screen {
  position: absolute;
  inset: 0;
  z-index: 9;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 50% 44%, rgba(31, 53, 50, 0.24), transparent 42%),
    rgba(9, 8, 7, 0.68);
}

.reward-panel,
.system-panel,
.valve-panel {
  width: min(92%, 900px);
  max-height: min(88%, 680px);
  overflow: auto;
  padding: 0;
  background:
    linear-gradient(180deg, rgba(35, 54, 49, 0.98), rgba(18, 23, 24, 0.99)),
    #141b1b;
  border: 2px solid rgba(229, 194, 119, 0.64);
  box-shadow:
    inset 0 0 0 2px rgba(14, 9, 7, 0.74),
    inset 0 0 0 4px rgba(106, 159, 151, 0.16),
    0 24px 64px rgba(0, 0, 0, 0.52);
}

.reward-panel {
  width: min(90%, 640px);
  padding: 16px;
}

.valve-panel {
  width: min(92%, 760px);
  padding: 16px;
}

.panel-kicker {
  display: block;
  color: #73b7b2;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.reward-panel h2,
.system-panel h2,
.valve-panel h2 {
  margin: 2px 0 0;
  color: #fff4df;
  font-size: 25px;
  line-height: 1.12;
}

.reward-summary {
  display: grid;
  gap: 8px;
  margin: 12px 0 16px;
}

.reward-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.reward-line,
.inventory-row,
.character-card,
.save-row,
.gear-card {
  padding: 10px 12px;
  color: #f8efe1;
  background: rgba(10, 8, 7, 0.48);
  border: 1px solid rgba(237, 204, 142, 0.2);
}

.reward-line.common {
  border-color: rgba(220, 220, 210, 0.34);
}

.reward-line.uncommon {
  border-color: rgba(83, 205, 123, 0.5);
  color: #bbefc5;
}

.reward-line.rare {
  border-color: rgba(98, 150, 255, 0.58);
  color: #c4d8ff;
}

.reward-line.epic {
  border-color: rgba(184, 119, 255, 0.65);
  color: #e3c5ff;
}

.system-header,
.system-actions,
.valve-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.system-header {
  align-items: center;
  padding: 14px 16px 12px;
  background:
    linear-gradient(90deg, rgba(134, 203, 195, 0.18), transparent 58%),
    rgba(6, 10, 10, 0.42);
  border-bottom: 1px solid rgba(229, 194, 119, 0.36);
}

.system-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.system-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin: 0;
  padding: 10px 16px;
  background: rgba(8, 10, 10, 0.34);
  border-bottom: 1px solid rgba(237, 204, 142, 0.2);
}

.system-tabs button,
.system-actions button,
.reward-panel button,
.valve-header button,
.valve-controls button {
  min-height: 36px;
  padding: 7px 11px;
  color: #f8efe1;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  background: #253d3b;
  border: 1px solid rgba(134, 203, 195, 0.48);
  cursor: pointer;
}

.system-actions button {
  min-width: 42px;
}

.system-tabs button {
  border-radius: 0;
  background: rgba(16, 28, 28, 0.68);
  border-color: rgba(229, 194, 119, 0.26);
}

.system-tabs button:disabled,
.system-actions button:disabled,
.reward-panel button:disabled,
.valve-controls button:disabled {
  opacity: 0.42;
  cursor: default;
}

.system-tabs button.active {
  color: #1b1410;
  background: #dfb96d;
  border-color: #fff1c5;
}

.system-tabs button:hover,
.system-actions button:hover,
.reward-panel button:hover,
.valve-header button:hover,
.valve-controls button:hover,
.system-tabs button:focus-visible,
.system-actions button:focus-visible,
.reward-panel button:focus-visible,
.valve-header button:focus-visible,
.valve-controls button:focus-visible {
  background: #365754;
  outline: 2px solid rgba(255, 244, 223, 0.75);
  outline-offset: 1px;
}

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

.valve-gauge {
  min-width: 0;
  padding: 12px;
  background: rgba(10, 8, 7, 0.48);
  border: 1px solid rgba(237, 204, 142, 0.22);
}

.valve-gauge span,
.valve-gauge small {
  display: block;
  color: #cbb79a;
  font-size: 13px;
  font-weight: 800;
}

.valve-gauge strong {
  display: block;
  margin: 2px 0 8px;
  color: #fff4df;
  font-size: 34px;
  line-height: 1;
}

.valve-bar {
  height: 14px;
  margin-bottom: 7px;
  overflow: hidden;
  background: #21150f;
  border: 1px solid rgba(255, 238, 204, 0.2);
}

.valve-bar span {
  display: block;
  width: 0%;
  height: 100%;
  transition: width 0.22s ease;
}

.valve-bar.pressure span {
  background: linear-gradient(90deg, #b13e2f, #e5b861);
}

.valve-bar.flow span {
  background: linear-gradient(90deg, #2f8078, #b9efe0);
}

.valve-bar.vibration span {
  background: linear-gradient(90deg, #8361bd, #e2c2ff);
}

.valve-feedback {
  min-height: 58px;
  margin: 12px 0;
  padding: 11px 12px;
  color: #fff4df;
  font-size: 16px;
  line-height: 1.35;
  background: rgba(8, 7, 6, 0.5);
  border: 1px solid rgba(134, 203, 195, 0.28);
}

.valve-feedback.warning {
  border-color: rgba(229, 184, 97, 0.72);
  color: #ffe4a8;
}

.valve-feedback.failure {
  border-color: rgba(205, 82, 62, 0.74);
  color: #ffc7b8;
}

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

.valve-controls button.primary {
  background: #8a3d27;
  border-color: #fff1c5;
}

.system-content {
  display: grid;
  gap: 10px;
  padding: 14px 16px 16px;
}

.inventory-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-height: 58px;
  background:
    linear-gradient(90deg, rgba(134, 203, 195, 0.08), transparent 36%),
    rgba(8, 9, 9, 0.58);
  border-color: rgba(229, 194, 119, 0.28);
}

.inventory-row > span {
  min-width: 0;
}

.inventory-row > span:last-child,
.menu-value {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  color: #ffe8b9;
  font-weight: 900;
  text-align: right;
}

.inventory-row button,
.save-row button {
  min-height: 30px;
  padding: 5px 9px;
  color: #f8efe1;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  background: #263b3a;
  border: 1px solid rgba(134, 203, 195, 0.48);
  cursor: pointer;
}

.inventory-row button:hover,
.save-row button:hover {
  background: #365754;
}

.inventory-row button:disabled,
.save-row button:disabled {
  opacity: 0.42;
  cursor: default;
}

.inventory-row button:disabled:hover,
.save-row button:disabled:hover {
  background: #263b3a;
}

.inventory-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.inventory-item-art {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  object-fit: cover;
  border: 1px solid rgba(229, 194, 119, 0.38);
  border-radius: 6px;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.24);
}

.inventory-meta {
  color: #b9c9bd;
  font-size: 13px;
  line-height: 1.28;
}

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

.gear-card {
  display: grid;
  gap: 4px;
  background:
    linear-gradient(135deg, rgba(111, 68, 37, 0.24), transparent 58%),
    rgba(8, 9, 9, 0.58);
  border-color: rgba(134, 203, 195, 0.3);
}

.gear-card strong {
  color: #fff1c5;
}

.gear-card span,
.gear-card small {
  color: #c6d6c9;
}

.menu-note {
  color: #d9c696;
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  background: rgba(49, 35, 21, 0.46);
  border-color: rgba(229, 194, 119, 0.34);
}

.save-slot {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.status-pill {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 6px;
  color: #1f140c;
  font-size: 11px;
  font-weight: 900;
  background: #f0dcaa;
}

.inventory-row .rarity {
  font-weight: 800;
  text-transform: uppercase;
}

.inventory-row .rarity.common {
  color: #d9d8cf;
}

.inventory-row .rarity.uncommon {
  color: #90e89f;
}

.inventory-row .rarity.rare {
  color: #9dbdff;
}

.inventory-row .rarity.epic {
  color: #d9adff;
}

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

.character-card {
  display: grid;
  gap: 10px;
  background:
    linear-gradient(135deg, rgba(134, 203, 195, 0.12), transparent 45%),
    rgba(8, 9, 9, 0.6);
  border-color: rgba(229, 194, 119, 0.32);
}

.character-card h3 {
  margin: 0;
  color: #fff3d1;
  font-size: 21px;
}

.character-card-top {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.character-token {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  color: #111817;
  font-size: 27px;
  font-weight: 900;
  background:
    radial-gradient(circle at 34% 28%, #fff1c5, #cfaa62 58%, #6b3f24);
  border: 2px solid rgba(255, 241, 197, 0.72);
  box-shadow:
    inset 0 -8px 14px rgba(69, 31, 15, 0.28),
    0 8px 18px rgba(0, 0, 0, 0.24);
}

.level-badge {
  padding: 5px 8px;
  color: #16100d;
  background: #dfb96d;
  border: 1px solid rgba(255, 241, 197, 0.72);
}

.character-card p {
  margin: -2px 0 0;
  color: #c6d6c9;
  font-size: 13px;
  line-height: 1.35;
}

.character-role {
  color: #73b7b2;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.meter-line {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 74px;
  align-items: center;
  gap: 8px;
  color: #e7d3b5;
  font-size: 13px;
  font-weight: 800;
}

.stat-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px 12px;
  color: #e7d3b5;
  font-size: 14px;
}

.stat-list span,
.equipment-list span {
  color: #90c8c1;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.stat-list strong,
.equipment-list strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.equipment-list {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 6px 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(237, 204, 142, 0.2);
  color: #e7d3b5;
  font-size: 14px;
}

.toast {
  position: absolute;
  left: 50%;
  top: 92px;
  z-index: 12;
  transform: translateX(-50%);
  padding: 9px 13px;
  color: #fff4df;
  font-weight: 800;
  background: rgba(25, 43, 40, 0.94);
  border: 1px solid rgba(134, 203, 195, 0.58);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.32);
}

.map-overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 50% 50%, rgba(15, 12, 9, 0.2), rgba(6, 5, 4, 0.74)),
    rgba(9, 8, 7, 0.58);
}

.map-panel {
  width: min(94%, 980px);
  height: min(90%, 700px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
  padding: 18px;
  color: #332116;
  background:
    linear-gradient(90deg, rgba(89, 51, 28, 0.2), transparent 13%, transparent 87%, rgba(89, 51, 28, 0.22)),
    radial-gradient(circle at 18% 12%, rgba(255, 239, 192, 0.56), transparent 26%),
    linear-gradient(135deg, #d8bc82, #b98955 52%, #7f4a2d);
  border: 5px solid #3a2113;
  box-shadow:
    inset 0 0 0 2px rgba(255, 235, 177, 0.24),
    inset 0 0 38px rgba(60, 30, 12, 0.36),
    0 26px 60px rgba(0, 0, 0, 0.48);
}

.map-topbar,
.map-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: #442915;
}

.map-heading {
  min-width: 0;
}

.map-scale {
  display: block;
  color: #7b2d25;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#map-title {
  margin: 1px 0 0;
  color: #2f1a0d;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
  font-weight: 900;
  line-height: 1.15;
}

.map-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.map-actions button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
  color: #f8ead3;
  font: inherit;
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  background: #3b2417;
  border: 1px solid rgba(255, 229, 171, 0.5);
  border-radius: 999px;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.24);
  cursor: pointer;
}

.map-actions button:disabled {
  opacity: 0.42;
  cursor: default;
}

.map-actions button:not(:disabled):hover,
.map-actions button:not(:disabled):focus-visible {
  background: #6d3324;
  outline: 2px solid rgba(79, 44, 21, 0.46);
  outline-offset: 1px;
}

.map-stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 2px solid rgba(78, 43, 19, 0.76);
  box-shadow:
    inset 0 0 0 1px rgba(255, 242, 198, 0.42),
    inset 0 0 42px rgba(84, 44, 19, 0.32);
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 246, 211, 0.56), transparent 28%),
    radial-gradient(circle at 80% 74%, rgba(91, 47, 20, 0.18), transparent 34%),
    linear-gradient(120deg, rgba(224, 196, 139, 0.96), rgba(184, 135, 81, 0.9)),
    #c6a06b;
}

.map-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    repeating-linear-gradient(6deg, rgba(93, 57, 29, 0.08) 0 1px, transparent 1px 9px),
    radial-gradient(circle at 12% 88%, rgba(92, 48, 25, 0.2), transparent 20%),
    radial-gradient(circle at 92% 12%, rgba(255, 244, 207, 0.32), transparent 18%);
  mix-blend-mode: multiply;
}

.map-image {
  width: 100%;
  height: 100%;
  object-fit: fill;
  display: block;
  filter: sepia(0.18) saturate(0.9) contrast(1.02);
  background: #c6a06b;
}

.map-diagram,
.map-markers {
  position: absolute;
  inset: 0;
}

.map-markers {
  z-index: 3;
}

.map-diagram {
  z-index: 2;
  background:
    radial-gradient(ellipse at 73% 50%, rgba(59, 98, 106, 0.28), transparent 36%),
    radial-gradient(ellipse at 34% 58%, rgba(94, 125, 82, 0.12), transparent 34%),
    linear-gradient(120deg, rgba(229, 203, 151, 0.94), rgba(194, 151, 90, 0.9)),
    #d2b274;
}

.map-diagram::before {
  content: "";
  position: absolute;
  inset: 5.5%;
  border: 2px solid rgba(84, 50, 23, 0.26);
  box-shadow: inset 0 0 0 1px rgba(255, 239, 194, 0.32);
}

.map-route {
  fill: none;
  stroke: #4f2d18;
  stroke-width: 0.9;
  stroke-linecap: round;
  stroke-dasharray: 1.4 1.1;
  opacity: 0.86;
}

.map-route-svg {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.map-route-quay {
  stroke: #315f62;
}

.map-route-market {
  stroke: #8b3f2b;
}

.map-route-stair {
  stroke: #6a4323;
}

.map-route-tunnel {
  stroke: #342017;
  stroke-width: 1.1;
  stroke-dasharray: 0.8 1.6;
}

.map-route-rumor,
.map-route.locked {
  opacity: 0.36;
  stroke-dasharray: 0.6 2.2;
}

.map-node,
.map-marker {
  position: absolute;
  transform: translate(-50%, -50%);
}

.map-node {
  z-index: 4;
  display: grid;
  grid-template-columns: 12px minmax(0, 116px);
  align-items: center;
  gap: 5px;
  max-width: 132px;
  color: #2d1a0f;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.05;
  overflow-wrap: anywhere;
  text-shadow: 0 1px rgba(255, 239, 190, 0.72);
}

.map-node::before {
  content: "";
  width: 12px;
  height: 12px;
  border: 2px solid rgba(48, 29, 16, 0.82);
  background: #f4dfab;
  box-shadow:
    0 0 0 2px rgba(244, 216, 150, 0.42),
    0 2px 4px rgba(71, 39, 18, 0.22);
  transform: rotate(45deg);
}

.map-node-market::before {
  background: #a7482f;
}

.map-node-quay::before {
  background: #4c8586;
}

.map-node-steps::before,
.map-node-forge::before {
  background: #77512c;
}

.map-node-tunnel::before {
  background: #2d211a;
}

.map-node.locked {
  color: rgba(46, 28, 15, 0.48);
  font-style: italic;
}

.map-node.locked::before {
  background: rgba(76, 50, 30, 0.32);
  border-style: dashed;
}

.map-node.current {
  color: #7b1f1a;
  text-shadow: 0 1px rgba(255, 241, 197, 0.8);
}

.map-node.current::before {
  background: #b82924;
  border-color: #fff3c7;
  box-shadow:
    0 0 0 3px rgba(123, 31, 26, 0.18),
    0 0 18px rgba(255, 229, 171, 0.92);
}

.map-feature {
  position: absolute;
  z-index: 1;
  opacity: 0.78;
  pointer-events: none;
}

.map-feature.water {
  border-radius: 48% 52% 46% 54%;
  background:
    repeating-linear-gradient(-8deg, rgba(255, 244, 204, 0.16) 0 2px, transparent 2px 9px),
    rgba(51, 104, 112, 0.46);
  border: 1px solid rgba(43, 83, 88, 0.4);
}

.map-feature.block {
  border-radius: 26% 32% 20% 28%;
  background: rgba(106, 84, 48, 0.2);
  border: 1px solid rgba(74, 47, 23, 0.22);
}

.map-feature.market {
  border-radius: 20% 36% 24% 38%;
  background:
    repeating-linear-gradient(90deg, rgba(130, 55, 37, 0.16) 0 5px, rgba(231, 190, 117, 0.12) 5px 10px),
    rgba(151, 76, 38, 0.24);
}

.map-feature.tunnel {
  border-radius: 999px 999px 40% 40%;
  background: rgba(43, 31, 24, 0.22);
  border: 1px dashed rgba(48, 29, 16, 0.42);
}

.map-marker {
  width: 18px;
  height: 18px;
  z-index: 3;
  border: 3px solid #fff3c7;
  background: #b82924;
  border-radius: 999px;
  box-shadow:
    0 0 0 4px rgba(20, 14, 10, 0.56),
    0 0 18px rgba(255, 228, 149, 0.9);
}

.map-marker::after {
  content: attr(data-label);
  position: absolute;
  left: 20px;
  top: 50%;
  min-width: 126px;
  transform: translateY(-50%);
  padding: 5px 7px;
  color: #25170d;
  font-size: 12px;
  font-weight: 800;
  background: rgba(255, 244, 223, 0.92);
  border: 1px solid rgba(66, 43, 25, 0.5);
}

.map-footer {
  min-height: 28px;
  color: #442915;
  font-size: 14px;
}

#map-current {
  font-weight: 800;
}

#map-note {
  color: #7b2d25;
  font-weight: 800;
  text-align: right;
}

.dialogue {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 20px;
  min-height: 178px;
  display: grid;
  grid-template-columns: 188px 1fr;
  gap: 16px;
  padding: 14px;
}

.portrait-frame {
  width: 188px;
  height: 188px;
  overflow: hidden;
  border: 2px solid rgba(244, 202, 132, 0.62);
  background: #2a1c14;
}

#portrait {
  width: 188px;
  height: 188px;
  display: block;
}

.bubble {
  position: relative;
  min-height: 150px;
  padding: 18px 20px 38px;
  background: #fff4df;
  color: #21170f;
  border: 2px solid #4b321d;
  border-radius: 8px;
}

.bubble::before {
  content: "";
  position: absolute;
  left: -18px;
  top: 42px;
  width: 0;
  height: 0;
  border-top: 13px solid transparent;
  border-bottom: 13px solid transparent;
  border-right: 18px solid #4b321d;
}

.bubble::after {
  content: "";
  position: absolute;
  left: -13px;
  top: 45px;
  width: 0;
  height: 0;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-right: 14px solid #fff4df;
}

.speaker {
  color: #7a351d;
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 6px;
}

.line {
  max-width: 780px;
  font-size: 22px;
  line-height: 1.32;
}

.continue {
  position: absolute;
  right: 18px;
  bottom: 12px;
  color: #74583e;
  font-size: 14px;
  font-weight: 700;
}

.choices {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.choice {
  width: 100%;
  padding: 9px 12px;
  color: #22170f;
  font: inherit;
  font-size: 17px;
  text-align: left;
  background: #f6d99f;
  border: 2px solid #7c5830;
  cursor: pointer;
}

.choice.active,
.choice:hover {
  background: #ffe9bb;
  border-color: #351e0e;
}

.hidden {
  display: none;
}

@media (max-width: 820px) {
  #game-shell {
    padding: 0;
  }

  #game-wrap {
    width: 100vw;
    height: 100vh;
    aspect-ratio: auto;
    border: 0;
  }

  .hud {
    left: 10px;
    top: 10px;
    width: min(310px, calc(100% - 20px));
  }

  .location-banner {
    top: 12px;
    min-width: min(82vw, 280px);
    font-size: 15px;
  }

  .map-overlay {
    padding: 10px;
  }

  .battle-hud {
    left: 10px;
    right: 10px;
    bottom: 10px;
    grid-template-columns: 1fr;
    max-height: 48vh;
    overflow: auto;
    padding: 10px;
  }

  .reward-screen,
  .system-screen,
  .valve-screen {
    padding: 10px;
  }

  .reward-panel,
  .system-panel,
  .valve-panel {
    width: 100%;
    max-height: 100%;
  }

  .system-header,
  .valve-header {
    flex-direction: column;
  }

  .valve-readouts,
  .valve-controls {
    grid-template-columns: 1fr;
  }

  .valve-gauge strong {
    font-size: 28px;
  }

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

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

  .inventory-row {
    align-items: flex-start;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .inventory-row > span:last-child {
    justify-content: flex-start;
    text-align: left;
  }

  .save-slot {
    grid-template-columns: 1fr;
  }

  .character-card-top {
    grid-template-columns: 46px minmax(0, 1fr) auto;
  }

  .character-token {
    width: 46px;
    height: 46px;
    font-size: 23px;
  }

  .meter-line {
    grid-template-columns: 30px minmax(0, 1fr);
  }

  .meter-line strong {
    grid-column: 2;
  }

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

  .party-card {
    grid-template-columns: 76px 1fr;
  }

  .battle-log {
    min-height: 54px;
    font-size: 14px;
  }

  .map-panel {
    width: 100%;
    height: 100%;
  }

  .map-topbar,
  .map-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  #map-title {
    font-size: 19px;
  }

  .map-actions {
    justify-content: flex-start;
  }

  .map-actions button {
    width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 0;
    font-size: 20px;
  }

  .map-node {
    grid-template-columns: 10px minmax(0, 78px);
    max-width: 96px;
    padding: 0;
    font-size: 11px;
  }

  .map-node::before {
    width: 10px;
    height: 10px;
  }

  .map-marker::after {
    min-width: 90px;
    font-size: 11px;
  }

  .dialogue {
    left: 10px;
    right: 10px;
    bottom: 10px;
    grid-template-columns: 104px 1fr;
    min-height: 136px;
    padding: 10px;
    gap: 10px;
  }

  .portrait-frame,
  #portrait {
    width: 104px;
    height: 104px;
  }

  .bubble {
    min-height: 112px;
    padding: 12px 13px 32px;
  }

  .line {
    font-size: 16px;
  }
}
