/* Word Tiles - the board, the rack, the buttons, the dialogs.
   Sized for the same people as Word Wheel: mostly over seventy, often on a
   laptop trackpad or a tablet. Every button carries words as well as an icon,
   nothing is smaller than 1rem, and the squares are as big as the screen
   allows. */

.word-tiles-page {
  margin: 0;

  /* The tiles and the premium squares are the game's own colours and do NOT
     follow the site themes: a triple-word square has to be the colour of a
     triple-word square in every theme, or the board stops being the board. */
  --sb-tile-bg: #f1deb0;
  --sb-tile-ink: #3a2a10;
  --sb-tile-edge: #b4964f;
  --sb-tw: #c23a2c;
  --sb-dw: #eeaaa0;
  --sb-tl: #2f66b0;
  --sb-dl: #a6c8ea;

  /* One square. The board is 15 of them, so this is what makes it fit: the
     window's width, less the gutters, over fifteen, held between a size
     that can still be read and one that is not silly on a big monitor. */
  --cell: clamp(21px, calc((100vw - 28px) / 15), 42px);
}

.sb-shell {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 12px 18px;
  background: var(--ground);
}


/* ----------------------------------------------------------------- scores */

.sb-scores {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  padding: 2px 4px;
  color: var(--ink-muted);
  font-size: 1.1rem;
}

