:root {
  color-scheme: dark;
  --bg: #111214;
  --panel: #1a1c1f;
  --panel-2: #22252a;
  --ink: #f2f0e6;
  --muted: #a9a397;
  --line: #4b4e52;
  --gold: #f5c45b;
  --green: #4fe26d;
  --red: #e65353;
  --blue: #4ab4ff;
  --shadow: rgba(0, 0, 0, 0.45);
  font-family: "Segoe UI", Arial, sans-serif;
}

@property --progress {
  syntax: "<percentage>";
  inherits: false;
  initial-value: 0%;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1780px;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(rgba(255,255,255,0.022) 1px, transparent 1px) 0 0 / 28px 28px,
    radial-gradient(circle at 35% 15%, rgba(129, 39, 39, 0.22), transparent 34rem),
    #0f1012;
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  height: 34px;
  border: 1px solid #5e6063;
  border-radius: 6px;
  background: #25282d;
  color: var(--ink);
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}

button:hover {
  border-color: var(--gold);
  background: #30343a;
}

button:disabled,
button.is-disabled {
  color: #696d73;
  border-color: #3a3c40;
  background: #181a1d;
  cursor: default;
}

button.is-disabled:hover {
  border-color: #3a3c40;
  background: #181a1d;
}

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: 76px 1fr;
}

.topbar {
  position: relative;
  display: grid;
  grid-template-columns: max-content minmax(294px, calc(50vw - 612px)) minmax(606px, 1fr);
  align-items: center;
  gap: 16px;
  padding: 7px 16px;
  border-bottom: 3px solid #3a3d40;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,0.03) 0 8px, transparent 8px 18px),
    linear-gradient(180deg, #511014, #2b090b);
  box-shadow: 0 3px 18px var(--shadow);
}

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

.brand-mark {
  width: 62px;
  height: 62px;
  flex: 0 0 auto;
  object-fit: contain;
  image-rendering: auto;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.7)) drop-shadow(0 0 6px rgba(255,190,72,0.22));
}

.brand > div {
  min-width: 0;
}

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

