:root {
  --paper: #f3eadc;
  --paper-deep: #e7dcc9;
  --ink: #1d1915;
  --muted: #655c52;
  --line: #d8cbb6;
  --rust: #8f3414;
  --rust-deep: #6d260e;
  --board: #14110f;
  --slot: #241f1b;
  --slot-hot: #322b25;
  --danger: #9f1239;
  --serif: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
  --sans: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.5;
}

* { box-sizing: border-box; }

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

button, input {
  font: inherit;
}

button { cursor: pointer; }

a { color: var(--rust-deep); }

code {
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.86em;
}

.app {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 22px 72px;
}

.mast {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.brand h1 {
  margin: 0;
  font-size: 2.1rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.82rem;
  letter-spacing: 0.01em;
}

nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

nav button {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.92rem;
  padding: 8px 10px 6px;
  border-bottom: 2px solid transparent;
}

nav button[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--rust);
}

.lede {
  margin: 22px 0 0;
  max-width: 42rem;
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 28px;
  margin-top: 22px;
  align-items: start;
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.menu button {
  display: flex;
  gap: 10px;
  align-items: baseline;
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--ink);
  padding: 8px 8px;
  border-radius: 8px;
}

.menu button .n {
  font-family: var(--sans);
  font-size: 0.75rem;
  color: var(--muted);
  width: 1.2rem;
}

.menu button.current {
  background: var(--paper-deep);
}

.menu button.done .n { color: var(--rust); }

.stage {
  display: grid;
  grid-template-columns: minmax(260px, 400px) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.board-panel {
  background: var(--board);
  color: #f6f1e8;
  border-radius: 22px;
  padding: 16px 14px 12px;
  box-shadow: 0 16px 36px rgba(48, 28, 14, 0.16);
}

.queue {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 22px;
  min-height: 92px;
  margin-bottom: 8px;
}

.q { text-align: center; }

.q-label {
  display: block;
  font-family: var(--sans);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #b5aa9c;
  margin-bottom: 6px;
}

.queue .cell {
  width: 64px;
  height: 64px;
}

.queue .next .cell {
  width: 48px;
  height: 48px;
  font-size: 0.85rem;
}

.well {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  border-top: 3px solid var(--danger);
  padding-top: 8px;
}

.column {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 4px 3px 6px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  appearance: none;
  min-width: 0;
}

button.column {
  cursor: pointer;
  width: 100%;
  min-width: 0;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.column:hover,
button.column:focus-visible {
  background: #1e1916;
  outline: none;
}

.column.hinted {
  box-shadow: inset 0 0 0 1px #e7c08a;
}

.column.locked { cursor: not-allowed; }

.col-index {
  text-align: center;
  font-family: var(--sans);
  font-size: 0.72rem;
  color: #8c8174;
}

.cell {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--slot);
  font-family: var(--sans);
  font-weight: 700;
  font-size: var(--size, 1rem);
  letter-spacing: -0.03em;
  min-height: 0;
}

.cell.filled {
  background: var(--tile);
  color: var(--ink-tile, #fff);
  font-weight: 800;
  text-shadow: 0 1.5px 2px rgba(0, 0, 0, 0.48), 0 0 1px rgba(0, 0, 0, 0.65);
}

.cell.high,
.ghost-tile.high {
  box-shadow:
    inset 0 0 0 3px #f4b04a,
    inset 0 0 0 5px #7a4e1a,
    0 2px 6px rgba(0, 0, 0, 0.35);
}

.cell.dropping {
  z-index: 3;
  animation: tile-drop calc(480ms * var(--anim-scale, 1)) cubic-bezier(0.22, 0.88, 0.36, 1) both;
}

.cell.packing {
  z-index: 2;
  animation: tile-pack calc(460ms * var(--anim-scale, 1)) cubic-bezier(0.25, 0.9, 0.35, 1) both;
}

.cell.merged {
  z-index: 4;
  animation: merge-pop calc(520ms * var(--anim-scale, 1)) cubic-bezier(0.2, 1.3, 0.4, 1) both;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.82);
}

.ghost-tile {
  position: absolute;
  inset: 0;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--tile);
  color: var(--ink-tile, #fff);
  font-size: var(--size, 1rem);
  z-index: 3;
  pointer-events: none;
  animation: tile-suck calc(460ms * var(--anim-scale, 1)) cubic-bezier(0.3, 0.05, 0.25, 1) forwards;
}

.score-pop {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--sans);
  font-weight: 800;
  font-size: 0.92rem;
  color: #fde68a;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.85);
  pointer-events: none;
  z-index: 6;
  white-space: nowrap;
  animation: popup-rise calc(850ms * var(--anim-scale, 1)) ease-out forwards;
}

