:root {
  --ink: #f3ead3;
  --muted: #b7a98d;
  --paper: #16130f;
  --panel: rgba(38, 30, 22, 0.86);
  --panel-strong: rgba(65, 47, 31, 0.95);
  --line: rgba(246, 207, 129, 0.22);
  --gold: #f5b84b;
  --red: #e6534f;
  --blue: #5fbdd0;
  --green: #98c76a;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.44);
  font-family: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    radial-gradient(circle at 18% 18%, rgba(230, 83, 79, 0.24), transparent 28rem),
    radial-gradient(circle at 86% 12%, rgba(95, 189, 208, 0.18), transparent 24rem),
    linear-gradient(135deg, #25170f 0%, #120f0c 42%, #21190f 100%);
  color: var(--ink);
}

body {
  min-height: 100vh;
  margin: 0;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  opacity: 0.16;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: linear-gradient(to bottom, black, transparent 90%);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.command-panel {
  position: sticky;
  top: 16px;
  z-index: 20;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(145deg, rgba(36, 27, 19, 0.96), rgba(19, 16, 13, 0.92));
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.brand,
.input-grid,
.control-row,
.track-head {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  justify-content: space-between;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold);
  font: 700 11px/1.1 ui-monospace, "SFMono-Regular", Menlo, monospace;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(30px, 4vw, 58px);
  line-height: 0.92;
}

h2 {
  margin-bottom: 4px;
  font-size: 22px;
  line-height: 1.05;
}

h3 {
  margin-bottom: 6px;
  font-size: 16px;
  line-height: 1;
}

.dice-mark {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #f0dfb8;
  color: #261810;
  font: 900 30px/1 ui-monospace, monospace;
  box-shadow: inset 0 -8px 0 rgba(0, 0, 0, 0.16);
  transform: rotate(6deg);
}

.input-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
}

.combo-wrap {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.combo-wrap > span,
.range-wrap > span {
  color: var(--muted);
  font: 700 12px/1 ui-monospace, "SFMono-Regular", Menlo, monospace;
  text-transform: uppercase;
}

.combo {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: visible;
  background: rgba(0, 0, 0, 0.24);
}

.combo input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  padding: 14px 14px;
  background: transparent;
  color: var(--ink);
}

.combo input::placeholder {
  color: rgba(243, 234, 211, 0.46);
}

.combo > button,
.ghost {
  border: 0;
  padding: 0 16px;
  background: var(--gold);
  color: #20140d;
  font-weight: 900;
}

.ghost {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
}

.suggestions {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  z-index: 60;
  max-height: min(318px, calc(100dvh - 220px));
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  border-radius: 8px;
  background: #24180f;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.58);
}

.suggestions,
.chips,
.hit-strip,
.chain {
  scrollbar-width: thin;
  scrollbar-color: rgba(245, 184, 75, 0.72) rgba(255, 255, 255, 0.08);
}

.suggestions::-webkit-scrollbar,
.chips::-webkit-scrollbar,
.hit-strip::-webkit-scrollbar,
.chain::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.suggestions::-webkit-scrollbar-track,
.chips::-webkit-scrollbar-track,
.hit-strip::-webkit-scrollbar-track,
.chain::-webkit-scrollbar-track {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.suggestions::-webkit-scrollbar-thumb,
.chips::-webkit-scrollbar-thumb,
.hit-strip::-webkit-scrollbar-thumb,
.chain::-webkit-scrollbar-thumb {
  border: 2px solid rgba(20, 15, 11, 0.96);
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold), var(--blue));
}

.suggestions::-webkit-scrollbar-thumb:hover,
.chips::-webkit-scrollbar-thumb:hover,
.hit-strip::-webkit-scrollbar-thumb:hover,
.chain::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(90deg, #ffd06d, #7ed8e7);
}

.suggestion {
  display: grid;
  width: 100%;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding: 9px 12px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  user-select: none;
}

.suggestion.is-active,
.suggestion:hover {
  background: rgba(245, 184, 75, 0.18);
}

.suggestion img,
.chip img,
.hit-strip img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  image-rendering: pixelated;
}

