:root {
  --ground: #262421;
  --panel: #21201d;
  --ink: #e4e1dd;
  --dim: #98948e;
  --tile: #4b4741;
  --tile-alt: #544f48;
  --edge: #221f1c;
  --go: #81b64c;
  --warn: #d9a13b;
  --you: #f2efeb;
  --foe: #8d9aa6;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--ground);
  color: var(--ink);
  font-family: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 16px;
  -webkit-text-size-adjust: 100%;
}

/* Fixed portrait stage: the same rectangle on a phone and on a laptop. */
.stage {
  width: min(100%, 430px);
  aspect-ratio: 10 / 16;
  max-height: calc(100dvh - 32px);
  background: var(--panel);
  border: 1.5px solid var(--edge);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  overflow: hidden;
}

h1 {
  font-size: 15px;
  letter-spacing: 0.16em;
  font-weight: 700;
  text-transform: uppercase;
}

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  background: var(--ground);
  border: 1.5px solid var(--edge);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
  white-space: nowrap;
}
.chip b { color: var(--ink); font-weight: 700; }
.chip.hot { color: var(--warn); border-color: var(--warn); }
.pips { letter-spacing: 2px; color: var(--go); }
.pips .spent { color: var(--tile); }

.board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  gap: 2px;
  /* Square always. It takes the height the stage has left over and derives its
     width from that, so a short screen shrinks the board instead of pushing the
     buttons out of the stage. */
  aspect-ratio: 1;
  flex: 1 1 auto;
  min-height: 0;
  width: auto;
  max-width: 100%;
  margin-inline: auto;
  touch-action: manipulation;
}

.cell {
  position: relative;
  background: var(--tile);
  border: 0;
  border-radius: 3px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: min(4.6vw, 21px);
  line-height: 1;
  min-width: 0;
  min-height: 0;
  cursor: pointer;
  color: inherit;
  font-family: inherit;
}
.cell.alt { background: var(--tile-alt); }

/* Dead ground is striped, never just a different colour. */
.cell.dead {
  background:
    repeating-linear-gradient(45deg, var(--edge) 0 3px, transparent 3px 7px),
    var(--ground);
  cursor: default;
}

.cell.doomed { box-shadow: inset 0 0 0 1.5px var(--warn); }
.cell.sel { box-shadow: inset 0 0 0 2px var(--go); }
.cell.last { background: color-mix(in srgb, var(--tile) 78%, var(--warn)); }

/* The two seats are told apart by fill, not by hue — a light disc and a dark
   one read at any size, on any screen, to any eye. */
