:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #05070d;
  color: #f4ead6;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 66% 48%, rgba(194, 138, 76, 0.32) 0 18%, transparent 38%),
    radial-gradient(circle at 78% 16%, rgba(84, 129, 136, 0.22), transparent 23%),
    linear-gradient(135deg, #05070d 0%, #0a1018 45%, #140d10 100%);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.loading-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  color: #f2d28b;
  background: #05070d;
}

.loading-screen.failed {
  align-content: center;
  gap: 10px;
  text-align: center;
}

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: 236px minmax(620px, 1fr) 450px;
  grid-template-rows: 58px minmax(0, 1fr) 226px;
  gap: 10px;
  padding: 10px;
}

.topbar {
  grid-column: 2 / 4;
  grid-row: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 12px;
  border: 1px solid rgba(235, 190, 105, 0.32);
  background: rgba(8, 11, 17, 0.78);
  backdrop-filter: blur(12px);
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1;
  letter-spacing: 0;
}

.eyebrow,
.player-kicker,
.section-title {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 10px;
  color: #d8b35e;
}

.status-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}

.status-strip span,
.chip {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.07);
  padding: 5px 8px;
  white-space: nowrap;
}

.status-strip .reveal-status {
  border-color: rgba(242, 210, 139, 0.55);
  background: rgba(242, 210, 139, 0.13);
  color: #f4dc7c;
  font-weight: 800;
}

.toggle-setting {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(54, 163, 255, 0.42);
  background: rgba(54, 163, 255, 0.1);
  padding: 5px 8px;
  white-space: nowrap;
  cursor: pointer;
  color: #bfe4ff;
  font-size: 12px;
}

.toggle-setting input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: #36a3ff;
}

.status-strip .toggle-setting span {
  border: 0;
  background: transparent;
  padding: 0;
}

.toggle-setting b {
  min-width: 20px;
  text-align: center;
  color: #f2d28b;
}

.toggle-setting:has(input:disabled),
.toggle-settings-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.toggle-settings-button {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(54, 163, 255, 0.42);
  background: rgba(54, 163, 255, 0.1);
  color: #bfe4ff;
  cursor: pointer;
}

.icon-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(216, 179, 94, 0.6);
  background: rgba(216, 179, 94, 0.12);
  cursor: pointer;
}

.player-rail,
.board-panel,
.side-panel,
.action-dock {
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: rgba(8, 11, 17, 0.72);
  backdrop-filter: blur(10px);
  min-width: 0;
  min-height: 0;
}

.player-rail {
  grid-column: 1;
  grid-row: 1 / 4;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  overflow: auto;
}

.player-panel {
  border-left: 4px solid var(--player-color);
  background: linear-gradient(90deg, color-mix(in srgb, var(--player-color) 18%, transparent), rgba(255, 255, 255, 0.04));
  padding: 8px;
}

.player-panel.active {
  outline: 2px solid color-mix(in srgb, var(--player-color) 72%, white);
}

.leader-row {
  display: flex;
  gap: 8px;
  min-width: 0;
}

.leader-portrait {
  width: 58px;
  height: 78px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: #111820;
  flex: 0 0 auto;
}

.leader-meta {
  min-width: 0;
}

.leader-meta h2 {
  margin: 2px 0 6px;
  font-size: 13px;
  line-height: 1.15;
  letter-spacing: 0;
}

.vp-line strong {
  font-size: 22px;
  color: #f2d28b;
}

.vp-line {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  cursor: help;
  outline: none;
}

.vp-line:focus-visible {
  box-shadow: 0 0 0 2px rgba(242, 210, 139, 0.45);
}

.vp-tooltip-panel {
  position: absolute;
  left: 50%;
  top: calc(100% + 7px);
  z-index: 30;
  width: max-content;
  min-width: 180px;
  max-width: 214px;
  padding: 8px;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -3px);
  transition: opacity 120ms ease, transform 120ms ease;
  border: 1px solid rgba(242, 210, 139, 0.42);
  background: rgba(10, 14, 20, 0.98);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

.vp-line:hover .vp-tooltip-panel,
.vp-line:focus-visible .vp-tooltip-panel {
  opacity: 1;
  transform: translate(-50%, 0);
}

.vp-tooltip-title {
  display: block;
  margin-bottom: 6px;
  color: #f2d28b;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.vp-tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
  line-height: 1.35;
  color: #f4ead6;
}

.vp-tooltip-row b {
  color: #fff;
  font-weight: 700;
  white-space: nowrap;
}

.vp-tooltip-empty {
  display: block;
  color: #d5d8d6;
  font-size: 11px;
}

.leader-status {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.leader-status span {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.07);
  padding: 3px 5px;
  color: #d5d8d6;
  font-size: 10px;
  line-height: 1;
  white-space: nowrap;
}

.leader-status .owned {
  border-color: rgba(242, 210, 139, 0.42);
  background: rgba(242, 210, 139, 0.13);
  color: #f4dc7c;
}

.leader-status .missing {
  color: #aeb5b7;
}

