/* The play screen: the mana bar, and the stats, action list and town panels. */

.icon {
  display: inline-flex;
}

.icon svg {
  width: 14px;
  height: 14px;
}

[hidden] {
  display: none !important;
}

/* ---- Top bar ------------------------------------------------------------------------------- */

.topBar {
  margin-bottom: 12px;
  padding-top: 10px;
}

.manaTrack {
  position: relative;
  height: 26px;
  margin-bottom: 10px;
  border-radius: 8px;
  background: var(--inset);
  border: 1px solid var(--line);
  overflow: hidden;
}

.manaTrack > span {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, #4a54c9, #6f7af0 70%, #a9b0ff);
  box-shadow: 0 0 14px rgba(140, 150, 255, 0.55);
}

.manaText {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 100%;
  padding: 0 12px;
  font-size: 12px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
}

.manaLabel {
  color: #e6e8ff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.manaText .value {
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.manaText .dim {
  color: #c9cdf5;
}

.topRow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.controls .button {
  min-width: 96px;
}

.bonusButton {
  gap: 7px;
}

.bonusButton .bonusState {
  padding: 0 6px;
  border-radius: 999px;
  background: var(--inset);
  font-size: 10px;
  letter-spacing: 0.1em;
}

.bonusButton.on {
  border-color: var(--bonus);
  color: var(--bonus);
  box-shadow: 0 0 12px rgba(79, 213, 255, 0.3);
}

.resources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}

.res-gold .label,
.res-gold .value {
  color: var(--gold);
}

.res-reputation .label {
  color: var(--rep);
}

.button:disabled {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

.segmented.small button {
  min-width: 28px;
  padding: 2px 8px;
  font-size: 12px;
}

/* ---- Columns ------------------------------------------------------------------------------- */

/* The action list is the main thing, so it gets the middle and all the width that's left. */
#app {
  max-width: 1560px;
}

.columns {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) clamp(330px, 29vw, 450px);
  gap: 12px;
  align-items: start;
}

@media (max-width: 1180px) {
  .columns {
    grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  }
  .listPanel {
    grid-column: 1;
    grid-row: 1;
  }
  .statsPanel {
    grid-column: 1;
    grid-row: 2;
  }
  .townPanel {
    grid-column: 2;
    grid-row: 1 / span 2;
  }
}

@media (max-width: 820px) {
  .columns {
    grid-template-columns: minmax(0, 1fr);
  }
  .columns > .panel {
    grid-column: 1;
    grid-row: auto;
  }
  .listPanel {
    order: 1;
  }
  .townPanel {
    order: 2;
  }
  .statsPanel {
    order: 3;
  }
}

@media (max-width: 720px) {
  .appHeader {
    gap: 10px;
  }
  .toolButton {
    padding: 0 10px;
  }
  .brandTag,
  .toolButton .icon + * {
    font-size: 9px;
  }
  .appFooter {
    flex-direction: column;
  }
}

/* ---- Stats --------------------------------------------------------------------------------- */

.statList,
.skillsBlock {
  display: grid;
  gap: 7px;
}

.skillsBlock {
  margin-top: 14px;
}

.statRow {
  display: grid;
  gap: 3px;
  padding: 3px 0;
}

.statHead {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.statName {
  flex: 1;
  font-weight: 600;
}

.statName::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 8px;
  border-radius: 2px;
  background: var(--bar, var(--accent));
  vertical-align: 1px;
}

.skillRow .statName::before {
  background: var(--accent);
}

.statLevel {
  min-width: 38px;
  font-size: 15px;
  font-weight: 700;
  text-align: right;
}

.statTalent {
  color: var(--muted);
  font-size: 11px;
}

.statSoul {
  color: #c3c8ff;
  font-size: 11px;
}

.talentBar > span {
  opacity: 0.45;
}

.bar.thick {
  height: 6px;
}

.bar.thin {
  height: 3px;
  margin-top: 2px;
}

.bar.thin > span {
  opacity: 0.5;
}

.radarWrap {
  text-align: center;
}

.radar {
  width: 100%;
  max-width: 260px;
}

