:root {
  color-scheme: dark;
  --bg: #070706;
  --panel: rgba(10, 12, 14, 0.78);
  --panel-strong: rgba(11, 15, 17, 0.92);
  --line: rgba(230, 195, 118, 0.32);
  --line-cold: rgba(111, 215, 207, 0.34);
  --text: #f4ecdd;
  --muted: #b8ad9d;
  --gold: #f0c66f;
  --gold-strong: #ffd889;
  --teal: #76d9d0;
  --red: #c45f55;
  --shadow: rgba(0, 0, 0, 0.55);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  letter-spacing: 0;
}

button,
textarea,
input {
  font: inherit;
}

button {
  color: inherit;
}

.scene-bg {
  position: fixed;
  inset: 0;
  z-index: -3;
  background: #050403;
  overflow: hidden;
}

.scene-bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.9) contrast(1.08) brightness(0.62);
  transform: scale(1.04);
}

.veil {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(90deg, rgba(3, 4, 5, 0.88), rgba(7, 8, 8, 0.55) 44%, rgba(3, 4, 5, 0.86)),
    linear-gradient(180deg, rgba(6, 5, 4, 0.52), rgba(6, 5, 4, 0.9));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 86px;
  padding: 20px 28px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  min-width: 90px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--gold-strong);
  background: rgba(240, 198, 111, 0.1);
  font-size: 0.73rem;
  font-weight: 800;
}

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

.brand h1 {
  font-size: 1.25rem;
  line-height: 1.2;
  font-weight: 750;
}

.brand p,
.eyebrow {
  color: var(--muted);
  font-size: 0.76rem;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  background: rgba(3, 4, 5, 0.44);
}

.tab,
.text-action,
.icon-action,
.primary-action {
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.tab {
  min-height: 34px;
  padding: 0 14px;
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
}

.tab:hover,
.tab.is-active {
  color: var(--text);
  border-color: var(--line);
  background: rgba(240, 198, 111, 0.12);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(340px, 1.2fr) minmax(300px, 1fr);
  gap: 16px;
  padding: 0 28px 28px;
  min-height: calc(100vh - 86px);
}

.tool-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 22px 70px var(--shadow);
  backdrop-filter: blur(18px);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.panel-head h2,
.archive-strip h2 {
  margin-top: 3px;
  font-size: 1.05rem;
  font-weight: 720;
}

.difficulty-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 12px 14px 0;
}

.difficulty-button {
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.045);
  cursor: pointer;
}

.difficulty-button:hover,
.difficulty-button.is-active {
  color: var(--text);
  border-color: var(--line-cold);
  background: rgba(118, 217, 208, 0.1);
}

.difficulty-brief {
  padding: 8px 14px 0;
  color: rgba(184, 173, 157, 0.78);
  font-size: 0.74rem;
  line-height: 1.45;
}

.count,
.phase,
.status-pill {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--gold-strong);
  background: rgba(240, 198, 111, 0.1);
  font-size: 0.76rem;
}

.status-pill.is-success {
  border-color: var(--line-cold);
  color: var(--teal);
  background: rgba(118, 217, 208, 0.11);
}

.status-pill.is-failed {
  border-color: rgba(196, 95, 85, 0.48);
  color: #ffafa8;
  background: rgba(196, 95, 85, 0.11);
}

.hero-list {
  display: grid;
  gap: 8px;
  padding: 14px 14px 0;
  overflow: auto;
}

.hero-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  width: 100%;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  color: var(--text);
  text-align: left;
  background: rgba(255, 255, 255, 0.045);
  cursor: pointer;
}

.hero-row:hover,
.hero-row.is-selected {
  border-color: var(--line);
  background: rgba(240, 198, 111, 0.11);
}

.hero-row strong {
  display: block;
  font-size: 0.95rem;
}

.hero-row span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.hero-row em {
  align-self: center;
  min-width: 42px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 4px 8px;
  color: var(--muted);
  font-size: 0.72rem;
  font-style: normal;
  text-align: center;
}

.hero-row.is-selected em {
  border-color: var(--line-cold);
  color: var(--teal);
}

.field {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.old-world-field {
  margin-top: auto;
}

.field span,
.range-field span,
dt {
  color: var(--muted);
  font-size: 0.78rem;
}

textarea {
  width: 100%;
  min-height: 120px;
  resize: vertical;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: var(--radius);
  outline: none;
  padding: 12px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.26);
  line-height: 1.65;
}

