﻿:root {
  --bg: #0b1016;
  --panel: #141d28;
  --panel-2: #1b2633;
  --text: #ecf2f8;
  --muted: #9fb2c7;
  --accent: #40c4ff;
  --ok: #1ecb70;
  --warn: #ffb84d;
  --bad: #ff6f7d;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: radial-gradient(circle at 20% 0%, #122132 0%, var(--bg) 45%);
  color: var(--text);
}

.layout { max-width: 1400px; margin: 0 auto; padding: 16px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.topbar-brand { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; min-width: 0; }
.topbar h1 { margin: 0; }
.build-badge {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #7f93a8;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  opacity: 0.85;
}
.build-badge.staging {
  padding: 3px 8px;
  border-radius: 999px;
  background: #3a2f14;
  color: #ffd789;
  border: 1px solid #6a5420;
  font-weight: 700;
  opacity: 1;
}
.badge { padding: 6px 10px; border-radius: 999px; font-weight: 700; }
.badge.offline { background: #3a2026; color: #ffccd3; }
.badge.online { background: #163427; color: #a8ffd1; }

.main-grid { display: grid; grid-template-columns: 1fr 330px; gap: 16px; margin-top: 14px; }
.article-panel, .card {
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid #29384a;
  border-radius: 14px;
}

.article-panel { padding: 12px; min-height: 78vh; min-width: 0; }
.search-overlay {
  margin: 8px 0 10px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid #395068;
  background: #0e1620;
}
.search-row { display: flex; gap: 8px; }
.search-row input {
  flex: 1;
  padding: 10px;
  border-radius: 9px;
  border: 1px solid #395068;
  background: #0e1620;
  color: var(--text);
}
.search-meta {
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.85rem;
}
.article-head { display: flex; gap: 8px; }
.article-head input {
  flex: 1;
  padding: 10px;
  border-radius: 9px;
  border: 1px solid #395068;
  background: #0e1620;
  color: var(--text);
}
button {
  border: 0;
  border-radius: 9px;
  padding: 10px 14px;
  background: var(--accent);
  color: #072033;
  font-weight: 700;
  cursor: pointer;
}
.article-title { margin: 12px 0 8px; font-size: 1.2rem; font-weight: 800; }
.article-body {
  max-height: calc(78vh - 90px);
  overflow-x: hidden;
  overflow-y: auto;
  background: #0d1621;
  border-radius: 10px;
  border: 1px solid #314358;
  padding: 12px;
  min-width: 0;
}
.article-body a { color: #8dd9ff; text-decoration: underline; cursor: pointer; }
.article-body img,
.article-body video,
.article-body .mw-file-element {
  display: inline-block;
  max-width: 100%;
  height: auto;
}
.article-body .thumb,
.article-body .gallery,
.article-body figure {
  max-width: 100%;
}
.article-body .mw-editsection { display: none !important; }
.article-body .wiki-section-external { display: none !important; }

/* Display lenses: hide locked wiki chrome until the matching Lens item arrives */
.article-body.lock-tables .table-scroll:has(> table:not(.infobox):not(.infobox_v2):not(.navbox):not(.vertical-navbox)),
.article-body.lock-tables table:not(.infobox):not(.infobox_v2):not(.navbox):not(.vertical-navbox) {
  display: none !important;
}
.article-body.lock-pictures img,
.article-body.lock-pictures video,
.article-body.lock-pictures .thumb,
.article-body.lock-pictures .gallery,
.article-body.lock-pictures .gallerybox,
.article-body.lock-pictures figure,
.article-body.lock-pictures .mw-file-element,
.article-body.lock-pictures .mw-gallery-style-bordered {
  display: none !important;
}
.article-body.lock-incipit .wiki-lead {
  display: none !important;
}
.article-body.lock-infoboxes .infobox,
.article-body.lock-infoboxes .infobox_v2,
.article-body.lock-infoboxes table.infobox,
.article-body.lock-infoboxes table.infobox_v2,
.article-body.lock-infoboxes .table-scroll:has(> table.infobox, > table.infobox_v2, > .infobox, > .infobox_v2) {
  display: none !important;
}
.article-body.lock-toc #toc,
.article-body.lock-toc .toc,
.article-body.lock-toc .mw-table-of-contents,
.article-body.lock-toc .sidebar-toc {
  display: none !important;
}
.article-body.lock-navboxes .navbox,
.article-body.lock-navboxes .navbox-inner,
.article-body.lock-navboxes .vertical-navbox,
.article-body.lock-navboxes table.navbox,
.article-body.lock-navboxes .table-scroll:has(> table.navbox, > .navbox, > .vertical-navbox),
.article-body.lock-navboxes .wiki-section-seealso {
  display: none !important;
}
.article-body.lock-hatnotes .hatnote,
.article-body.lock-hatnotes .dablink,
.article-body.lock-hatnotes .rellink {
  display: none !important;
}
.article-body.lock-references .reference,
.article-body.lock-references .references,
.article-body.lock-references .reflist,
.article-body.lock-references .mw-references-wrap,
.article-body.lock-references ol.references,
.article-body.lock-references .wiki-section-references {
  display: none !important;
}
.article-body p, .article-body li { line-height: 1.45; }
.article-body .mw-parser-output {
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
}
.article-body .table-scroll {
  display: block;
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  margin: 12px 0;
  border: 1px solid #395068;
  border-radius: 8px;
  background: #101a26;
  -webkit-overflow-scrolling: touch;
}
.article-body table {
  display: table;
  width: auto;
  max-width: none;
  border-collapse: collapse;
  margin: 0;
  font-size: 0.92rem;
  background: transparent;
}
.article-body th,
.article-body td {
  border: 1px solid #395068;
  padding: 6px 8px;
  vertical-align: top;
  white-space: normal;
  color: var(--text);
}
.article-body td {
  background: transparent;
}
.article-body tr:nth-child(even) > td {
  background: #152131;
}
.article-body th {
  background: #182433;
  color: var(--text);
  font-weight: 700;
}
.article-body caption {
  caption-side: top;
  text-align: left;
  padding: 8px;
  color: var(--muted);
}
.wiki-search-hit {
  background: #ffdf6b;
  color: #1d1400;
  border-radius: 3px;
  padding: 0 1px;
}

.side-panel { display: flex; flex-direction: column; gap: 12px; }
.bingo-boards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.bingo-board-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.bingo-board-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.bingo-board-label {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
}
.bingo-board-toggle {
  flex-shrink: 0;
  font-size: 0.72rem;
  padding: 2px 8px;
}
.bingo-board-block.collapsed .bingo-grid {
  display: none;
}
.bingo-grid {
  display: grid;
  gap: 0;
  width: min(100%, 10.5rem);
  border-top: 1px solid #3a5068;
  border-left: 1px solid #3a5068;
  background: #3a5068;
}
.bingo-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid #3a5068;
  border-bottom: 1px solid #3a5068;
  border-radius: 0;
  padding: 0;
  background: #14202e;
  color: var(--text);
  font-size: clamp(0.48rem, 1.35vw, 0.62rem);
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1;
  user-select: none;
}
.bingo-cell.stamped {
  background: #243246;
  color: #7f93a8;
  opacity: 0.55;
}
.bingo-cell.line-complete {
  background: #1ecb70;
  color: #062816;
  opacity: 1;
}
.target-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}
.target-hover {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: inline-block;
  max-width: 100%;
}
.target-hover #targetText {
  border-bottom: 1px dotted #6f8499;
  cursor: help;
}
.target-tooltip {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 40;
  width: min(320px, 75vw);
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #3a5068;
  background: #0e1620;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.35;
  white-space: pre-wrap;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}
.target-tooltip.loading { color: var(--muted); font-style: italic; white-space: normal; }
.btn-quiet {
  padding: 4px 9px;
  border-radius: 7px;
  border: 1px solid #3a5068;
  background: #152131;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
  cursor: pointer;
}
.btn-quiet:hover:not(:disabled) {
  color: var(--text);
  border-color: #52708d;
}
.btn-quiet:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.muted-meta {
  color: #6f8499;
  font-size: 0.75rem;
}
.helper-box {
  margin: 2px 4px 0;
  font-size: 0.78rem;
  color: #6f8499;
  line-height: 1.4;
}
.helper-toggle {
  padding: 0;
  border: 0;
  background: transparent;
  color: #6f8499;
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.helper-toggle:hover { color: var(--muted); }
.helper-panel {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.helper-panel.hidden { display: none; }
.helper-line { margin: 0; }
.helper-line a {
  color: #8aa3bb;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.helper-line a:hover { color: var(--muted); }
.helper-debug-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
  cursor: pointer;
  color: #8aa3bb;
}
.helper-debug-label input {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
}
.card { padding: 12px; }
.card h2 { margin: 0 0 10px; font-size: 1rem; }
.card label { display: block; margin-top: 8px; color: var(--muted); font-size: 0.86rem; }
.card input {
  width: 100%; margin-top: 4px; padding: 9px;
  border-radius: 8px; border: 1px solid #3a5068;
  background: #0f1824; color: var(--text);
}
.card p { margin: 6px 0; }
.connection-summary {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.connection-summary-line {
  margin: 0;
  word-break: break-word;
}
.connection-summary .btn-quiet {
  align-self: flex-start;
}

.run-label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin: 8px 0 6px;
}
.run-label-row:first-of-type { margin-top: 0; }
.rounds-track,
.fragments-track {
  --track-chip-min: 28px;
  display: flex;
  gap: 2px;
  width: 100%;
  min-height: 18px;
  margin-bottom: 10px;
  /* Room for current-round outline-offset and end-chip borders. */
  padding: 3px 4px;
  overflow: hidden;
  align-items: center;
  box-sizing: border-box;
}
.rounds-track .seg,
.fragments-track .seg {
  flex: 1 1 0;
  min-width: 4px;
  height: 12px;
  border-radius: 2px;
  border: 1px solid #314557;
  background: #0d1620;
}
.rounds-track .seg.overflow,
.fragments-track .seg.overflow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  flex-shrink: 0;
  width: max-content;
  min-width: var(--track-chip-min);
  padding: 0 4px;
  height: 14px;
  box-sizing: border-box;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: #d7e6f5;
  overflow: hidden;
}
.rounds-track .seg.overflow.done { color: #062816; }
.rounds-track .seg.overflow.open { color: #9fb2c7; }
.rounds-track .seg.overflow.locked { color: #ffd0d6; }
.fragments-track .seg.overflow.filled { color: #3a2a00; }
.fragments-track .seg.overflow.empty { color: #9fb2c7; }
.rounds-track .seg.done {
  background: #1ecb70;
  border-color: #148a4c;
}
.rounds-track .seg.open {
  background: #152131;
  border-color: #4a657f;
}
.rounds-track .seg.locked {
  background: repeating-linear-gradient(
    -45deg,
    #3a2026,
    #3a2026 3px,
    #5a2a32 3px,
    #5a2a32 6px
  );
  border-color: #7a3a44;
}
.rounds-track .seg.current {
  flex: 0 0 auto;
  flex-shrink: 0;
  width: var(--track-chip-min);
  min-width: var(--track-chip-min);
  outline: 1px solid #40c4ff;
  outline-offset: 1px;
  position: relative;
  z-index: 1;
}
.fragments-track .seg.filled {
  background: linear-gradient(180deg, #ffd76a 0%, #d4a017 100%);
  border-color: #c4922a;
}
.goal-block { margin: 4px 0 8px; }
.goal-row { margin: 6px 0 0; }

.item-rows { display: flex; flex-direction: column; gap: 10px; }
.item-icon-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.item-icon {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid #3a5068;
  background: #152131;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
}
.item-icon svg { width: 20px; height: 20px; fill: currentColor; }
.item-icon--ok {
  color: #ecf2f8;
  border-color: #40c4ff;
  background: #163042;
}
.item-icon--locked {
  color: #5f7388;
  filter: grayscale(1);
  opacity: 0.7;
}
.item-icon--off {
  color: #6f8499;
  opacity: 0.55;
}
.item-icon--dim {
  filter: grayscale(0.85);
  opacity: 0.45;
}
.item-icon--off::after {
  content: "";
  position: absolute;
  inset: 6px;
  background: linear-gradient(
    to top left,
    transparent 0 44%,
    #ff6f7d 44% 56%,
    transparent 56% 100%
  );
  pointer-events: none;
}
.item-icon--bomb-few.item-icon--ok {
  color: #ffe08a;
  border-color: #c4a24a;
  background: #2a2414;
}
.item-icon--bomb-more.item-icon--ok {
  color: #ffb84d;
  border-color: #c47a20;
  background: #2a1c10;
}
.item-icon--bomb-insane.item-icon--ok {
  color: #ff8a96;
  border-color: #c44a58;
  background: #2a1418;
}
#sanityCard .letter-row { margin-top: 8px; }
#sanityCard .letter-row:empty,
#sanityCard .item-icon-row:empty { display: none; margin: 0; }
.item-icon-badge {
  position: absolute;
  right: -4px;
  bottom: -4px;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  border-radius: 999px;
  background: #0e1620;
  border: 1px solid #52708d;
  color: #ffd789;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 12px;
  text-align: center;
}
.letter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}
.letter-chip {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  background: #101820;
  border: 1px solid #2a3a4c;
  color: #4a5a6c;
}
.letter-chip.on {
  color: #ecf2f8;
  border-color: #6a849e;
  background: #1a2838;
  font-weight: 800;
}

.toast { margin-top: 8px; padding: 8px; border-radius: 9px; font-weight: 700; }
.toast.ok { background: #173a2a; color: #aaffd0; }
.toast.warn { background: #3a2b14; color: #ffd79d; }
.debug-menu-card h3 {
  margin: 10px 0 6px;
  font-size: 0.86rem;
  color: var(--muted);
  font-weight: 700;
}
.debug-warn {
  margin: 0 0 8px;
  font-size: 0.75rem;
  color: #ffb84d;
  line-height: 1.35;
}
.debug-section { margin-bottom: 4px; }
.debug-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
  align-items: center;
}
.debug-btn {
  padding: 5px 8px;
  font-size: 0.78rem;
}
.debug-input {
  width: 72px;
  margin: 0;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid #3a5068;
  background: #0f1824;
  color: var(--text);
  font-size: 0.8rem;
}
.debug-input-wide { width: min(100%, 160px); flex: 1 1 120px; }
.debug-opt-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 8px;
  margin-bottom: 8px;
}
.debug-lens-list { display: flex; flex-direction: column; gap: 6px; }
.debug-lens-row { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--text); font-size: 0.86rem; cursor: pointer; }

.hidden { display: none; }

@media (max-width: 1000px) {
  .main-grid { grid-template-columns: 1fr; }
  .article-panel { min-height: 62vh; }
  .article-body { max-height: 50vh; }
}