.suggestion span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.control-row {
  justify-content: space-between;
  margin-top: 14px;
  flex-wrap: wrap;
}

.range-wrap {
  display: grid;
  grid-template-columns: auto minmax(140px, 260px) 34px;
  align-items: center;
  gap: 12px;
}

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

.chips {
  display: flex;
  gap: 8px;
  min-height: 44px;
  margin-top: 14px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: max-content;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
}

.chip b,
.muted {
  color: var(--muted);
}

.target-planner {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: center;
  margin: 18px 0;
  padding: 14px;
  border: 1px solid rgba(246, 207, 129, 0.16);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.12);
}

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

.planner-head .eyebrow {
  grid-column: 1 / -1;
}

.target-planner h2 {
  margin: 0;
}

.planner-toggle {
  min-width: 122px;
  height: 38px;
  border: 1px solid rgba(95, 189, 208, 0.58);
  border-radius: 8px;
  padding: 0 12px;
  background: rgba(95, 189, 208, 0.13);
  color: var(--ink);
  font-weight: 900;
}

.planner-toggle:hover {
  border-color: rgba(95, 189, 208, 0.9);
  background: rgba(95, 189, 208, 0.22);
}

.target-planner.is-collapsed {
  gap: 0;
}

.target-planner.is-collapsed .reverse-planner {
  display: none;
}

.reverse-planner {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
  min-width: 0;
}

.target-focus {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.055);
}

.target-focus img {
  width: 46px;
  height: 46px;
  object-fit: contain;
  image-rendering: pixelated;
}

.target-focus strong,
.target-focus span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.target-focus span {
  color: var(--muted);
  font-size: 13px;
}

.reverse-chain {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 8px;
  min-width: 0;
}

.feeder {
  display: grid;
  grid-template-columns: auto 38px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.18);
  color: var(--ink);
  text-align: left;
}

.feeder img {
  width: 38px;
  height: 38px;
  object-fit: contain;
  image-rendering: pixelated;
}

.feeder span {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 50%;
  background: rgba(152, 199, 106, 0.18);
  color: var(--green);
  font: 900 12px/1 ui-monospace, monospace;
}

.feeder strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feeder small {
  grid-column: 3;
  color: var(--muted);
  font: 800 11px/1 ui-monospace, monospace;
}

.feeder:hover,
.chip:hover,
.ghost:hover {
  border-color: rgba(245, 184, 75, 0.72);
  background: rgba(245, 184, 75, 0.13);
}

.chip.is-selected {
  border-color: rgba(95, 189, 208, 0.72);
  background: rgba(95, 189, 208, 0.14);
}

.chip i {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 50%;
  color: rgba(243, 234, 211, 0.72);
  font-style: normal;
  font-weight: 900;
}

.chip i:hover {
  background: rgba(230, 83, 79, 0.22);
  color: var(--ink);
}

.tracker {
  display: grid;
  gap: 18px;
}

.track-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.3);
}

.track-card::before {
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  content: "";
  background: linear-gradient(90deg, var(--red), var(--gold), var(--green), var(--blue));
}

.track-head {
  justify-content: space-between;
  padding: 18px;
}

.start-item {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 14px;
  min-width: 0;
}

.start-item img {
  width: 76px;
  height: 76px;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 8px 0 rgba(0, 0, 0, 0.16));
}

.start-item p {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--muted);
}

.track-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.keep-button,
.lifetime {
  height: 38px;
  border: 1px solid rgba(95, 189, 208, 0.58);
  border-radius: 8px;
  padding: 0 12px;
  background: rgba(95, 189, 208, 0.13);
  color: var(--ink);
  font-weight: 900;
}

.keep-button b {
  margin-left: 4px;
  color: var(--blue);
  font: 900 13px/1 ui-monospace, monospace;
}

.lifetime {
  display: grid;
  place-items: center;
  border-color: rgba(152, 199, 106, 0.48);
  background: rgba(152, 199, 106, 0.12);
  color: var(--green);
}

.hit-callout {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: 180px;
  max-width: 280px;
  border: 1px solid rgba(152, 199, 106, 0.48);
  border-radius: 8px;
  padding: 9px 12px;
  background: rgba(152, 199, 106, 0.12);
}