.resource-row,
.troop-line,
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.res {
  font-size: 11px;
  padding: 3px 5px;
  background: rgba(255, 255, 255, 0.08);
}

.water { color: #8fd3ff; }
.spice { color: #ffb45f; }
.solari { color: #f4dc7c; }
.intrigue { color: #caa7ff; }

.influence-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin-top: 8px;
}

.influence {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  font-size: 10px;
  padding: 4px 5px;
  background: rgba(255, 255, 255, 0.06);
}

.influence b {
  color: #fff;
}

.troop-line {
  color: #d5d8d6;
  font-size: 10px;
}

.board-panel {
  grid-column: 2;
  grid-row: 2;
  padding: 8px;
}

.board-map {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 520px;
  overflow: hidden;
  background:
    radial-gradient(circle at 66% 63%, rgba(207, 148, 86, 0.5) 0 18%, rgba(139, 88, 54, 0.45) 34%, transparent 51%),
    radial-gradient(circle at 42% 21%, rgba(33, 93, 88, 0.4), transparent 35%),
    #070b11;
}

.board-map::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle, rgba(255,255,255,0.9) 0 1px, transparent 1.2px),
    radial-gradient(circle, rgba(255,255,255,0.35) 0 1px, transparent 1.2px);
  background-size: 91px 91px, 137px 137px;
  opacity: 0.28;
}

.planet {
  position: absolute;
  right: -7%;
  bottom: -34%;
  width: 74%;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 42% 35%, rgba(238, 189, 122, 0.95), rgba(143, 82, 50, 0.72) 42%, rgba(68, 42, 34, 0.35) 68%, transparent 70%),
    repeating-radial-gradient(circle at 38% 34%, rgba(255,255,255,0.1) 0 2px, transparent 3px 10px);
  filter: saturate(0.82);
}

.space-tile {
  position: absolute;
  z-index: 2;
  display: block;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(10, 14, 20, 0.9);
  cursor: pointer;
  text-align: left;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.33);
}

.space-tile.legal {
  border-color: #f2d28b;
  box-shadow: 0 0 0 2px rgba(242, 210, 139, 0.28), 0 8px 18px rgba(0, 0, 0, 0.33);
}

.space-tile.unreachable {
  opacity: 0.24;
  filter: grayscale(0.9) brightness(0.55);
  cursor: not-allowed;
  box-shadow: none;
}

.space-tile.unreachable .space-art {
  opacity: 0.36;
}

.space-tile.selected {
  border-color: #7ee7cb;
  box-shadow: 0 0 0 3px rgba(126, 231, 203, 0.35);
}

.space-art {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.68;
}

.space-name {
  position: absolute;
  left: 6px;
  right: 6px;
  top: 5px;
  font-size: 11px;
  line-height: 1.05;
  font-weight: 800;
  text-shadow: 0 1px 4px #000;
}

.space-tags {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 5px;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.space-tags b {
  font-size: 9px;
  padding: 2px 4px;
  background: rgba(0, 0, 0, 0.62);
  color: #f2d28b;
}

.agents {
  position: absolute;
  right: 5px;
  top: 5px;
  display: flex;
  gap: 3px;
}

.agents i,
.combat-marker::before {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--player-color);
  border: 1px solid #fff;
}

.control {
  position: absolute;
  right: 5px;
  bottom: 5px;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  background: var(--player-color);
  color: #05070d;
  font-size: 10px;
  font-weight: 900;
}

.conflict-track {
  position: absolute;
  z-index: 3;
  left: 39%;
  top: 21%;
  width: 27%;
  min-height: 132px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 74px;
  gap: 8px;
  align-items: start;
  padding: 7px;
  border: 1px solid rgba(195, 62, 62, 0.55);
  background: rgba(70, 24, 24, 0.74);
  pointer-events: none;
}

.track-title {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  font-size: 11px;
  text-transform: uppercase;
  color: #f0c06b;
  margin-bottom: 6px;
}

.track-title b {
  color: #f4ead6;
}

.board-conflict-card {
  width: 74px;
  min-height: 104px;
}

.board-conflict-card .card-art {
  height: 104px;
  aspect-ratio: auto;
}

.board-conflict-card .card-caption {
  padding: 4px;
  font-size: 8px;
}

.board-conflict-card .card-caption b {
  width: 16px;
  height: 16px;
  font-size: 9px;
}

.combat-marker {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  margin: 3px 0;
}

.combat-marker::before {
  content: "";
  display: inline-block;
}

.combat-marker b {
  margin-left: auto;
}

.side-panel {
  grid-column: 3;
  grid-row: 2;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 8px;
  padding: 8px;
  overflow: hidden;
}

.side-panel section {
  min-height: 0;
  overflow: hidden;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}

.section-title b {
  color: #f4ead6;
}

.section-title em {
  margin-left: auto;
  color: #f4dc7c;
  font-style: normal;
  font-weight: 800;
  white-space: nowrap;
}

.small-card {
  position: relative;
  overflow: hidden;
  background: #12151b;
  border: 1px solid rgba(255, 255, 255, 0.16);
  min-height: 80px;
}