@keyframes tile-drop {
  0% {
    transform: translateY(calc(var(--drop-rows, 2) * -108% - 28%));
    opacity: 0.85;
  }
  82% {
    transform: translateY(4%);
    opacity: 1;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes tile-pack {
  0% {
    transform: translateY(calc(var(--fall-rows, 1) * -108%));
  }
  100% {
    transform: translateY(0);
  }
}

@keyframes tile-suck {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 0.95;
  }
  100% {
    transform: translate(calc(var(--dc, 0) * 112%), calc(var(--dr, 0) * -108%)) scale(0.55);
    opacity: 0;
  }
}

@keyframes merge-pop {
  0% { transform: scale(0.78); }
  55% { transform: scale(1.16); }
  100% { transform: scale(1); }
}

@keyframes popup-rise {
  0% {
    opacity: 1;
    transform: translate(-50%, 6px) scale(0.88);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -22px) scale(1.06);
  }
}

.cell.landing > span:not(.score-pop) { opacity: 0; }

button.column:hover .cell.landing,
button.column:focus-visible .cell.landing {
  background: var(--tile);
  color: var(--ink-tile, #fff);
}

button.column:hover .cell.landing > span:not(.score-pop),
button.column:focus-visible .cell.landing > span:not(.score-pop) {
  opacity: 1;
}

.prose h2 {
  margin: 0 0 8px;
  font-size: 1.7rem;
  letter-spacing: -0.03em;
}

.kicker {
  font-family: var(--sans);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--rust);
  margin: 0 0 6px;
}

.prose p { margin: 0 0 12px; }

.say p { margin: 0 0 12px; }

.note {
  background: #fffaf3;
  border-left: 3px solid var(--rust);
  padding: 10px 12px;
  margin: 8px 0 14px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.actions button,
.tools button,
.lab button {
  background: var(--ink);
  color: var(--paper);
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  font-family: var(--sans);
  font-size: 0.92rem;
}

.actions button.ghost,
.tools button.ghost {
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}

.tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 14px 0;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 22px;
  font-family: var(--sans);
  font-size: 0.92rem;
  margin: 0 0 8px;
}

.stats span { color: var(--muted); }
.stats strong { color: var(--ink); font-weight: 650; }

.compare {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 0.86rem;
  margin-top: 8px;
}

.compare th,
.compare td {
  text-align: left;
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.compare tr.pick td { background: #f7efe2; }

.seed-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.seed-row input {
  width: 8rem;
  background: #fffaf3;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  color: var(--ink);
}

.check {
  display: flex;
  gap: 8px;
  align-items: center;
  font-family: var(--sans);
  font-size: 0.88rem;
}

.banner {
  margin: 0 0 10px;
  color: #fecdd3;
  font-family: var(--sans);
  font-size: 0.92rem;
}

.manual {
  max-width: 44rem;
  margin-top: 8px;
}

.manual h1 { font-size: 2rem; letter-spacing: -0.03em; }
.manual h2 { margin-top: 1.6em; font-size: 1.45rem; }
.manual table {
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 0.92rem;
  margin: 8px 0 16px;
}
.manual th, .manual td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 6px 12px 6px 0;
}

.lab {
  background: #fffaf3;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 16px 8px;
  margin: 18px 0 8px;
}

.lab h2 { margin: 0 0 6px; font-size: 1.3rem; }

.lab-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }

.lab button[aria-pressed="true"] {
  background: var(--rust);
}

.focus {
  font-family: var(--sans);
  font-size: 0.92rem;
  color: var(--muted);
}

.foot {
  margin-top: 36px;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.8rem;
}

