:root {
  --ink: #15211f;
  --muted: #64706c;
  --paper: #fbfaf4;
  --surface: #ffffff;
  --line: #c9d1c7;
  --board-line: #213f38;
  --accent: #007f73;
  --accent-dark: #005f56;
  --danger: #b42318;
  --gold: #f2b84b;
  --player-one: #e64b3c;
  --player-two: #2878d7;
  --shadow: 0 16px 36px rgba(22, 33, 31, 0.16);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(0, 127, 115, 0.12), transparent 30%),
    linear-gradient(315deg, rgba(242, 184, 75, 0.18), transparent 32%),
    #eef2ea;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.app-shell {
  width: min(1180px, calc(100vw - 24px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 0;
  display: grid;
  place-items: center;
}

.screen {
  width: 100%;
}

.setup-screen {
  display: grid;
  place-items: center;
}

.setup-panel {
  width: min(760px, 100%);
  padding: 28px;
  border: 2px solid var(--board-line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.title-block {
  display: grid;
  gap: 6px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 3rem;
  line-height: 0.95;
}

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

.player-setup {
  min-width: 0;
  margin: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.player-setup legend {
  padding: 0 6px;
  font-weight: 900;
}

.player-setup label {
  display: block;
  margin: 12px 0 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.player-setup input,
.player-setup select {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

.setup-error {
  min-height: 1.4em;
  margin: 14px 0 12px;
  color: var(--danger);
  font-weight: 800;
}

.primary-button,
.secondary-button,
.text-button {
  min-height: 42px;
  border-radius: 6px;
  font-weight: 900;
}

.primary-button {
  border: 1px solid var(--accent-dark);
  background: var(--accent);
  color: #fff;
  box-shadow: 0 3px 0 var(--accent-dark);
}

.primary-button:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--accent-dark);
}

.secondary-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.text-button {
  min-height: 32px;
  border: 0;
  background: transparent;
  color: var(--accent-dark);
  font-size: 0.82rem;
}

#start-game-button {
  width: 100%;
}

.game-screen {
  display: grid;
  place-items: center;
}

.board-wrap {
  width: min(96vmin, 980px);
  min-width: min(100%, 320px);
  aspect-ratio: 1;
}

.board {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(11, minmax(0, 1fr));
  grid-template-rows: repeat(11, minmax(0, 1fr));
  gap: 3px;
  padding: 6px;
  border: 3px solid var(--board-line);
  border-radius: 8px;
  background: var(--board-line);
  box-shadow: var(--shadow);
}

.space {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  border: 1px solid rgba(21, 33, 31, 0.26);
  border-radius: 5px;
  background: var(--paper);
}

.space.corner {
  background: #fff8de;
}

.space.tax,
.space.card-space,
.space.rest,
.space.goto-jail,
.space.jail {
  background: #fff;
}

.color-strip {
  flex: 0 0 8px;
  width: 100%;
  background: var(--space-color, transparent);
}

.space-body {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 2px;
  padding: 5px 4px 4px;
}

.space-name {
  align-self: center;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 0.64rem;
  font-weight: 900;
  line-height: 1.02;
  text-align: center;
}

.space-meta {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.52rem;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.owner-bar {
  position: absolute;
  right: 3px;
  bottom: 3px;
  left: 3px;
  height: 5px;
  border-radius: 4px;
  background: transparent;
}

.token-stack {
  position: absolute;
  top: 2px;
  right: 2px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 1px;
  max-width: calc(100% - 4px);
  pointer-events: none;
}

.token {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--player-color);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  color: #fff;
  font-size: 0.86rem;
  line-height: 1;
}

.center-panel {
  grid-column: 2 / 11;
  grid-row: 2 / 11;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto auto auto auto minmax(72px, 1fr);
  gap: 8px;
  padding: 14px;
  border: 2px solid var(--board-line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.turn-card {
  min-width: 0;
}

.turn-card h2 {
  margin: 3px 0 4px;
  overflow-wrap: anywhere;
  font-size: 1.45rem;
  line-height: 1.05;
}

.turn-status {
  min-height: 1.2em;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
}

.dice-row {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.die {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 2px solid var(--board-line);
  border-radius: 8px;
  background: #fffdf6;
  color: var(--ink);
  font-size: 1.45rem;
  font-weight: 950;
}

.button-row,
.action-buttons {
  display: flex;
  gap: 8px;
}

.button-row > button,
.action-buttons > button {
  flex: 1;
}

.action-panel {
  min-height: 0;
}

.action-box {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fbf9;
}

.action-box h3 {
  margin-bottom: 0;
  font-size: 0.98rem;
}

.action-box p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.25;
}

.player-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

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

.player-stat.active {
  background: #fff8de;
}

.player-stat-name {
  overflow: hidden;
  font-weight: 950;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-stat-detail {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 750;
  line-height: 1.25;
}

.log-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

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

.log-heading h3 {
  margin-bottom: 0;
  font-size: 0.95rem;
}

.game-log {
  min-height: 0;
  margin: 6px 0 0;
  padding-left: 20px;
  overflow: auto;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.25;
}

.game-log li + li {
  margin-top: 5px;
}

.bankrupt {
  color: var(--danger);
  font-weight: 900;
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100vw - 12px, 680px);
    padding: 8px 0;
  }

  .setup-panel {
    padding: 18px;
  }

  h1 {
    font-size: 2.35rem;
  }

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

  .board-wrap {
    width: min(100%, 98vmin);
  }

  .board {
    gap: 2px;
    padding: 4px;
  }

  .center-panel {
    gap: 6px;
    padding: 8px;
    grid-template-rows: auto auto auto auto auto minmax(58px, 1fr);
  }

  .space-body {
    padding: 3px 2px;
  }

  .space-name {
    font-size: 0.48rem;
  }

  .space-meta {
    display: none;
  }

  .color-strip {
    flex-basis: 5px;
  }

  .token {
    width: 18px;
    height: 18px;
    font-size: 0.68rem;
  }

  .turn-card h2 {
    font-size: 1.05rem;
  }

  .turn-status,
  .action-box p,
  .player-stat-detail {
    font-size: 0.72rem;
  }

  .die {
    width: 42px;
    height: 42px;
    font-size: 1.1rem;
  }

  .primary-button,
  .secondary-button {
    min-height: 36px;
    padding: 5px 7px;
    font-size: 0.78rem;
  }

  .player-summary {
    gap: 5px;
  }

  .player-stat {
    padding: 6px;
    border-left-width: 6px;
  }

  .player-stat-name {
    font-size: 0.78rem;
  }

  .log-heading h3 {
    font-size: 0.82rem;
  }

  .game-log {
    padding-left: 18px;
    font-size: 0.68rem;
  }
}

@media (max-width: 430px) {
  .space-name {
    font-size: 0.42rem;
  }

  .center-panel {
    padding: 6px;
  }

  .button-row,
  .action-buttons {
    gap: 5px;
  }

  .action-box {
    padding: 7px;
  }
}
