:root {
  --paper: #efe7d8;
  --ink: #2f2a24;
  --muted: #7a6f60;
  --panel: #fbf7ef;
  --line: #ddd2bf;
  --board: #c9bba2;
  --tile: #f6f0e3;
  --tile-edge: #8f8270;
  --accent: #2f8fe0;
  --p1: #8db3ec;
  --p1-edge: #3e6fb8;
  --p1-wall: #3f7fd0;
  --p2: #ee9a85;
  --p2-edge: #b84a35;
  --p2-wall: #d45845;
  --button: #2f2a24;
  --button-ink: #fff;
  /* small enough that the controls stay on screen with the board */
  --board-max: min(560px, 60vh, 100%);
}

/* P2 is green when a person played them, red against the AI, as in the game */
.human-p2 {
  --p2: #b6e38a;
  --p2-edge: #4f8f2b;
  --p2-wall: #66b03e;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: "Nunito", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, .brand, .tension, .seat-name, .caption-move, .get-app strong {
  font-family: "Lilita One", "Nunito", sans-serif;
  font-weight: 400;
  letter-spacing: 0.01em;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
  color: var(--ink);
  text-decoration: none;
}

.brand img { border-radius: 8px; }
.brand span { color: var(--accent); }

.meta { color: var(--muted); font-size: 14px; text-align: right; }

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  grid-template-areas: "story story" "stage side";
  gap: 16px 24px;
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
  padding: 0 16px 24px;
}

.app[hidden] { display: none; }

.story { grid-area: story; }
.stage { grid-area: stage; min-width: 0; }
.side { grid-area: side; min-width: 0; }

.headline-row { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }

h1 { font-size: clamp(24px, 4vw, 34px); line-height: 1.15; margin: 4px 0; flex: 1 1 320px; }

.tension {
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 16px;
  background: var(--ink);
  color: #fff;
  margin-top: 6px;
}

.tension[data-level="4"], .tension[data-level="5"] { background: #d4543c; }
.tension[data-level="3"] { background: #e39a2c; }

.result { margin: 2px 0 0; color: var(--muted); font-size: 17px; }

.seat {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: var(--board-max);
  margin: 0 auto;
  padding: 6px 4px;
}

.seat-badge {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--seat-colour);
  border: 3px solid var(--seat-edge);
  flex: none;
}

.seat-name { font-size: 20px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-walls { display: flex; gap: 3px; align-items: center; color: var(--muted); font-size: 14px; }
.seat-walls i { display: block; width: 6px; height: 18px; border-radius: 2px; background: var(--seat-wall); }
.seat-walls i.used { opacity: 0.18; }
.seat.to-move .seat-name::after { content: " · to move"; color: var(--muted); font-family: "Nunito", sans-serif; font-size: 14px; }
.seat.p1 { --seat-colour: var(--p1); --seat-edge: var(--p1-edge); --seat-wall: var(--p1-wall); }
.seat.p2 { --seat-colour: var(--p2); --seat-edge: var(--p2-edge); --seat-wall: var(--p2-wall); }

.board-wrap { max-width: var(--board-max); margin: 0 auto; }

.board {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  background: var(--board);
  border-radius: 14px;
  box-shadow: 0 0 0 6px var(--board), 0 10px 24px rgba(60, 45, 20, 0.25);
}

.tile {
  position: absolute;
  background: var(--tile);
  border: 2px solid var(--tile-edge);
  border-radius: 14%;
}

.tile.goal-p1 { box-shadow: inset 0 -4px 0 color-mix(in srgb, var(--p1-wall) 45%, transparent); }
.tile.goal-p2 { box-shadow: inset 0 4px 0 color-mix(in srgb, var(--p2-wall) 45%, transparent); }
.tile.last { background: #fff2b8; }

.wall {
  position: absolute;
  border-radius: 999px;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.2);
}

.wall.p1 { background: var(--p1-wall); }
.wall.p2 { background: var(--p2-wall); }
.wall.last { outline: 3px solid #ffd23e; outline-offset: 1px; animation: drop 0.35s ease-out; }

@keyframes drop {
  from { transform: translateY(-14%) scale(1.04); opacity: 0.3; }
  to { transform: none; opacity: 1; }
}

.pawn {
  position: absolute;
  border-radius: 50%;
  transition: left 0.28s ease, top 0.28s ease;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.18);
}

.pawn.p1 { background: var(--p1); border: 3px solid var(--p1-edge); }
.pawn.p2 { background: var(--p2); border: 3px solid var(--p2-edge); }

.caption { text-align: center; min-height: 28px; margin: 8px 0 4px; color: var(--muted); }
.caption-move { color: var(--ink); font-size: 18px; }

.controls {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.controls button {
  min-width: 48px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--button);
  color: var(--button-ink);
  font-size: 17px;
  cursor: pointer;
}

.controls button:disabled { opacity: 0.35; cursor: default; }
.controls button.play { min-width: 64px; background: var(--accent); }
.controls button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.scrub { display: block; width: 100%; max-width: var(--board-max); margin: 12px auto 0; accent-color: var(--accent); }

.chart {
  margin: 0 0 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}

.chart figcaption { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.chart svg { display: block; width: 100%; height: 160px; cursor: pointer; }

h2 { font-size: 20px; margin: 0 0 8px; }

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

.highlights button {
  width: 100%;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.highlights button:hover, .highlights button.current { border-color: var(--accent); }
.highlights .turn { display: block; font-size: 12px; color: var(--muted); }
.highlights .empty { color: var(--muted); }

.message { text-align: center; padding: 48px 16px; color: var(--muted); flex: 1; }
.message[hidden] { display: none; }
.message h1 { color: var(--ink); }

.get-app {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  max-width: 1048px;
  width: calc(100% - 32px);
  margin: 8px auto 0;
  padding: 14px 16px;
  background: var(--ink);
  color: #fff;
  border-radius: 16px;
}

.get-app img { border-radius: 12px; }
.get-app-text { flex: 1 1 220px; display: flex; flex-direction: column; }
.get-app strong { font-size: 20px; }
.get-app-text span { color: #d8cfbf; font-size: 14px; }
.stores { display: flex; gap: 8px; flex-wrap: wrap; }

.store {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 10px;
  background: #000;
  border: 1px solid #555;
  color: #fff;
  text-decoration: none;
}

.store svg { width: 22px; height: 22px; }
.store span { display: flex; flex-direction: column; line-height: 1.1; }
.store small { font-size: 10px; }
.store b { font-size: 15px; }

.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 16px; }

@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-areas: "story" "stage" "side"; }
  .meta { display: none; }
}

/* one row of controls on a phone */
@media (max-width: 420px) {
  .controls { gap: 6px; }
  .controls button { min-width: 42px; }
  .controls button.play { min-width: 52px; }
}
