:root {
  --bg: #f4f1e8;
  --paper: #fbf8f2;
  --ink: #24221b;
  --muted: #6f6a5c;
  --line: #d6cbb6;
  --accent: #305f5a;
  --accent-soft: #dbeae7;
  --danger: #8d2d2d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 10%, #efe4d3 0%, transparent 45%),
    radial-gradient(circle at 90% 90%, #e2e9dd 0%, transparent 35%),
    var(--bg);
  font-family: "Trebuchet MS", "Gill Sans", "Segoe UI", sans-serif;
}

.topbar {
  display: grid;
  gap: 6px;
  padding: 16px 20px;
  border-bottom: 2px solid var(--line);
  background: linear-gradient(180deg, #fffaf0 0%, #f7f1e6 100%);
}

.topbar-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar h1 {
  margin: 0;
  font-size: 1.4rem;
}

.phase-theme-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 86px;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.86rem;
  font-weight: 800;
  letter-spacing: 0;
  background: #fff8d8;
  color: #5a4a00;
  box-shadow: 0 1px 0 rgba(255,255,255,0.75) inset;
}

.phase-theme-icon {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  display: block;
}

.phase-theme-night {
  background: #1d2f25;
  border-color: #586f5f;
  color: #f1e6aa;
  box-shadow: 0 0 0 1px rgba(241,230,170,0.15) inset;
}

.restart-btn {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 14px;
  border: 1px solid #c88;
  border-radius: 999px;
  background: #fff;
  color: var(--danger);
  cursor: pointer;
  transition: background 0.1s;
}

.restart-btn:hover {
  background: #fceaea;
}

#statusLine {
  margin: 0;
  color: var(--muted);
}

.refresh-meta {
  font-size: 0.92rem;
  line-height: 1.45;
  display: grid;
  gap: 2px;
}

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  padding: 14px;
}

.layout-v2 {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 400px);
  align-items: start;
}

.left-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.right-col {
  position: sticky;
  top: 14px;
  align-self: start;
  min-width: 0;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 1px 0 #fff inset;
}

.panel h2 {
  margin: 0 0 10px 0;
  font-size: 1.05rem;
  letter-spacing: 0.2px;
}

.side-horizontal {
  display: grid;
  gap: 10px;
}

.info-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(240px, 1fr));
  gap: 10px;
}

.subpanel {
  border: 1px solid #dfd3bf;
  border-radius: 9px;
  background: #fffdf8;
  padding: 10px;
}

.command-subpanel {
  grid-column: span 2;
}

.phase-summary-subpanel {
  grid-column: span 2;
}

.command-feed {
  max-height: 220px;
  overflow: auto;
  border: 1px solid #e7dccb;
  border-radius: 8px;
  background: #fff;
}

.cmd-row {
  padding: 6px 8px;
  border-bottom: 1px solid #f0e7d8;
}

.cmd-row:last-child {
  border-bottom: 0;
}

.cmd-row-error .cmd-text {
  color: var(--danger);
}

.cmd-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.69rem;
  color: #746d5f;
}

.cmd-seq {
  font-weight: 700;
  color: #4d4537;
}

.cmd-round {
  font-weight: 700;
  color: #5e563f;
}

.cmd-time {
  margin-left: auto;
}

.cmd-text {
  margin-top: 2px;
  font-size: 0.76rem;
  line-height: 1.24;
  color: #2f2a22;
  word-break: break-word;
}

.cmd-empty {
  padding: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.phase-summary-feed {
  max-height: 220px;
  overflow: auto;
  border: 1px solid #e7dccb;
  border-radius: 8px;
  background: #fff;
}

.phase-row {
  padding: 8px 9px;
  border-bottom: 1px solid #f0e7d8;
}

.phase-row:last-child {
  border-bottom: 0;
}

.phase-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  color: #746d5f;
}

.phase-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: #ece3d3;
  color: #564b3a;
}

.phase-produce .phase-badge {
  background: #dcebe6;
  color: #244f49;
}

.phase-seq,
.phase-round {
  font-weight: 700;
}

.phase-round {
  margin-left: auto;
}

.phase-text {
  margin-top: 3px;
  font-size: 0.79rem;
  line-height: 1.3;
  color: #2f2a22;
}

.phase-empty {
  padding: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.players-panel {
  background: #fff;
}

.board-area {
  position: relative;
}

/* --- Minimap --- */
.minimap {
  display: grid;
  gap: 2px;
  padding: 6px;
  background: #f5f0e4;
  border: 2px solid var(--line);
  border-radius: 8px;
  flex-shrink: 0;
  max-width: 200px;
  position: fixed;
  bottom: 16px;
  left: 16px;
  z-index: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  overflow: hidden;
}

.mm-cell {
  aspect-ratio: 1;
  border-radius: 3px;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s, box-shadow 0.1s;
  border: 1.5px solid transparent;
  min-width: 0;
  min-height: 0;
}

.mm-cell:hover {
  transform: scale(1.15);
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  z-index: 2;
}

.mm-terreno {
  background: #6cc47a;
  border-color: #3a8a4e;
}

.mm-academia {
  background: #b48ad8;
  border-color: #6a45a0;
}

.mm-neutral {
  background: #a0a4ac;
  border-color: #6e727a;
}

.mm-occupied {
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.6);
}

.mm-monument {
  outline: 2px solid #c9a030;
  outline-offset: -1px;
  box-shadow: 0 0 6px rgba(201, 160, 48, 0.5);
}

.mm-empty {
  aspect-ratio: 1;
  min-width: 0;
  min-height: 0;
}

.mm-owner {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.7);
}

