:root {
  --bg: #08101f;
  --bg-2: #0d1630;
  --panel: rgba(255, 255, 255, 0.055);
  --panel-2: rgba(255, 255, 255, 0.075);
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.16);

  --text: #eef4ff;
  --muted: #98a6c3;
  --muted-2: #7f8cad;

  --primary: #7c6cff;
  --primary-2: #5f8bff;

  --good: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;

  --set0: rgba(90, 200, 250, 0.28);
  --set1: rgba(255, 184, 77, 0.28);
  --set2: rgba(167, 139, 250, 0.28);

  --shadow: 0 18px 42px rgba(0, 0, 0, 0.28);
  --shadow-soft: 0 12px 28px rgba(0, 0, 0, 0.18);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(95, 139, 255, 0.12), transparent 28%),
    radial-gradient(circle at top right, rgba(124, 108, 255, 0.12), transparent 24%),
    linear-gradient(180deg, var(--bg), #070c16);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
}

img {
  display: block;
  max-width: 100%;
}

button,
input,
textarea,
a {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.shell {
  width: min(100%, 1460px);
  margin: 0 auto;
  padding: 16px;
}

.host-shell {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.topbar h1 {
  margin: 6px 0 0;
  font-size: 2rem;
  line-height: 1.08;
  letter-spacing: -0.02em;
}

.eyebrow {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.status-row,
.meta-row,
.btn-row,
.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.status-row {
  justify-content: flex-end;
}

.top-actions {
  margin-right: 4px;
}

.pill,
.mini-pill,
.badge {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  border-radius: 999px;
  backdrop-filter: blur(10px);
}

.pill {
  padding: 9px 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.94rem;
  font-weight: 600;
  box-shadow: var(--shadow-soft);
}

.mini-pill {
  padding: 7px 11px;
  font-size: 0.82rem;
  font-weight: 600;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  font-size: 0.74rem;
  font-weight: 800;
}

.badge.good {
  background: rgba(34, 197, 94, 0.14);
  border-color: rgba(34, 197, 94, 0.32);
  color: #baf6c9;
}

.badge.warn {
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.32);
  color: #ffe1ab;
}

.badge.bad {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.32);
  color: #ffc2c2;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #5f6f8d;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.045);
}

.dot.good {
  background: var(--good);
}

.dot.bad {
  background: var(--danger);
}

.host-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.24fr) minmax(320px, 380px);
  gap: 14px;
  align-items: start;
}

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

.panel {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.028));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  backdrop-filter: blur(12px);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head h2,
.panel-head h3 {
  margin: 4px 0 0;
  line-height: 1.15;
}

.panel-head h2 {
  font-size: 1.12rem;
}

.panel-head h3 {
  font-size: 1rem;
}

.host-main {
  min-width: 0;
}

.host-side {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  padding-right: 4px;
}

.host-side::-webkit-scrollbar {
  width: 8px;
}

.host-side::-webkit-scrollbar-track {
  background: transparent;
}

.host-side::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}

.side-panel {
  min-width: 0;
}

.room-card,
.info-card,
.link-card,
.item,
.chat-item {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.035);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}

.room-card,
.info-card,
.link-card {
  padding: 13px;
}

.room-panel-grid {
  display: grid;
  grid-template-columns: 180px 150px minmax(0, 1fr) 190px;
  gap: 12px;
  align-items: stretch;
}

.room-card {
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.room-label {
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 10px;
}

.room-code {
  font-size: 1.7rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.room-sub {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

.qr-wrap {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 10px;
}

.qr-box {
  width: 128px;
  min-height: 128px;
  display: grid;
  place-items: center;
  padding: 8px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.045);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}

.qr-box img {
  border-radius: 10px;
}

.qr-sub {
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
  line-height: 1.4;
}

.links-stack {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.link-label {
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 8px;
}

.join-link {
  width: 100%;
  font-size: 0.8rem;
  color: var(--text);
  word-break: break-all;
  line-height: 1.45;
  padding: 10px 11px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 10px;
}

.room-actions {
  display: flex;
  align-items: center;
}

.room-actions .btn-row {
  width: 100%;
  flex-direction: column;
}

.room-actions .btn {
  width: 100%;
}

.btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border-radius: 14px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.94rem;
  font-weight: 800;
  transition:
    transform 0.18s ease,
    background 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    opacity 0.18s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255,255,255,0.18);
}

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

.btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  border-color: transparent;
  box-shadow: 0 12px 26px rgba(103, 104, 255, 0.25);
}