.compare td:first-child,
.compare th:first-child {
  white-space: nowrap;
  width: 4.5rem;
}

/* --- AI Spelar Visualizer --- */

.ai-header-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px 20px;
  margin-top: 14px;
  padding: 12px 16px;
  background: #fffaf3;
  border: 1px solid var(--line);
  border-radius: 14px;
  font-family: var(--sans);
  font-size: 0.9rem;
}

.ai-run-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.ai-run-picker select {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 600;
}

.ai-new-live-btn {
  background: #0284c7;
  color: #ffffff;
  border: 0;
  border-radius: 999px;
  padding: 7px 14px;
  font-family: var(--sans);
  font-size: 0.86rem;
  font-weight: 700;
}

.ai-new-live-btn:hover {
  background: #0369a1;
}

.ai-run-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  color: var(--muted);
}

.ai-run-summary strong {
  color: var(--ink);
}

.ai-live-scoreboard {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 14px 24px;
  margin-top: 12px;
  padding: 16px 20px;
  background: linear-gradient(135deg, #18181b 0%, #27221d 100%);
  color: #fff;
  border-radius: 16px;
  border: 2px solid #fbbf24;
  box-shadow: 0 10px 25px -12px rgba(0, 0, 0, 0.45);
  font-family: var(--sans);
}

.ai-score-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ai-score-label {
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #fde68a;
  text-transform: uppercase;
}

.ai-score-value-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.ai-score-big {
  font-size: 2.35rem;
  font-weight: 900;
  line-height: 1.05;
  color: #fde047;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  text-shadow: 0 2px 10px rgba(250, 204, 21, 0.28);
}

.ai-score-gain-pill {
  display: inline-block;
  padding: 4px 11px;
  border-radius: 999px;
  background: #16a34a;
  color: #fff;
  font-size: 0.96rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.ai-score-gain-pill.muted {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.55);
  font-weight: 600;
}

.ai-score-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
}

.ai-stat-box {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  min-width: 110px;
}

.ai-stat-label {
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  color: #d6d3d1;
  text-transform: uppercase;
}

.ai-stat-val {
  font-size: 1.2rem;
  font-weight: 800;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.ai-stat-val small {
  font-size: 0.85rem;
  font-weight: 600;
  color: #a8a29e;
}

.ai-stat-tile {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--tile);
  color: var(--ink-tile, #fff);
  font-size: 1rem;
  font-weight: 900;
}

.ai-score-pill {
  background: #16a34a;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 800;
  padding: 3px 11px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

.ai-board-score-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid rgba(251, 191, 36, 0.45);
  border-radius: 12px;
  font-family: var(--sans);
}

.ai-board-score-left {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.ai-board-score-kicker {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #fde68a;
}

.ai-board-score-num {
  font-size: 1.55rem;
  font-weight: 900;
  color: #fde047;
  font-variant-numeric: tabular-nums;
}

.ai-board-score-gain {
  font-size: 0.82rem;
  font-weight: 800;
  color: #4ade80;
  font-variant-numeric: tabular-nums;
}

.ai-board-score-right {
  display: flex;
  gap: 10px;
  font-size: 0.78rem;
  color: #d6d3d1;
  font-variant-numeric: tabular-nums;
}

.ai-board-score-right strong {
  color: #fff;
}

.ai-callout {
  margin-top: 12px;
  padding: 14px 18px;
  background: linear-gradient(135deg, #27221d 0%, #1c1917 100%);
  color: #fef3c7;
  border-radius: 16px;
  border: 2px solid #f59e0b;
  box-shadow: 0 10px 24px -14px rgba(0, 0, 0, 0.35);
  font-family: var(--sans);
}

.ai-callout-badge {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.ai-step-pill {
  background: rgba(255, 255, 255, 0.12);
  color: #fde68a;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 3px 9px;
  border-radius: 999px;
}

.ai-target-pill {
  background: #f59e0b;
  color: #1c1917;
  font-size: 0.84rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  padding: 3px 12px;
  border-radius: 999px;
}

.ai-callout-text {
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.4;
  color: #fffbeb;
}

.ai-callout-text strong {
  color: #fde047;
}

.ai-stage {
  margin-top: 14px;
  grid-template-columns: minmax(300px, 380px) 1fr;
}

.ai-board-panel {
  background: #333333;
  padding: 14px 12px 14px;
  border-radius: 20px;
}

.ig-next-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #252525;
  border: 2px solid #1b1b1b;
  border-radius: 6px;
  height: 44px;
  padding: 0 12px;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.65);
}

.ig-next-label {
  font-family: var(--sans);
  font-size: 0.92rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.01em;
}

.ig-next-arrow {
  width: 10px;
  height: 14px;
  color: #ffffff;
  flex-shrink: 0;
}

.ig-next-tile {
  width: 38px;
  height: 38px;
  aspect-ratio: 1;
  border-radius: 3px;
  font-size: 0.98rem;
}

.ig-next-tile.empty {
  background: transparent;
}

.ig-conveyor-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px;
  margin: 5px 0 6px;
  font-size: 0.52rem;
  line-height: 1;
  color: #d4d4d4;
}

.ai-chute-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  margin-bottom: 6px;
  padding: 0;
  background: #1f1f1f;
  border: 3px solid #181818;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: inset 0 4px 10px rgba(0, 0, 0, 0.72);
}