h1 {
  color: #ffbd3c;
  font-size: 26px;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

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

.donate-button {
  height: 34px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  margin-left: 4px;
  padding: 0 12px;
  border: 1px solid #ffc15a;
  border-radius: 6px;
  background: linear-gradient(180deg, #2d2412, #17120b);
  color: #ffd27a;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.12), 0 0 0 1px rgba(0,0,0,0.45);
}

.donate-button:hover {
  background: linear-gradient(180deg, #4a3514, #21170c);
  color: #ffe3a4;
}

.donate-button.is-disabled {
  border-color: #695333;
  color: #a89061;
}

.donate-button.is-disabled:hover {
  background: linear-gradient(180deg, #2d2412, #17120b);
  color: #a89061;
}

.summary {
  position: absolute;
  left: 50%;
  top: 12px;
  width: 330px;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.summary div {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid #5b2e12;
  border-radius: 6px;
  background: rgba(15, 13, 12, 0.72);
}

.summary span {
  display: block;
  color: #c3aa75;
  font-size: 11px;
}

.summary strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--gold);
  font-size: 18px;
  line-height: 1.1;
}

.toolbar {
  display: grid;
  grid-template-columns: 190px 132px 70px 68px 54px 62px;
  gap: 6px;
  align-items: end;
  justify-content: end;
  justify-self: end;
}

.search {
  display: grid;
  gap: 3px;
}

.search span {
  color: #ceb98a;
  font-size: 11px;
}

.search input {
  width: 100%;
  height: 34px;
  border: 1px solid #666b70;
  border-radius: 6px;
  padding: 0 10px;
  background: #111316;
  color: var(--ink);
}

.mode-control {
  display: grid;
  gap: 3px;
}

.mode-control > span {
  color: #ceb98a;
  font-size: 11px;
}

.segmented {
  height: 34px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid #666b70;
  border-radius: 6px;
  overflow: hidden;
  background: #111316;
}

.segmented button {
  height: 32px;
  border: 0;
  border-right: 1px solid #3c4045;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  font-size: 12px;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.is-active {
  background: #3a2b15;
  color: var(--gold);
}

button.is-active {
  border-color: var(--gold);
  color: var(--gold);
}

.workspace {
  --bonus-width: 300px;
  --detail-width: 360px;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--bonus-width) minmax(0, 1fr) var(--detail-width);
  transition: grid-template-columns 180ms ease;
}

.workspace.is-sidebar-closed {
  --bonus-width: 0;
}

.workspace.is-detail-closed {
  --detail-width: 0;
}

.bonus-sidebar {
  min-width: 0;
  overflow: auto;
  padding: 16px;
  border-right: 2px solid #35383c;
  background: #15171a;
}

.workspace.is-sidebar-closed .bonus-sidebar {
  padding-left: 0;
  padding-right: 0;
  border-right: 0;
  opacity: 0;
  pointer-events: none;
}

.profile-panel,
.controls-panel,
.bonus-panel {
  display: grid;
  gap: 10px;
}

.controls-panel,
.bonus-panel {
  margin-top: 18px;
}

.bonus-sidebar > .bonus-panel:first-child {
  margin-top: 0;
}

.profile-panel h2,
.controls-panel h2,
.bonus-panel h2 {
  color: var(--gold);
  font-size: 15px;
  text-transform: uppercase;
}

.profile-panel select {
  width: 100%;
  height: 34px;
  border: 1px solid #666b70;
  border-radius: 6px;
  padding: 0 8px;
  background: #111316;
  color: var(--ink);
}

.profile-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.header-profile {
  width: min(322px, 100%);
  justify-self: center;
  display: grid;
  grid-template-columns: 73px 1fr;
  grid-template-rows: 28px 28px;
  align-items: center;
  gap: 3px 6px;
}

.header-profile h2 {
  grid-column: 1;
  grid-row: 1;
  margin-bottom: 0;
  font-size: 15px;
}

.header-profile select {
  grid-column: 2;
  grid-row: 1;
  height: 28px;
  min-width: 0;
}

.header-profile .profile-actions {
  grid-column: 1 / -1;
  grid-row: 2;
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr 1fr;
  gap: 6px;
}

.header-profile .profile-actions button {
  height: 28px;
  padding: 0 4px;
  font-size: 16px;
  line-height: 1;
}

.controls-list {
  display: grid;
  grid-template-columns: minmax(96px, auto) 1fr;
  gap: 7px 9px;
  margin: 0;
  padding: 9px;
  border: 1px solid #34383d;
  border-radius: 6px;
  background: #1d2024;
}

.controls-overlay {
  position: absolute;
  z-index: 9;
  right: 14px;
  bottom: 14px;
  width: 282px;
  padding: 10px;
  border: 1px solid #44484e;
  border-radius: 6px;
  background: rgba(24, 27, 31, 0.94);
  box-shadow: 0 12px 26px rgba(0,0,0,0.45);
}

.controls-overlay.is-hidden {
  display: none;
}

.overlay-heading {
  display: grid;
  grid-template-columns: 1fr 28px;
  align-items: center;
  gap: 8px;
}

.overlay-heading h2 {
  color: var(--gold);
  font-size: 13px;
  text-transform: uppercase;
}

.overlay-heading button {
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

.controls-overlay .controls-list {
  margin-top: 8px;
}

.controls-show-button {
  position: absolute;
  z-index: 9;
  right: 14px;
  bottom: 14px;
  width: 82px;
  display: none;
}

.controls-show-button.is-visible {
  display: block;
}

.controls-list dt {
  color: #d6bf82;
  font-size: 12px;
  font-weight: 700;
}

.controls-list dd {
  margin: 0;
  color: #ddd6c7;
  font-size: 12px;
  line-height: 1.3;
}

.bonus-list {
  display: grid;
  gap: 7px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.bonus-list li {
  display: grid;
  grid-template-columns: minmax(76px, auto) 1fr;
  gap: 9px;
  align-items: baseline;
  padding: 8px;
  border: 1px solid #34383d;
  border-radius: 6px;
  background: #1d2024;
}

.bonus-list strong {
  color: var(--green);
  font-size: 14px;
}

.bonus-list span,
.bonus-list .is-empty {
  color: #ddd6c7;
  font-size: 12px;
  line-height: 1.3;
}

.bonus-list .is-empty {
  grid-template-columns: 1fr;
  color: var(--muted);
}

.graph-panel {
  position: relative;
  min-width: 0;
  min-height: 0;
  border-right: 2px solid #35383c;
  background:
    radial-gradient(circle at center, rgba(255,255,255,0.035) 0 1px, transparent 1px 100%) 0 0 / 18px 18px,
    #17191c;
}

.graph-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: grab;
}

.graph-viewport.is-dragging {
  cursor: grabbing;
}

.graph-scene {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
}

.edge-layer,
.node-layer {
  position: absolute;
  inset: 0;
}

.edge-layer {
  overflow: visible;
}

.edge {
  fill: none;
  stroke: rgba(210, 214, 218, 0.44);
  stroke-width: 3;
}

.edge.is-active {
  stroke: var(--green);
  stroke-width: 4;
}

.edge.is-available {
  stroke: var(--gold);
}

.edge.is-hidden {
  opacity: 0.06;
}

.rune-node {
  --node-color: var(--gold);
  --progress: 0%;
  --progress-start: -90deg;
  position: absolute;
  width: 42px;
  height: 42px;
  transform: translate(-21px, -21px);
  border: 0;
  border-radius: 4px;
  color: white;
  background: #050607;
  box-shadow:
    0 0 0 2px #050607,
    0 4px 8px rgba(0,0,0,0.55);
  display: grid;
  place-items: center;
  padding: 3px;
  overflow: visible;
}

.rune-progress {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: 4px;
  background: conic-gradient(from var(--progress-start), var(--node-color) 0 var(--progress), #4a4d52 var(--progress) 100%);
  transition: --progress 180ms ease;
}

.rune-node::before {
  content: "";
  position: absolute;
  inset: 3px;
  z-index: 1;
  border-radius: 2px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.28) 0 18%, transparent 18%),
    repeating-linear-gradient(45deg, rgba(255,255,255,0.08) 0 3px, transparent 3px 7px),
    #15171a;
  box-shadow: inset 0 0 0 2px rgba(0,0,0,0.55);
}

.rune-node::after {
  content: attr(data-level);
  position: absolute;
  z-index: 3;
  right: 1px;
  bottom: 1px;
  min-width: 21px;
  height: 14px;
  padding: 0 3px;
  display: grid;
  place-items: center;
  border: 1px solid #0a0b0d;
  border-radius: 4px;
  background: #20242a;
  color: #d7d2c2;
  font-size: 9px;
  line-height: 1;
}

.rune-node.is-planned::before {
  background:
    linear-gradient(135deg, rgba(255,255,255,0.38) 0 18%, transparent 18%),
    repeating-linear-gradient(45deg, rgba(255,255,255,0.12) 0 3px, transparent 3px 7px),
    color-mix(in srgb, var(--node-color) 36%, #15171a);
}

.rune-node.is-max {
  box-shadow:
    0 0 0 2px #050607,
    0 4px 8px rgba(0,0,0,0.55);
}

.rune-node.is-locked {
  filter: saturate(0.45) brightness(0.6);
}

.rune-node:focus {
  outline: none;
}

.rune-node.is-selected {
  box-shadow:
    0 4px 8px rgba(0,0,0,0.55);
}

.rune-node.is-hidden {
  opacity: 0.12;
}

.rune-glyph {
  width: 28px;
  height: 28px;
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,0.16);
  color: #fff5cf;
  font-size: 11px;
  font-weight: 800;
  text-shadow: 0 1px 0 #000;
  overflow: hidden;
}

.selection-corners {
  position: absolute;
  inset: -7px;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  background:
    linear-gradient(#fff, #fff) left top / 13px 3px no-repeat,
    linear-gradient(#fff, #fff) left top / 3px 13px no-repeat,
    linear-gradient(#fff, #fff) right top / 13px 3px no-repeat,
    linear-gradient(#fff, #fff) right top / 3px 13px no-repeat,
    linear-gradient(#fff, #fff) left bottom / 13px 3px no-repeat,
    linear-gradient(#fff, #fff) left bottom / 3px 13px no-repeat,
    linear-gradient(#fff, #fff) right bottom / 13px 3px no-repeat,
    linear-gradient(#fff, #fff) right bottom / 3px 13px no-repeat;
  filter: drop-shadow(0 0 3px rgba(255,255,255,0.8)) drop-shadow(0 1px 1px #000);
}

.rune-node.is-selected .selection-corners {
  opacity: 1;
}

.rune-glyph img,
.selected-icon img,
.tooltip-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  transform: scaleY(-1);
}

.graph-controls {
  position: absolute;
  z-index: 8;
  left: 14px;
  bottom: 14px;
  display: grid;
  gap: 6px;
}

.graph-controls button {
  width: 38px;
  height: 38px;
  font-size: 20px;
}

.detail-panel {
  min-width: 0;
  overflow: auto;
  padding: 18px;
  background: var(--panel);
  transition: padding 180ms ease, opacity 180ms ease;
}

.workspace.is-detail-closed .detail-panel {
  padding-left: 0;
  padding-right: 0;
  opacity: 0;
  pointer-events: none;
}

.selected-heading {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 12px;
  align-items: center;
  padding-bottom: 14px;
  border-bottom: 1px solid #3a3d40;
}

.selected-icon {
  --node-color: var(--gold);
  width: 58px;
  height: 58px;
  border: 3px solid var(--node-color);
  border-radius: 6px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.3) 0 20%, transparent 20%),
    repeating-linear-gradient(45deg, rgba(255,255,255,0.08) 0 4px, transparent 4px 9px),
    #15171a;
  display: grid;
  place-items: center;
  color: #fff5cf;
  font-weight: 800;
  overflow: hidden;
}

.selected-heading h2 {
  font-size: 22px;
  line-height: 1.1;
}

.level-line {
  margin-top: 4px;
  color: var(--green);
  font-weight: 700;
}

.action-row {
  display: grid;
  grid-template-columns: 46px 46px 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}

.detail-panel section {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid #303338;
}

.detail-panel h3 {
  margin-bottom: 8px;
  color: #d6bf82;
  font-size: 13px;
  text-transform: uppercase;
}

#selectedDescription {
  color: #eee8d8;
  line-height: 1.45;
}

.cost-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 24px;
}

.cost-list li {
  color: #d7d2c2;
}

.cost-list li.is-owned {
  color: var(--green);
}

.cost-list li.is-next {
  color: var(--gold);
}

.link-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.link-list button {
  width: 100%;
  height: auto;
  min-height: 32px;
  text-align: left;
  padding: 7px 8px;
}

.notes {
  display: none;
}

.notes.is-visible {
  display: block;
}

.notes ul {
  margin: 0;
  padding-left: 18px;
  color: #f2bc75;
}

.tooltip {
  position: fixed;
  z-index: 30;
  pointer-events: none;
  width: min(390px, calc(100vw - 28px));
  display: none;
  padding: 12px;
  border: 2px solid #686b6f;
  border-radius: 6px;
  background: rgba(7, 8, 9, 0.96);
  box-shadow: 0 14px 34px rgba(0,0,0,0.55);
}

.tooltip.is-visible {
  display: block;
}

.tooltip.is-help {
  width: min(300px, calc(100vw - 28px));
  padding: 9px 10px;
}

.tooltip .control-help {
  margin: 0;
  color: #eee8d8;
  font-size: 13px;
  line-height: 1.35;
  white-space: pre-line;
}

.tooltip h4 {
  margin: 0;
  font-size: 17px;
}

.tooltip-title {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 9px;
  align-items: center;
}

.tooltip-icon {
  --node-color: var(--gold);
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 2px solid var(--node-color);
  border-radius: 4px;
  background: #15171a;
  overflow: hidden;
}

.tooltip .tooltip-level {
  margin-top: 2px;
  color: var(--green);
  font-weight: 700;
}

.tooltip p {
  margin-top: 8px;
  color: #eee8d8;
}

.tooltip dl {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 5px 8px;
  margin: 10px 0 0;
}

.tooltip dt {
  color: #c3aa75;
}

.tooltip dd {
  margin: 0;
  color: #dad5c9;
}

.tooltip .mini-costs {
  display: grid;
  gap: 5px;
  margin-top: 9px;
}

.tooltip .mini-costs span {
  display: grid;
  grid-template-columns: 58px 1fr;
  align-items: center;
  gap: 8px;
  border: 1px solid #3d4146;
  border-radius: 4px;
  padding: 5px 7px;
  background: #171a1e;
  font-size: 13px;
}

.tooltip .mini-costs strong {
  color: inherit;
}

.tooltip .mini-costs em {
  color: inherit;
  font-style: normal;
}

.tooltip .mini-costs .is-owned {
  border-color: var(--green);
  color: var(--green);
}

.tooltip .mini-costs .is-next {
  border-color: var(--gold);
  color: var(--gold);
}

@media (max-width: 1780px) {
  body {
    min-width: 1780px;
  }

  .topbar {
    grid-template-columns: max-content 294px minmax(606px, 1fr);
  }

  .workspace {
    --detail-width: 330px;
  }
}
