:root {
  color-scheme: dark;
  --bg: #080806;
  --panel: #11100d;
  --panel-2: #191713;
  --ink: #e8dfcf;
  --muted: #9a9488;
  --line: #4a4035;
  --red: #9f3d4a;
  --amber: #b2986b;
  --green: #5c665c;
  --blue: #657683;
  --violet: #5f4778;
  --black: #030303;
  --shadow: rgba(0, 0, 0, 0.62);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  color: var(--ink);
  font-family: "Microsoft YaHei", "Noto Sans SC", "SimSun", sans-serif;
  background:
    radial-gradient(circle at 16% 10%, rgba(95, 71, 120, 0.16), transparent 32%),
    radial-gradient(circle at 82% 18%, rgba(159, 61, 74, 0.13), transparent 28%),
    linear-gradient(135deg, rgba(178, 152, 107, 0.055) 0 25%, transparent 25% 50%, rgba(159, 61, 74, 0.035) 50% 75%, transparent 75%),
    var(--bg);
  background-size: auto, auto, 18px 18px, auto;
}

button,
textarea {
  font: inherit;
}

button {
  min-height: 36px;
  min-width: 38px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: linear-gradient(#241f19, #100f0d);
  cursor: pointer;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.06), 0 3px 10px var(--shadow);
}

.icon-button {
  width: 38px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

.icon-button.danger {
  border-color: rgba(159, 61, 74, 0.58);
}

button:hover {
  border-color: var(--amber);
  color: #fff5d9;
}

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

.game-shell {
  width: min(1500px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 18px 0 24px;
}

.topbar,
.hud-strip,
.panel {
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 22%),
    radial-gradient(circle at top left, rgba(95, 71, 120, 0.08), transparent 34%),
    radial-gradient(circle at bottom right, rgba(159, 61, 74, 0.06), transparent 42%),
    var(--panel);
  box-shadow: 0 18px 42px var(--shadow), inset 0 0 0 1px rgba(255, 255, 255, 0.025);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  min-height: 74px;
  padding: 14px 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: #b2986b;
  font-size: 12px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: "KaiTi", "STKaiti", serif;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0;
}

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

.hud-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-top: 10px;
}

.hud-strip > div {
  padding: 10px 14px;
  border-right: 1px solid var(--line);
}

.hud-strip > div:last-child {
  border-right: 0;
}

.hud-strip span {
  display: block;
  color: var(--amber);
  font-size: 18px;
  line-height: 1;
}

.hud-strip strong {
  display: block;
  margin-top: 3px;
  font-size: 22px;
  font-weight: 700;
}

.game-grid {
  display: grid;
  grid-template-columns: 270px minmax(480px, 1fr) 280px;
  gap: 10px;
  margin-top: 10px;
}

.lower-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 10px;
  margin-top: 10px;
}

.panel {
  min-width: 0;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
  color: #d0b98c;
  font-family: "KaiTi", "STKaiti", serif;
  font-size: 19px;
}

.party-list {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.party-card {
  position: relative;
  min-height: 132px;
  padding: 14px 10px 10px 96px;
  border: 1px solid rgba(74, 64, 53, 0.92);
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.38), rgba(255, 255, 255, 0.025)),
    #11100d;
  overflow: hidden;
}

.party-card.dead {
  filter: grayscale(1);
  opacity: 0.58;
}