.btn.primary:hover:not(:disabled) {
  box-shadow: 0 16px 30px rgba(103, 104, 255, 0.32);
}

.btn.ghost {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.04);
}

.btn.ghost span:first-child {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn.ghost img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.stack-list,
.chat-list {
  display: grid;
  gap: 10px;
}

.item,
.chat-item {
  padding: 11px;
  transition: 0.18s ease;
}

.item.turn {
  border-color: rgba(124, 108, 255, 0.55);
  box-shadow:
    0 0 0 1px rgba(124, 108, 255, 0.24) inset,
    0 10px 24px rgba(124, 108, 255, 0.1);
}

.item.disconnected {
  border-color: rgba(245, 158, 11, 0.35);
}

.item.bot {
  border-color: rgba(95, 139, 255, 0.34);
}

.chat-top,
.item-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.chat-name,
.item-title {
  font-size: 0.94rem;
  font-weight: 800;
}

.chat-meta,
.item-sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.chat-body {
  margin-top: 8px;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text);
  word-break: break-word;
}

.player-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  opacity: 0.92;
}

.empty {
  border: 1px dashed var(--line);
  color: var(--muted);
  border-radius: 16px;
  padding: 15px;
  text-align: center;
  background: rgba(255,255,255,0.018);
}

/* BOARD */
.board-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.legend-swatch.set0 { background: var(--set0); }
.legend-swatch.set1 { background: var(--set1); }
.legend-swatch.set2 { background: var(--set2); }

.legend-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.legend-icon img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

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

.tile {
  position: relative;
  min-height: 124px;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.025));
  padding: 11px;
  overflow: hidden;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    border-color 0.2s ease,
    background 0.2s ease;
}

.tile::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,0.04), transparent 48%);
}

.tile.start {
  border-color: rgba(34, 197, 94, 0.34);
}

.tile.event {
  border-color: rgba(245, 158, 11, 0.34);
}

.tile.tax {
  border-color: rgba(239, 68, 68, 0.34);
}

.tile.set-0 {
  box-shadow: inset 0 0 0 1px var(--set0);
}

.tile.set-1 {
  box-shadow: inset 0 0 0 1px var(--set1);
}

.tile.set-2 {
  box-shadow: inset 0 0 0 1px var(--set2);
}

.tile.current {
  box-shadow:
    0 0 0 2px rgba(124, 108, 255, 0.34) inset,
    0 10px 24px rgba(124, 108, 255, 0.08);
}

.tile.buyable {
  box-shadow:
    0 0 0 2px rgba(34, 197, 94, 0.34) inset,
    0 10px 24px rgba(34, 197, 94, 0.08);
}

.tile.trail {
  background: rgba(124, 108, 255, 0.08);
}

.tile.step-active {
  transform: scale(1.02);
  box-shadow:
    0 0 0 2px rgba(124, 108, 255, 0.45) inset,
    0 10px 25px rgba(124, 108, 255, 0.14);
}

.tile.resolve-event {
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.45) inset;
}

.tile.resolve-tax {
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.45) inset;
}

.tile.resolve-buy {
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.45) inset;
}

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

.tile-name {
  font-size: 0.98rem;
  font-weight: 900;
  line-height: 1.15;
}