.piece {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 80%;
  aspect-ratio: 1;
  border-radius: 50%;
  font-size: 1.02em;
  line-height: 1;
}
.piece.you { background: var(--you); color: #1d1b19; }
.piece.foe { background: #14130f; color: #d8d3cc; box-shadow: inset 0 0 0 1.5px #3d3831; }

.chest {
  position: absolute;
  inset: 12%;
  border: 1.5px dashed var(--dim);
  border-radius: 4px;
  display: grid;
  place-items: center;
  font-size: 0.9em;
  color: var(--dim);
}
.chest.expiring { border-color: var(--warn); color: var(--warn); border-style: solid; }

/* Green means only one thing: you can act here. */
.dot {
  position: absolute;
  width: 30%;
  aspect-ratio: 1;
  height: auto;
  border-radius: 50%;
  background: var(--go);
  pointer-events: none;
}
.dot.take {
  width: 78%;
  background: none;
  border: 2.5px solid var(--go);
}

.say { font-size: 13px; color: var(--dim); min-height: 2.6em; }
.say b { color: var(--ink); font-weight: 700; }

.tray {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
}
.tray div { display: flex; align-items: baseline; gap: 9px; }
.tray span:first-child { width: 6.4em; flex: none; }
.tray .won { font-size: 19px; letter-spacing: 3px; text-transform: none; }
.tray .won { display: inline-flex; gap: 5px; }
.tray .won i {
  font-style: normal;
  display: grid;
  place-items: center;
  width: 1.35em; height: 1.35em;
  border-radius: 50%;
  font-size: 15px;
}
.tray .won.you i { background: var(--you); color: #1d1b19; }
.tray .won.foe i { background: #14130f; color: #d8d3cc; box-shadow: inset 0 0 0 1.5px #3d3831; }
.tray .none { font-size: 12px; color: var(--tile-alt); letter-spacing: 0.08em; }

.acts { display: flex; gap: 8px; margin-top: auto; padding-top: 12px; }
button.btn {
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 9px;
  padding: 13px 16px;
  min-height: 46px;
  border: 1.5px solid var(--edge);
  cursor: pointer;
}
.btn.primary { flex: 1; background: var(--go); color: #14210a; }
.btn.ghost { flex: 1; background: var(--ground); color: var(--dim); }
.btn.ghost.narrow { flex: none; }
.btn:disabled { opacity: 0.4; cursor: default; }

.over {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--panel) 93%, transparent);
  display: grid;
  place-content: center;
  gap: 12px;
  text-align: center;
  padding: 24px;
}
.over[hidden] { display: none; }
.over h2 { font-size: 26px; letter-spacing: 0.06em; text-transform: uppercase; }
.over p { color: var(--dim); font-size: 14px; }

.rail {
  width: 300px;
  color: var(--dim);
  font-size: 13px;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.rail h3 {
  font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink); font-weight: 700;
}
.rail ul { list-style: none; display: flex; flex-direction: column; gap: 5px; }
.rail li { display: flex; gap: 9px; }
.rail li span:first-child { color: var(--ink); width: 1.4em; text-align: center; }
@media (max-width: 820px) { .rail { display: none; } }

/* On a phone the board is the thing; give it back the space the chrome takes. */
@media (max-width: 480px) {
  body { padding: 8px; }
  .stage { padding: 12px; gap: 9px; border-radius: 12px; }
  h1 { font-size: 13px; }
  .chip { padding: 4px 9px; font-size: 10px; }
  .say { font-size: 12px; min-height: 2.4em; }
  .tray { font-size: 11px; }
  .tray .won i { width: 1.3em; height: 1.3em; font-size: 14px; }
  .acts { padding-top: 8px; }
  button.btn { padding: 11px 12px; font-size: 12px; }
}

/* ---- menu, lobby and the shared chrome the three modes need ---- */

.topline { display: flex; align-items: center; gap: 10px; }
.back {
  color: var(--dim); text-decoration: none; font-size: 18px; line-height: 1;
  width: 30px; height: 30px; display: grid; place-items: center;
  border: 1.5px solid var(--edge); border-radius: 8px; background: var(--ground);
  flex: none;
}
.back:hover { color: var(--ink); }

.lede { font-size: 14px; line-height: 1.55; color: var(--dim); }
.fine { font-size: 12px; line-height: 1.5; color: var(--tile-alt); }

.menu { justify-content: flex-start; gap: 16px; }
.modes { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.mode {
  display: flex; flex-direction: column; gap: 4px;
  padding: 15px 16px; border-radius: 11px;
  background: var(--ground); border: 1.5px solid var(--edge);
  text-decoration: none; color: var(--ink);
}
.mode b { font-size: 15px; letter-spacing: 0.02em; }
.mode span { font-size: 12.5px; color: var(--dim); line-height: 1.45; }
.mode:hover { border-color: var(--go); }
.menu .fine { margin-top: auto; }

.lobby { display: flex; flex-direction: column; gap: 12px; }
.joinrow { display: flex; gap: 8px; }
.joinrow input {
  flex: 1; min-width: 0; font: inherit; font-size: 15px; letter-spacing: 0.22em;
  text-transform: uppercase; text-align: center;
  background: var(--ground); color: var(--ink);
  border: 1.5px solid var(--edge); border-radius: 9px; padding: 12px;
  min-height: 46px;
}
.joinrow input::placeholder { letter-spacing: 0.08em; text-transform: none; color: var(--tile-alt); }
.joinrow input:focus { outline: none; border-color: var(--go); }

/* Point value tucked into the corner of a chest. */
.chest b {
  position: absolute; right: -2px; bottom: -4px;
  font-size: 9px; font-weight: 700; letter-spacing: 0;
  color: var(--ink); background: var(--panel);
  border-radius: 3px; padding: 0 2px; line-height: 1.3;
}

.share {
  font: inherit; font-size: 13px; line-height: 1.5;
  background: var(--ground); border: 1.5px solid var(--edge);
  border-radius: 9px; padding: 12px 14px; text-align: left;
  white-space: pre-wrap; word-break: break-word; color: var(--ink);
}