.radar .ring {
  fill: none;
  stroke: var(--line);
}

.radar .axis {
  stroke: var(--line);
}

.radar .axisLabel {
  font: 700 11px var(--font);
  text-anchor: middle;
}

.radar .radarLevel {
  fill: rgba(184, 148, 255, 0.22);
  stroke: var(--stat-Int);
  stroke-width: 2;
  stroke-linejoin: round;
}

.radar .radarMult {
  fill: rgba(255, 196, 77, 0.14);
  stroke: var(--gold);
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
}

.radarLegend {
  display: flex;
  justify-content: center;
  gap: 14px;
  color: var(--muted);
  font-size: 12px;
}

.radarLegend span::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 3px;
  margin-right: 6px;
  vertical-align: middle;
}

.legendLevel::before {
  background: var(--stat-Int);
}

.legendMult::before {
  background: var(--gold);
}

/* ---- Action lists -------------------------------------------------------------------------- */

.listPanel {
  container-type: inline-size;
}

.listColumns {
  display: grid;
  grid-template-columns: minmax(190px, 33%) minmax(0, 1fr);
  gap: 12px;
}

.listColumn {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.listHead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  min-height: 28px;
  margin-bottom: 6px;
}

.listHead .spacer {
  flex: 1;
}

.listLabel {
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.listMeta {
  color: var(--dim);
  font-size: 11px;
}

.currentList,
.nextList {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
  height: clamp(320px, calc(100vh - 370px), 1000px);
  overflow-y: auto;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--inset);
  scrollbar-width: thin;
  scrollbar-color: var(--line-hi) transparent;
}

.actionIcon {
  width: 24px;
  height: 24px;
  flex: none;
}

.itemName {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.itemIndex {
  min-width: 18px;
  color: var(--dim);
  font-size: 11px;
  text-align: right;
}

.emptyHint {
  display: grid;
  gap: 4px;
  margin: auto;
  padding: 16px;
  color: var(--dim);
  font-size: 12px;
  text-align: center;
}

.emptyHint b {
  color: var(--muted);
}

/* This loop: read-only, shows where the loop is. */

.currentItem {
  position: relative;
  display: flex;
  flex: none;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 2px 8px 2px 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  overflow: hidden;
}

.currentItem > * {
  position: relative;
}

.currentItem .itemFill {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, rgba(140, 150, 255, 0.1), rgba(140, 150, 255, 0.28));
}

.itemState {
  display: grid;
  place-items: center;
  width: 18px;
}

.itemState .icon {
  display: none;
}

.itemState .icon svg {
  width: 14px;
  height: 14px;
}

.itemLoops {
  color: var(--muted);
  font-size: 12px;
}

.currentItem.active {
  border-color: var(--mana);
  box-shadow:
    inset 3px 0 0 var(--mana),
    0 0 12px rgba(140, 150, 255, 0.25);
}

.currentItem.active .itemName {
  color: #fff;
  font-weight: 700;
}

.currentItem.active .itemLoops,
.currentItem.active .itemIndex {
  color: var(--mana);
}

.currentItem.done {
  color: var(--dim);
  border-color: transparent;
  background: transparent;
}

.currentItem.done .itemFill {
  background: rgba(255, 255, 255, 0.025);
}

.currentItem.done img {
  opacity: 0.5;
}

.currentItem.done .itemIndex,
.currentItem.failed .itemIndex {
  display: none;
}

.currentItem.done .stateDone {
  display: inline-flex;
  color: var(--accent-dim);
}

.currentItem.failed {
  border-color: rgba(255, 90, 95, 0.55);
  color: #ffc9cb;
}

.currentItem.failed .itemFill {
  background: rgba(255, 90, 95, 0.14);
}

.currentItem.failed .stateFail {
  display: inline-flex;
  color: var(--danger);
}

.currentItem.failed .itemLoops {
  color: var(--danger);
}

.failText,
.lockedText {
  color: var(--danger) !important;
}

/* Next loop: the list you edit. Every entry shows all its controls, and the one under the pointer
   lights up so it's clear which entry they belong to. */