.portrait {
  position: absolute;
  left: 10px;
  bottom: 8px;
  width: 76px;
  height: 112px;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at 50% 24%, var(--skin, #d8b89d) 0 13px, transparent 14px),
    linear-gradient(135deg, transparent 0 48%, var(--hair, #332820) 49% 100%),
    linear-gradient(180deg, var(--cloth, #6f7370), #211914);
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.62), 0 0 0 1px rgba(159, 61, 74, 0.18);
  overflow: hidden;
}

.portrait::after {
  content: "";
  position: absolute;
  inset: 45px 12px 0;
  border: 1px solid rgba(236, 225, 199, 0.22);
  border-bottom: 0;
  transform: skewX(-4deg);
}

.portrait-art {
  position: absolute;
  left: 50%;
  bottom: -2px;
  width: 118px;
  max-width: none;
  transform: translateX(-50%);
  filter: saturate(0.88) contrast(1.04);
}

.party-card h2 {
  margin: 0;
  font-size: 16px;
}

.party-card p {
  display: none;
  margin: 0;
}

.party-card h2 + .meter {
  margin-top: 12px;
}

.party-card p {
  color: var(--muted);
  font-size: 12px;
}

.meter {
  height: 8px;
  border: 1px solid rgba(232, 224, 210, 0.18);
  background: rgba(0, 0, 0, 0.58);
  overflow: hidden;
}

.meter > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #9f3d4a, #b2986b);
}

.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.protection {
  color: #d0b98c;
}

.hate {
  display: inline-flex;
  width: 44px;
  height: 7px;
  border: 1px solid rgba(159, 61, 74, 0.58);
  background: linear-gradient(90deg, rgba(159, 61, 74, 0.95), transparent);
  opacity: var(--hate, 0.45);
}

.stage {
  position: relative;
  min-height: 560px;
  padding: 12px;
}

.viewport {
  position: relative;
  height: 430px;
  border: 1px solid #4a4035;
  background: #050504;
  overflow: hidden;
}

.viewport::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.026) 1px, transparent 1px),
    radial-gradient(circle at center, transparent 0 42%, rgba(0, 0, 0, 0.78) 78%);
  background-size: 100% 4px, auto;
  pointer-events: none;
  z-index: 4;
  mix-blend-mode: screen;
}

.corridor {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, #050504 0 18%, transparent 19% 81%, #050504 82%),
    linear-gradient(180deg, #20201b 0, #12110f 52%, #050504 100%);
}

.corridor.asset-scene {
  background:
    radial-gradient(circle at center, transparent 0 52%, rgba(0, 0, 0, 0.52) 80%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0.24)),
    url("../assets/scenes/corridor.webp?v=20260522-art2") center / cover no-repeat;
}

.corridor.asset-scene .ceiling,
.corridor.asset-scene .left-wall,
.corridor.asset-scene .right-wall,
.corridor.asset-scene .floor,
.corridor.asset-scene .front {
  display: none;
}

.corridor .floor {
  position: absolute;
  left: 22%;
  right: 22%;
  bottom: -12%;
  height: 44%;
  background:
    linear-gradient(90deg, rgba(232, 224, 210, 0.06) 1px, transparent 1px),
    linear-gradient(#1c1b17, #090807);
  background-size: 36px 100%, auto;
  clip-path: polygon(15% 0, 85% 0, 100% 100%, 0 100%);
}

.corridor .ceiling {
  position: absolute;
  left: 25%;
  right: 25%;
  top: 0;
  height: 28%;
  background: linear-gradient(#0a0908, #1b1b17);
  clip-path: polygon(0 0, 100% 0, 78% 100%, 22% 100%);
}

.corridor .left-wall,
.corridor .right-wall {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 40%;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.58), transparent),
    repeating-linear-gradient(180deg, #24241f 0 42px, #151411 43px 45px);
}

.corridor .left-wall {
  left: 0;
  clip-path: polygon(0 0, 72% 24%, 72% 78%, 0 100%);
}

.corridor .right-wall {
  right: 0;
  transform: scaleX(-1);
  clip-path: polygon(0 0, 72% 24%, 72% 78%, 0 100%);
}

.corridor .front {
  position: absolute;
  left: 35%;
  top: 24%;
  width: 30%;
  height: 54%;
  border: 2px solid #504737;
  background:
    radial-gradient(circle at 70% 45%, rgba(159, 61, 74, 0.16), transparent 16%),
    repeating-linear-gradient(90deg, #1d1c17 0 34px, #11100d 35px 38px);
  box-shadow: inset 0 0 82px rgba(0, 0, 0, 0.78);
}

.corridor .sigil {
  position: absolute;
  left: calc(50% - 32px);
  top: 38%;
  width: 64px;
  height: 64px;
  border: 1px solid rgba(178, 152, 107, 0.66);
  border-radius: 50%;
  opacity: 0.55;
}

.battle-view {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at center 46%, rgba(159, 61, 74, 0.23), transparent 28%),
    radial-gradient(circle at 58% 30%, rgba(95, 71, 120, 0.12), transparent 22%),
    linear-gradient(#11100e, #030303);
}

.enemy-silhouette {
  position: absolute;
  left: 50%;
  top: 52%;
  width: 240px;
  height: 290px;
  transform: translate(-50%, -50%);
  object-fit: contain;
  filter: drop-shadow(0 0 22px rgba(159, 61, 74, 0.38)) saturate(0.9);
}

.enemy-name {
  position: absolute;
  left: 24px;
  top: 20px;
  color: #d7c094;
  font-size: 22px;
}

.enemy-hp {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 24px;
}

.bubble-layer {
  position: absolute;
  left: 18px;
  right: 18px;
  top: 18px;
  pointer-events: none;
  z-index: 8;
}

.bubble {
  display: inline-block;
  max-width: 340px;
  margin: 0 8px 8px 0;
  padding: 8px 11px;
  border: 1px solid rgba(232, 224, 210, 0.36);
  color: #eee0c8;
  background: rgba(15, 14, 13, 0.96);
  box-shadow: 0 8px 18px var(--shadow);
  animation: bubbleIn 2.4s ease both;
}

@keyframes bubbleIn {
  0% { opacity: 0; transform: translateY(6px); }
  12% { opacity: 1; transform: translateY(0); }
  84% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-4px); }
}

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