.mm-label {
  font-size: 0.5rem;
  font-weight: 700;
  color: rgba(255,255,255,0.85);
  text-transform: uppercase;
  letter-spacing: -0.02em;
  line-height: 1;
}

/* Flash animation for scroll target */
@keyframes card-flash {
  0% { outline: 3px solid #f5a623; outline-offset: 0; }
  50% { outline: 3px solid #f5a623; outline-offset: 3px; }
  100% { outline: 3px solid transparent; outline-offset: 0; }
}

.card-flash {
  animation: card-flash 1.2s ease-out;
}

.board-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdfa;
  padding: 8px;
}

.board {
  display: grid;
  gap: 8px;
  min-height: 420px;
}

.empty-cell {
  border: 2px dashed #e0d6c4;
  min-height: 190px;
  border-radius: 10px;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 8px,
    rgba(0,0,0,0.015) 8px,
    rgba(0,0,0,0.015) 16px
  );
}

.card {
  min-height: 210px;
  border: 2px solid #cabca6;
  border-radius: 10px;
  padding: 0;
  background: #fff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: box-shadow 0.15s, transform 0.15s;
}

.card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.14);
  transform: translateY(-1px);
}

.card.en-obras {
  border-color: #a9682b;
  box-shadow: inset 0 0 0 2px #e8bf8d66, 0 2px 8px rgba(0,0,0,0.08);
}

.card.type-terreno {
  border-color: #3a8a4e;
  background: linear-gradient(180deg, #edf7ef 0%, #dceedd 100%);
}

.card.type-academia {
  border-color: #6a45a0;
  background: linear-gradient(180deg, #f3eef9 0%, #e8dff3 100%);
}

.card.type-neutral {
  border-color: #7a7e86;
  background: linear-gradient(180deg, #f0f1f3 0%, #e4e6ea 100%);
}

/* --- Emblemático (monument) --- */
.card-chips {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.monument-token {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #8a6a30, #5a3e10 50%, #3a2505 100%);
  border: 2px solid #2a1a05;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  line-height: 1;
  padding-top: 1px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.35), inset 0 1px 2px rgba(255,255,255,0.4), inset 0 -1px 2px rgba(0,0,0,0.2);
  color: white;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6), 0 0 1px rgba(0,0,0,0.8);
}

/* --- Card header --- */
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px 4px;
}

.card-head-left {
  flex: 1;
  min-width: 0;
}

.card-title {
  font-weight: 800;
  font-size: 0.92rem;
  line-height: 1.15;
  color: #1a1815;
}

.card-owner {
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: 2px;
}

.badge-obras {
  font-size: 0.65rem;
  padding: 1px 5px;
  margin-left: 4px;
  background: #fff3e0;
  border-color: #ffcc80;
  color: #8d5e00;
}

.pp-chip {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.88rem;
  font-weight: 800;
  flex-shrink: 0;
  border: 2px solid #b9a17a;
  background: #fff5de;
  color: #69490f;
}

.pp-chip-type-terreno {
  background: #d4f0d0;
  border-color: #3a8a4e;
  color: #1a4015;
}

.pp-chip-type-academia {
  background: #e8dff5;
  border-color: #6a45a0;
  color: #3a1550;
}

.pp-chip-type-neutral {
  background: #e0e2e6;
  border-color: #7a7e86;
  color: #333;
}

/* --- Card illustration area --- */
.card-illus-wrap {
  position: relative;
  min-height: 28px;
  margin: 0 8px;
  border-radius: 6px;
  overflow: hidden;
}

.card-illus-wrap.has-illus {
  min-height: 100px;
}

.card-illus {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
  image-rendering: high-quality;
}

.card-illus-wrap:not(.has-illus) .card-illus {
  display: none;
}

.card-overlay {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
}

.has-illus .card-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 4px 6px;
  background: linear-gradient(transparent, rgba(0,0,0,0.55));
}

.has-illus .card-overlay .type-badge {
  opacity: 0.95;
}

.has-illus .card-cost-pill .token-list {
  background: rgba(255,255,255,0.85);
  padding: 1px 6px;
  border-radius: 999px;
}

.has-illus .card-cost-pill .muted-inline {
  color: rgba(255,255,255,0.9);
}

.card-deposit-stack {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 6px;
  border: 1px solid rgba(46, 80, 94, 0.35);
  border-radius: 8px;
  background: rgba(247, 252, 255, 0.94);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.16);
}

.deposit-label {
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1;
  text-transform: uppercase;
  color: #31515d;
}

/* --- Type badge --- */
.type-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.type-badge-terreno {
  background: #a8d8a0;
  color: #1a4015;
}

.type-badge-academia {
  background: #d4a8e0;
  color: #3a1550;
}

.type-badge-neutral {
  background: #c8cad0;
  color: #333;
}

.card-cost-pill {
  font-size: 0.74rem;
}

/* --- Card body --- */
.card-body {
  padding: 4px 10px 6px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-coord {
  font-size: 0.7rem;
  color: var(--muted);
  text-align: right;
  padding: 0 8px 4px;
}

.card-cost-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 0.74rem;
  color: #3e392f;
}

.card-cost-line .mini-label {
  font-weight: 700;
}

.entry-cost-line {
  margin-bottom: 2px;
  padding: 3px 6px;
  background: rgba(255,255,255,0.6);
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,0.06);
}

.zones {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 6px;
  row-gap: 3px;
  align-items: start;
}

.track-zone {
  grid-column: 1 / 3;
  grid-row: 2;
}

.produce-block {
  margin-top: 5px;
  padding: 6px 8px;
  border: 1px solid rgba(166, 152, 130, 0.7);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.55) inset;
  display: grid;
  gap: 4px;
}

.effect-steps {
  display: grid;
  gap: 3px;
}