textarea:focus {
  border-color: var(--line-cold);
  box-shadow: 0 0 0 3px rgba(118, 217, 208, 0.09);
}

.weapon-card {
  margin: 14px 14px 0;
  padding: 14px;
  border: 1px solid rgba(118, 217, 208, 0.28);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(118, 217, 208, 0.09), rgba(240, 198, 111, 0.045)),
    rgba(0, 0, 0, 0.22);
}

.weapon-card.is-armed {
  animation: armFlash 620ms ease;
}

.weapon-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.weapon-head h3 {
  margin-top: 4px;
  color: var(--teal);
  font-size: 1.05rem;
  line-height: 1.25;
}

.weapon-head span {
  flex: 0 0 auto;
  border: 1px solid var(--line-cold);
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--teal);
  background: rgba(118, 217, 208, 0.09);
  font-size: 0.72rem;
}

.weapon-card blockquote {
  margin: 14px 0 9px;
  padding: 12px 13px;
  border-left: 2px solid var(--gold);
  color: #ffe2a2;
  background: rgba(240, 198, 111, 0.08);
  font-size: 1.02rem;
  font-weight: 720;
  line-height: 1.6;
}

.weapon-card > p {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.55;
}

.hint-card {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.hint-card span {
  color: var(--gold-strong);
  font-size: 0.75rem;
  font-weight: 720;
}

.hint-card p {
  color: rgba(244, 236, 221, 0.84);
  font-size: 0.82rem;
  line-height: 1.55;
}

.hint-card .text-action {
  justify-self: start;
  min-height: 34px;
}

.control-grid {
  display: grid;
  gap: 12px;
  padding: 0 14px 14px;
}

.range-field {
  display: grid;
  gap: 8px;
}

.range-field span {
  display: flex;
  justify-content: space-between;
}

.range-field b {
  color: var(--gold-strong);
  font-weight: 700;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--gold);
}

.locked-resources {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 0 14px 14px;
}

.locked-resources div {
  min-height: 56px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  padding: 9px 10px;
  background: rgba(255, 255, 255, 0.035);
  opacity: 0.62;
}

.locked-resources strong,
.locked-resources span {
  display: block;
}

.locked-resources strong {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 650;
}

.locked-resources span {
  margin-top: 5px;
  color: rgba(244, 236, 221, 0.72);
  font-size: 0.82rem;
}

.locked-resources p {
  grid-column: 1 / -1;
  color: rgba(184, 173, 157, 0.72);
  font-size: 0.75rem;
  line-height: 1.45;
}

.button-row {
  display: flex;
  gap: 8px;
  padding: 0 14px 14px;
}

.primary-action {
  min-height: 42px;
  padding: 0 18px;
  color: #130d05;
  background: linear-gradient(180deg, #ffe4a4, #e2aa45);
  border-color: rgba(255, 232, 177, 0.6);
  font-weight: 780;
  box-shadow: 0 14px 32px rgba(226, 170, 69, 0.16);
}

.primary-action:hover {
  transform: translateY(-1px);
}

.icon-action,
.text-action {
  min-height: 42px;
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.055);
  color: var(--muted);
}

.icon-action {
  width: 44px;
  font-size: 1.05rem;
}

.text-action {
  padding: 0 12px;
}

.icon-action:hover,
.text-action:hover {
  color: var(--text);
  border-color: var(--line);
}

.score-board {
  display: grid;
  grid-template-columns: 128px 1fr;
  gap: 14px;
  align-items: center;
  margin: auto 14px 14px;
  padding: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.2);
}

.score-ring {
  display: grid;
  place-items: center;
  width: 108px;
  height: 108px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(240, 198, 111, 0.14), rgba(240, 198, 111, 0) 68%),
    rgba(0, 0, 0, 0.2);
}

.score-ring span {
  color: var(--gold-strong);
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
}

.score-ring small {
  color: var(--muted);
}

.result-panel.is-resolving .rule-card {
  animation: resultPulse 680ms ease;
}

.meter-stack {
  display: grid;
  gap: 11px;
}

.meter-row {
  display: grid;
  gap: 6px;
}

