:root {
  color-scheme: dark;
  --bg: #101312;
  --panel: #181d1b;
  --panel-2: #202823;
  --line: #3a463f;
  --text: #f4f2eb;
  --muted: #b7b2a6;
  --gold: #d7ad53;
  --green: #31c487;
  --red: #ef6f6c;
  --blue: #79b7ff;
  --place: #49d88f;
  --stay: #76b9ff;
  --bust: #ff7772;
  --ink: #090b0a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 980px;
  min-height: 100vh;
  background: radial-gradient(circle at top left, #243b2e 0, #101312 36rem), var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

.app-shell {
  width: min(1440px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 18px 0 28px;
}

.topbar,
.workspace,
.bottom-panels,
.input-panel {
  width: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.topbar h1 {
  margin: 2px 0 0;
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0;
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.top-actions {
  display: flex;
  gap: 10px;
}

.ghost-button,
.rank-button,
.move-button,
.stay-button,
.bust-button,
.accept-best-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111614;
  color: var(--text);
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}

.ghost-button {
  min-width: 82px;
  min-height: 40px;
  padding: 0 14px;
}

.ghost-button:hover,
.rank-button:hover,
.move-button:hover,
.stay-button:hover,
.bust-button:hover,
.accept-best-button:hover {
  border-color: var(--gold);
  background: #1c241f;
}

.ghost-button:active,
.rank-button:active,
.move-button:active,
.stay-button:active,
.bust-button:active,
.accept-best-button:active {
  transform: translateY(1px);
}

.ghost-button.danger {
  color: #ffaaa8;
}

.ghost-button.active {
  border-color: var(--green);
  color: var(--green);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(680px, 1fr) 360px;
  gap: 14px;
}

.board-panel,
.side-panel,
.input-panel,
.deck-panel,
.history-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
}

.board-panel {
  padding: 16px;
}

.board-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.pending-card {
  display: inline-grid;
  place-items: center;
  min-width: 74px;
  height: 54px;
  margin-top: 6px;
  border: 1px solid var(--gold);
  border-radius: 8px;
  background: #f6f2e8;
  color: #151515;
  font-size: 24px;
  font-weight: 900;
}

.pending-card.empty {
  border-color: var(--line);
  background: #111614;
  color: var(--muted);
  font-size: 16px;
}

.status-message {
  max-width: 460px;
  color: var(--muted);
  text-align: right;
}

.lanes {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.lane {
  min-height: 438px;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #1d4f39, #173827);
}

.lane.command-active {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--place) 42%, transparent), inset 0 0 42px rgb(73 216 143 / 0.12);
}

.lane.command-place {
  border-color: var(--place);
}

.lane.command-stay {
  border-color: var(--stay);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--stay) 46%, transparent), inset 0 0 42px rgb(118 185 255 / 0.13);
}

.lane.command-bust {
  border-color: var(--bust);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--bust) 46%, transparent), inset 0 0 42px rgb(255 119 114 / 0.13);
}

.lane.illegal {
  border-color: color-mix(in srgb, var(--red) 55%, var(--line));
}

.lane.command-stay.illegal {
  border-color: var(--blue);
}

.lane.command-bust.illegal {
  border-color: var(--red);
}

.lane-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.lane-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.lane-total {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--text);
  font-size: 21px;
  font-weight: 900;
}

.lane-total.danger {
  color: var(--red);
}

.lane-command-badge {
  display: grid;
  place-items: center;
  min-height: 44px;
  padding: 0 8px;
  border: 2px solid currentColor;
  border-radius: 8px;
  background: #0b0f0d;
  color: var(--place);
  font-size: 18px;
  font-weight: 950;
  text-align: center;
}

.lane-command-badge.stay {
  color: var(--stay);
}

.lane-command-badge.bust {
  color: var(--bust);
}

.cards {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 292px;
  padding-top: 4px;
}

.card {
  display: grid;
  place-items: center;
  width: 82px;
  height: 112px;
  margin-top: -36px;
  border: 1px solid #d5cfc2;
  border-radius: 7px;
  background: #f6f2e8;
  color: #161616;
  font-size: 30px;
  font-weight: 950;
  box-shadow: 0 8px 18px rgb(0 0 0 / 0.22);
}

.card:first-child {
  margin-top: 0;
}

.card.red-card {
  color: #c43d39;
}

.lane-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.move-button,
.stay-button,
.bust-button {
  min-height: 42px;
  padding: 0 8px;
  font-weight: 800;
}