.card-art {
  display: block;
  width: 100%;
  aspect-ratio: 5 / 7;
  object-fit: cover;
}

.card-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  padding: 5px 6px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.82) 18%);
  font-size: 10px;
  line-height: 1.1;
  text-shadow: 0 1px 3px #000;
}

.card-caption b {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  color: #080b11;
  background: #f2d28b;
  flex: 0 0 auto;
}

.market-zone {
  flex: 0 0 auto;
}

.market-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(80px, 1fr));
  gap: 8px;
}

.market-row .small-card {
  min-height: 124px;
}

.market-row .card-caption {
  font-size: 9px;
}

.reserve-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.reserve-row .small-card {
  min-height: 0;
}

.reserve-row .card-art {
  height: clamp(88px, 15vh, 132px);
  aspect-ratio: auto;
}

.reserve-card {
  position: relative;
}

.reserve-card > span {
  position: absolute;
  right: 4px;
  top: 4px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #f2d28b;
  color: #05070d;
  font-weight: 900;
}

.log-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.log-list {
  min-height: 0;
  overflow: auto;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 5px;
}

.log-entry {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 6px;
  padding: 5px;
  background: rgba(255, 255, 255, 0.055);
  font-size: 11px;
}

.log-entry span {
  color: #f2d28b;
}

.log-entry p {
  margin: 0;
  line-height: 1.25;
}

.action-dock {
  grid-column: 2 / 4;
  grid-row: 3;
  display: grid;
  grid-template-columns: minmax(600px, 55%) 1fr;
  gap: 10px;
  padding: 8px;
}

.hand-zone,
.actions-zone {
  min-width: 0;
  min-height: 0;
}

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

.hand-column,
.intrigue-column {
  min-width: 0;
  min-height: 0;
}

.hand-row {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.hand-card,
.intrigue-card {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  flex: 0 0 auto;
}

.hand-card {
  width: 108px;
}

.intrigue-row {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.intrigue-card {
  width: 88px;
}

.hand-card.selected .small-card,
.intrigue-card.selected .small-card {
  border-color: #7ee7cb;
  box-shadow: 0 0 0 2px rgba(126, 231, 203, 0.34);
}

.hand-art-card .card-art {
  height: 152px;
}

.intrigue-art-card .card-art {
  height: 124px;
}

.no-intrigue {
  width: 100%;
  min-height: 124px;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(202, 167, 255, 0.42);
  color: #caa7ff;
  background: rgba(202, 167, 255, 0.055);
  font-size: 12px;
  text-align: center;
}

.action-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

#action-search {
  width: 190px;
  height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.35);
  color: #f4ead6;
  padding: 0 9px;
}

.chip {
  cursor: pointer;
  font-size: 11px;
}

.actions-list {
  height: calc(100% - 50px);
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  align-content: start;
}

.action-button {
  position: relative;
  min-height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.07);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
  padding: 7px 9px;
  text-align: left;
  cursor: pointer;
}

.action-button:hover {
  border-color: #f2d28b;
  background: rgba(242, 210, 139, 0.12);
}

.action-button.recommended {
  border-color: #36a3ff;
  background: rgba(54, 163, 255, 0.22);
  box-shadow:
    inset 0 0 0 1px rgba(191, 228, 255, 0.22),
    0 0 18px rgba(54, 163, 255, 0.18);
}

.action-button.recommended:hover {
  border-color: #8fd3ff;
  background: rgba(54, 163, 255, 0.3);
}

.action-button span {
  font-size: 12px;
  font-weight: 800;
  line-height: 1.1;
}

.action-button .action-label {
  padding-right: 88px;
}

.recommendation-badge {
  position: absolute;
  top: 5px;
  right: 6px;
  white-space: nowrap;
  padding: 2px 5px;
  border: 1px solid rgba(191, 228, 255, 0.52);
  background: rgba(4, 21, 35, 0.82);
  color: #bfe4ff;
  font-size: 9px;
  line-height: 1;
}

.action-button small {
  color: #d4c3a6;
  font-size: 10px;
  line-height: 1.15;
}

.no-actions {
  padding: 14px;
  color: #d4c3a6;
}

.image-fallback {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-height: 70px;
  color: #f2d28b;
  background: linear-gradient(135deg, #161b23, #352a23);
  font-weight: 900;
}

.error-banner {
  position: fixed;
  left: 50%;
  top: 14px;
  transform: translateX(-50%);
  z-index: 99;
  max-width: 640px;
  padding: 10px 14px;
  background: #6d1f2b;
  border: 1px solid #ff9c9c;
}

.busy .action-button,
.busy .icon-button {
  opacity: 0.58;
  pointer-events: none;
}

@media (max-width: 1100px) {
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 620px auto auto;
  }

  .player-rail,
  .topbar,
  .board-panel,
  .side-panel,
  .action-dock {
    grid-column: 1;
    grid-row: auto;
  }

  .player-rail {
    flex-direction: row;
  }

  .player-panel {
    min-width: 220px;
  }

  .side-panel {
    max-height: none;
  }

  .action-dock {
    grid-template-columns: 1fr;
  }
}