.meter-row span {
  color: var(--muted);
  font-size: 0.76rem;
}

.meter {
  height: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.meter i {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--red), var(--gold), var(--teal));
  transition: width 320ms ease;
}

.rule-card {
  margin: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(240, 198, 111, 0.08);
}

.card-label {
  color: var(--muted);
  font-size: 0.76rem;
}

.rule-card h3 {
  margin-top: 6px;
  color: var(--gold-strong);
  font-size: 1.3rem;
  line-height: 1.25;
}

dl {
  display: grid;
  gap: 14px;
  margin: 18px 0 0;
}

dt {
  margin-bottom: 5px;
}

dd {
  margin: 0;
  color: var(--text);
  line-height: 1.6;
}

.rule-footnote {
  margin-top: 16px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(184, 173, 157, 0.72);
  font-size: 0.68rem;
  line-height: 1.55;
}

.achievement-line {
  margin-top: 16px;
  padding: 10px 11px;
  border-left: 2px solid rgba(118, 217, 208, 0.56);
  color: rgba(244, 236, 221, 0.82);
  background: rgba(118, 217, 208, 0.08);
  font-size: 0.82rem;
  line-height: 1.45;
}

.achievement-line.is-unlocked {
  color: var(--teal);
  background: rgba(118, 217, 208, 0.12);
}

.archive-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 14px 10px;
}

.archive-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0 14px 14px 34px;
  overflow: auto;
}

.archive-list li {
  padding: 9px 10px;
  border-left: 2px solid var(--line-cold);
  color: var(--muted);
  background: rgba(118, 217, 208, 0.065);
  line-height: 1.45;
}

.archive-list strong {
  display: block;
  color: var(--text);
  font-size: 0.92rem;
}

.archive-list small {
  color: var(--muted);
}

.victory-view {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 260ms ease;
}

.victory-view.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.victory-view img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(1.02) contrast(1.06) brightness(0.78);
  transform: scale(1.01);
}

.victory-scrim {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 51% 18%, rgba(255, 221, 150, 0.16), rgba(0, 0, 0, 0) 28%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0.82));
}

.victory-copy {
  position: relative;
  width: min(640px, calc(100vw - 36px));
  margin-top: 22vh;
  text-align: center;
  text-shadow: 0 3px 22px rgba(0, 0, 0, 0.9);
}

.victory-copy h2 {
  margin: 8px 0 10px;
  color: #ffe8b0;
  font-size: 2.8rem;
  line-height: 1.05;
}

.victory-copy p {
  margin: 0 auto 18px;
  max-width: 560px;
  color: #f7ead5;
  line-height: 1.6;
}

body[data-overlay="visible"] {
  overflow: hidden;
}

@keyframes armFlash {
  0% {
    border-color: rgba(118, 217, 208, 0.2);
    box-shadow: none;
  }

  45% {
    border-color: rgba(118, 217, 208, 0.78);
    box-shadow: 0 0 0 4px rgba(118, 217, 208, 0.1);
  }

  100% {
    border-color: rgba(118, 217, 208, 0.28);
    box-shadow: none;
  }
}

@keyframes resultPulse {
  0% {
    border-color: rgba(230, 195, 118, 0.32);
    transform: translateY(0);
  }

  42% {
    border-color: rgba(255, 216, 137, 0.95);
    transform: translateY(-2px);
  }

  100% {
    border-color: rgba(230, 195, 118, 0.32);
    transform: translateY(0);
  }
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.1fr);
  }

  .result-panel {
    grid-column: 1 / -1;
  }
}

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

  .topbar {
    align-items: stretch;
    flex-direction: column;
    padding: 16px;
  }

  .brand {
    align-items: flex-start;
  }

  .brand-mark {
    min-width: 76px;
  }

  .tabs {
    overflow-x: auto;
  }

  .difficulty-strip {
    grid-template-columns: 1fr;
  }

  .app-shell {
    grid-template-columns: 1fr;
    min-height: auto;
    padding: 0 16px 16px;
  }

  .score-board {
    grid-template-columns: 1fr;
  }

  .locked-resources {
    grid-template-columns: 1fr;
  }

  .score-ring {
    width: 96px;
    height: 96px;
  }

  .victory-copy {
    margin-top: 34vh;
  }

  .victory-copy h2 {
    font-size: 2rem;
  }
}