.nextItem {
  position: relative;
  display: flex;
  flex: none;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 2px 4px 2px 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  transition:
    background 0.08s,
    border-color 0.08s;
}

.nextItem:hover,
.nextItem:focus-within {
  border-color: var(--line-hi);
  background: var(--panel-hi);
  box-shadow: inset 3px 0 0 var(--accent);
}

.nextItem:hover .itemName,
.nextItem:focus-within .itemName {
  color: #fff;
}

.nextItem.empty .itemName {
  color: var(--dim);
  text-decoration: line-through;
}

.nextItem.empty .actionIcon {
  opacity: 0.45;
}

.grip {
  display: grid;
  place-items: center;
  width: 14px;
  align-self: stretch;
  color: var(--dim);
  cursor: grab;
  opacity: 0.45;
}

.grip svg {
  width: 12px;
  height: 12px;
}

.nextItem:hover .grip {
  opacity: 1;
}

.nextItem .itemIndex {
  min-width: 16px;
}

.itemHead {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.stepper {
  display: inline-flex;
  flex: none;
  align-items: stretch;
  width: 92px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--inset);
  overflow: hidden;
}

.stepper .listOp {
  width: 24px;
  height: auto;
  border-radius: 0;
  opacity: 0.85;
}

.loopInput {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  border-inline: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font: 600 13px var(--mono);
  text-align: center;
}

.loopInput:focus {
  outline: none;
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.stepper.fixed {
  border-style: dashed;
  background: transparent;
}

.loopFixed {
  flex: 1;
  align-self: center;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.itemOps {
  display: flex;
  flex: none;
  gap: 1px;
}

.opGap {
  width: 26px;
}

.listOp {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  opacity: 0.6;
}

.listOp svg {
  width: 14px;
  height: 14px;
}

.nextItem:hover .listOp,
.nextItem:focus-within .listOp {
  opacity: 1;
}

.listOp:hover,
.listOp:focus-visible {
  background: var(--line);
  color: var(--text);
}

.listOp.off {
  opacity: 0.15 !important;
  pointer-events: none;
}

.listOp.remove {
  margin-left: 2px;
  opacity: 0.9;
}

.listOp.remove:hover,
.listOp.remove:focus-visible {
  background: rgba(255, 90, 95, 0.18);
  color: var(--danger);
}

.nextItem.fresh {
  animation: freshRow 1.4s ease-out;
}

@keyframes freshRow {
  from {
    border-color: var(--accent);
    background: rgba(46, 230, 166, 0.2);
  }
}

.nextItem.dragging {
  opacity: 0.35;
}

.nextList.sorting .nextItem:hover {
  box-shadow: none;
}

.nextList .nextItem.dropBefore {
  box-shadow: 0 -3px 0 -1px var(--accent);
}

.nextList .nextItem.dropAfter {
  box-shadow: 0 3px 0 -1px var(--accent);
}

.clearButton.armed {
  border-color: rgba(255, 90, 95, 0.6);
  color: var(--danger);
}

.listFooter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.controlGroup {
  display: flex;
  align-items: center;
  gap: 8px;
}

.controlLabel {
  color: var(--dim);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.listOptions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  font-size: 12px;
}

/* A narrow panel stacks the lists: the running one short on top, the one you edit below. */
@container (max-width: 640px) {
  .listColumns {
    grid-template-columns: minmax(0, 1fr);
  }
  .currentList {
    height: auto;
    min-height: 80px;
    max-height: 200px;
  }
  .nextList {
    height: clamp(300px, 60vh, 640px);
  }
}

@container (max-width: 400px) {
  .nextItem .itemIndex,
  .itemOps .listOp[data-op="moveUp"],
  .itemOps .listOp[data-op="moveDown"] {
    display: none;
  }
  .nextItem {
    padding-left: 4px;
  }
  .grip {
    display: none;
  }
  .stepper {
    width: 80px;
  }
}

/* ---- Town ---------------------------------------------------------------------------------- */

.townHeader {
  display: flex;
  align-items: center;
  gap: 10px;
}

.townTitle {
  flex: 1;
  text-align: center;
}

.townName {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.hereBadge {
  display: inline-block;
  margin-top: 2px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(46, 230, 166, 0.12);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.townArrow {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--bg-raised);
  color: var(--muted);
  cursor: pointer;
}

.townArrow:hover {
  color: var(--text);
  border-color: var(--line-hi);
}

.townArrow.hiddenArrow {
  visibility: hidden;
}

.townDesc {
  margin: 6px 0 12px;
  color: var(--muted);
  text-align: center;
}

.townInfo {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.infoRow {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--inset);
}

.infoHead {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
}

.infoLabel {
  font-weight: 600;
}

.infoValue {
  color: var(--muted);
}

.progressRow {
  --bar: var(--gold);
}

.lootRow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
}

.lootRow .infoLabel {
  flex: 1;
}

.lootCounts {
  display: flex;
  align-items: center;
  gap: 6px;
}

.lootLeft {
  color: var(--accent);
  font-weight: 700;
}

.lootGood {
  color: var(--text);
}

.lootUnchecked {
  color: var(--muted);
}

.arrow {
  color: var(--dim);
}

.lootFirst {
  font-size: 12px;
}

.segments {
  display: flex;
  gap: 4px;
}

.segment {
  position: relative;
  flex: 1;
  height: 10px;
  border-radius: 3px;
  background: var(--panel);
  border: 1px solid var(--line);
  overflow: hidden;
}

.segment > span {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--bar, var(--accent));
}

.actionsTitle {
  margin-top: 4px;
}

.actionGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
}

