:root {
  --bg: #f3f4f5;
  --paper: #fafafa;
  --panel: #ffffff;
  --panel-2: #eceff1;
  --line: #d5d9dd;
  --text: #202327;
  --muted: #687078;
  --accent: #30343a;
  --green: #2f9d69;
  --red: #d75345;
  --blue: #3579c8;
  --shadow: 0 12px 28px rgba(20, 23, 27, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  background: linear-gradient(180deg, #fafafa, #eceff1 55%, #e5e7e9);
}

button,
select,
input::file-selector-button {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f9fafb;
  color: var(--text);
  min-height: 34px;
  padding: 0 10px;
  font: inherit;
}

button {
  cursor: pointer;
}

button * {
  cursor: inherit;
  pointer-events: none;
}

button:hover:not(:disabled),
input::file-selector-button:hover {
  border-color: var(--accent);
  background: #eef0f2;
}

button.toggle-on {
  color: #fff;
  border-color: #202327;
  background: #202327;
}

button.toggle-on:hover:not(:disabled) {
  background: #30343a;
}

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

select {
  padding-right: 22px;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 14px;
  border-bottom: 1px solid #d8dcdf;
  background: rgba(250, 250, 250, 0.92);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(145deg, #ffffff, #cfd3d7);
  color: #1f2328;
  font-weight: 900;
  box-shadow: inset 0 0 0 5px rgba(255, 255, 255, 0.35);
}

.brand h1 {
  font-size: 18px;
  line-height: 1;
  margin: 0;
  white-space: nowrap;
}

.brand p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 8px;
}

.file-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f9fafb;
  cursor: pointer;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.file-button span {
  color: var(--text);
  white-space: nowrap;
  pointer-events: none;
}

.file-button:hover {
  border-color: var(--accent);
  background: #eef0f2;
}

.status {
  position: fixed;
  left: 12px;
  bottom: 10px;
  z-index: 30;
  max-width: min(540px, calc(100vw - 24px));
  color: #b42318;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.84);
  pointer-events: none;
}

.ai-level {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f9fafb;
}

.ai-level span {
  color: var(--muted);
  font-weight: 800;
}

.ai-level select {
  min-height: 26px;
  border: 0;
  background: transparent;
  padding-left: 0;
}

.game-shell {
  display: grid;
  gap: 10px;
  padding: 10px;
}

.scoreboard,
.analysis-card,
.history-card,
.bank-card,
.noble-strip,
.table,
.action-dock {
  border: 1px solid rgba(20, 23, 27, 0.14);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  border-radius: 8px;
}

.scoreboard {
  display: grid;
  gap: 8px;
  padding: 10px;
  margin-top: 10px;
}

.turn-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #000;
  font-size: 17px;
  font-weight: 800;
  padding-left: 6px;
}

.players {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 8px;
}

.player {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fbfbfb;
  min-width: 0;
}

.player.active {
  border-color: var(--accent);
  box-shadow: inset 0 3px 0 var(--accent);
}

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

.player-top strong {
  color: #202327;
}

.player-ident {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.player-ident select,
.player-ident button {
  min-height: 26px;
  padding: 0 6px;
  font-size: 12px;
}

.player-mode {
  min-width: 46px;
  font-weight: 800;
}

.mini-row,
.reserve-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.reserve-row {
  align-items: stretch;
}

.points {
  margin-left: auto;
  color: var(--accent);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 10px;
}

.board-panel,
.right-panel {
  min-width: 0;
}

.right-panel {
  display: grid;
  align-content: start;
  gap: 14px;
}

.noble-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(90px, 1fr));
  gap: 8px;
  padding: 10px;
  margin-bottom: 10px;
}

.noble {
  min-height: 70px;
  border-radius: 8px;
  padding: 8px;
  background: linear-gradient(145deg, #a976dd, #5b3a94);
  color: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(20, 23, 27, 0.12);
}

.noble strong {
  display: block;
  color: #ffffff;
  font-size: 18px;
  margin-bottom: 6px;
}

.table {
  padding: 10px;
}

.tier-row {
  --tier-color: var(--line);
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 8px;
  align-items: stretch;
  padding: 8px;
  margin-bottom: 8px;
  border-radius: 8px;
  background: #f9fafb;
}

.tier-row:last-child {
  margin-bottom: 0;
}

.tier-1 {
  --tier-color: #69b889;
  border: 2px solid var(--tier-color);
  background: #eaf7ef;
}

.tier-2 {
  --tier-color: #d8bd48;
  border: 2px solid var(--tier-color);
  background: #fbf6d8;
}

.tier-3 {
  --tier-color: #6f9fd1;
  border: 2px solid var(--tier-color);
  background: #e8f2fc;
}

.tier-head {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 6px;
  border-radius: 8px;
  background: var(--tier-color);
  padding: 6px;
  text-align: center;
}

.tier-head strong {
  color: #202327;
  font-size: 16px;
}

.tier-head span {
  color: rgba(32, 35, 39, 0.74);
  font-size: 12px;
}

.deck-reserve {
  min-height: 26px;
  min-width: 46px;
  color: var(--text);
  border-color: rgba(20, 23, 27, 0.18);
  background: rgba(249, 250, 251, 0.88);
}

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(104px, 1fr));
  gap: 8px;
}

