:root {
  /* Surfaces */
  --bg:           #f7f3e8;
  --paper:        #fffcf5;
  --paper-strong: #ffffff;
  --line:         #ddd5c4;

  /* Text */
  --text:         #1e1810;

  /* Primary accent */
  --accent:       #c05a14;
  --accent-soft:  #faeade;

  /* Semantic states */
  --info:         #f5ebd4;
  --auto:         #d8f0e0;
  --manual:       #fff0c0;
  --conflict:     #fddede;
  --pulse:        #fff2a0;
  --possible:     #faf5e8;

  /* Kategorie — 5 kolorów */
  --cat-color-bg:  #fce8f4;  --cat-color-bd:  #d6479c;
  --cat-nat-bg:    #fef4e0;  --cat-nat-bd:    #c97c10;
  --cat-drink-bg:  #e4f2fd;  --cat-drink-bd:  #2388c8;
  --cat-smoke-bg:  #f2f2f6;  --cat-smoke-bd:  #6e6e98;
  --cat-pet-bg:    #e6f8ec;  --cat-pet-bd:    #1f9e4a;

  /* Domy — 5 kolorów */
  --house-1: #7c3aed;
  --house-2: #0369a1;
  --house-3: #047857;
  --house-4: #b45309;
  --house-5: #9f1239;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Nunito", system-ui, sans-serif;
  background:
    radial-gradient(circle at top right, rgba(192, 90, 20, 0.10), transparent 30%),
    linear-gradient(170deg, #faf7ed 0%, #f4efe0 100%);
  color: var(--text);
}

.app {
  display: grid;
  gap: 1rem;
}

.card {
  background: rgba(255, 252, 245, 0.96);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.25rem;
  box-shadow: 0 2px 8px rgba(30, 24, 16, 0.06), 0 6px 20px rgba(30, 24, 16, 0.04);
}

/* ── Typography ─────────────────────────────────── */

header h1 {
  font-weight: 800;
  font-size: clamp(1.5rem, 3vw, 2rem);
  letter-spacing: -0.02em;
  color: var(--accent);
  margin: 0 0 0.3rem;
  line-height: 1.1;
}

header p {
  font-size: 0.9rem;
  color: #6b5840;
  line-height: 1.65;
  max-width: 72ch;
  margin: 0;
}

header strong {
  color: var(--accent);
}

header h1,
.sandbox h2,
.deduction h2,
.clues-overlay h2,
.overview h2 {
  margin-top: 0;
}

.card h2 {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  margin-bottom: 0.5rem;
}

.token-group h3 {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin: 0 0 0.5rem;
  color: #8a7055;
}

#status,
#progress-counter,
#overview-summary {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: #7a5c3c;
}

code {
  font-family: "Cascadia Code", Consolas, monospace;
}

/* ── Controls / Buttons ──────────────────────────── */