.tile-index,
.tile-type {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.tile-type-wrap {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: flex-end;
}

.tile-set-badge {
  font-size: 0.68rem;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-weight: 700;
}

.tile-set-badge.set-0 {
  background: rgba(90, 200, 250, 0.08);
  border-color: rgba(90, 200, 250, 0.3);
}

.tile-set-badge.set-1 {
  background: rgba(255, 184, 77, 0.08);
  border-color: rgba(255, 184, 77, 0.3);
}

.tile-set-badge.set-2 {
  background: rgba(167, 139, 250, 0.08);
  border-color: rgba(167, 139, 250, 0.3);
}

.tile-desc {
  margin-top: 8px;
  font-size: 0.77rem;
  color: var(--muted);
  line-height: 1.38;
}

.tile-buildings {
  margin-top: 9px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.building-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 700;
}

.building-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
  display: block;
}

.tile-players {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.token {
  width: 29px;
  height: 29px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.08);
  font-size: 0.9rem;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}

/* TOAST */
.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%) translateY(12px);
  background: rgba(7, 10, 20, 0.92);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 0.92rem;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
  z-index: 70;
  max-width: calc(100vw - 32px);
  text-align: center;
  box-shadow: var(--shadow-soft);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* FX */
.fx-layer {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: min(360px, calc(100vw - 24px));
  display: grid;
  justify-items: stretch;
  gap: 10px;
  z-index: 60;
  pointer-events: none;
}

.event-feed {
  display: none;
  gap: 8px;
  max-height: min(42vh, 380px);
  overflow-y: auto;
  pointer-events: auto;
  padding-right: 2px;
}

.event-feed::-webkit-scrollbar {
  width: 6px;
}

.event-feed::-webkit-scrollbar-track {
  background: transparent;
}

.event-feed::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
}

.feed-empty,
.feed-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(20, 27, 50, 0.95), rgba(10, 15, 29, 0.95));
  box-shadow: var(--shadow-soft);
  padding: 10px 12px;
}

.feed-empty {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
  text-align: center;
}

.feed-item.info {
  border-color: rgba(124, 108, 255, 0.28);
}

.feed-item.log {
  border-color: rgba(255, 255, 255, 0.16);
}

.feed-item.event {
  border-color: rgba(245, 158, 11, 0.3);
}

.feed-item.dice {
  border-color: rgba(90, 200, 250, 0.3);
}

.feed-item.system {
  border-color: rgba(34, 197, 94, 0.34);
}

.feed-meta {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 4px;
  letter-spacing: 0.03em;
}

.feed-text {
  font-size: 0.84rem;
  line-height: 1.4;
  color: var(--text);
}

.dice-overlay {
  position: static;
  display: none;
  width: 100%;
}

.dice-overlay.show {
  display: block;
}

.event-overlay {
  position: static;
  display: none;
  width: 100%;
  pointer-events: none;
}

.event-overlay.show {
  display: block;
  pointer-events: auto;
}

.dice-card,
.event-card {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(20, 27, 50, 0.96), rgba(12, 18, 35, 0.96));
  box-shadow: var(--shadow-soft);
  padding: 14px 15px;
  text-align: left;
  pointer-events: auto;
}

.dice-label,
.event-kicker {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
}

.dice-value {
  font-size: 2.2rem;
  line-height: 1;
  font-weight: 900;
  margin: 8px 0 4px;
}

.dice-sub,
.event-body {
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.86rem;
}

.event-title {
  margin-top: 6px;
  font-size: 1rem;
  font-weight: 900;
  line-height: 1.2;
}

.event-card {
  transform: translateY(6px);
  opacity: 0.96;
  transition:
    transform 0.24s ease,
    opacity 0.24s ease;
}

.event-overlay.show .event-card {
  transform: translateY(0);
  opacity: 1;
}

.event-card .btn {
  margin-top: 10px;
  width: 100%;
}

/* DESKTOP COMPACT MODE
   Applied for shorter desktop viewports (typical 100% zoom on 1080p-like screens). */