.actionCard {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, var(--panel-hi), var(--panel));
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition:
    border-color 0.12s,
    transform 0.06s;
}

.actionCard:hover {
  border-color: var(--accent);
}

.actionCard.queued {
  border-color: rgba(140, 150, 255, 0.45);
}

/* How many of this action are on the next list. */
.cardCount {
  position: absolute;
  top: 4px;
  right: 4px;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(140, 150, 255, 0.18);
  color: var(--mana);
  font-size: 10.5px;
  font-weight: 700;
}

.actionCard:active {
  transform: translateY(1px);
}

.actionCard.travel {
  grid-column: 1 / -1;
  flex-direction: row;
  justify-content: center;
  border-style: dashed;
  border-color: var(--line-hi);
}

.actionCard.locked {
  opacity: 0.38;
  cursor: not-allowed;
}

.actionCard.locked:hover {
  border-color: var(--line);
}

.cardIcon {
  position: relative;
  display: block;
  width: 40px;
  height: 40px;
}

.cardIcon > img:first-child {
  width: 40px;
  height: 40px;
}

.cardIcon .badge {
  position: absolute;
  right: -10px;
  bottom: -4px;
  width: 18px;
  height: 18px;
  padding: 1px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--line-hi);
}

.cardName {
  line-height: 1.2;
}

/* ---- Tooltip extras ------------------------------------------------------------------------ */

.statTags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.statTag {
  padding: 0 6px;
  border-radius: 999px;
  background: var(--inset);
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 700;
}

.statTag[data-stat="Dex"] {
  color: var(--stat-Dex);
}
.statTag[data-stat="Str"] {
  color: var(--stat-Str);
}
.statTag[data-stat="Con"] {
  color: var(--stat-Con);
}
.statTag[data-stat="Spd"] {
  color: var(--stat-Spd);
}
.statTag[data-stat="Per"] {
  color: var(--stat-Per);
}
.statTag[data-stat="Cha"] {
  color: var(--stat-Cha);
}
.statTag[data-stat="Int"] {
  color: var(--stat-Int);
}
.statTag[data-stat="Luck"] {
  color: var(--stat-Luck);
}
.statTag[data-stat="Soul"] {
  color: var(--stat-Soul);
}

.hasTip {
  cursor: help;
}

button.hasTip,
.actionCard.hasTip,
.nextItem.hasTip {
  cursor: pointer;
}

/* ---- Dialog extras ------------------------------------------------------------------------- */

.storyText {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text) !important;
}

.storyNav {
  justify-content: space-between;
}

.license {
  max-height: 200px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--inset);
  color: var(--muted);
  font: 11px/1.45 var(--mono);
  white-space: pre-wrap;
}