.sb-scores b {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.sb-score.is-turn { color: var(--ink); font-weight: 700; }
.sb-score.is-turn::before { content: '\25B6\00a0'; color: var(--accent); }

.sb-bag { margin-left: auto; }


/* ------------------------------------------------------------------- play */

.sb-play {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: center;
  gap: 14px 24px;
}

.sb-board {
  display: grid;
  grid-template-columns: repeat(15, var(--cell));
  grid-auto-rows: var(--cell);
  gap: 1px;
  padding: 3px;
  background: var(--rule-strong);
  border-radius: 6px;
  user-select: none;
  touch-action: manipulation;
}

.sb-sq {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: var(--surface-alt);
  color: var(--ink-muted);
  font: 700 calc(var(--cell) * 0.3) var(--font-head, inherit);
  letter-spacing: 0;
  cursor: pointer;
}

.sb-sq[data-p="W"] { background: var(--sb-tw); color: #fff; }
.sb-sq[data-p="w"] { background: var(--sb-dw); color: #5a1a12; }
.sb-sq[data-p="L"] { background: var(--sb-tl); color: #fff; }
.sb-sq[data-p="l"] { background: var(--sb-dl); color: #123a66; }

.sb-sq.is-target:hover { outline: 2px solid var(--accent); outline-offset: -2px; }

/* A tile lying on a square. */
.sb-sq.has-tile,
.sb-tile {
  background: var(--sb-tile-bg);
  color: var(--sb-tile-ink);
  box-shadow: inset 0 0 0 1px var(--sb-tile-edge), 0 1px 1px rgba(0, 0, 0, 0.35);
}

.sb-sq.has-tile {
  font-size: calc(var(--cell) * 0.58);
  font-weight: 700;
  cursor: default;
}

/* A tile you have put down this turn and can still take back. */
.sb-sq.is-pending {
  cursor: pointer;
  box-shadow: inset 0 0 0 3px var(--accent), 0 1px 1px rgba(0, 0, 0, 0.35);
}

/* The computer's last play, so you can see what changed while you were
   looking at your rack. */
.sb-sq.is-last { box-shadow: inset 0 0 0 3px var(--warn, #d08a00), 0 1px 1px rgba(0, 0, 0, 0.35); }

.sb-sq.is-blank { font-style: italic; color: #7a6a4a; }

.sb-pts {
  position: absolute;
  right: 8%;
  bottom: 2%;
  font-size: calc(var(--cell) * 0.27);
  font-weight: 600;
  line-height: 1;
}

.sb-star { font-size: calc(var(--cell) * 0.55); line-height: 1; }


/* ------------------------------------------------------------------- side */

.sb-side {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1 1 19rem;
  max-width: 34rem;
  min-width: min(19rem, 100%);
}

.sb-status {
  margin: 0;
  min-height: 2.9em;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--rule);
  color: var(--ink);
  font-size: 1.05rem;
  line-height: 1.35;
}

.sb-status.is-bad { color: var(--ink-muted); }
.sb-status.is-good { border-color: var(--ok, var(--accent)); }

.sb-rack {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: calc(var(--cell) * 1.5);
  padding: 8px;
  border-radius: 8px;
  background: var(--rule);
}

.sb-tile {
  position: relative;
  width: calc(var(--cell) * 1.35);
  height: calc(var(--cell) * 1.35);
  max-width: 3.4rem;
  max-height: 3.4rem;
  padding: 0;
  border: 0;
  border-radius: 5px;
  font: 700 calc(var(--cell) * 0.78) var(--font-head, inherit);
  cursor: pointer;
}

.sb-tile .sb-pts { font-size: calc(var(--cell) * 0.34); }

.sb-tile.is-selected { transform: translateY(-6px); outline: 3px solid var(--accent); }
.sb-tile.is-used { visibility: hidden; }
.sb-tile.is-ticked { outline: 3px solid var(--danger, #b3261e); transform: translateY(-4px); }

.sb-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sb-buttons button,
.sb-dialog__actions button {
  flex: 1 1 6.2rem;
  min-height: 2.8rem;
  padding: 0 0.7rem;
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  background: var(--button-bg, var(--surface));
  color: var(--button-ink, var(--ink));
  font: inherit;
  cursor: pointer;
}

.sb-buttons button i { margin-right: 0.4em; }
.sb-buttons button:hover:not(:disabled),
.sb-dialog__actions button:hover:not(:disabled) { background: var(--accent-soft); }
.sb-buttons button:disabled,
.sb-dialog__actions button:disabled { opacity: 0.45; cursor: default; }

.sb-primary {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: var(--on-accent) !important;
  font-weight: 700;
}

.sb-primary:hover:not(:disabled) { filter: brightness(1.12); }

.sb-log {
  margin: 0;
  padding: 0 0 0 1.4em;
  max-height: 12rem;
  overflow-y: auto;
  color: var(--ink-muted);
  font-size: 1rem;
  line-height: 1.5;
}

.sb-log li b { color: var(--ink); }


/* ---------------------------------------------------------------- dialogs */

.sb-dialog {
  width: min(32rem, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0 18px 18px;
  border: 1px solid var(--rule-strong);
  border-radius: 12px;
  background: var(--raised, var(--surface));
  color: var(--ink);
}

.sb-dialog::backdrop { background: var(--backdrop, rgba(0, 0, 0, 0.55)); }

.sb-dialog__head {
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  padding: 14px 0 10px;
  background: inherit;
  border-bottom: 1px solid var(--rule);
}

.sb-dialog__head h2 { flex: 1; margin: 0; font-size: 1.25rem; }

.sb-dialog__head button {
  min-width: 2.4rem;
  min-height: 2.4rem;
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  background: var(--button-bg, var(--surface));
  color: inherit;
  font-size: 1.2rem;
  cursor: pointer;
}

.sb-dialog__title { margin: 16px 0 0; font-size: 1.25rem; }

.sb-dialog__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.sb-dialog__actions--stack { flex-direction: column; }

.sb-levels { margin: 14px 0 0; padding: 0; border: 0; }
.sb-levels legend { padding: 0; margin-bottom: 6px; font-weight: 700; }

.sb-levels label {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
  padding: 8px 4px;
  cursor: pointer;
}

.sb-levels small { color: var(--ink-muted); }

.sb-letters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(3rem, 1fr));
  gap: 6px;
  margin-top: 14px;
}

.sb-letters button {
  min-height: 3rem;
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  background: var(--sb-tile-bg);
  color: var(--sb-tile-ink);
  font: 700 1.3rem var(--font-head, inherit);
  cursor: pointer;
}

.sb-rack--swap { margin-top: 12px; }

.sb-rules h3 { margin: 18px 0 4px; font-size: 1.05rem; }
.sb-rules p, .sb-rules ul { margin: 6px 0; }
.sb-rules li { margin: 5px 0; }

.sb-final {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 4px 18px;
  margin: 14px 0 0;
  font-variant-numeric: tabular-nums;
}

.sb-final b { text-align: right; }
.sb-final .sb-final__head { color: var(--ink-muted); }


/* ------------------------------------------------------------------ phone */

@media (max-width: 560px) {
  .sb-shell { padding: 6px 6px 14px; }
  .sb-buttons button span { font-size: 0.95rem; }
  .sb-buttons button i { display: none; }
}