.effect-step {
  display: grid;
  grid-template-columns: minmax(72px, auto) 1fr;
  gap: 6px;
  align-items: start;
}

.effect-step-icons-only {
  grid-template-columns: 1fr;
}

.effect-step-text-only {
  grid-template-columns: 1fr;
}

.effect-step-empty .effect-text {
  color: var(--muted);
}

.effect-icons {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  min-height: 18px;
}

.effect-text {
  font-size: 0.73rem;
  line-height: 1.24;
  color: #3e392f;
}

.produce-block > .zone-label {
  font-weight: 700;
}

.zone-label {
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #635f54;
  margin-bottom: 2px;
}

.zone-label-instant {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #9a5a00;
}

.zone-label-production {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #305f5a;
}

.zone-icon {
  font-size: 0.78rem;
  line-height: 1;
}

.mini-label {
  font-size: 0.64rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #5b564b;
}

.token-list {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
}

.mini-token {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border: 1px solid #c9bea9;
  border-radius: 999px;
  padding: 1px 4px;
  background: rgba(255, 255, 255, 0.8);
  line-height: 1;
}

.mini-count {
  font-size: 0.72rem;
  font-weight: 700;
  color: #2f2a22;
}

.mini-icon {
  width: 16px;
  height: 16px;
  display: block;
}

.text-pill {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  vertical-align: text-bottom;
  margin: 0 1px;
}

.mini-sign {
  font-size: 0.72rem;
  font-weight: 700;
  color: #2f2a22;
  line-height: 1;
}

.mini-plus {
  font-size: 0.7rem;
  line-height: 1;
  color: #6d6759;
  font-weight: 700;
}

.muted-inline {
  font-size: 0.72rem;
  color: #7b7466;
  font-style: italic;
}

.track-frame {
  display: flex;
  gap: 4px;
  align-items: center;
  border: 2px solid #7f7460;
  border-radius: 8px;
  padding: 5px;
  min-height: 46px;
  background: rgba(255, 253, 248, 0.55);
  width: fit-content;
}

.track-slot {
  width: 38px;
  height: 38px;
  border-radius: 4px;
  border: 1.6px solid #8f866f;
  background: rgba(255, 255, 255, 0.56);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.track-slot.occupied {
  background: rgba(255, 255, 255, 0.78);
}

.slot-label {
  position: absolute;
  right: 2px;
  bottom: 1px;
  font-size: 0.58rem;
  color: #766e5c;
  line-height: 1;
}

.slot-meeple {
  width: 31px;
  height: 31px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.over-zone {
  grid-column: 2;
  grid-row: 1;
  min-height: 32px;
  justify-self: end;
}

.over-stack {
  display: grid;
  gap: 4px;
  justify-items: end;
}

.over-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 3px 9px 3px 6px;
  background: rgba(255, 255, 255, 0.74);
  font-size: 0.8rem;
}

.over-code {
  font-weight: 700;
}

.over-role {
  color: #4c483d;
  font-size: 0.7rem;
}

.over-empty {
  font-size: 0.86rem;
  color: var(--muted);
}

.meeple-icon {
  width: 24px;
  height: 24px;
  display: block;
}

.hint {
  margin: 8px 0 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.discard {
  margin: 0 0 14px 0;
  padding-left: 22px;
  max-height: 180px;
  overflow: auto;
}

.discard li {
  padding: 3px 2px;
  border-bottom: 1px solid #eee5d6;
}

.deck-box {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding: 8px;
  border: 1px solid #e5d9c4;
  border-radius: 8px;
  background: #fffcf7;
}

.deck-stack {
  position: relative;
  width: 52px;
  height: 70px;
}

.deck-stack span {
  position: absolute;
  width: 52px;
  height: 70px;
  border-radius: 6px;
  border: 1px solid #9f8f75;
  background: #f3e7d2 url("/images/card_back.png?v=20260422b") center/cover no-repeat;
  box-shadow: inset 0 0 0 1px #ffffff66;
}

.deck-stack span:nth-child(1) {
  left: 0;
  top: 0;
}

.deck-stack span:nth-child(2) {
  left: 4px;
  top: -3px;
}

.deck-stack span:nth-child(3) {
  left: 8px;
  top: -6px;
}

.deck-meta {
  font-size: 0.9rem;
}

.players {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 10px;
}

.player {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  padding: 9px;
}

.player-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.player-name {
  font-weight: 700;
}

.badge {
  font-size: 0.76rem;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #20433f;
  border: 1px solid #a9c8c2;
}

.badge-human {
  background: #e3f2fd;
  color: #1565c0;
  border-color: #90caf9;
}

.badge-bot {
  background: #f3e5f5;
  color: #7b1fa2;
  border-color: #ce93d8;
}

.res-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 7px;
}

.res {
  padding: 4px 5px;
  border-radius: 6px;
  background: #f7f3ea;
  border: 1px solid #e7dccb;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 0.82rem;
}

.res-icon-img {
  width: 20px;
  height: 20px;
  display: inline-block;
  vertical-align: middle;
}

.sub {
  margin: 4px 0;
  font-size: 0.83rem;
  color: var(--muted);
}

.score-split {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 8px 0;
}

.score-chip {
  font-size: 0.78rem;
  border-radius: 999px;
  padding: 3px 8px;
  border: 1px solid #d9d0c1;
  background: #f8f5ef;
  color: #3d382d;
}

.score-chip-base {
  border-color: #c8ba9f;
  background: #f4efe5;
}

.score-chip-obj {
  border-color: #b5a0d4;
  background: #f3edf9;
}

.score-chip-total {
  border-color: #b9a17a;
  background: #fff5de;
}

/* --- Objective market --- */
.obj-market-subpanel {
  grid-column: span 2;
}

.obj-market {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}

.obj-illus {
  width: 100%;
  height: 80px;
  object-fit: cover;
  border-radius: 8px 8px 0 0;
  margin: -10px -12px 8px -12px;
  width: calc(100% + 24px);
  display: none;
}

.obj-market-card {
  border: 2px solid #c5a030;
  border-radius: 10px;
  background: linear-gradient(135deg, #fffde6 0%, #fff5c2 100%);
  padding: 10px 12px;
  cursor: default;
  transition: box-shadow 0.15s, transform 0.15s;
  overflow: hidden;
}

.obj-market-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  transform: translateY(-1px);
}

.obj-market-card.pickable {
  cursor: pointer;
  border-color: #2f7a3a;
  box-shadow: 0 0 0 2px rgba(47, 122, 58, 0.25);
}

.obj-market-card.pickable:hover {
  border-color: #1f5a2a;
  box-shadow: 0 6px 16px rgba(47, 122, 58, 0.35), 0 0 0 2px rgba(47, 122, 58, 0.45);
  transform: translateY(-2px);
}

.obj-market-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.obj-market-name {
  font-weight: 700;
  font-size: 0.88rem;
  color: #5a4200;
}

.obj-market-desc {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}

.obj-pp-chip {
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 999px;
  background: #fff0a0;
  border: 1px solid #c5a030;
  color: #5a4200;
  font-weight: 700;
  white-space: nowrap;
}

/* --- Player objective cards --- */
.obj-list {
  display: grid;
  gap: 6px;
  margin: 4px 0 6px 0;
}

.obj-illus-sm {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 5px;
  flex-shrink: 0;
  display: none;
}

.obj-card {
  border-radius: 7px;
  padding: 7px 9px;
  font-size: 0.82rem;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.obj-card-body {
  flex: 1;
  min-width: 0;
}

.obj-active {
  border: 2px solid #c5a030;
  background: linear-gradient(135deg, #fffde6 0%, #fff8d0 100%);
  cursor: default;
}

.obj-completed {
  border: 1px solid #8cc49e;
  background: linear-gradient(135deg, #f2faf5 0%, #dcf0e2 100%);
}

.obj-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3px;
}

.obj-card-name {
  font-weight: 700;
  font-size: 0.84rem;
}

.obj-active .obj-card-name {
  color: #5a4200;
}

.obj-completed .obj-card-name {
  color: #2a6b3e;
}

.obj-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  margin-right: 5px;
  border-radius: 50%;
  background: #3f8f55;
  color: #fff;
  font-family: system-ui, sans-serif;
  font-size: 0.75rem;
  font-weight: 800;
  line-height: 1;
  vertical-align: text-bottom;
}

.obj-card-desc {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.3;
  margin-bottom: 4px;
}

.obj-progress-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
}

.obj-progress-label {
  font-size: 0.72rem;
  color: var(--muted);
  min-width: 36px;
}

.obj-progress-bar {
  flex: 1;
  height: 6px;
  background: #ede3c0;
  border-radius: 3px;
  overflow: hidden;
}

.obj-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #c5a030, #dab840);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.obj-completed .obj-progress-bar {
  background: #c8e6d0;
}

