:root {
  --ink: #22342f;
  --muted: #6e7d78;
  --paper: #f5f2e9;
  --panel: #fffdf8;
  --line: #d8ddd5;
  --green: #245c4d;
  --green-dark: #17463a;
  --mint: #dceae3;
  --gold: #d2a54a;
  --danger: #ad3f42;
  --shadow: 0 18px 60px rgba(34, 52, 47, 0.12);
  --shadow-soft: 0 8px 24px rgba(34, 52, 47, 0.09);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 7% 12%, rgba(210, 165, 74, 0.13), transparent 25rem),
    radial-gradient(circle at 90% 88%, rgba(36, 92, 77, 0.12), transparent 28rem),
    var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

.is-hidden {
  display: none !important;
}

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

.topbar {
  min-height: 72px;
  padding: 12px clamp(20px, 3vw, 52px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(34, 52, 47, 0.1);
  background: rgba(245, 242, 233, 0.88);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: #fffdf8;
  background: var(--green);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2), 0 6px 16px rgba(36, 92, 77, 0.18);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 19px;
  letter-spacing: -0.02em;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.button {
  min-height: 42px;
  padding: 10px 17px;
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 760;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, opacity 160ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:focus-visible,
input:focus-visible,
select:focus-visible,
.player-card:focus-visible {
  outline: 3px solid rgba(210, 165, 74, 0.45);
  outline-offset: 2px;
}

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

.button-primary {
  color: #fff;
  background: var(--green);
  box-shadow: 0 8px 18px rgba(36, 92, 77, 0.22);
}

.button-primary:hover:not(:disabled) {
  background: var(--green-dark);
  box-shadow: 0 10px 22px rgba(36, 92, 77, 0.28);
}

.button-secondary {
  border-color: #ccd4cd;
  background: #f6f4ee;
}

.button-secondary:hover:not(:disabled),
.button-ghost:hover:not(:disabled) {
  background: #ece9df;
}

.button-ghost {
  border-color: rgba(34, 52, 47, 0.14);
  background: transparent;
}

.button-large {
  min-height: 52px;
  width: 100%;
  margin-top: 18px;
}

.setup-screen {
  min-height: calc(100vh - 73px);
  padding: clamp(32px, 6vw, 88px) clamp(20px, 7vw, 120px);
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(420px, 1.1fr);
  align-items: center;
  gap: clamp(40px, 8vw, 130px);
}

.setup-copy {
  max-width: 600px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.14em;
}

.setup-copy h1 {
  max-width: 760px;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(42px, 5vw, 72px);
  font-weight: 600;
  line-height: 0.98;
  letter-spacing: -0.045em;
}

.setup-copy > p:not(.eyebrow) {
  max-width: 570px;
  margin: 28px 0 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.65;
}

.feature-strip {
  margin-top: 34px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.feature-strip span {
  padding: 9px 13px;
  border: 1px solid rgba(36, 92, 77, 0.16);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.58);
  color: var(--green);
  font-size: 12px;
  font-weight: 750;
}

.setup-card {
  width: 100%;
  max-width: 680px;
  justify-self: end;
  padding: clamp(24px, 3.2vw, 42px);
  border: 1px solid rgba(34, 52, 47, 0.1);
  border-radius: 24px;
  background: rgba(255, 253, 248, 0.95);
  box-shadow: var(--shadow);
}

.setup-card-heading,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.setup-card h2,
.section-heading h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
  font-weight: 600;
}

.count-control {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.count-control select {
  min-width: 64px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: #fff;
  font-weight: 800;
}

.player-fields {
  max-height: min(48vh, 460px);
  margin-top: 24px;
  padding-right: 5px;
  display: grid;
  gap: 10px;
  overflow-y: auto;
  scrollbar-color: #b9c2bb transparent;
}

.player-field {
  padding: 9px 10px;
  display: grid;
  grid-template-columns: 28px 1fr minmax(130px, 0.62fr);
  align-items: center;
  gap: 10px;
  border: 1px solid #e0e3dc;
  border-radius: 13px;
  background: #fbfaf6;
}

.field-number {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border-radius: 8px;
  color: #fff;
  font-size: 11px;
  font-weight: 850;
}

.player-field input,
.player-field select {
  min-width: 0;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid #d7dcd5;
  border-radius: 9px;
  color: var(--ink);
  background: #fff;
  font-size: 13px;
}

.form-error {
  min-height: 18px;
  margin: 10px 0 -8px;
  color: var(--danger);
  font-size: 12px;
}

.game-screen {
  padding: 20px clamp(14px, 2vw, 34px) 28px;
  display: grid;
  grid-template-columns: minmax(650px, 1fr) 300px;
  align-items: start;
  gap: 22px;
}

.board-column {
  min-width: 0;
}

.board {
  width: min(79vh, calc(100vw - 370px));
  max-width: 880px;
  min-width: 620px;
  aspect-ratio: 1;
  margin-inline: auto;
  display: grid;
  grid-template-columns: 1.35fr repeat(9, 1fr) 1.35fr;
  grid-template-rows: 1.35fr repeat(9, 1fr) 1.35fr;
  gap: 2px;
  padding: 5px;
  border: 1px solid rgba(34, 52, 47, 0.14);
  border-radius: 22px;
  background: var(--green-dark);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.tile {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 5px 4px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 2px;
  border: 2px solid transparent;
  background: #fffdf8;
  text-align: center;
  overflow: hidden;
  transition: border-color 180ms ease, filter 180ms ease;
}

.tile[data-owner] {
  border-color: var(--owner-color);
  box-shadow: inset 0 0 0 1px #fff;
}

.tile.tile-active {
  filter: brightness(0.95);
}

.tile-corner {
  padding: 8px 6px;
  justify-content: center;
}

.tile-band {
  width: calc(100% + 8px);
  min-height: 9px;
  margin: -5px -4px 1px;
  background: var(--group-color, transparent);
}

.tile-number {
  position: absolute;
  top: 3px;
  right: 4px;
  color: rgba(34, 52, 47, 0.55);
  font-size: clamp(6px, 0.46vw, 8px);
  font-weight: 750;
}

.tile-corner .tile-number {
  top: 5px;
  right: 6px;
}

.tile-icon {
  font-size: clamp(13px, 1.35vw, 23px);
  line-height: 1;
}

.tile-name {
  width: 100%;
  display: -webkit-box;
  overflow: hidden;
  color: var(--ink);
  font-size: clamp(6px, 0.52vw, 9px);
  font-weight: 760;
  line-height: 1.08;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.tile-price {
  color: var(--muted);
  font-size: clamp(6px, 0.48vw, 8px);
  font-weight: 700;
}

.tokens {
  width: 100%;
  min-height: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1px;
}

.token {
  width: clamp(6px, 0.7vw, 11px);
  height: clamp(6px, 0.7vw, 11px);
  border: 1.5px solid #fff;
  border-radius: 50%;
  background: var(--token-color);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  animation: token-arrive 220ms ease-out;
}

@keyframes token-arrive {
  from { transform: scale(0.55); opacity: 0.4; }
  to { transform: scale(1); opacity: 1; }
}

.center-console {
  min-width: 0;
  min-height: 0;
  grid-row: 2 / 11;
  grid-column: 2 / 11;
  padding: clamp(14px, 2.2vw, 34px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-radius: 5px;
  background:
    linear-gradient(rgba(255, 253, 248, 0.94), rgba(255, 253, 248, 0.94)),
    repeating-linear-gradient(45deg, #dfe9e2 0 1px, transparent 1px 10px);
  box-shadow: inset 0 0 0 1px rgba(36, 92, 77, 0.08);
  overflow: auto;
}

.turn-kicker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: clamp(9px, 0.75vw, 12px);
  font-weight: 760;
}

.phase-pill {
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--green);
  background: var(--mint);
  font-size: 0.9em;
}

.current-player-line {
  margin-top: clamp(11px, 1.5vw, 22px);
  padding-bottom: clamp(12px, 1.5vw, 22px);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: clamp(8px, 1.2vw, 15px);
  border-bottom: 1px solid var(--line);
}

.current-player-dot {
  width: clamp(24px, 2.6vw, 39px);
  height: clamp(24px, 2.6vw, 39px);
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--player-color, var(--green));
  box-shadow: 0 0 0 1px rgba(34, 52, 47, 0.18), 0 5px 12px rgba(34, 52, 47, 0.16);
}

.current-player-line small,
.last-action small,
.dice-total small,
.winner-stats small {
  display: block;
  color: var(--muted);
  font-size: clamp(8px, 0.66vw, 11px);
}

.current-player-line h2 {
  margin: 2px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(17px, 2.1vw, 32px);
  font-weight: 600;
  line-height: 1;
}

.current-money {
  font-size: clamp(16px, 1.9vw, 28px);
}

.dice-area {
  margin: clamp(12px, 2vw, 28px) 0;
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: clamp(8px, 1vw, 14px);
}

.die {
  width: clamp(43px, 5.2vw, 72px);
  height: clamp(43px, 5.2vw, 72px);
  display: grid;
  place-items: center;
  border: 1px solid #d6d8d2;
  border-radius: clamp(11px, 1vw, 16px);
  background: #fff;
  box-shadow: var(--shadow-soft), inset 0 -3px 0 rgba(34, 52, 47, 0.05);
  font-size: clamp(22px, 2.7vw, 40px);
  font-weight: 850;
}

.dice-total {
  justify-self: end;
  text-align: right;
}

.dice-total strong {
  display: block;
  margin-top: 1px;
  font-size: clamp(23px, 3vw, 44px);
  line-height: 1;
}

.action-panel {
  min-height: 52px;
  display: grid;
  gap: 8px;
}

.action-panel .button {
  min-height: clamp(42px, 4.3vw, 58px);
}

.purchase-panel {
  padding: clamp(10px, 1.2vw, 16px);
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px 16px;
  border: 1px solid rgba(36, 92, 77, 0.15);
  border-left: 5px solid var(--group-color, var(--green));
  border-radius: 12px;
  background: #f6f8f3;
}

.purchase-panel h3,
.purchase-panel p {
  margin: 0;
}

.purchase-panel h3 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(13px, 1.25vw, 19px);
}

.purchase-panel p {
  margin-top: 4px;
  color: var(--muted);
  font-size: clamp(8px, 0.72vw, 11px);
}

.purchase-actions {
  display: flex;
  gap: 7px;
}

.purchase-actions .button {
  min-height: 36px;
  padding: 7px 11px;
  font-size: clamp(8px, 0.74vw, 12px);
}

.status-message {
  min-height: 52px;
  display: grid;
  place-items: center;
  border: 1px dashed #cdd4cd;
  border-radius: 12px;
  color: var(--muted);
  font-size: clamp(10px, 0.78vw, 13px);
  text-align: center;
}

.last-action {
  min-height: 44px;
  margin-top: clamp(10px, 1.3vw, 18px);
  padding: 9px 11px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 9px;
  border-radius: 10px;
  color: var(--green);
  background: rgba(220, 234, 227, 0.65);
}

.last-action p {
  margin: 2px 0 0;
  display: -webkit-box;
  overflow: hidden;
  color: var(--ink);
  font-size: clamp(8px, 0.72vw, 12px);
  line-height: 1.25;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.board-legend {
  max-width: 880px;
  margin: 10px auto 0;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 18px;
  color: var(--muted);
  font-size: 10px;
}

.board-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.board-legend i {
  width: 10px;
  height: 10px;
  display: inline-block;
}

.legend-owner {
  border: 2px solid var(--green);
}

.legend-token {
  border-radius: 50%;
  background: var(--gold);
}

.sidebar {
  height: calc(100vh - 114px);
  min-height: 620px;
  display: grid;
  grid-template-rows: minmax(320px, 1.3fr) minmax(220px, 0.8fr);
  gap: 14px;
}

.sidebar-section {
  min-height: 0;
  padding: 18px;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(34, 52, 47, 0.1);
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.93);
  box-shadow: var(--shadow-soft);
}

.section-heading h2 {
  font-size: 22px;
}

.section-count {
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--green);
  background: var(--mint);
  font-size: 10px;
  font-weight: 800;
}

.players-list,
.event-log {
  min-height: 0;
  margin-top: 14px;
  overflow-y: auto;
  scrollbar-color: #b9c2bb transparent;
}

.players-list {
  display: grid;
  align-content: start;
  gap: 7px;
}

.player-card {
  padding: 9px 10px;
  border: 1px solid #e0e3dc;
  border-radius: 11px;
  background: #fbfaf6;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.player-card:hover {
  transform: translateX(-2px);
  border-color: #c8d2ca;
}

.player-card.current {
  border-color: var(--player-color);
  background: color-mix(in srgb, var(--player-color) 8%, #fbfaf6);
  box-shadow: inset 3px 0 0 var(--player-color);
}

.player-card.bankrupt {
  opacity: 0.62;
  filter: grayscale(0.65);
}

.player-summary {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 9px;
}

.player-dot {
  width: 12px;
  height: 12px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--player-color);
  box-shadow: 0 0 0 1px rgba(34, 52, 47, 0.2);
}

.player-name {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-compact-stats {
  display: flex;
  gap: 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
}

.bankrupt-label {
  color: var(--danger);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.player-details {
  display: none;
  margin-top: 9px;
  padding: 9px 0 0 21px;
  border-top: 1px solid #e4e6e0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.player-card.expanded .player-details {
  display: block;
}

.property-list {
  margin: 5px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  list-style: none;
}

.property-list li {
  padding: 3px 5px;
  border-radius: 5px;
  color: var(--ink);
  background: #ecefe9;
  font-size: 8px;
}

.event-log {
  margin-bottom: 0;
  padding: 0 4px 0 0;
  list-style: none;
}

.event-log li {
  position: relative;
  padding: 0 0 10px 17px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.event-log li::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 2px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 3px rgba(210, 165, 74, 0.14);
}

.event-log li:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 11px;
  bottom: 1px;
  left: 4px;
  width: 1px;
  background: #daddd7;
}

.modal-layer {
  position: fixed;
  z-index: 100;
  inset: 0;
  padding: 20px;
  display: grid;
  place-items: center;
  background: rgba(21, 38, 33, 0.62);
  backdrop-filter: blur(8px);
}

.modal-card {
  width: min(100%, 440px);
  padding: 36px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: 0 30px 100px rgba(17, 35, 30, 0.3);
  text-align: center;
  animation: modal-in 230ms ease-out;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.modal-icon,
.winner-crown {
  width: 58px;
  height: 58px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  color: #fff;
  background: var(--green);
  box-shadow: 0 10px 24px rgba(36, 92, 77, 0.26);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 30px;
}

.modal-card h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 34px;
  font-weight: 600;
}

.chance-card > p:not(.eyebrow) {
  margin: 15px 0 24px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}

.winner-crown {
  color: var(--green-dark);
  background: #e4c66d;
}

.winner-name {
  margin-top: 13px;
  color: var(--green);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 26px;
  font-weight: 650;
}

.winner-stats {
  margin: 24px 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.winner-stats span {
  padding: 14px;
  border-radius: 12px;
  background: #f0f1eb;
}

.winner-stats strong {
  display: block;
  margin-top: 3px;
  font-size: 20px;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 1180px) {
  .game-screen {
    grid-template-columns: minmax(600px, 1fr) 270px;
  }

  .board {
    width: min(76vh, calc(100vw - 330px));
    min-width: 580px;
  }

  .sidebar {
    min-height: 580px;
  }
}

@media (max-width: 920px) {
  .setup-screen {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .setup-card {
    max-width: none;
    justify-self: stretch;
  }

  .game-screen {
    grid-template-columns: 1fr;
  }

  .board {
    width: min(94vw, 780px);
    min-width: 0;
  }

  .sidebar {
    width: min(94vw, 780px);
    height: 540px;
    min-height: 0;
    margin-inline: auto;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr;
  }
}

@media (max-width: 620px) {
  .topbar {
    min-height: 64px;
    padding-inline: 15px;
  }

  .brand small {
    display: none;
  }

  .header-action {
    padding-inline: 10px;
    font-size: 11px;
  }

  .setup-screen {
    min-height: calc(100vh - 64px);
    padding: 28px 16px 42px;
    gap: 30px;
  }

  .setup-copy h1 {
    font-size: clamp(39px, 13vw, 57px);
  }

  .setup-copy > p:not(.eyebrow) {
    margin-top: 20px;
    font-size: 15px;
  }

  .setup-card {
    padding: 20px 15px;
    border-radius: 19px;
  }

  .player-field {
    grid-template-columns: 25px 1fr;
  }

  .player-field select {
    grid-column: 2;
  }

  .game-screen {
    padding: 10px 5px 20px;
    gap: 12px;
  }

  .board {
    width: calc(100vw - 10px);
    padding: 3px;
    gap: 1px;
    border-radius: 12px;
  }

  .tile {
    padding: 3px 2px 2px;
    border-width: 1px;
  }

  .tile-band {
    width: calc(100% + 4px);
    min-height: 5px;
    margin: -3px -2px 0;
  }

  .tile-price,
  .tile-number {
    display: none;
  }

  .center-console {
    padding: 10px;
  }

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

  .dice-area {
    margin: 9px 0;
  }

  .last-action {
    display: none;
  }

  .sidebar {
    width: calc(100vw - 10px);
    height: auto;
    grid-template-columns: 1fr;
    grid-template-rows: 390px 270px;
  }

  .modal-card {
    padding: 28px 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
