:root {
  --bg: #f3eee2;
  --card: #fffaf0;
  --ink: #2b2a26;
  --muted: #6d675c;
  --line: #ddd2bd;
  --bar: #3b5d3a;
  --grass: #c9dfae;
  --blue: #2f6fd6;
  --red: #d23b2f;
  --gold: #e0a800;
  --accent: #b5651d;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

/* ---------------------------------------------------------------- top bar */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 1.2rem;
  padding: 0.6rem 1rem;
  background: var(--bar);
  color: #fff;
}

.brand {
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}

.status {
  font-weight: 600;
}

.turn-info {
  margin-left: auto;
  color: #dfe9d8;
  font-size: 0.9rem;
}

/* ---------------------------------------------------------------- buttons */
button {
  font: inherit;
  padding: 0.45rem 0.9rem;
  border: 1px solid #b9ad97;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

button:hover:not(:disabled) {
  background: #f6efe0;
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button.primary:hover:not(:disabled) {
  background: #9c5517;
}

/* ---------------------------------------------------------------- play page */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 1rem;
  padding: 1rem;
  height: calc(100vh - 3rem);
}

.board-area {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-height: 0;
}

.board-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: auto;
  background: var(--grass);
  border-radius: 8px;
}

#board {
  display: block;
  flex: none;
  margin: auto; /* centred, but still scrollable when larger than the frame */
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  min-height: 2.6rem;
}

.control-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

/* zoom buttons: the right-hand end of the controls row */
.zoom-group {
  margin-left: auto;
}

.zoom-label {
  color: var(--muted);
}

.zoom-group button {
  min-width: 2.6rem;
}

.warning {
  font-weight: 600;
  color: var(--red);
}

.message {
  margin: 0;
  color: var(--red);
}

/* board overlays */
.cell {
  fill: rgba(255, 214, 0, 0.3);
  stroke: var(--gold);
  stroke-width: 3;
  cursor: pointer;
}

.cell:hover {
  fill: rgba(255, 214, 0, 0.55);
}

.cell.selected {
  fill: transparent;
  stroke: #ff7a00;
  stroke-width: 6;
}

.preview {
  opacity: 0.9;
  pointer-events: none;
}

.last-placed {
  fill: none;
  stroke: #fff;
  stroke-width: 4;
  stroke-dasharray: 10 6;
  pointer-events: none;
}

.meeple {
  pointer-events: none;
}

.spot {
  cursor: pointer;
}

/* three circles per spot, back to front: an invisible click target, a white halo, a ring in the seat colour */
.spot .hit {
  fill: none;
  stroke: none;
  pointer-events: all;
}

.spot .halo {
  fill: none;
  stroke: #fff;
  animation: pulse 1.2s ease-in-out infinite;
}

.spot .ring {
  fill: rgba(255, 255, 255, 0.35); /* the road or city under the circle stays visible */
}

.spot .ring.blue {
  stroke: var(--blue);
}

.spot .ring.red {
  stroke: var(--red);
}

.spot:hover .ring {
  fill: rgba(255, 224, 102, 0.85);
}

@keyframes pulse {
  50% {
    stroke-opacity: 0.45; /* only the halo fades, the ring keeps its colour */
  }
}

@media (prefers-reduced-motion: reduce) {
  .spot .halo {
    animation: none;
  }
}

/* side panel */
.panel {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  min-height: 0;
  overflow: auto;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
}

.card h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.player {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 0.2rem 0.5rem;
  padding: 0.35rem 0.4rem;
  border-radius: 6px;
}

.player.current {
  background: #fff1c7;
  outline: 2px solid var(--gold);
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
}

.swatch.blue {
  background: var(--blue);
}

.swatch.red {
  background: var(--red);
}

.name {
  font-weight: 600;
}

.score {
  font-weight: 700;
}

.meeple-row {
  grid-column: 2 / 4;
  display: flex;
  gap: 2px;
  min-height: 18px;
}

.meeple-row img {
  width: 18px;
  height: 18px;
}

.hand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.hand-tile {
  width: 72px;
  height: 72px;
  transition: transform 0.15s;
}

.hand-letter {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--muted);
}

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

.rem {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 0.75rem;
}

.rem img {
  width: 36px;
  height: 36px;
}

.rem.none {
  opacity: 0.3;
}

.log {
  margin: 0;
  padding-left: 1.1rem;
  max-height: 16rem;
  overflow: auto;
  font-size: 0.9rem;
}

.log li {
  margin-bottom: 0.25rem;
}

.log .empty {
  list-style: none;
  margin-left: -1.1rem;
  color: var(--muted);
}

.log .log-discard {
  color: var(--muted);
  font-style: italic;
}

.final {
  border-color: var(--gold);
  background: #fff6d8;
}

.breakdown {
  width: 100%;
  border-collapse: collapse;
}

.breakdown th,
.breakdown td {
  padding: 0.2rem 0.4rem;
  border-bottom: 1px solid var(--line);
  text-align: right;
}

.breakdown tr > th:first-child {
  text-align: left;
}

.breakdown .total td,
.breakdown .total th {
  font-weight: 700;
  border-bottom: none;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .board-wrap {
    flex: none;
    height: 70vh;
  }
}

/* ---------------------------------------------------------------- start page */
.start {
  max-width: 40rem;
  margin: 1.5rem auto;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.start form {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.start label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.start fieldset {
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.start fieldset label {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.start input[type="password"],
.start input[type="number"],
.start select {
  font: inherit;
  padding: 0.4rem;
  border: 1px solid #b9ad97;
  border-radius: 6px;
}

.error {
  margin: 0;
  color: var(--red);
  font-weight: 600;
}

.links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.links li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.links input {
  flex: 1;
  min-width: 14rem;
  font: inherit;
  padding: 0.35rem;
}