.obj-completed .obj-progress-fill {
  background: #4caf50;
}

.obj-extra {
  font-size: 0.74rem;
  color: var(--muted);
  margin-top: 2px;
}

.obj-resource-extra {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.hand {
  margin: 5px 0 0 0;
  padding-left: 18px;
  max-height: 155px;
  overflow: auto;
  font-size: 0.86rem;
}

.meeples {
  display: grid;
  gap: 2px;
  font-size: 0.82rem;
  margin-top: 5px;
}

.error {
  color: var(--danger);
}

.card-hover-preview {
  position: fixed;
  z-index: 1000;
  width: 310px;
  max-height: 80vh;
  overflow-y: auto;
  background: #fdfdf9;
  border: 2px solid #b5a48d;
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(255, 255, 255, 0.6) inset;
  pointer-events: none;
  font-size: 0.88rem;
  line-height: 1.4;
  color: #3b372f;
}

.preview-title {
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 4px;
  color: #1a1815;
  border-bottom: 1px solid #e1d6c2;
  padding-bottom: 4px;
}

.preview-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: #6a6456;
  margin-bottom: 8px;
}

.preview-type {
  text-transform: capitalize;
  font-style: italic;
}

.preview-track {
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #5d5547;
}

.preview-pp {
  font-weight: bold;
  background: #e9e1ce;
  padding: 1px 6px;
  border-radius: 4px;
  color: #4a4538;
}

.preview-text {
  margin-top: 6px;
}

.preview-text strong {
  color: #2b2820;
}

.preview-text .res-icon-img {
  width: 16px;
  height: 16px;
  vertical-align: text-bottom;
  margin: 0 1px;
}