.hit-callout b {
  color: var(--green);
  font: 900 28px/1 ui-monospace, monospace;
}

.hit-callout span {
  color: var(--ink);
  line-height: 1.1;
}

.hit-callout.is-dim {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.hit-callout.is-dim b,
.hit-callout.is-dim span {
  color: var(--muted);
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
  color: var(--ink);
  font-weight: 900;
}

.hit-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 18px 14px;
  scrollbar-gutter: stable;
}

.hit-strip span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: max-content;
  border: 1px solid rgba(152, 199, 106, 0.46);
  border-radius: 8px;
  padding: 6px 10px;
  background: rgba(152, 199, 106, 0.13);
}

.hit-strip b {
  color: var(--green);
}

.chain {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(154px, 180px);
  gap: 10px;
  overflow-x: auto;
  padding: 0 18px 18px;
  scrollbar-gutter: stable;
  scroll-snap-type: x proximity;
}

.chain-item {
  position: relative;
  display: grid;
  grid-template-rows: 26px 76px minmax(36px, auto) minmax(56px, 1fr) auto;
  min-height: 250px;
  scroll-snap-align: start;
  border: 1px solid rgba(246, 207, 129, 0.16);
  border-radius: 8px;
  padding: 10px;
  background: rgba(8, 7, 6, 0.36);
}

.chain-item.is-origin {
  background: rgba(245, 184, 75, 0.12);
}

.chain-item.is-target {
  border-color: rgba(152, 199, 106, 0.9);
  box-shadow: inset 0 0 0 1px rgba(152, 199, 106, 0.46);
}

.step-badge {
  justify-self: start;
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--gold);
  font: 900 12px/1 ui-monospace, monospace;
}

.chain-item img {
  align-self: center;
  justify-self: center;
  width: 74px;
  height: 74px;
  object-fit: contain;
  image-rendering: pixelated;
  transition: transform 150ms ease;
}

.chain-item:hover img {
  transform: translateY(-3px) scale(1.08);
}

.chain-item p {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.22;
}

.chain-item footer {
  color: rgba(243, 234, 211, 0.5);
  font: 800 11px/1 ui-monospace, monospace;
}

.empty {
  position: relative;
  min-height: 360px;
  display: grid;
  place-items: center;
  align-content: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
  overflow: hidden;
}

.empty h2 {
  margin-top: 80px;
  font-size: 30px;
}

.empty p {
  width: min(520px, 86%);
  color: var(--muted);
}

.empty-orbit {
  position: absolute;
  width: 96px;
  height: 96px;
  border: 2px solid var(--gold);
  border-radius: 50%;
  animation: pulse 2.6s ease-in-out infinite;
}

.empty-orbit::after {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--red);
  content: "";
}

.site-notice {
  margin-top: 24px;
  color: rgba(243, 234, 211, 0.62);
  font: 700 12px/1.45 ui-monospace, "SFMono-Regular", Menlo, monospace;
  text-align: center;
}

.site-notice a {
  color: var(--gold);
}

@keyframes pulse {
  50% {
    transform: scale(1.08) rotate(16deg);
    opacity: 0.72;
  }
}

@media (max-width: 860px) {
  .command-panel {
    position: static;
  }

  .input-grid,
  .target-planner,
  .track-head {
    grid-template-columns: 1fr;
    display: grid;
  }

  .reverse-planner {
    grid-template-columns: 1fr;
  }

  .track-actions {
    justify-content: space-between;
  }

  .hit-callout {
    min-width: 0;
    width: 100%;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 18px, 1480px);
    padding-top: 9px;
  }

  .brand {
    align-items: start;
  }

  .dice-mark {
    width: 44px;
    height: 44px;
    font-size: 24px;
  }

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

  .combo > button {
    min-height: 42px;
  }

  .suggestions {
    max-height: min(52dvh, 360px);
  }

  .range-wrap {
    width: 100%;
    grid-template-columns: 1fr;
  }

  .start-item {
    grid-template-columns: 58px minmax(0, 1fr);
  }

  .start-item img {
    width: 58px;
    height: 58px;
  }
}
