:root {
  --bg: #1b2230;
  --panel: rgba(22, 27, 38, 0.93);
  --card: rgba(255, 248, 232, 0.06);
  --card2: rgba(255, 248, 232, 0.12);
  --line: rgba(255, 240, 210, 0.14);
  --ink: #f5eedd;
  --mut: #aeb0b4;
  --gold: #f2c45a;
  --gold2: #c9962c;
  --green: #8fd16a;
  --red: #ff8a6b;
  --blue: #7cc3f0;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font:
    15px/1.35 system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}
#world {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}
button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
}
#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: calc(var(--safe-t) + 6px) 10px 6px;
  background: linear-gradient(rgba(15, 18, 26, 0.85), rgba(15, 18, 26, 0));
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  align-items: center;
  pointer-events: none;
  text-shadow: 0 1px 2px #000;
}
#hud .town {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
#hud .name {
  font:
    600 17px/1.2 Georgia,
    "Times New Roman",
    serif;
  letter-spacing: 0.02em;
}
#hud .stage {
  color: var(--gold);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
#hud .when {
  color: var(--mut);
  font-size: 12px;
  text-align: right;
}
#hud .st {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
#hud .st i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}
#hud .st small {
  color: var(--mut);
  font-size: 11px;
}
.pos {
  color: var(--green);
}
.neg {
  color: var(--red);
}
#hud .menu {
  pointer-events: auto;
  margin-left: auto;
  width: 34px;
  height: 30px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
  font-size: 18px;
}
#goal {
  position: fixed;
  left: 10px;
  right: 10px;
  top: calc(var(--safe-t) + 76px);
  pointer-events: none;
  display: flex;
  justify-content: center;
}
#goal .g {
  pointer-events: auto;
  max-width: 460px;
  background: rgba(22, 27, 38, 0.82);
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13px;
  backdrop-filter: blur(4px);
}
#goal .g b {
  color: var(--gold);
}
#toasts {
  position: fixed;
  left: 0;
  right: 0;
  top: calc(var(--safe-t) + 130px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
.toast {
  background: rgba(20, 24, 34, 0.9);
  border: 1px solid var(--line);
  padding: 7px 12px;
  border-radius: 18px;
  font-size: 13px;
  max-width: 90vw;
  animation: tin 0.3s ease-out;
}
.toast.bad {
  border-color: rgba(255, 120, 90, 0.6);
}
.toast.good {
  border-color: rgba(242, 196, 90, 0.6);
}
@keyframes tin {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
}
#insp {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: calc(var(--safe-b) + 62px);
  display: none;
  justify-content: center;
  pointer-events: none;
}
#insp.on {
  display: flex;
}
#insp .card {
  pointer-events: auto;
  width: 100%;
  max-width: 480px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}
#dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}
#panel {
  pointer-events: auto;
  width: 100%;
  max-width: 560px;
  max-height: 52vh;
  overflow-y: auto;
  background: var(--panel);
  border-top: 1px solid var(--line);
  border-radius: 14px 14px 0 0;
  padding: 10px 12px 12px;
  display: none;
  backdrop-filter: blur(6px);
}
#panel.on {
  display: block;
}
#tabs {
  pointer-events: auto;
  width: 100%;
  max-width: 560px;
  display: flex;
  background: rgba(16, 20, 28, 0.96);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
#tabs button {
  flex: 1;
  padding: 9px 2px 8px;
  font-size: 12px;
  color: var(--mut);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
#tabs button svg {
  width: 22px;
  height: 22px;
}
#tabs button.on {
  color: var(--gold);
}
#tabs button .dot {
  position: absolute;
}
h3 {
  margin: 2px 0 8px;
  font:
    600 16px Georgia,
    serif;
}
h4 {
  margin: 12px 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--mut);
}
.chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: none;
}
.chip {
  flex: none;
  padding: 6px 11px;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 13px;
}
.chip.on {
  background: var(--gold);
  color: #241b08;
  border-color: var(--gold);
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px;
}
.bt {
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 9px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 54px;
}
.bt.on {
  border-color: var(--gold);
  background: rgba(242, 196, 90, 0.14);
}
.bt.dis {
  opacity: 0.45;
}
.bt b {
  font-size: 14px;
  font-weight: 600;
}
.bt small {
  color: var(--mut);
  font-size: 11.5px;
}
.cost {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
}
.cost .lack {
  color: var(--red);
}
.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 14px;
}
.row span:last-child {
  font-variant-numeric: tabular-nums;
}
.bar {
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  flex: 1;
  max-width: 120px;
}
.bar i {
  display: block;
  height: 100%;
  background: var(--green);
}
.btn {
  background: var(--gold);
  color: #241b08;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: 10px;
}
.btn.sec {
  background: var(--card2);
  color: var(--ink);
  font-weight: 500;
}
.btn:disabled {
  opacity: 0.4;
}
.btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.step {
  display: flex;
  align-items: center;
  gap: 6px;
}
.step button {
  width: 32px;
  height: 30px;
  border-radius: 8px;
  background: var(--card2);
  font-size: 17px;
}
.step span {
  min-width: 46px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
p.mut,
.mut {
  color: var(--mut);
  font-size: 13px;
  margin: 4px 0;
}
.opt {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  margin-bottom: 6px;
  text-align: left;
  width: 100%;
  display: block;
}
.opt.on {
  border-color: var(--gold);
}
.opt b {
  display: block;
  margin-bottom: 2px;
}
.opt small {
  color: var(--mut);
}
#modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 16, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 10;
}
#modal.on {
  display: flex;
}
#modal .box {
  width: 100%;
  max-width: 440px;
  max-height: 86vh;
  overflow-y: auto;
  background: #1e2533;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
#modal h2 {
  margin: 0 0 8px;
  font:
    600 21px Georgia,
    serif;
  color: var(--gold);
}
.close {
  float: right;
  font-size: 20px;
  color: var(--mut);
  width: 32px;
  height: 32px;
}
.mode {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--safe-b) + 66px);
  background: rgba(22, 27, 38, 0.92);
  border: 1px solid var(--gold);
  border-radius: 20px;
  padding: 6px 8px 6px 14px;
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 13px;
  width: max-content;
  max-width: calc(100vw - 16px);
}
.mode button {
  background: var(--card2);
  border-radius: 14px;
  padding: 4px 10px;
}
.title {
  text-align: center;
}
.title h1 {
  font:
    600 34px Georgia,
    serif;
  margin: 4px 0 2px;
  color: var(--gold);
  letter-spacing: 0.04em;
}
.lens {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
