:root {
  --ink: #17151b;
  --paper: #fff8de;
  --panel: #fff3bc;
  --line: rgba(23, 21, 27, .18);
  --muted: #6d6575;
  --pink: #ff4d6d;
  --green: #25c2a0;
  --blue: #5b8cff;
  --yellow: #ffbe3d;
  --purple: #8d5cff;
  --orange: #ff7b54;
  --shadow: 0 22px 70px rgba(23, 21, 27, .18);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 10%, rgba(255,77,109,.28), transparent 22rem),
    radial-gradient(circle at 92% 0%, rgba(91,140,255,.25), transparent 24rem),
    linear-gradient(135deg, #fff8de, #d8f6ff 48%, #ffe1f0);
  font-family: Arial, Verdana, sans-serif;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }

.app-shell {
  width: min(1480px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 32px;
}

.game-header,
.setup-card,
.board-panel,
.side-panel > section,
.action-panel,
.modal-card {
  border: 3px solid var(--ink);
  border-radius: 22px;
  background: rgba(255, 248, 222, .9);
  box-shadow: var(--shadow);
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  margin-bottom: 16px;
}

.eyebrow {
  display: inline-flex;
  margin-bottom: 8px;
  color: #4e2ac8;
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 {
  margin-bottom: 0;
  font-size: clamp(2.4rem, 5vw, 5rem);
  line-height: .86;
  letter-spacing: -.05em;
}
h2 {
  margin-bottom: 10px;
  font-size: clamp(1.7rem, 3vw, 3rem);
  line-height: .95;
  letter-spacing: -.04em;
}
h3 { margin-bottom: 6px; }
p { color: var(--muted); line-height: 1.55; }

.header-actions,
.turn-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.primary-button,
.ghost-button,
.danger-button,
.small-button {
  min-height: 42px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 0 14px;
  color: var(--ink);
  background: #fff;
  font-weight: 900;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.primary-button {
  background: var(--green);
  box-shadow: 0 6px 0 var(--ink);
}

.danger-button {
  background: var(--pink);
}

.small-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: .78rem;
}

.primary-button:hover,
.ghost-button:hover,
.danger-button:hover,
.small-button:hover,
.action-button:hover {
  transform: translateY(-2px);
}

.setup-screen {
  min-height: calc(100vh - 150px);
  display: grid;
  place-items: center;
}

.setup-card {
  width: min(760px, 100%);
  padding: 26px;
}

.setup-row,
.name-field {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.setup-row label,
.name-field span {
  font-weight: 900;
}

.name-field span::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 8px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--player-color);
}

input, select {
  width: 100%;
  min-height: 46px;
  border: 2px solid var(--ink);
  border-radius: 14px;
  padding: 0 12px;
  background: #fff;
}

.name-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.name-field small {
  color: var(--muted);
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: start;
}

.board-panel {
  padding: 14px;
}

.board-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 12px;
}

.board-wrap {
  overflow: hidden;
  border: 3px solid var(--ink);
  border-radius: 24px;
  background: #263238;
}

#game-board {
  display: block;
  width: 100%;
  height: auto;
}

.board-path {
  fill: none;
  stroke: #1b1b1b;
  stroke-width: 30;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: .28;
}

.space-dot {
  fill: #fff7d1;
  stroke: #17151b;
  stroke-width: 5;
}

.special-space {
  fill: #ffef5a;
  animation: pulse 1.6s ease-in-out infinite;
}

.district-label {
  fill: rgba(23,21,27,.82);
  font-size: 24px;
  font-weight: 900;
  letter-spacing: .02em;
}

.location {
  cursor: pointer;
  transition: transform 160ms ease, filter 160ms ease;
}

.location:hover,
.location.selected {
  filter: drop-shadow(0 0 12px rgba(255,255,255,.9));
  transform: translateY(-4px);
}

.location-name {
  fill: #17151b;
  font-size: 15px;
  font-weight: 900;
  text-anchor: middle;
  paint-order: stroke;
  stroke: #fff7d1;
  stroke-width: 4px;
}

.player-token {
  transition: transform 420ms cubic-bezier(.2,.7,.2,1);
}

.player-token.active {
  animation: currentPulse 1s ease-in-out infinite alternate;
}

.action-panel {
  display: grid;
  grid-template-columns: minmax(220px, .45fr) minmax(0, 1fr);
  gap: 12px;
  margin-top: 14px;
  padding: 14px;
}

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

.action-button {
  display: grid;
  gap: 4px;
  min-height: 76px;
  border: 2px solid var(--ink);
  border-radius: 16px;
  padding: 10px;
  text-align: left;
  background: #fff;
  box-shadow: 0 4px 0 rgba(23,21,27,.88);
}

.action-button span {
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.35;
}

.side-panel {
  display: grid;
  gap: 12px;
}

.side-panel > section {
  padding: 14px;
}

.player-head {
  display: flex;
  gap: 10px;
  align-items: center;
}

.player-head > span {
  width: 42px;
  height: 42px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--player-color);
}

.player-head strong {
  display: block;
  font-size: 1.2rem;
}

.player-head small {
  color: var(--muted);
  font-weight: 700;
}

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

.stats-grid div {
  min-height: 64px;
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 8px;
  background: #fff;
}

.stats-grid span {
  display: block;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.stats-grid strong {
  display: block;
  margin-top: 5px;
  font-size: .92rem;
}

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

#ranking-list {
  display: grid;
  gap: 8px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

#ranking-list li {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  gap: 8px;
  align-items: center;
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 8px;
  background: #fff;
}

#ranking-list span {
  width: 14px;
  height: 14px;
  border: 2px solid var(--ink);
  border-radius: 50%;
}

#ranking-list em {
  font-style: normal;
  font-weight: 900;
}

.event-log {
  display: grid;
  max-height: 220px;
  overflow: auto;
  gap: 8px;
}

.event-log p {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 0;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  font-size: .88rem;
}

.event-log span {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 50%;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(23,21,27,.62);
}

.modal-card {
  width: min(560px, 100%);
  padding: 24px;
  background: #fff8de;
}

.modal-card ul {
  margin: 0 0 18px;
  padding-left: 18px;
}

.floating-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 40;
}

.float-effect {
  position: absolute;
  left: 50%;
  top: 50%;
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 8px 12px;
  background: #fff;
  font-weight: 900;
  animation: floatUp 1s ease forwards;
}

.float-effect.money { color: #13945e; }
.float-effect.heart { color: #d91b5c; }

[hidden] { display: none !important; }

@keyframes pulse {
  50% { r: 24; }
}

@keyframes currentPulse {
  to { filter: drop-shadow(0 0 14px var(--token-color)); }
}

@keyframes floatUp {
  to {
    opacity: 0;
    transform: translateY(-80px) rotate(-8deg);
  }
}

@media (max-width: 1120px) {
  .game-layout {
    grid-template-columns: 1fr;
  }

  .side-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 18px, 1480px);
    padding-top: 10px;
  }

  .game-header,
  .board-toolbar,
  .action-panel {
    grid-template-columns: 1fr;
    display: grid;
  }

  .header-actions,
  .turn-buttons {
    width: 100%;
  }

  .header-actions button,
  .turn-buttons button {
    flex: 1;
  }

  .name-grid,
  .action-grid,
  .side-panel,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .board-wrap {
    overflow-x: auto;
  }

  #game-board {
    min-width: 920px;
  }
}