.preview-card-inner {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.preview-card-inner.preview-terreno {
  border-left: 4px solid rgba(28, 99, 51, 0.8);
  padding-left: 8px;
}

.preview-card-inner.preview-academia {
  border-left: 4px solid rgba(73, 46, 127, 0.8);
  padding-left: 8px;
}

.preview-card-inner.preview-objetivo {
  border-left: 4px solid #c5a030;
  padding-left: 8px;
  background: linear-gradient(135deg, #fffde6 0%, #fff9d4 100%);
  border-radius: 6px;
  padding: 8px 10px;
}

.preview-obj-illus {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 6px;
  display: none;
}

.preview-obj-desc {
  font-size: 0.84rem;
  line-height: 1.4;
  color: #3b372f;
  margin-top: 4px;
  padding: 6px 0;
  border-top: 1px solid #ede3c0;
  border-bottom: 1px solid #ede3c0;
}

.preview-obj-section {
  font-size: 0.78rem;
  color: #5a5344;
  margin-top: 5px;
  line-height: 1.4;
}

.preview-obj-section strong {
  color: #3b372f;
}

.preview-costs {
  display: grid;
  gap: 3px;
}

.preview-card-inner .produce-block {
  font-size: 0.82rem;
}

.preview-card-inner .zone-label {
  font-size: 0.64rem;
}

.preview-card-inner .effect-text {
  font-size: 0.7rem;
}

.preview-card-inner .mini-label {
  font-size: 0.6rem;
}

/* Action panel for human players */
.action-panel {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(180deg, #fff8eb 0%, #fef3dc 100%);
  border-bottom: 3px solid #c9a84c;
  padding: 12px 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.action-panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.action-panel-header h2 {
  margin: 0;
  font-size: 1.1rem;
  color: #5a4210;
}

.action-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.action-filter-btn {
  font-size: 0.78rem;
  padding: 4px 10px;
  border: 1px solid #c9b88a;
  border-radius: 999px;
  background: #fff;
  color: #5a4e34;
  cursor: pointer;
}

.action-filter-btn:hover {
  background: #f5edda;
}

.action-filter-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.action-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
}

.action-btn {
  text-align: left;
  font-size: 0.82rem;
  padding: 8px 12px;
  border: 1px solid #d4c9b0;
  border-radius: 7px;
  background: #fff;
  color: #2f2a22;
  cursor: pointer;
  line-height: 1.3;
  transition: background 0.1s, border-color 0.1s;
}

.action-btn:hover {
  background: #f0ead8;
  border-color: #b5a17a;
}

.action-btn.type-pasar {
  border-color: #8b8070;
  background: #f5f2ec;
}

.action-btn.type-construir {
  border-left: 3px solid #6a3fa0;
}

.action-btn.type-trabajar {
  border-left: 3px solid #2e7d52;
}

.action-btn.type-supervision {
  border-left: 3px solid #3f73bd;
}

.action-btn.type-responder {
  border-left: 3px solid #c9a84c;
}

.action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.action-status {
  font-size: 0.85rem;
  color: #5a4210;
  padding: 8px 0;
}

/* Player info strip in action panel */
.player-info-strip {
  display: grid;
  gap: 5px;
  padding: 8px 10px;
  margin-bottom: 8px;
  background: rgba(255,255,255,0.6);
  border: 1px solid #e2d6be;
  border-radius: 8px;
  font-size: 0.82rem;
}

.pi-resources {
  display: flex;
  gap: 6px;
}

.pi-res {
  padding: 3px 8px;
  border-radius: 6px;
  background: #f7f3ea;
  border: 1px solid #e7dccb;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.82rem;
}

.pi-section {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  line-height: 1.5;
}

.pi-label {
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #5a4e34;
  white-space: nowrap;
}

.pi-card {
  padding: 1px 6px;
  background: #fff;
  border: 1px solid #d4c9b0;
  border-radius: 4px;
  font-size: 0.78rem;
  cursor: default;
  white-space: nowrap;
}

.pi-card:hover {
  background: #f5edda;
  border-color: #b5a17a;
}

.pi-meeples {
  display: grid;
  gap: 3px;
}

.pi-meeple {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  white-space: nowrap;
}

.pi-meeple .meeple-icon {
  width: 18px;
  height: 18px;
}

.pi-meeple-free {
  background: #e8f5e9;
  border: 1px solid #a5d6a7;
  color: #2e7d32;
}

.pi-meeple-used {
  background: #fff3e0;
  border: 1px solid #ffcc80;
  color: #6d4c00;
}

.pi-meeple-detail {
  font-size: 0.72rem;
  color: #8a7040;
}

/* Board highlights for wizard */
.board-highlight {
  outline: 3px solid #1e88e5;
  outline-offset: -2px;
  box-shadow: 0 0 12px rgba(30, 136, 229, 0.5), inset 0 0 8px rgba(30, 136, 229, 0.12);
  cursor: pointer !important;
  position: relative;
  z-index: 2;
  animation: highlight-pulse 1.5s ease-in-out infinite;
}

.board-highlight-pos {
  outline-style: dashed;
  background: rgba(30, 136, 229, 0.1) !important;
  min-height: 60px;
}

@keyframes highlight-pulse {
  0%, 100% { outline-color: #1e88e5; box-shadow: 0 0 12px rgba(30, 136, 229, 0.5); }
  50% { outline-color: #42a5f5; box-shadow: 0 0 20px rgba(30, 136, 229, 0.7); }
}

/* Wizard step-by-step UI */
.wizard-hint {
  font-size: 0.85rem;
  color: #8a7d65;
  padding: 10px 0;
  font-style: italic;
}

.wizard-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 8px;
}

.wizard-crumb {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  background: #f0ead8;
  color: #4a4230;
  border: 1px solid #d4c9b0;
}

.wizard-crumb-type {
  background: #fff;
  border-width: 2px;
  font-weight: 700;
}

.wizard-crumb-sep {
  color: #b5a17a;
  font-size: 0.9rem;
  font-weight: 700;
}

.wizard-cancel-btn {
  margin-left: auto;
  font-size: 0.76rem;
  padding: 3px 10px;
  border: 1px solid #c88;
  border-radius: 999px;
  background: #fff;
  color: var(--danger);
  cursor: pointer;
  font-weight: 600;
}

.wizard-cancel-btn:hover {
  background: #fceaea;
}

.wizard-step-label {
  font-size: 0.88rem;
  font-weight: 700;
  color: #5a4210;
  margin-bottom: 6px;
}

.wizard-choices {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
}

.wizard-choice-btn {
  text-align: left;
  font-size: 0.85rem;
  padding: 9px 14px;
  border: 1px solid #d4c9b0;
  border-left: 4px solid #888;
  border-radius: 7px;
  background: #fff;
  color: #2f2a22;
  cursor: pointer;
  line-height: 1.3;
  transition: background 0.1s, border-color 0.1s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.wizard-choice-btn:hover {
  background: #f0ead8;
  border-color: #b5a17a;
}

.wizard-meeple-choice {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.wizard-meeple-choice .meeple-icon {
  width: 22px;
  height: 22px;
}

.wizard-pay-choice {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.wizard-pay-icon {
  width: 20px;
  height: 20px;
}

.wizard-confirm {
  display: grid;
  gap: 8px;
  padding: 4px 0 2px;
}

.wizard-confirm-summary {
  font-size: 0.84rem;
  line-height: 1.35;
  color: #4a4230;
  background: #f6f0e3;
  border: 1px solid #dfd2b7;
  border-radius: 8px;
  padding: 10px 12px;
}

.wizard-confirm-btn {
  justify-self: start;
  min-width: 160px;
  font-weight: 700;
}

.wizard-extra {
  margin-top: 12px;
}

body.phase-night {
  --bg: #111412;
  --paper: #181d1a;
  --ink: #eef4ea;
  --muted: #b8c4b5;
  --line: #3c473d;
  --accent: #d6c66f;
  --accent-soft: #263b2f;
  --danger: #ff9b9b;
  background:
    radial-gradient(circle at 12% 12%, rgba(76, 108, 85, 0.28) 0%, transparent 38%),
    radial-gradient(circle at 88% 88%, rgba(214, 198, 111, 0.16) 0%, transparent 34%),
    var(--bg);
}

body.phase-night .topbar {
  border-bottom-color: var(--line);
  background: linear-gradient(180deg, #1e251f 0%, #151a17 100%);
}

body.phase-night .panel,
body.phase-night .subpanel,
body.phase-night .players-panel,
body.phase-night .board-wrap,
body.phase-night .command-feed,
body.phase-night .phase-summary-feed,
body.phase-night .deck-box,
body.phase-night .card-hover-preview,
body.phase-night .action-panel {
  background: #181d1a;
  border-color: var(--line);
  color: var(--ink);
  box-shadow: none;
}

body.phase-night .action-panel {
  background: linear-gradient(180deg, #202a23 0%, #17201a 100%);
  border-bottom-color: #a99c55;
}

body.phase-night .action-panel-header h2,
body.phase-night .card-title,
body.phase-night .preview-title,
body.phase-night .preview-text strong,
body.phase-night .obj-card-name,
body.phase-night .obj-market-name {
  color: var(--ink);
}

body.phase-night #statusLine,
body.phase-night .cmd-head,
body.phase-night .cmd-seq,
body.phase-night .cmd-round,
body.phase-night .cmd-text,
body.phase-night .phase-head,
body.phase-night .phase-text,
body.phase-night .over-role,
body.phase-night .preview-meta,
body.phase-night .preview-track,
body.phase-night .preview-obj-desc,
body.phase-night .preview-obj-section,
body.phase-night .wizard-confirm-summary {
  color: var(--muted);
}

body.phase-night .cmd-row,
body.phase-night .phase-row,
body.phase-night .discard li {
  border-bottom-color: #2b352d;
}

body.phase-night .minimap,
body.phase-night .empty-cell {
  background: #151a17;
  border-color: var(--line);
}

body.phase-night .card {
  background: #1b211d;
  border-color: #556052;
  box-shadow: 0 2px 10px rgba(0,0,0,0.35);
}

body.phase-night .card.type-terreno {
  background: linear-gradient(180deg, #16291c 0%, #18351f 100%);
  border-color: #5ab46a;
}

body.phase-night .card.type-academia {
  background: linear-gradient(180deg, #211e2b 0%, #2a2437 100%);
  border-color: #a78ad8;
}

body.phase-night .card.type-neutral {
  background: linear-gradient(180deg, #202420 0%, #2a2f2a 100%);
  border-color: #8f988f;
}

body.phase-night .obj-market-card,
body.phase-night .obj-active,
body.phase-night .preview-card-inner.preview-objetivo {
  background: linear-gradient(135deg, #2b2d1c 0%, #34351f 100%);
  border-color: #a99c55;
}

body.phase-night .obj-completed {
  background: #15271b;
  border-color: #579869;
}

body.phase-night .obj-pp-chip,
body.phase-night .preview-pp,
body.phase-night .phase-badge,
body.phase-night .wizard-confirm-summary {
  background: #263b2f;
  border-color: var(--line);
}

body.phase-night .phase-produce .phase-badge {
  background: #214232;
  color: #c6f0d0;
}

body.phase-night .action-filter-btn,
body.phase-night .action-btn,
body.phase-night .restart-btn {
  background: #202720;
  border-color: #4b574b;
  color: var(--ink);
}

body.phase-night .action-filter-btn:hover,
body.phase-night .action-btn:hover,
body.phase-night .restart-btn:hover {
  background: #293329;
}

body.phase-night .action-filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #171914;
}

@media (max-width: 1080px) {
  .info-strip {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }
}

@media (max-width: 760px) {
  .info-strip {
    grid-template-columns: 1fr;
  }

  .command-subpanel {
    grid-column: span 1;
  }
}

/* ============================================================
   v2 Redesign — topbar badges, market-strip, rivals, tu-panel,
   debug drawer, end-game modal, turn highlighting
   ============================================================ */

/* Topbar layout */
.topbar-row {
  align-items: center;
}

.topbar-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  flex: 1 1 auto;
  justify-content: center;
}

.topbar-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

/* Status badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  letter-spacing: 0.01em;
}

.status-badge-round {
  background: #f3ecdb;
  color: #4a4235;
  border-color: #d6cbb6;
}

.status-badge-turn {
  gap: 8px;
  min-width: max-content;
  white-space: nowrap;
  background: #fff;
}

.status-badge-turn::before {
  content: "";
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  border-radius: 50%;
  background: var(--turn-color, var(--accent));
  box-shadow: 0 0 0 1px rgba(0,0,0,0.08);
}

.status-badge-leader {
  background: #fff8d8;
  color: #5a4a00;
  border-color: #e4cc6a;
}

.ghost-btn {
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink);
  transition: background 0.12s, border-color 0.12s;
}

.ghost-btn:hover {
  background: #f7f1e6;
  border-color: #c2b594;
}

.ghost-btn[aria-expanded="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.status-line-compact {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

/* Market strip — compact horizontal strip above the board */
.market-strip {
  display: grid;
  grid-template-columns: minmax(120px, auto) minmax(0, 1fr) minmax(0, 1.3fr);
  gap: 12px;
  padding: 12px 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 1px 0 #fff inset;
}

.market-strip-item {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.market-strip-item h3 {
  margin: 0 0 6px 0;
  font-size: 0.74rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}

.market-strip .deck-box-compact {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: #fff;
  border: 1px solid #e7dccb;
  border-radius: 8px;
}

.market-strip .deck-box-compact .deck-meta {
  font-size: 1.3rem;
  line-height: 1;
}

.market-strip .discard {
  margin: 0;
  padding: 0;
  max-height: 120px;
  overflow-y: auto;
}

/* Rivals section below the board */
.rivals-section {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: 0 1px 0 #fff inset;
}

.rivals-section[hidden] {
  display: none;
}

.rivals-head {
  margin: 0 0 8px 0;
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.rivals {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.rival-card {
  position: relative;
  border: 1px solid #dfd3bf;
  border-left: 4px solid var(--rival-color, #888);
  border-radius: 9px;
  background: #fffdf8;
  padding: 8px 10px;
  display: grid;
  gap: 6px;
  font-size: 0.85rem;
  transition: box-shadow 0.2s, border-color 0.2s;
}

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

.rival-name {
  font-weight: 700;
  letter-spacing: 0.01em;
}

.rival-score {
  font-weight: 800;
  font-size: 0.95rem;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #20433f;
}

.rival-badges {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 0.7rem;
}

.rival-res {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  font-size: 0.76rem;
  align-items: center;
}

.rival-res-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  background: #f3ecdb;
  border-radius: 5px;
  font-weight: 700;
  color: #4a4235;
}

.rival-res-chip img {
  width: 14px;
  height: 14px;
}

.rival-meta {
  font-size: 0.74rem;
  color: var(--muted);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.rival-obj-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.rival-obj-chip {
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: 999px;
  background: #eee5ce;
  color: #524632;
  border: 1px solid #d6cbb6;
  cursor: help;
}

.rival-obj-chip.completed {
  background: #d8efd3;
  color: #234a23;
  border-color: #a8c99a;
  font-weight: 700;
}

.rival-obj-prog {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-left: 2px;
  opacity: 0.85;
}

.rival-obj-card {
  font-style: italic;
  margin-left: 2px;
  opacity: 0.9;
}

.rival-meeples {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  font-size: 0.7rem;
}

.rival-meeple {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  max-width: 100%;
  padding: 2px 6px;
  background: #eee7d3;
  border-radius: 4px;
  color: #534928;
  font-family: monospace;
}

.rival-meeple span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rival-passed .rival-name::after {
  content: " · pasó";
  color: var(--muted);
  font-weight: 500;
  font-size: 0.78rem;
}

/* Tu-panel (right column) */
.tu-panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  display: grid;
  gap: 10px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05), 0 1px 0 #fff inset;
  max-height: calc(100vh - 28px);
  overflow-y: auto;
}

.tu-head {
  display: grid;
  gap: 4px;
}

.tu-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

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

.tu-panel .player {
  padding: 10px 11px;
}

/* Action panel: inline variant (inside tu-panel instead of sticky top) */
.action-panel-inline {
  position: static;
  z-index: auto;
  padding: 10px 12px;
  border: 2px solid #c9a84c;
  border-radius: 9px;
  box-shadow: 0 1px 4px rgba(201, 168, 76, 0.18);
}

.action-panel-inline .action-list {
  grid-template-columns: 1fr;
  max-height: 340px;
}

/* Rivals row condensed — lay out for 1-2 bots */
.phase-summary-inline {
  margin-top: 0;
}

.phase-summary-inline .phase-summary-feed {
  max-height: 170px;
}

/* Current turn highlight */
.player.is-current-turn,
.rival-card.is-current-turn {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent), 0 0 14px rgba(48, 95, 90, 0.35);
  animation: turn-pulse 2.4s ease-in-out infinite;
}

@keyframes turn-pulse {
  0%, 100% {
    box-shadow: 0 0 0 2px var(--accent), 0 0 10px rgba(48, 95, 90, 0.30);
  }
  50% {
    box-shadow: 0 0 0 2px var(--accent), 0 0 22px rgba(48, 95, 90, 0.65);
  }
}

.rival-card.is-thinking {
  position: relative;
}

.rival-card.is-thinking::before {
  content: "pensando…";
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 0.7rem;
  color: var(--accent);
  font-style: italic;
  letter-spacing: 0.02em;
  animation: thinking-blink 1.4s ease-in-out infinite;
}

@keyframes thinking-blink {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

/* Debug drawer */
.debug-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(520px, 92vw);
  height: 100vh;
  background: #fffdf8;
  border-left: 2px solid var(--line);
  padding: 48px 16px 20px;
  overflow-y: auto;
  z-index: 200;
  box-shadow: -4px 0 16px rgba(0,0,0,0.12);
  display: grid;
  gap: 14px;
  align-content: start;
}

.debug-drawer[hidden] {
  display: none;
}

.debug-drawer h3 {
  margin: 0 0 6px 0;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-transform: uppercase;
  font-weight: 700;
}

.debug-meta {
  display: grid;
  gap: 4px;
  font-size: 0.86rem;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.debug-meta strong {
  color: var(--muted);
  font-weight: 600;
}

.debug-commands .command-feed {
  max-height: calc(100vh - 230px);
}

.debug-close {
  position: absolute;
  top: 10px;
  right: 12px;
  padding: 4px 10px;
  font-size: 0.9rem;
}

/* End-game modal */
.end-game-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.end-game-modal[hidden] {
  display: none;
}

.end-game-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 10, 0.55);
  backdrop-filter: blur(3px);
}

.end-game-dialog {
  position: relative;
  background: var(--paper);
  border: 2px solid var(--accent);
  border-radius: 14px;
  padding: 28px 32px 24px;
  max-width: 620px;
  width: 92vw;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 14px 50px rgba(0,0,0,0.4);
}

.end-game-dialog h2 {
  margin: 0 0 16px 0;
  font-size: 1.6rem;
  text-align: center;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.end-game-winner {
  text-align: center;
  font-size: 1.25rem;
  margin-bottom: 20px;
  padding: 14px 18px;
  background: #fff8d8;
  border: 2px solid #e4cc6a;
  border-radius: 10px;
  font-weight: 800;
  color: #5a4a00;
  line-height: 1.35;
}

.end-game-winner .winner-sub {
  display: block;
  font-weight: 500;
  font-size: 0.9rem;
  color: #7a6420;
  margin-top: 4px;
  font-style: italic;
}

.end-game-ranking {
  display: grid;
  gap: 8px;
  margin-bottom: 22px;
}

.end-game-row {
  display: grid;
  grid-template-columns: 32px 1fr auto auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.end-game-row.is-winner {
  background: #fff8d8;
  border-color: #e4cc6a;
  box-shadow: 0 0 0 1px #e4cc6a;
}

.end-game-rank {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--muted);
  text-align: center;
}

.end-game-name {
  font-weight: 700;
  color: var(--ink);
}

.end-game-pp {
  font-size: 0.78rem;
  padding: 3px 9px;
  border-radius: 999px;
  background: #f3ecdb;
  font-weight: 700;
  color: #4a4235;
  white-space: nowrap;
}

.end-game-pp-obj {
  background: #f3edf9;
  color: #4a3a6a;
}

.end-game-pp-total {
  font-size: 1.05rem;
  font-weight: 800;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}

.end-game-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Responsive for v2 */
@media (max-width: 1080px) {
  .layout-v2 {
    grid-template-columns: 1fr;
  }
  .right-col {
    position: static;
  }
  .tu-panel {
    max-height: none;
  }
  .market-strip {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .market-strip {
    grid-template-columns: 1fr;
  }
  .topbar-badges {
    justify-content: flex-start;
  }
}

/* Night theme adjustments for new surfaces */
body.phase-night .market-strip,
body.phase-night .rivals-section,
body.phase-night .tu-panel,
body.phase-night .debug-drawer,
body.phase-night .end-game-dialog {
  background: #1e2420;
  color: #e8dfc8;
  border-color: #4b574b;
}

body.phase-night .rival-card,
body.phase-night .market-strip .deck-box-compact,
body.phase-night .debug-meta,
body.phase-night .end-game-row {
  background: #262d28;
  border-color: #4b574b;
  color: #e8dfc8;
}

body.phase-night .end-game-row.is-winner,
body.phase-night .end-game-winner {
  background: #3a341c;
  color: #f1e6aa;
  border-color: #9d8a46;
}

body.phase-night .rival-obj-chip {
  background: #2d332d;
  color: #c9c1a6;
  border-color: #4b574b;
}

body.phase-night .rival-obj-chip.completed {
  background: #254425;
  color: #c6f0d0;
  border-color: #5a8a5a;
}

body.phase-night .rival-res-chip,
body.phase-night .rival-meeple {
  background: #2d332d;
  color: #d9cfac;
}

body.phase-night .rival-score {
  background: #2d3d3a;
  color: #c8e8e3;
}

body.phase-night .status-badge {
  background: #2b3229;
  color: #e8dfc8;
  border-color: #4b574b;
}

body.phase-night .status-badge-round {
  background: #2e3228;
  color: #d4c9a6;
}

body.phase-night .status-badge-leader {
  background: #3a341c;
  color: #f1e6aa;
  border-color: #9d8a46;
}

body.phase-night .ghost-btn {
  background: #2b3229;
  border-color: #4b574b;
  color: #e8dfc8;
}

body.phase-night .ghost-btn:hover {
  background: #343c32;
}

body.phase-night .end-game-backdrop {
  background: rgba(0, 0, 0, 0.75);
}

body.phase-night .end-game-pp {
  background: #2d332d;
  color: #d4c9a6;
}

body.phase-night .end-game-pp-obj {
  background: #2b2837;
  color: #c9b8e0;
}

body.phase-night .end-game-pp-total {
  background: #2d3d3a;
  color: #c8e8e3;
}

body.phase-night .market-strip-item h3,
body.phase-night .rivals-head {
  color: #a9a58f;
}