.control-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.control-row button {
  width: 44px;
  padding: 0;
  font-size: 18px;
}

.battle-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.action-card {
  padding: 8px;
  border: 1px solid rgba(74, 64, 53, 0.9);
  background: rgba(0, 0, 0, 0.28);
}

.action-card h3 {
  margin: 0 0 6px;
  font-size: 13px;
}

.action-card .control-row {
  gap: 5px;
}

.action-card button {
  flex: 1 1 36px;
  min-height: 30px;
  min-width: 34px;
  font-size: 14px;
}

.mini-map {
  display: grid;
  grid-template-columns: repeat(10, 18px);
  gap: 3px;
  padding: 12px;
}

.map-cell {
  width: 18px;
  height: 18px;
  border: 1px solid rgba(74, 64, 53, 0.58);
  background: rgba(0, 0, 0, 0.45);
}

.map-cell.wall {
  background: #0b0907;
}

.map-cell.known {
  background: #28251f;
}

.map-cell.party {
  background: #d0b98c;
}

.map-cell.anchor {
  box-shadow: inset 0 0 0 2px var(--blue);
}

.map-cell.threat {
  box-shadow: inset 0 0 0 2px var(--red);
}

.inventory-block {
  padding: 0 12px 12px;
}

.inventory-block h2 {
  margin: 10px 0 6px;
  color: var(--amber);
  font-size: 16px;
  font-weight: 400;
}

.loot-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 32px;
}

.loot-pill {
  padding: 5px 7px;
  border: 1px solid rgba(178, 152, 107, 0.42);
  color: #d8c198;
  background: rgba(0, 0, 0, 0.38);
  font-size: 12px;
}

.log-panel {
  min-height: 180px;
}

.log-list {
  display: flex;
  flex-direction: column-reverse;
  gap: 4px;
  max-height: 164px;
  overflow: auto;
  padding: 10px 12px;
  color: #cfc5b8;
  font-size: 13px;
}

.feedback-panel {
  padding-bottom: 12px;
}

.feedback-panel textarea,
dialog textarea {
  width: calc(100% - 24px);
  min-height: 96px;
  margin: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: #050506;
  resize: vertical;
}

.feedback-panel textarea {
  min-height: 76px;
}

.feedback-panel button {
  margin-left: 12px;
}

dialog {
  width: min(620px, calc(100vw - 32px));
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--panel);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

dialog h2 {
  margin: 0;
  padding: 14px 16px 0;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 12px 12px;
}

@media (max-width: 1120px) {
  .game-grid {
    grid-template-columns: 1fr;
  }

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

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

  .stage {
    min-height: 520px;
  }
}

@media (max-width: 720px) {
  .game-shell {
    width: calc(100vw - 16px);
  }

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

  .hud-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .party-list {
    grid-template-columns: 1fr;
  }

  .battle-actions {
    grid-template-columns: 1fr;
  }
}