.ai-chute-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  min-width: 0;
  border-radius: 0;
  padding: 0;
  position: relative;
}

.ai-chute-slot:nth-child(odd) {
  background: rgba(0, 0, 0, 0.16);
}

.ai-chute-slot:nth-child(even) {
  background: rgba(255, 255, 255, 0.03);
}

.ai-chute-slot.active {
  box-shadow: none;
}

.ig-chute-chevron {
  width: 28px;
  height: 14px;
  color: #525252;
  pointer-events: none;
}

.ai-chute-tile {
  position: absolute;
  inset: 3px;
  width: auto;
  height: auto;
  aspect-ratio: auto;
  border-radius: 5px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5);
  z-index: 2;
}

.ig-well-wrap {
  position: relative;
  overflow: visible;
}

.ig-ceiling-line {
  height: 4px;
  margin-bottom: 2px;
  background: repeating-linear-gradient(90deg, #dc2626 0 12px, transparent 12px 20px);
  border-radius: 2px;
}

.ai-well {
  gap: 0;
  border-top: 0;
  padding-top: 0;
  background: #1e1e1e;
  border: 3px solid #171717;
  border-radius: 6px;
  overflow: visible;
  box-shadow:
    inset 0 28px 34px -14px rgba(165, 24, 34, 0.42),
    inset 0 4px 12px rgba(0, 0, 0, 0.75);
}

.ai-well .column {
  padding: 4px 3px 6px;
  border-radius: 0;
  gap: 5px;
  overflow: visible;
}

.ai-well .cell.dropping {
  z-index: 12;
  animation: ai-tile-drop calc(480ms * var(--anim-scale, 1)) cubic-bezier(0.32, 0.06, 0.55, 1) both;
}

@keyframes ai-tile-drop {
  0% {
    transform: translateY(calc(var(--drop-rows, 2) * (-100% - 5px) - 21px));
    opacity: 1;
  }
  88% {
    transform: translateY(3%);
    opacity: 1;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

.ai-well .column:nth-child(odd),
.ai-well .column.ai-target-col:nth-child(odd) {
  background: rgba(0, 0, 0, 0.16);
  box-shadow: none;
}

.ai-well .column:nth-child(even),
.ai-well .column.ai-target-col:nth-child(even) {
  background: rgba(255, 255, 255, 0.025);
  box-shadow: none;
}

.ai-well .cell.empty {
  background: transparent;
}

.ai-well .cell.filled {
  border-radius: 5px;
}

.ai-well .column.ai-target-col .col-index {
  color: #fde047;
  font-weight: 900;
}

.ai-well .column.ai-macro-col .col-index {
  color: #38bdf8;
  font-weight: 800;
}

.ai-well .column.ai-macro-col-sec .col-index {
  color: #2dd4bf;
  font-weight: 800;
}

.ai-macro-card {
  background: linear-gradient(135deg, #182232 0%, #0f172a 100%);
  color: #f8fafc;
  border: 1.5px solid #38bdf8;
  border-radius: 16px;
  padding: 12px 16px;
  margin-bottom: 14px;
  font-family: var(--sans);
  box-shadow: 0 8px 20px -12px rgba(15, 23, 42, 0.45);
}

.ai-macro-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.ai-macro-kicker {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #7dd3fc;
}

.ai-macro-badge {
  background: #0284c7;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 2px 9px;
  border-radius: 999px;
}

.ai-macro-sec-badge {
  background: #0f766e;
  color: #ccfbf1;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 2px 9px;
  border-radius: 999px;
}

.ai-macro-headline {
  margin: 0 0 5px !important;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.35;
  color: #f0f9ff;
}

.ai-macro-secondary {
  margin: 0 0 6px !important;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.35;
  color: #99f6e4;
}

.ai-macro-subline {
  margin: 0 !important;
  font-size: 0.8rem;
  line-height: 1.35;
  color: #bae6fd;
  padding-top: 4px;
  border-top: 1px solid rgba(125, 211, 252, 0.2);
}

.ai-well .column.ai-settled-col {
  box-shadow: none;
}

.ai-well .cell {
  overflow: visible;
}

.row-coord {
  position: absolute;
  top: 3px;
  left: 5px;
  font-size: 0.56rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.38);
  pointer-events: none;
  line-height: 1;
}

.cell.empty .row-coord {
  color: rgba(255, 255, 255, 0.22);
}

.cell.ai-preview-cell {
  background: var(--tile);
  color: var(--ink-tile, #fff);
  opacity: 0.92;
  box-shadow: 0 0 0 3px #fde047, 0 0 18px rgba(250, 204, 21, 0.65);
  animation: preview-pulse 900ms ease-in-out infinite;
  z-index: 5;
}

@keyframes preview-pulse {
  0%, 100% { transform: scale(0.97); }
  50% { transform: scale(1.03); }
}

.cell.ai-placed-cell {
  box-shadow: 0 0 0 3px #fde047, 0 0 16px rgba(250, 204, 21, 0.6);
  z-index: 5;
}

.cell.ai-origin-cell {
  box-shadow: inset 0 0 0 2.5px #fbbf24;
  outline: 2px dashed #fde047;
  outline-offset: -2px;
  background-color: rgba(245, 158, 11, 0.22);
  z-index: 4;
}

.cell.ai-settled-cell {
  box-shadow: 0 0 0 3px #34d399, 0 0 16px rgba(52, 211, 153, 0.55);
  z-index: 5;
}

.ai-cell-badge {
  position: absolute;
  bottom: -7px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--sans);
  font-size: 0.54rem;
  font-weight: 900;
  letter-spacing: 0.03em;
  padding: 2px 5px;
  border-radius: 999px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 7;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.65);
}

.badge-aim,
.badge-placed {
  background: #fde047;
  color: #1c1917;
}

.badge-origin {
  background: #1c1917;
  color: #fde047;
  border: 1px solid #fbbf24;
}

.badge-settled {
  background: #10b981;
  color: #052e16;
}

.ai-legend {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-family: var(--sans);
  font-size: 0.74rem;
  color: #d6d0c4;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
}

.legend-swatch {
  display: inline-block;
  width: 13px;
  height: 13px;
  border-radius: 4px;
  flex-shrink: 0;
}

.swatch-origin {
  border: 2px dashed #fde047;
  background: rgba(245, 158, 11, 0.25);
}

.swatch-settled {
  border: 2px solid #34d399;
  background: rgba(16, 185, 129, 0.3);
}

.ai-controls-card {
  background: #fffaf3;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 14px;
  font-family: var(--sans);
}

.ai-transport {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.ai-transport button,
.ai-subcontrols button,
.ai-milestones button {
  background: var(--ink);
  color: var(--paper);
  border: 0;
  border-radius: 999px;
  padding: 8px 13px;
  font-family: var(--sans);
  font-size: 0.86rem;
  font-weight: 600;
}

.ai-transport button.ghost,
.ai-subcontrols button.ghost,
.ai-milestones button.ghost {
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}

.ai-transport button.ai-play-btn {
  background: #d97706;
  color: #fff;
  padding: 8px 18px;
  font-weight: 700;
}

.ai-transport button.ai-play-btn.playing {
  background: #b91c1c;
}

.ai-subcontrols button.active-toggle,
.ai-milestones button.active-toggle {
  background: var(--ink);
  color: var(--paper);
  box-shadow: none;
}

.ai-subcontrols {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.ai-speed-group {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.84rem;
  color: var(--muted);
}

.ai-speed-group button {
  padding: 5px 10px;
  font-size: 0.8rem;
}

.ai-timeline {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.ai-timeline-labels {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.ai-timeline-labels strong {
  color: var(--ink);
}

.ai-timeline-labels .gain {
  color: #15803d;
  font-style: normal;
  font-weight: 700;
}

#ai-slider {
  width: 100%;
  height: 28px;
  margin: 6px 0;
  accent-color: #d97706;
  cursor: grab;
  touch-action: pan-y;
}

#ai-slider:active {
  cursor: grabbing;
}

.ai-milestones {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--muted);
}

.ai-milestones button {
  padding: 4px 10px;
  font-size: 0.76rem;
}

.ai-move-strip {
  background: #fffaf3;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-family: var(--sans);
}

.ai-move-strip h3 {
  margin: 0 0 8px;
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.ai-move-pills {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px;
}

.ai-move-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--ink);
  text-align: left;
}

.ai-move-pill.active {
  background: #27221d;
  color: #fef3c7;
  border-color: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.35);
}

.ai-move-pill .m-num {
  font-size: 0.72rem;
  color: var(--muted);
  min-width: 2.2rem;
}

.ai-move-pill.active .m-num {
  color: #fde68a;
}

.ai-move-pill .m-tile {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 22px;
  padding: 0 5px;
  border-radius: 5px;
  background: var(--tile);
  color: var(--ink-tile, #fff);
  font-weight: 800;
  font-size: 0.74rem;
}

.ai-move-pill .m-pos {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pick-tag {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #d97706;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
}

.ai-compare .score-col {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.play-own-btn {
  background: #16a34a;
}

.play-own-btn:hover {
  background: #15803d;
}

.playable-board {
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  cursor: grab;
}

.playable-board.is-aiming {
  cursor: grabbing;
}

.playable-chute .ai-chute-slot {
  cursor: pointer;
  transition: background-color 100ms ease;
}

.playable-chute .ai-chute-slot.holding {
  background: rgba(253, 224, 71, 0.16);
}

.playable-well .column {
  cursor: pointer;
  transition: background-color 100ms ease, box-shadow 100ms ease;
}

.playable-well .column.aim-holding {
  background: rgba(253, 224, 71, 0.1) !important;
  box-shadow: inset 0 0 0 1.5px rgba(253, 224, 71, 0.48) !important;
}

.playable-well .cell.landing {
  background: transparent;
  opacity: 0;
  pointer-events: none;
  transition: opacity 90ms ease;
}

.playable-well .column.aim-holding .cell.landing {
  background: var(--tile);
  color: var(--ink-tile, #fff);
  opacity: 0.42;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.85);
}

.playable-well .column.aim-holding .cell.landing > span:not(.score-pop) {
  opacity: 1;
}

.playable-well .column.hinted {
  box-shadow: inset 0 0 0 2px #fde047 !important;
}

@media (max-width: 860px) {
  .app { padding: 18px 16px 48px; }
  .brand h1 { font-size: 1.8rem; line-height: 1.15; }
  .mast { flex-direction: column; align-items: flex-start; gap: 10px; padding-bottom: 8px; }
  nav button { padding: 6px 8px 4px; }
  .lede { margin: 12px 0 0; line-height: 1.35; }
  .layout, .stage { grid-template-columns: 1fr; }
  .layout { margin-top: 12px; gap: 10px; }
  .stage { gap: 16px; }
  .stage .board-panel,
  .stage .board-column { order: 1; }
  .stage .prose { order: 2; }
  .menu { flex-direction: row; overflow-x: auto; }
  .menu button { white-space: nowrap; padding: 4px 8px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto; }
}