@media (min-width: 1200px) and (max-height: 980px) {
  html {
    font-size: 15px;
  }

  .shell {
    width: min(100%, 1540px);
    padding: 12px;
  }

  .host-shell,
  .host-main-col,
  .host-side {
    gap: 10px;
  }

  .topbar h1 {
    font-size: 1.75rem;
  }

  .top-actions {
    gap: 8px;
  }

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

  .host-side {
    max-height: calc(100vh - 96px);
  }

  .panel {
    padding: 12px;
    border-radius: 16px;
  }

  .panel-head {
    margin-bottom: 10px;
  }

  .panel-head h2 {
    font-size: 1.04rem;
  }

  .panel-head h3 {
    font-size: 0.96rem;
  }

  .btn {
    padding: 8px 12px;
    font-size: 0.9rem;
  }

  .btn.ghost {
    padding: 8px 11px;
  }

  .pill {
    padding: 8px 12px;
    font-size: 0.88rem;
  }

  .mini-pill {
    padding: 6px 10px;
    font-size: 0.78rem;
  }

  .board-legend {
    margin-bottom: 10px;
  }

  .legend-item {
    padding: 6px 9px;
    font-size: 0.76rem;
  }

  .board-grid {
    gap: 10px;
  }

  .tile {
    min-height: 108px;
    padding: 9px;
    border-radius: 16px;
  }

  .tile-name {
    font-size: 0.92rem;
  }

  .tile-index,
  .tile-type {
    font-size: 0.72rem;
  }

  .tile-desc {
    margin-top: 7px;
    font-size: 0.73rem;
    line-height: 1.32;
  }

  .tile-buildings,
  .tile-players {
    margin-top: 7px;
    gap: 5px;
  }

  .building-chip {
    padding: 3px 7px;
    font-size: 0.68rem;
  }

  .token {
    width: 24px;
    height: 24px;
    font-size: 0.8rem;
  }

  .item,
  .chat-item {
    padding: 9px;
  }

  .room-panel-grid {
    grid-template-columns: 165px 132px minmax(0, 1fr) 170px;
    gap: 10px;
  }

  .room-code {
    font-size: 1.45rem;
  }

  .qr-box {
    width: 110px;
    min-height: 110px;
  }

  .join-link {
    font-size: 0.76rem;
    padding: 8px 10px;
    margin-bottom: 8px;
  }

  .fx-layer {
    right: 12px;
    bottom: 12px;
    width: min(310px, calc(100vw - 20px));
  }

  .dice-card,
  .event-card {
    padding: 12px;
  }
}

/* RESPONSIVE */
@media (max-width: 1250px) {
  .host-layout {
    grid-template-columns: 1fr;
  }

  .host-side {
    max-height: none;
    overflow: visible;
  }

  .room-panel-grid {
    grid-template-columns: 180px 150px minmax(0, 1fr);
  }

  .room-actions {
    grid-column: 1 / -1;
  }

  .room-actions .btn-row {
    flex-direction: row;
  }

  .room-actions .btn {
    width: auto;
    flex: 1 1 0;
  }
}

@media (max-width: 900px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .status-row {
    justify-content: flex-start;
  }

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

  .room-actions .btn-row {
    flex-direction: column;
  }

  .room-actions .btn {
    width: 100%;
  }
}

@media (max-width: 700px) {
  .shell {
    padding: 12px;
  }

  .topbar h1 {
    font-size: 1.55rem;
  }

  .panel {
    padding: 12px;
    border-radius: 18px;
  }

  .board-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .tile {
    min-height: 132px;
  }

  .meta-row {
    gap: 8px;
  }

  .fx-layer {
    right: 10px;
    bottom: 10px;
    width: min(340px, calc(100vw - 20px));
  }

  .event-feed {
    max-height: 34vh;
  }

  .dice-value {
    font-size: 2rem;
  }

  .btn.ghost {
    padding: 9px 12px;
  }
}

@media (max-width: 520px) {
  .fx-layer {
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
  }

  .event-feed {
    max-height: 30vh;
  }

  .board-grid {
    grid-template-columns: 1fr;
  }

  .top-actions,
  .status-row,
  .meta-row,
  .btn-row {
    width: 100%;
  }

  .mini-pill,
  .pill,
  .btn.ghost {
    width: 100%;
    justify-content: center;
  }
}