.controls {
  display: flex;
  gap: 0.5rem 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.btn-group + .btn-group::before {
  content: "";
  display: block;
  width: 1px;
  height: 1.8rem;
  background: var(--line);
  margin-right: 0.2rem;
  flex-shrink: 0;
}

button {
  font-family: "Nunito", system-ui, sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  border: 1.5px solid var(--line);
  background: var(--paper);
  border-radius: 999px;
  padding: 0.42rem 0.85rem;
  cursor: pointer;
  color: var(--text);
  transition: border-color 140ms ease, transform 120ms ease, background-color 140ms ease, box-shadow 140ms ease;
}

button:hover {
  border-color: var(--accent);
  background: var(--paper-strong);
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(192, 90, 20, 0.14);
}

.btn-secondary {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 700;
}

.btn-secondary:hover {
  background: #f5d9c6;
  border-color: var(--accent);
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
  font-weight: 700;
  padding: 0.48rem 1.1rem;
  box-shadow: 0 2px 8px rgba(192, 90, 20, 0.28);
}

.btn-primary:hover {
  background: #a34c10;
  border-color: #a34c10;
  transform: translateY(-2px);
  box-shadow: 0 5px 14px rgba(192, 90, 20, 0.32);
}

/* ── Section identity (coloured top borders) ────── */

section.board.card        { border-top: 3px solid var(--accent); }
section.sandbox.card      { border-top: 3px solid var(--cat-nat-bd); }
section.free-sandbox.card { border-top: 3px solid var(--cat-drink-bd); }
section.deduction.card    { border-top: 3px solid var(--cat-pet-bd); }
section.overview.card     { border-top: 3px solid var(--cat-color-bd); }
.reference-sidebar.card   { border-top: 3px solid var(--accent); }

/* ── Board (houses grid) ─────────────────────────── */

.board {
  overflow-x: clip;
}

.board-grid {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(112px, 1.1fr) repeat(5, minmax(88px, 1fr));
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.cell {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  min-height: 64px;
  padding: 0.3rem;
  background: rgba(255, 255, 255, 0.58);
}

.row-label,
.house-label {
  font-weight: 700;
  background: var(--info);
}

/* House header labels */
.board-grid .house-label:nth-child(2) { background: #ede9fe; color: #5b21b6; border-bottom: 2px solid var(--house-1); }
.board-grid .house-label:nth-child(3) { background: #dbeafe; color: #1e40af; border-bottom: 2px solid var(--house-2); }
.board-grid .house-label:nth-child(4) { background: #d1fae5; color: #065f46; border-bottom: 2px solid var(--house-3); }
.board-grid .house-label:nth-child(5) { background: #fef3c7; color: #92400e; border-bottom: 2px solid var(--house-4); }
.board-grid .house-label:nth-child(6) { background: #ffe4e6; color: #9f1239; border-bottom: 2px solid var(--house-5); }

/* Subtle column tint per house */
.board-grid .cell:nth-child(6n+2):not(.house-label):not(.row-label) { background: rgba(124, 58, 237, 0.04); }
.board-grid .cell:nth-child(6n+3):not(.house-label):not(.row-label) { background: rgba(3, 105, 161, 0.04); }
.board-grid .cell:nth-child(6n+4):not(.house-label):not(.row-label) { background: rgba(4, 120, 87, 0.04); }
.board-grid .cell:nth-child(6n+5):not(.house-label):not(.row-label) { background: rgba(180, 83, 9, 0.04); }
.board-grid .cell:nth-child(6n+6):not(.house-label):not(.row-label) { background: rgba(159, 18, 57, 0.04); }

/* Category row labels — positions 7,13,19,25,31 in flat grid */
.board-grid .row-label:nth-child(7)  { border-left: 3px solid var(--cat-color-bd); background: var(--cat-color-bg); }
.board-grid .row-label:nth-child(13) { border-left: 3px solid var(--cat-nat-bd);   background: var(--cat-nat-bg);   }
.board-grid .row-label:nth-child(19) { border-left: 3px solid var(--cat-drink-bd); background: var(--cat-drink-bg); }
.board-grid .row-label:nth-child(25) { border-left: 3px solid var(--cat-smoke-bd); background: var(--cat-smoke-bg); }
.board-grid .row-label:nth-child(31) { border-left: 3px solid var(--cat-pet-bd);   background: var(--cat-pet-bg);   }

.drop-zone {
  min-height: 50px;
  border: 2px dashed transparent;
  border-radius: 8px;
}

.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* ── Tokens ──────────────────────────────────────── */

.tokens {
  display: grid;
  gap: 1rem;
}

.token-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.token-group {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem;
  background: rgba(255, 253, 248, 0.84);
}

/* Category colours for sidebar token groups (rowOrder: color,nat,drink,smoke,pet) */
.token-groups > .token-group:nth-child(1) { border-color: var(--cat-color-bd); background: var(--cat-color-bg); }
.token-groups > .token-group:nth-child(2) { border-color: var(--cat-nat-bd);   background: var(--cat-nat-bg);   }
.token-groups > .token-group:nth-child(3) { border-color: var(--cat-drink-bd); background: var(--cat-drink-bg); }
.token-groups > .token-group:nth-child(4) { border-color: var(--cat-smoke-bd); background: var(--cat-smoke-bg); }
.token-groups > .token-group:nth-child(5) { border-color: var(--cat-pet-bd);   background: var(--cat-pet-bg);   }

.token-groups > .token-group:nth-child(1) h3 { color: var(--cat-color-bd); }
.token-groups > .token-group:nth-child(2) h3 { color: var(--cat-nat-bd);   }
.token-groups > .token-group:nth-child(3) h3 { color: var(--cat-drink-bd); }
.token-groups > .token-group:nth-child(4) h3 { color: var(--cat-smoke-bd); }
.token-groups > .token-group:nth-child(5) h3 { color: var(--cat-pet-bd);   }

.token-list,
.sandbox-group-items {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.token {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border: 1.5px solid #cfb8a1;
  background: var(--paper-strong);
  border-radius: 999px;
  padding: 0.32rem 0.75rem;
  cursor: grab;
  user-select: none;
  font-size: 0.85rem;
  font-weight: 600;
  transition: box-shadow 120ms ease, transform 120ms ease;
}

.token:hover {
  box-shadow: 0 2px 8px rgba(192, 90, 20, 0.18);
  transform: translateY(-1px);
}

/* Per-category token colours */
.token[data-id^="color:"]       { border-color: var(--cat-color-bd); background: var(--cat-color-bg); }
.token[data-id^="nationality:"] { border-color: var(--cat-nat-bd);   background: var(--cat-nat-bg);   }
.token[data-id^="drink:"]       { border-color: var(--cat-drink-bd); background: var(--cat-drink-bg); }
.token[data-id^="smoke:"]       { border-color: var(--cat-smoke-bd); background: var(--cat-smoke-bg); }
.token[data-id^="pet:"]         { border-color: var(--cat-pet-bd);   background: var(--cat-pet-bg);   }

.board .token {
  width: 100%;
  max-width: 100%;
  padding: 0.28rem 0.45rem;
  white-space: normal;
  line-height: 1.15;
  text-align: center;
  font-size: 0.92rem;
}

.token.selected {
  outline: 2.5px solid var(--accent);
  outline-offset: 1px;
  box-shadow: 0 0 0 4px rgba(192, 90, 20, 0.14);
}

.token[data-group] {
  border-width: 2px;
}

.group-badge,
.clue-chip,
.token-relation-badge {
  display: inline-block;
  min-width: 1.8rem;
  text-align: center;
  margin-left: 0.3rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--accent-soft);
  padding: 0.05rem 0.38rem;
}

.clue-chip {
  margin-left: 0;
  margin-right: 0.35rem;
}

/* ── Sandbox (glue groups) ───────────────────────── */

#sandbox-groups,
#deduction-board,
#overview-board {
  display: grid;
  gap: 0.75rem;
}

.sandbox-group,
.deduction-pair,
.overview-house {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.45);
}

.sandbox-group {
  padding: 0.75rem;
}

.sandbox-group-header,
.sandbox-link-row,
.overview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.overview-header {
  align-items: flex-start;
}

.sandbox-group-title {
  margin: 0;
  font-weight: 700;
}

.sandbox-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

/* ── Free sandbox (relation canvas) ─────────────── */

.free-sandbox {
  overflow-x: auto;
}

.free-sandbox-stage {
  position: relative;
  width: 1200px;
  height: 860px;
  min-width: 1200px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background:
    linear-gradient(90deg, rgba(192, 90, 20, 0.04) 1px, transparent 1px),
    linear-gradient(rgba(192, 90, 20, 0.04) 1px, transparent 1px),
    #fdf9f0;
  background-size: 34px 34px;
  overflow: hidden;
}

#sandbox-links-svg,
#sandbox-links-svg-2 {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: auto;
}

#free-sandbox-items,
#free-sandbox-mirror-items {
  position: relative;
  width: 1200px;
  height: 860px;
}

.sandbox-item {
  position: absolute;
  cursor: grab;
  min-width: 126px;
  justify-content: center;
}

.sandbox-link-line {
  stroke-width: 4;
  fill: none;
  pointer-events: none;
  opacity: 0.92;
}

.sandbox-link-line.same_house {
  stroke: #8b613a;
}

.sandbox-link-line.left_of {
  stroke: #2f7a63;
  stroke-dasharray: 14 9;
  marker-end: url(#arrow-left-of);
}

.sandbox-link-line.next_to {
  stroke: #6a5ca0;
  stroke-dasharray: 2 10;
  stroke-linecap: round;
}

.sandbox-link-badge {
  fill: #fff7ed;
  stroke: #b77845;
  stroke-width: 1.1;
  pointer-events: all;
}

.sandbox-link-badge-text {
  fill: #7a3b14;
  font-size: 12px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: all;
}

.sandbox-link-list {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0;
  display: grid;
  gap: 0.4rem;
}

.sandbox-link-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  background: rgba(255, 255, 255, 0.78);
}

.sandbox-link-row.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.sandbox-link-row.same_house { border-left: 6px solid #8b613a; }
.sandbox-link-row.left_of   { border-left: 6px solid #2f7a63; }
.sandbox-link-row.next_to   { border-left: 6px solid #6a5ca0; }

#sandbox-links-list-2 .sandbox-link-row {
  cursor: default;
}

.free-sandbox-mirror {
  margin-top: -0.25rem;
}

.sandbox-item.readonly {
  cursor: default;
}

.sandbox-same-house-shadow {
  position: absolute;
  min-width: 126px;
  padding: 0.26rem 0.62rem;
  border-radius: 999px;
  border: 1px solid rgba(207, 184, 161, 0.72);
  background: rgba(255, 253, 248, 0.55);
  color: rgba(39, 33, 26, 0.52);
  pointer-events: none;
}

.sandbox-same-house-shadow .group-badge {
  opacity: 0.78;
}

.sandbox-link-line.ghost {
  opacity: 0.28;
}

/* ── Overview (Dodatkowa Matryca) ───────────────── */

.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.8rem;
}

.overview-house {
  padding: 0.75rem;
}

.overview-house h3 {
  margin-top: 0;
  font-weight: 800;
}

/* House identity — top border + title colour */
.overview-grid .overview-house:nth-child(1) { border-top: 3px solid var(--house-1); }
.overview-grid .overview-house:nth-child(2) { border-top: 3px solid var(--house-2); }
.overview-grid .overview-house:nth-child(3) { border-top: 3px solid var(--house-3); }
.overview-grid .overview-house:nth-child(4) { border-top: 3px solid var(--house-4); }
.overview-grid .overview-house:nth-child(5) { border-top: 3px solid var(--house-5); }

.overview-grid .overview-house:nth-child(1) h3 { color: var(--house-1); }
.overview-grid .overview-house:nth-child(2) h3 { color: var(--house-2); }
.overview-grid .overview-house:nth-child(3) h3 { color: var(--house-3); }
.overview-grid .overview-house:nth-child(4) h3 { color: var(--house-4); }
.overview-grid .overview-house:nth-child(5) h3 { color: var(--house-5); }

.overview-house.has-pending {
  box-shadow: 0 0 0 2px rgba(192, 90, 20, 0.35), 0 8px 22px rgba(52, 38, 24, 0.06);
  background: rgba(255, 248, 238, 0.98);
}

.overview-category {
  display: grid;
  gap: 0.35rem;
  border-top: 1px solid rgba(209, 199, 183, 0.7);
  padding-top: 0.55rem;
  margin-top: 0.55rem;
}

.overview-category:first-of-type {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}

.overview-category-label {
  font-weight: 800;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Category label colours (nth-of-type: rowOrder = color,nat,drink,smoke,pet) */
.overview-house section.overview-category:nth-of-type(1) .overview-category-label { color: var(--cat-color-bd); }
.overview-house section.overview-category:nth-of-type(2) .overview-category-label { color: var(--cat-nat-bd);   }
.overview-house section.overview-category:nth-of-type(3) .overview-category-label { color: var(--cat-drink-bd); }
.overview-house section.overview-category:nth-of-type(4) .overview-category-label { color: var(--cat-smoke-bd); }
.overview-house section.overview-category:nth-of-type(5) .overview-category-label { color: var(--cat-pet-bd);   }

.overview-values {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.overview-pill {
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--possible);
}

.overview-pill.confirmed {
  background: #d0f0de;
  border-color: var(--cat-pet-bd);
  color: #145228;
  font-weight: 700;
}

.overview-pill.manual-excluded {
  background: #f0ede8;
  color: #9a8870;
  text-decoration: line-through;
  border-color: #c8bfaf;
}

.overview-pill.clickable {
  cursor: pointer;
  transition: background-color 120ms ease, transform 80ms ease;
}

.overview-pill.clickable:hover {
  filter: brightness(0.93);
  transform: scale(1.05);
}

.overview-pending-banner {
  display: inline-block;
  margin-bottom: 0.55rem;
  padding: 0.18rem 0.65rem;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
}

/* ── Deduction board ─────────────────────────────── */

.deduction-pair {
  scroll-margin-top: 1rem;
}

.deduction-pair h3 {
  margin: 0;
  padding: 0.55rem 0.75rem;
  background: var(--info);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* Category accent on deduction pair headers (left category) */
[data-pair-id^="color|"]       h3 { border-left: 4px solid var(--cat-color-bd); padding-left: 0.9rem; }
[data-pair-id^="nationality|"] h3 { border-left: 4px solid var(--cat-nat-bd);   padding-left: 0.9rem; }
[data-pair-id^="drink|"]       h3 { border-left: 4px solid var(--cat-drink-bd); padding-left: 0.9rem; }
[data-pair-id^="smoke|"]       h3 { border-left: 4px solid var(--cat-smoke-bd); padding-left: 0.9rem; }
[data-pair-id^="pet|"]         h3 { border-left: 4px solid var(--cat-pet-bd);   padding-left: 0.9rem; }

.deduction-pair.reveal-target {
  box-shadow: 0 0 0 3px rgba(192, 90, 20, 0.18), 0 12px 28px rgba(52, 38, 24, 0.12);
}

.deduction-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 520px;
}

.deduction-table th,
.deduction-table td {
  border: 1px solid var(--line);
  padding: 0.35rem 0.5rem;
  text-align: center;
}

.deduction-table th {
  font-family: "Nunito", system-ui, sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--info);
}

.deduction-table th:first-child {
  text-align: left;
  background: rgba(255, 252, 246, 0.9);
}

.deduction-cell {
  cursor: pointer;
  min-width: 32px;
  font-weight: 700;
  transition: transform 180ms ease, background-color 220ms ease, box-shadow 220ms ease;
}

.deduction-cell.auto     { background: var(--auto); }
.deduction-cell.manual   { background: var(--manual); }
.deduction-cell.conflict { background: var(--conflict); color: #8d2f1f; }

.deduction-cell.animating-fill {
  background: var(--pulse);
  box-shadow: inset 0 0 0 2px rgba(192, 90, 20, 0.25);
  transform: scale(1.06);
}

/* ── Clue highlight ──────────────────────────────── */

[data-clue-number].clue-highlight {
  box-shadow: 0 0 0 3px rgba(192, 90, 20, 0.22);
  background: #fff0c0;
}

li[data-clue-number].clue-highlight {
  background: #ffe8a8;
  color: #5f2a0a;
  padding: 0.15rem 0.35rem;
  border-radius: 8px;
}

line[data-clue-number].clue-highlight,
path[data-clue-number].clue-highlight {
  stroke-width: 6;
}

text[data-clue-number].clue-highlight,
rect[data-clue-number].clue-highlight,
span[data-clue-number].clue-highlight,
g[data-clue-number].clue-highlight {
  filter: drop-shadow(0 2px 4px rgba(192, 90, 20, 0.28));
}

/* ── Clues overlay (fixed sidebar) ─────────────── */

.clues-overlay {
  position: fixed;
  top: 1rem;
  right: 1rem;
  width: 340px;
  max-height: calc(100vh - 2rem);
  overflow: auto;
  opacity: 0.78;
  pointer-events: none;
}

.clues-overlay ol,
.clues-overlay li {
  font-family: "Lora", Georgia, serif;
  font-size: 0.93rem;
  line-height: 1.6;
}

/* ── Clue picker dialog ──────────────────────────── */

.clue-picker {
  width: min(760px, calc(100vw - 2rem));
  border: 1.5px solid var(--line);
  border-radius: 20px;
  padding: 0;
  background: var(--paper);
  box-shadow: 0 20px 50px rgba(30, 24, 16, 0.22);
}

.clue-picker::backdrop {
  background: rgba(36, 24, 12, 0.32);
}

.clue-picker-form {
  padding: 1.1rem;
}

.clue-picker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.clue-picker-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.7rem;
  margin-top: 1rem;
}

.clue-picker-option {
  display: grid;
  gap: 0.3rem;
  align-items: start;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: var(--paper-strong);
  padding: 0.8rem;
  text-align: left;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.clue-picker-option:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 10px rgba(192, 90, 20, 0.12);
}

.clue-picker-option strong { color: var(--accent); font-weight: 800; }
.clue-picker-option small  { color: #6b5840; line-height: 1.35; }

/* ── Reference sidebar (token list) ─────────────── */

.reference-sidebar {
  position: fixed;
  top: 1rem;
  left: 1rem;
  width: 256px;
  max-height: calc(100vh - 2rem);
  overflow: auto;
  z-index: 3;
}

.reference-sidebar p {
  margin-top: 0;
  font-size: 0.85rem;
  color: #7a5c3c;
}

.reference-sidebar .token-groups {
  grid-template-columns: 1fr;
}

.reference-sidebar .token-group {
  padding: 0.65rem;
}

.reference-sidebar .token {
  width: 100%;
  justify-content: flex-start;
  white-space: normal;
  text-align: left;
}

.token-relation-badge {
  min-width: 1.65rem;
  margin-left: 0.1rem;
  font-size: 0.68rem;
  padding: 0.04rem 0.32rem;
}

.token-relation-badge.is-link {
  background: #e7f0ea;
}

/* ── Toast notification ──────────────────────────── */

.overview-notification {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--paper-strong);
  border: 2px solid var(--accent);
  border-radius: 16px;
  padding: 0.9rem 1.2rem;
  box-shadow: 0 8px 28px rgba(30, 24, 16, 0.18);
  max-width: calc(100vw - 3rem);
  animation: notification-slide-up 220ms ease;
}

.overview-notification[hidden] {
  display: none;
}

@keyframes notification-slide-up {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.overview-notification p {
  margin: 0;
  font-weight: 700;
  color: var(--accent);
}

#overview-notification-go {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 700;
  white-space: nowrap;
}

#overview-notification-go:hover {
  background: #a34c10;
  border-color: #a34c10;
}

#overview-notification-close {
  padding: 0.3rem 0.55rem;
  font-size: 0.85rem;
  color: #7a6552;
}

/* ── Layout — main app ───────────────────────────── */

.app {
  max-width: none;
  margin: 0;
  padding: 1rem 23rem 1rem 18rem;
  display: grid;
  gap: 1rem;
}

header h1,
.reference-sidebar h2,
.sandbox h2,
.deduction h2,
.clues-overlay h2,
.overview h2 {
  margin-top: 0;
}

/* ── Responsive ──────────────────────────────────── */

@media (max-width: 1180px) {
  .app {
    padding: 1rem;
  }

  .clues-overlay {
    position: static;
    width: auto;
    max-height: none;
    margin: 0 1rem 1rem;
  }

  .reference-sidebar {
    position: static;
    width: auto;
    max-height: none;
    margin: 0 1rem 1rem;
  }
}

@media (max-width: 860px) {
  .board {
    overflow-x: auto;
  }

  .board-grid {
    min-width: 700px;
  }
}