.move-button.primary {
  border-color: var(--green);
  color: var(--green);
}

.move-button.danger-action {
  color: #ffaaa8;
}

.move-button.primary.danger-action {
  border-color: var(--red);
  color: var(--red);
}

.stay-button {
  color: var(--gold);
}

.stay-button.primary {
  border-color: var(--blue);
  color: var(--blue);
}

.bust-button {
  color: #ffaaa8;
}

.bust-button.primary {
  border-color: var(--red);
  color: var(--red);
}

.accept-best-button {
  width: 100%;
  min-height: 54px;
  margin-top: 14px;
  border-color: var(--green);
  background: #10251d;
  color: var(--green);
  font-size: 20px;
  font-weight: 950;
}

.move-button:disabled,
.stay-button:disabled,
.bust-button:disabled,
.rank-button:disabled,
.ghost-button:disabled,
.accept-best-button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
}

.recommendation {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.best-move {
  margin-top: 8px;
  font-size: 30px;
  font-weight: 950;
}

.best-move.place {
  color: var(--place);
}

.best-move.stay {
  color: var(--stay);
}

.best-move.bust {
  color: var(--bust);
}

.best-reason {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.4;
}

.move-rankings {
  display: grid;
  gap: 8px;
}

.ranking-row {
  display: grid;
  grid-template-columns: 88px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111614;
}

.ranking-row:first-child {
  border-color: var(--gold);
}

.ranking-row.place strong {
  color: var(--place);
}

.ranking-row.stay strong {
  color: var(--stay);
}

.ranking-row.bust strong {
  color: var(--bust);
}

.ranking-row span {
  color: var(--muted);
  font-size: 12px;
}

.ranking-row strong {
  overflow-wrap: anywhere;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stats-grid div {
  min-height: 72px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111614;
}

.stats-grid span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.stats-grid strong {
  font-size: 22px;
}

.input-panel {
  margin-top: 14px;
  padding: 12px;
}

.rank-buttons {
  display: grid;
  grid-template-columns: repeat(13, minmax(54px, 1fr));
  gap: 8px;
}

.rank-button {
  min-height: 58px;
  font-size: 22px;
  font-weight: 950;
}

.rank-button.selected {
  border-color: var(--green);
  color: var(--green);
}

.bottom-panels {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 14px;
  margin-top: 14px;
}

.deck-panel,
.history-panel {
  padding: 14px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--muted);
}

.deck-counts {
  display: grid;
  grid-template-columns: repeat(13, minmax(0, 1fr));
  gap: 8px;
}

.deck-rank {
  min-height: 58px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111614;
}

.deck-rank strong {
  display: block;
  text-align: center;
}

.deck-rank span {
  color: var(--muted);
  font-size: 12px;
}

.history-list {
  height: 136px;
  margin: 0;
  padding-left: 22px;
  overflow: auto;
  color: var(--muted);
}

.history-list li {
  margin-bottom: 5px;
}

body.fast-mode .app-shell {
  width: min(1580px, calc(100vw - 24px));
}

body.fast-mode .workspace {
  grid-template-columns: minmax(760px, 1fr) 420px;
}

body.fast-mode .best-move {
  font-size: 58px;
  line-height: 0.95;
}

body.fast-mode .best-move.stay {
  font-size: 46px;
}

body.fast-mode .best-reason {
  font-size: 22px;
  line-height: 1.25;
}

body.fast-mode .accept-best-button {
  min-height: 68px;
  font-size: 26px;
}

body.fast-mode .move-rankings,
body.fast-mode .bottom-panels,
body.fast-mode .panel-title,
body.fast-mode .deck-panel,
body.fast-mode .history-panel {
  display: none;
}

body.fast-mode .side-panel {
  gap: 18px;
}

body.fast-mode .recommendation {
  border-bottom: 0;
  padding-bottom: 0;
}

body.fast-mode .stats-grid {
  grid-template-columns: repeat(2, 1fr);
}

body.fast-mode .stay-button:not(.primary) {
  visibility: hidden;
}

body.fast-mode .lane-command-badge {
  min-height: 58px;
  font-size: 24px;
}

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

  .app-shell {
    width: min(100vw - 20px, 920px);
  }

  .workspace,
  .bottom-panels {
    grid-template-columns: 1fr;
  }

  .rank-buttons,
  .deck-counts {
    grid-template-columns: repeat(7, minmax(54px, 1fr));
  }
}