.card {
  position: relative;
  min-height: 132px;
  border-radius: 8px;
  padding: 8px;
  color: #161719;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.13), 0 10px 22px rgba(20, 23, 27, 0.13);
}

.card::after {
  content: "";
  position: absolute;
  inset: 46px -20px auto auto;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.27);
  pointer-events: none;
  z-index: 0;
}

.card > * {
  position: relative;
  z-index: 2;
}

.card.can-buy {
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.42),
    inset 0 0 0 2px rgba(47, 157, 105, 0.72),
    0 0 0 1px rgba(47, 157, 105, 0.34),
    0 10px 24px rgba(20, 23, 27, 0.16),
    0 0 22px rgba(47, 157, 105, 0.36);
}

.card.can-buy::before {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.52);
  background:
    linear-gradient(135deg, transparent 0 34%, rgba(255, 255, 255, 0.34) 35%, rgba(47, 157, 105, 0.12) 39%, transparent 43%),
    repeating-linear-gradient(135deg, transparent 0 17px, rgba(255, 255, 255, 0.24) 18px 21px, rgba(47, 157, 105, 0.16) 22px 24px, transparent 25px 42px);
  box-shadow: inset 0 0 18px rgba(255, 255, 255, 0.14);
  opacity: 0.9;
  pointer-events: none;
  z-index: 1;
}

.compact {
  min-height: 104px;
  width: 86px;
  padding: 6px;
}

