/*
 * One stylesheet. The app is a dozen pages and a grid; a build step and a
 * component library would both be more machinery than the thing they dress.
 *
 * Dark by default, because it is played in the evening on a phone.
 */

:root {
  --ink: #e8ecf4;
  --ink-dim: #97a2b8;
  --ground: #12161f;
  --panel: #1d2433;
  --line: #2f3a4f;
  --accent: #6ea8ff;
  --good: #57d9a3;
  --bad: #ff6b6b;
  --cell: #263049;
  --cell-line: #3d4a68;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 0 3rem;
  background: var(--ground);
  color: var(--ink);
  font: 16px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 34rem;
  margin: 0 auto;
  padding: 1rem;
}

h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 1.25rem 0 .5rem; }
h3 { font-size: .95rem; margin: 1rem 0 .35rem; color: var(--ink-dim); }
p { margin: .5rem 0; }

/* ── masthead ─────────────────────────────────────────────────────────────── */

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 10;
}

.modes { display: flex; gap: .25rem; }

.mode {
  padding: .35rem .7rem;
  border-radius: 999px;
  color: var(--ink-dim);
  text-decoration: none;
  font-weight: 600;
  font-size: .9rem;
}

.mode.active { background: var(--cell); color: var(--ink); }

.account { display: flex; align-items: center; gap: .6rem; font-size: .85rem; }
.account .who { color: var(--ink-dim); text-decoration: none; }

.badge {
  background: var(--accent);
  color: #0b1020;
  padding: .2rem .5rem;
  border-radius: 999px;
  font-weight: 700;
  text-decoration: none;
  font-size: .78rem;
}

/* ── cards ────────────────────────────────────────────────────────────────── */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 0 0 1rem;
}

.card.narrow { max-width: 24rem; margin: 3rem auto; }

.lede { color: var(--ink-dim); }
.note { color: var(--ink-dim); font-size: .85rem; }

.flash {
  padding: .6rem .8rem;
  border-radius: var(--radius);
  margin: 0 0 1rem;
  font-size: .9rem;
}
.flash.notice { background: rgba(87, 217, 163, .15); color: var(--good); }
.flash.alert  { background: rgba(255, 107, 107, .15); color: var(--bad); }

/* ── controls ─────────────────────────────────────────────────────────────── */

.button, button, input[type="submit"] {
  font: inherit;
  font-weight: 600;
  padding: .6rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--cell);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.button.primary, input[type="submit"] { background: var(--accent); color: #0b1020; border-color: transparent; }
.button.small { padding: .35rem .7rem; font-size: .85rem; }
.button.danger { background: transparent; color: var(--bad); border-color: var(--bad); margin-top: 1rem; }

input[type="text"], input[type="email"] {
  font: inherit;
  padding: .6rem .75rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--ground);
  color: var(--ink);
  width: 100%;
}

input.code { font-size: 1.6rem; letter-spacing: .35em; text-align: center; }

.stack { display: flex; flex-direction: column; gap: .5rem; }
.stack label { font-size: .85rem; color: var(--ink-dim); }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row input { flex: 1 1 12rem; }
form { margin: 0; }

/* ── the board ────────────────────────────────────────────────────────────── */

.board-card { padding: 1rem .75rem; }

.board-head { display: flex; align-items: baseline; justify-content: space-between; }
.counters { display: flex; gap: 1rem; align-items: baseline; }
.timer { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.mistake-count { color: var(--ink-dim); font-size: .85rem; }

.board {
  display: grid;
  grid-template-columns: repeat(var(--board-size), 1fr);
  gap: 0;
  margin: 1rem auto;
  width: 100%;
  max-width: 26rem;
  background: var(--cell);
  border: 3px solid var(--ink);
  border-radius: 6px;
  overflow: hidden;
  /* Stops the browser waiting to see whether a tap is a double-tap-to-zoom,
     which would put ~300ms of lag on every mark on a board you are timed on. */
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.cell {
  aspect-ratio: 1;
  border: 0;
  margin: 0;
  padding: 0;
  background: var(--cell);
  border-radius: 0;
  /* The thin grid. Region edges overwrite these below. */
  box-shadow: inset -1px -1px 0 var(--cell-line), inset 1px 1px 0 var(--cell-line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: min(6vw, 1.6rem);
  line-height: 1;
  cursor: pointer;
  position: relative;
}

/* The regions, drawn as thick borders rather than eight colours nobody can tell
   apart. The classes come from ApplicationHelper#region_edges. */
.cell.edge-top    { border-top:    3px solid var(--ink); }
.cell.edge-bottom { border-bottom: 3px solid var(--ink); }
.cell.edge-left   { border-left:   3px solid var(--ink); }
.cell.edge-right  { border-right:  3px solid var(--ink); }

.cell.has-cross::after {
  content: "×";
  color: var(--ink-dim);
  font-size: 1.1em;
  font-weight: 400;
}

.cell.has-dog::after {
  content: "🐕";
  font-size: .85em;
}

.cell.has-dog.is-wrong {
  background: rgba(255, 107, 107, .28);
}

.cell.has-dog.is-wrong::after { content: "🐕"; }

.board.static .cell { cursor: default; }

/* ── results and scoreboards ──────────────────────────────────────────────── */

.result { display: grid; grid-template-columns: auto 1fr; gap: .25rem 1rem; margin: 1rem 0; }
.result dt { color: var(--ink-dim); font-size: .9rem; }
.result dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.result dd.big { font-size: 1.5rem; color: var(--accent); }

.done { font-size: 1.05rem; }
.score { font-size: 1.05rem; }

.standings, .wins, .groups, .archive, .pending { list-style: none; margin: .5rem 0; padding: 0; }

.standings li, .wins li, .archive-row {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  padding: .45rem .5rem;
  border-radius: 8px;
}

.standings li:nth-child(odd), .wins li:nth-child(odd), .archive-row:nth-child(odd) {
  background: rgba(255, 255, 255, .03);
}

.standings li.winner { background: rgba(87, 217, 163, .14); }
.standings li.winner .who::before { content: "🏆 "; }

.standings .who, .wins .who, .archive .day { flex: 1 1 auto; font-weight: 600; }
.standings .detail, .archive .outcome { color: var(--ink-dim); font-size: .82rem; }
.standings .score, .wins .count, .archive-score {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  min-width: 3.5rem;
  text-align: right;
}

.groups li { padding: .5rem 0; border-bottom: 1px solid var(--line); }
.groups li:last-child { border-bottom: 0; }
.group-name { color: var(--ink); font-weight: 600; text-decoration: none; }

.invitation {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .75rem;
  margin: .5rem 0;
}

.rules ul { margin: .5rem 0; padding-left: 1.1rem; color: var(--ink-dim); font-size: .9rem; }
.rules li { margin: .3rem 0; }

.day { margin-bottom: 1rem; }