.card-white { background: linear-gradient(145deg, #ffffff, #d3d8dd); }
.card-blue { background: linear-gradient(145deg, #b8dbff, #5f94d6); }
.card-green { background: linear-gradient(145deg, #bceac9, #5aaa7d); }
.card-red { background: linear-gradient(145deg, #ffc2bb, #d8665e); }
.card-black { background: linear-gradient(145deg, #666b72, #22252b); color: #f8f4ea; }

.empty-card {
  display: grid;
  place-items: center;
  min-height: 112px;
  border: 1px dashed var(--line);
  background: rgba(255, 255, 255, 0.54);
  color: var(--muted);
}

.compact.empty-card {
  min-height: 104px;
}

.noble.empty-card {
  min-height: 70px;
}

.card-score {
  font-size: 21px;
  font-weight: 900;
}

.card-color-dot {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 20px;
  height: 20px;
  border: 1.5px solid rgba(20, 23, 27, 0.42);
  border-radius: 4px;
  box-shadow: 0 2px 5px rgba(20, 23, 27, 0.2);
  filter: drop-shadow(0 1px 1px rgba(20, 23, 27, 0.16));
  clip-path: none;
}

.card-color-dot.white,
.card-color-dot.blue,
.card-color-dot.green,
.card-color-dot.red,
.card-color-dot.black {
  border-radius: 4px;
  clip-path: none;
  transform: none;
}

.cost {
  position: absolute;
  left: 10px;
  bottom: 40px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-width: calc(100% - 20px);
}

.compact .cost {
  bottom: 32px;
}

.card-actions {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  display: flex;
  gap: 6px;
  z-index: 2;
}

.card-actions button {
  min-height: 26px;
  flex: 1;
  background: rgba(249, 250, 251, 0.88);
  border-color: rgba(20, 23, 27, 0.18);
}

.bank-card {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 10px;
  margin-top: 10px;
}

.bank-title h2,
.analysis-card h2,
.history-card h2 {
  margin: 0;
  font-size: 15px;
}

.bank-title h2 {
  color: #000;
  font-size: 17px;
  font-weight: 800;
}

.bank-title {
  flex: 0 0 100%;
  min-width: 0;
  padding: 0 0 0 6px;
}

.bank-title p,
.gem-order p,
.analysis-source,
.empty {
  color: var(--muted);
  font-size: 13px;
}

.bank-title p,
.gem-order p {
  margin: 5px 0 0;
}

.bank-gems {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.bank-gem {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 46px;
  min-height: 46px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.bank-gem.selected {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.bank-gem:disabled {
  opacity: 1;
}

.bank-gem:hover:not(:disabled),
.bank-gem.selected:hover:not(:disabled) {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.bank-gem .gem {
  width: 40px;
  height: 40px;
  font-size: 14px;
}

.bank-gem b {
  position: absolute;
  top: 4px;
  right: 6px;
  color: #202327;
}

.gem-order {
  display: flex;
  align-items: stretch;
  gap: 6px;
  flex-wrap: wrap;
}

.selected-gems {
  min-height: 28px;
  display: flex;
  align-items: center;
  min-width: 112px;
  padding: 5px 8px;
  border-radius: 7px;
  background: #f9fafb;
  border: 1px solid var(--line);
  color: #202327;
  font-weight: 800;
}

.gem-tools {
  display: flex;
  gap: 6px;
}

.gem-tools button {
  min-width: 48px;
  padding: 0 8px;
}

.action-dock {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding: 8px 8px 8px 10px;
}

.pass-button {
  min-width: 96px;
  color: var(--text);
  background: #f9fafb;
  border-color: var(--line);
}

.badge,
.gem {
  display: inline-grid;
  place-items: center;
  position: relative;
  width: 26px;
  height: 26px;
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 900;
  color: var(--gem-color, #111);
  background: var(--gem-fill, #dfe3e7);
  box-shadow: 0 2px 5px rgba(20, 23, 27, 0.28), inset 0 0 0 1px rgba(20, 23, 27, 0.1);
  clip-path: none;
  filter: drop-shadow(0 1px 1px rgba(20, 23, 27, 0.14));
  overflow: hidden;
}

.gem {
  width: 32px;
  height: 32px;
}

.gem-face {
  display: grid;
  place-items: center;
  position: absolute;
  inset: 0;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0) 44%), var(--gem-fill, #dfe3e7);
  color: var(--gem-color, #111);
  border-radius: 50%;
  clip-path: none;
  font-style: normal;
  line-height: 1;
  pointer-events: none;
}

.white {
  background: #fafafa;
  color: #161616;
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}

.blue {
  background: #4f92db;
  color: #071422;
  border-radius: 50%;
}

.green {
  background: #4eb579;
  color: #07160f;
  clip-path: polygon(50% 4%, 96% 94%, 4% 94%);
}

.red {
  background: #df675b;
  color: #1b0705;
  clip-path: polygon(50% 0%, 94% 50%, 50% 100%, 6% 50%);
}

.owned-card {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1.5px solid rgba(20, 23, 27, 0.42);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 900;
  box-shadow: 0 2px 5px rgba(20, 23, 27, 0.2);
  filter: drop-shadow(0 1px 1px rgba(20, 23, 27, 0.16));
}

.owned-card.white,
.owned-card.green,
.owned-card.red,
.owned-card.gold {
  clip-path: none;
}

.owned-card.blue {
  border-radius: 4px;
}

.owned-card i {
  font-style: normal;
}

.owned-stack {
  position: relative;
  display: inline-grid;
  place-items: center;
  outline: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.owned-stack:focus-visible .owned-card {
  outline: 2px solid #202327;
  outline-offset: 2px;
}

.owned-popover {
  position: fixed;
  left: 0;
  top: 0;
  display: grid;
  gap: 6px;
  width: max-content;
  max-width: calc(100vw - 16px);
  padding: 8px;
  border: 1px solid rgba(20, 23, 27, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 12px 28px rgba(20, 23, 27, 0.18);
  color: #202327;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(4px) scale(0.98);
  transform-origin: top center;
  transition: opacity 120ms ease, transform 120ms ease;
  z-index: 80;
}

.owned-popover::before {
  content: "";
  position: absolute;
  left: var(--owned-popover-arrow-left, 50%);
  top: -5px;
  width: 10px;
  height: 10px;
  border-left: 1px solid rgba(20, 23, 27, 0.18);
  border-top: 1px solid rgba(20, 23, 27, 0.18);
  background: rgba(255, 255, 255, 0.98);
  transform: translateX(-50%) rotate(45deg);
}

.owned-popover.popover-above {
  transform-origin: bottom center;
}

.owned-popover.popover-above::before {
  top: auto;
  bottom: -5px;
  border: 0;
  border-right: 1px solid rgba(20, 23, 27, 0.18);
  border-bottom: 1px solid rgba(20, 23, 27, 0.18);
}

.owned-stack.owned-stack-open .owned-popover {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.owned-popover-title {
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.owned-popover-cards {
  display: grid;
  grid-template-columns: repeat(var(--owned-popover-cols, 4), 54px);
  gap: 5px;
  max-height: min(390px, calc(100vh - 86px));
  overflow-y: auto;
  scrollbar-width: thin;
}

.owned-mini-card {
  display: grid;
  align-content: space-between;
  min-height: 70px;
  padding: 5px;
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px rgba(20, 23, 27, 0.16);
}

.owned-mini-card b {
  font-size: 15px;
  line-height: 1;
}

.owned-mini-card > span {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.owned-mini-card .badge {
  width: 17px;
  height: 17px;
  border-width: 1px;
  font-size: 9px;
}

.reserved-card .badge,
.reserved-card .gem {
  width: 18px;
  height: 18px;
  font-size: 10px;
}

.reserved-card .card-score {
  font-size: 16px;
}

.reserved-card .card-actions button {
  min-height: 22px;
  padding: 0 4px;
  font-size: 11px;
}

.black {
  background: #22252b;
  color: #f8f4ea;
  border-radius: 4px;
}

.gold {
  background: #d9ad3f;
  color: #1d1505;
  clip-path: polygon(50% 0%, 98% 36%, 80% 100%, 20% 100%, 2% 36%);
}

.gem-shape.white {
  --gem-fill: #fafafa;
  --gem-color: #161616;
  --gem-shape: circle(50% at 50% 50%);
  background: #ffffff;
  border-radius: 50%;
  clip-path: none;
}

.gem-shape.blue {
  --gem-fill: #4f92db;
  --gem-color: #071422;
  --gem-shape: circle(50% at 50% 50%);
  background: #ffffff;
  border-radius: 50%;
  clip-path: none;
}

.gem-shape.green {
  --gem-fill: #4eb579;
  --gem-color: #07160f;
  --gem-shape: circle(50% at 50% 50%);
  background: #ffffff;
  border-radius: 50%;
  clip-path: none;
}

.gem-shape.red {
  --gem-fill: #df675b;
  --gem-color: #1b0705;
  --gem-shape: circle(50% at 50% 50%);
  background: #ffffff;
  border-radius: 50%;
  clip-path: none;
}

.gem-shape.black {
  --gem-fill: #22252b;
  --gem-color: #f8f4ea;
  --gem-shape: circle(50% at 50% 50%);
  background: #ffffff;
  border-radius: 50%;
  clip-path: none;
}

.gem-shape.gold {
  --gem-fill: #d9ad3f;
  --gem-color: #1d1505;
  --gem-shape: circle(50% at 50% 50%);
  background: #ffffff;
  border-radius: 50%;
  clip-path: none;
}

.badge.cost-power {
  --cost-start: 180deg;
  --cost-arc: 0deg;
  border-color: transparent;
  background:
    linear-gradient(#ffffff, #ffffff) padding-box,
    conic-gradient(from var(--cost-start), #ff6fae 0 var(--cost-arc), rgba(255, 255, 255, 0.92) var(--cost-arc) 360deg) border-box;
}

.analysis-card,
.history-card {
  padding: 10px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.panel-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.panel-actions button,
.panel-actions .file-button {
  min-height: 30px;
}

.analysis-source,
.empty {
  margin-bottom: 12px;
}

.ai-models {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.ai-model-row {
  display: grid;
  grid-template-columns: 42px 66px 62px minmax(0, 1fr) 44px 48px;
  align-items: center;
  gap: 5px;
  min-width: 0;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fafb;
}

.ai-model-row.current {
  border-color: #8d959d;
  background: #f1f3f5;
}

.ai-seat {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.ai-seat strong {
  line-height: 1;
}

.ai-seat span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.ai-strategy,
.ai-depth,
.ai-load-model,
.ai-import {
  min-width: 0;
  width: 100%;
  min-height: 28px;
  padding: 0 6px;
  font-size: 12px;
}

.ai-model-name {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-button.disabled {
  cursor: not-allowed;
  opacity: 0.44;
}

.analysis-progress {
  position: relative;
  height: 6px;
  margin: -4px 0 12px;
  border-radius: 999px;
  background: #e0e3e6;
  overflow: hidden;
}

.animated-bar i {
  display: block;
  position: absolute;
  inset: 0 auto 0 0;
  height: 100%;
  border-radius: inherit;
  width: 0;
  will-change: width;
}

.animated-bar .bar-instant {
  transition: width 90ms linear;
}

.analysis-progress .bar-instant {
  background: linear-gradient(90deg, rgba(47, 157, 105, 0.28), rgba(48, 52, 58, 0.22));
}

.analysis-progress .bar-lag {
  background: linear-gradient(90deg, #2f9d69, #30343a);
  transition: width 780ms cubic-bezier(0.18, 0.86, 0.28, 1);
}

.rates {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.rate {
  display: grid;
  grid-template-columns: 28px 1fr 42px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.rate div {
  height: 8px;
  border-radius: 999px;
  background: #e0e3e6;
  overflow: hidden;
}

.rate i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2f3338, #8a9199);
}

.moves {
  display: grid;
  gap: 5px;
}

.moves-head {
  display: grid;
  grid-template-columns: 22px 1fr 38px 64px;
  align-items: center;
  gap: 6px;
  padding: 0 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.moves-head span {
  grid-column: 2;
}

.moves-head b {
  grid-column: 3;
  text-align: right;
}

.suggestion {
  position: relative;
  display: grid;
  grid-template-columns: 22px 1fr 38px 64px;
  align-items: center;
  gap: 6px;
  padding: 0 6px;
  border-radius: 8px;
  background: #f9fafb;
  border: 1px solid var(--line);
  overflow: hidden;
}

.suggestion > *:not(.suggestion-heat) {
  position: relative;
  z-index: 1;
}

.suggestion-heat {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  pointer-events: none;
}

.suggestion-heat .bar-instant {
  background: #e9ecef;
}

.suggestion-heat .bar-lag {
  background: #d7dce1;
  transition: width 560ms cubic-bezier(0.18, 0.86, 0.28, 1);
}

.suggestion-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.suggestion-main strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggestion-main em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  line-height: 1.1;
}

.intent-row {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  height: 22px;
  overflow: hidden;
}

.intent-label {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.intent-card,
.intent-noble,
.intent-empty {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border: 1px solid rgba(20, 23, 27, 0.22);
  border-radius: 5px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.32);
}

.intent-card b,
.intent-noble b,
.intent-empty {
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.intent-noble {
  color: #ffffff;
  background: linear-gradient(145deg, #a976dd, #5b3a94);
}

.intent-empty {
  color: #202327;
  background: #eef1f3;
}

.intent-card.owned-card {
  width: 22px;
  height: 22px;
  border-width: 1px;
  font-size: 12px;
}

.intent-card.owned-card.black {
  color: #f8f4ea;
}

.intent-cost {
  display: flex;
  align-items: center;
  gap: 3px;
  min-width: 0;
  overflow: hidden;
}

.intent-cost .badge {
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  border-width: 1px;
  font-size: 10px;
}

.intent-cost .owned-card {
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  border-width: 1px;
  font-size: 10px;
}

.suggestion button {
  min-width: 64px;
  white-space: nowrap;
  padding: 0 10px;
}

.rank {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
}

.history-list {
  display: block;
  max-height: 360px;
  overflow: auto;
}

.history-root {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  width: 100%;
  margin-bottom: 6px;
  color: #30343a;
  background: #f9fafb;
  text-align: left;
}

.history-root.current {
  color: #fff;
  border-color: #202327;
  background: #202327;
}

.history-root strong,
.history-cell strong,
.branch-move strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-root span,
.history-cell span,
.branch-move span {
  color: inherit;
  font-size: 11px;
  font-weight: 900;
  opacity: 0.72;
}

.history-mainline {
  display: grid;
  gap: 3px;
}

.history-turn {
  display: grid;
  grid-template-columns: 28px repeat(var(--players), minmax(0, 1fr));
  gap: 3px;
  min-width: 0;
}

.history-turn-no {
  display: grid;
  place-items: center;
  min-height: 30px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.history-cell,
.branch-move {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px;
  min-width: 0;
  min-height: 30px;
  padding: 0 6px;
  color: #30343a;
  background: #f9fafb;
  border-color: var(--line);
  text-align: left;
}

.history-cell.current,
.branch-move.current {
  color: #fff;
  border-color: #202327;
  background: #202327;
}

.history-cell.future {
  border-style: dashed;
  background: #f3f5f6;
}

.history-root.has-branches,
.history-cell.has-branches,
.branch-move.has-branches {
  border-color: #8d959d;
}

.branch-move.mainline-choice:not(.current) {
  background: #eef1f3;
  box-shadow: inset 3px 0 0 #30343a;
}

.branch-badge {
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  color: #202327;
  background: #dfe3e7;
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
}

.current .branch-badge {
  color: #202327;
  background: #ffffff;
}

.empty-cell {
  display: grid;
  place-items: center;
  min-height: 30px;
  border: 1px dashed var(--line);
  border-radius: 7px;
  color: rgba(104, 112, 120, 0.52);
  font-size: 11px;
}

.history-branches {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.branch-group {
  display: grid;
  gap: 5px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.branch-group h3 {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.branch-moves {
  display: grid;
  gap: 4px;
}

.history-empty {
  padding: 8px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .right-panel {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 920px) {
  .topbar {
    align-items: center;
    flex-direction: row;
  }

  .toolbar {
    justify-content: flex-end;
  }

  .players,
  .right-panel {
    grid-template-columns: 1fr 1fr;
  }

  .bank-card {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .topbar {
    gap: 6px;
    padding: 6px 8px;
  }

  .brand {
    min-width: 0;
    gap: 8px;
  }

  .mark {
    width: 32px;
    height: 32px;
    flex: 0 0 auto;
    box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.35);
  }

  .brand h1 {
    font-size: 16px;
  }

  .toolbar {
    width: auto;
    flex: 0 0 auto;
    gap: 5px;
  }

  .toolbar > * {
    width: auto;
    min-width: 0;
  }

  .toolbar select {
    max-width: 66px;
    padding: 0 18px 0 7px;
  }

  .toolbar button {
    padding: 0 8px;
  }

  .ai-level {
    justify-content: space-between;
  }

  .game-shell {
    padding: 6px;
  }

  .noble-strip,
  .table,
  .scoreboard,
  .bank-card,
  .action-dock,
  .analysis-card,
  .history-card {
    padding: 6px;
  }

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

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

  .noble-strip {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
  }

  .tier-row {
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 4px;
    padding: 4px;
  }

  .tier-head {
    gap: 4px;
    padding: 3px;
  }

  .tier-head strong {
    font-size: 14px;
  }

  .tier-head span {
    font-size: 10px;
  }

  .deck-reserve {
    min-width: 34px;
    min-height: 22px;
    padding: 0 3px;
    font-size: 11px;
  }

  .card {
    min-height: 104px;
    padding: 5px;
    border-radius: 6px;
  }

  .card-score {
    font-size: 17px;
  }

  .card-color-dot {
    top: 7px;
    right: 7px;
    width: 15px;
    height: 15px;
  }

  .cost {
    left: 5px;
    bottom: 31px;
    gap: 3px;
    max-width: calc(100% - 10px);
  }

  .card-actions {
    left: 4px;
    right: 4px;
    bottom: 4px;
    gap: 3px;
  }

  .card-actions button {
    min-height: 22px;
    padding: 0 2px;
    font-size: 11px;
  }

  .badge,
  .gem {
    width: 20px;
    height: 20px;
    border-width: 1px;
    font-size: 10px;
  }

  .noble {
    min-height: 48px;
    padding: 5px;
    border-radius: 6px;
  }

  .noble strong {
    font-size: 14px;
    margin-bottom: 3px;
  }

  .noble div {
    display: flex;
    flex-wrap: nowrap;
    gap: 2px;
  }

  .noble .owned-card {
    width: 16px;
    height: 16px;
    font-size: 9px;
  }

  .player {
    padding: 5px;
    border-radius: 6px;
  }

  .player-top {
    display: grid;
    gap: 3px;
  }

  .player-ident {
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 3px;
  }

  .player-ident button {
    min-height: 22px;
    padding: 0 4px;
    font-size: 10px;
  }

  .player-top span {
    font-size: 11px;
  }

  .mini-row,
  .reserve-row {
    gap: 3px;
    margin-top: 4px;
  }

  .player .mini-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 1px;
  }

  .player .mini-row,
  .player .reserve-row {
    scrollbar-width: none;
  }

  .player .mini-row::-webkit-scrollbar,
  .player .reserve-row::-webkit-scrollbar {
    display: none;
  }

  .player .gem,
  .player .owned-card {
    width: 18px;
    height: 18px;
    font-size: 9px;
  }

  .compact {
    flex: 0 0 76px;
    width: 76px;
    min-height: 104px;
    padding: 4px;
  }

  .compact.empty-card {
    min-height: 104px;
  }

  .player .reserve-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .right-panel {
    grid-template-columns: 1fr;
  }
}
