/* Squabble. Phone first, where it's cramped: the board takes the whole
   width (fifteen squares of about 25px on a phone) and is a container, so
   letters and marks scale with it (cqw). The rack, Play and the score a
   play would make sit right under it.

   Our own colours, not the original board's: warm for the word squares
   (brick for triple, apricot for double), cool for the letter squares
   (deep teal for triple, pale aqua for double), on a pale sage board. */
.sq {
  --sq-board: #dfe4d4;
  --sq-grid: #b8c2a9;
  --sq-tw: #c9503a;
  --sq-dw: #f1a98a;
  --sq-tl: #2b7a94;
  --sq-dl: #a9d6e0;
  --sq-tile: #f7e8c6;
  --sq-tile-edge: #c9ad75;
  --sq-tile-ink: #3a2f22;
  --sq-blank-ink: #a8432f;
  /* In one column (a phone, a narrow window) the board is no taller than
     the window leaves room for. A phone is narrower than that anyway. */
  width: min(40rem, 100%, max(20rem, calc(100svh - 25rem)));
  display: flex; flex-direction: column; gap: 0.4rem;
}
/* On a wide screen the board stands on the left, as tall as the window
   allows, and everything else (the news, the scores, the rack) in a
   column beside it, so nothing has to sit over the board. */
@media (min-width: 60rem) {
  .sq {
    width: auto; display: grid; column-gap: 1.5rem; row-gap: 0.5rem; align-items: start; align-content: start;
    grid-template-columns: min(40rem, calc(100svh - 13rem), calc(100vw - 25rem)) 20rem;
  }
  .sq > * { grid-column: 2; }
  .sq > .sq-board { grid-column: 1; grid-row: 1 / span 12; }
  /* The column is narrow: the words get a line, the buttons the next. */
  .sq-play { flex-wrap: wrap; }
  .sq-preview { flex: 1 0 100%; }
}
.sq .status { margin: 0; }
@media (max-width: 40rem) { .sq .status { font-size: 1.05rem; } }
/* Whose turn it is, and what is left in the bag, on one line. */
.sq-statusrow { display: flex; align-items: baseline; justify-content: space-between; gap: 0.2rem 0.8rem; flex-wrap: wrap; }

/* What happened last, first on the page: the word in big letters and a
   line saying who and for how much. Challenge sits in it (and Let it
   stand, on a play that would end the game), and during a challenge the
   referee's Word and Not a word, or I'll referee when the referee is
   away. A challenge waiting on the referee is amber, between a play and
   a play taken back. */
.sq-news {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.8rem; padding: 0.4rem 0.8rem;
  border-radius: var(--radius); background: var(--felt); color: var(--felt-ink);
}
.sq-news.bingo { background: #8a6a12; }
.sq-news.phony { background: #9c3527; }
.sq-news.challenge { background: #a3560f; }
.sq-news.stands { background: var(--felt-dark); }
.sq-news.quiet { background: var(--paper-2); color: var(--ink); }
.sq-news-text { display: flex; align-items: baseline; gap: 0.6rem; flex: 1 1 14rem; min-width: 0; }
.sq-news-word {
  flex: none; font-size: 1.7rem; line-height: 1.1; font-weight: 900; letter-spacing: 0.06em;
  overflow-wrap: anywhere;
}
.sq-news-detail { min-width: 0; font-size: 0.85rem; line-height: 1.25; }
.sq-news-earlier { flex: 1 0 100%; margin: 0; font-size: 0.8rem; opacity: 0.9; }
/* It shrinks to the banner and wraps its buttons, so a ruling on three
   words fits a phone. */
.sq-judge { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; flex: 0 1 auto; min-width: 0; }
.sq-judge .gn-button { min-height: 2.6rem; }
@media (prefers-reduced-motion: no-preference) {
  .sq-news.gn-fresh { animation: sq-pop 0.6s cubic-bezier(.3, 1.5, .5, 1) calc(0s - var(--played, 0s)) both; }
}
@keyframes sq-pop {
  0% { transform: scale(0.7); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Who has what: names, scores, tiles in hand, and the bag. */
.sq-scores { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0; padding: 0; list-style: none; font-size: 0.85rem; }
.sq-score {
  display: flex; align-items: baseline; gap: 0.35rem; padding: 0.15rem 0.55rem;
  border: 2px solid var(--line); border-radius: 999px; background: var(--card);
}
.sq-score.turn { border-color: var(--accent); }
.sq-score.me .sq-score-name { font-weight: 700; }
.sq-score-points { font-size: 1rem; }
.sq-score-tiles { color: var(--ink-soft); font-size: 0.75rem; }
.sq-bag { color: var(--ink-soft); font-size: 0.85rem; }
.sq-lost { color: var(--bad); font-weight: 600; }
/* Who rules on challenges, beside their name: small, but on a phone too. */
.sq-ref-tag {
  padding: 0 0.35rem; border-radius: 999px; background: var(--paper-2); color: var(--ink-soft);
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.02em;
}
/* A phone is short as well as narrow, and a page taller than the screen
   leaves the board's bottom rows under the sticky strip until the player
   scrolls (night 5). So what sits above the board is kept to little:
   the scores in one row for four players (the number of tiles, its word
   left for a screen reader) and a banner with less padding. */
@media (max-width: 40rem) {
  .sq-scores { gap: 0.25rem; font-size: 0.8rem; }
  .sq-score { gap: 0.25rem; padding: 0.1rem 0.45rem; border-width: 1.5px; }
  .sq-score-points { font-size: 0.95rem; }
  .sq-score-tiles { font-size: 0.72rem; }
  .sq-long { font-size: 0; }
  .sq-news { padding: 0.25rem 0.6rem; }
  .sq-news-word { font-size: 1.5rem; }
}

/* The board. */
.sq-board {
  container-type: inline-size;
  display: grid; grid-template-columns: repeat(15, minmax(0, 1fr)); gap: 1px; padding: 1px;
  background: var(--sq-grid); border-radius: 4px;
  user-select: none; -webkit-user-select: none;
}
.sq-sq {
  position: relative; aspect-ratio: 1; min-width: 0; box-sizing: border-box;
  display: flex; align-items: center; justify-content: center;
  margin: 0; padding: 0; border: 0; font: inherit; color: var(--ink);
  background: var(--sq-board); touch-action: manipulation;
}
.sq-sq.tw { background: var(--sq-tw); color: #fff; }
.sq-sq.dw { background: var(--sq-dw); color: #6b2a17; }
.sq-sq.tl { background: var(--sq-tl); color: #fff; }
.sq-sq.dl { background: var(--sq-dl); color: #17495a; }
.sq-mark { font-size: 2.3cqw; font-weight: 800; letter-spacing: -0.02em; opacity: 0.9; }
.sq-sq.star .sq-mark { font-size: 4.2cqw; }
button.sq-sq { cursor: pointer; }
button.sq-sq:not(.tile):hover { filter: brightness(1.08); box-shadow: inset 0 0 0 0.4cqw var(--accent); }
button.sq-sq:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; z-index: 1; }

/* A tile, on the board or the rack: ivory, with its value small in the corner. */
.sq-sq.tile, .sq-tile {
  background: var(--sq-tile); color: var(--sq-tile-ink);
  box-shadow: inset 0 -0.35cqw 0 var(--sq-tile-edge);
  border-radius: 0.5cqw;
}
.sq-sq.tile .sq-letter { font-size: 4.3cqw; font-weight: 800; line-height: 1; }
.sq-sq.tile .sq-value { position: absolute; right: 6%; bottom: 3%; font-size: 1.8cqw; font-weight: 700; }
.sq-sq.blank .sq-letter { color: var(--sq-blank-ink); }
.sq-sq.blank .sq-letter { font-weight: 600; }
/* Your own tiles not yet played: outlined in the accent colour. */
.sq-sq.draft { box-shadow: inset 0 0 0 0.5cqw var(--accent); background: #fff4dc; }
/* The last play that stands, and a play that may still be challenged. */
.sq-sq.last { box-shadow: inset 0 -0.35cqw 0 var(--sq-tile-edge), inset 0 0 0 0.45cqw #d9a21b; }
.sq-sq.pending { background: #fff1a6; box-shadow: inset 0 0 0 0.45cqw #c98a0b; }

/* The strip under the board: the preview and Play, then the rack. It does
   not stick to the bottom of the screen. It once did, over the Rules/Chat
   bar, and on a phone with four players and a banner it covered the
   board's last three rows until the page was scrolled (night 5). In the
   page, under the board, nothing is ever covered: the board and the rack
   fit one screen together once the page is scrolled a little, and on most
   phones with two players they fit as it is. */
.sq-dock { display: flex; flex-direction: column; gap: 0.35rem; padding: 0.2rem 0; }
/* One row on a phone: the words (wrapping in their own space), then the
   buttons, sized to their words, so the strip covers as little board as
   it can. */
.sq-play { display: flex; align-items: center; gap: 0.4rem; }
.sq-preview { margin: 0; flex: 1 1 0; min-width: 0; font-size: 0.85rem; line-height: 1.25; color: var(--ink-soft); }
.sq-play .gn-button { flex: none; min-height: 2.75rem; padding: 0.3rem 0.8rem; }
.sq-play-button { font-weight: 800; font-size: 1.05rem; }
.sq-word { font-weight: 700; color: var(--ink); }
.sq-hint { margin: 0; font-size: 0.85rem; line-height: 1.3; color: var(--ink-soft); }

/* The rack: seven tiles big enough for a thumb, and Shuffle beside them. */
.sq-rack-row { display: flex; align-items: center; gap: 0.4rem; }
.sq-rack {
  container-type: inline-size;
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0.3rem; flex: 1; max-width: 24rem;
}
.sq-tile, .sq-slot {
  position: relative; aspect-ratio: 1; min-width: 0; max-height: 3.4rem; box-sizing: border-box;
  display: flex; align-items: center; justify-content: center;
  margin: 0; padding: 0; border: 0; font: inherit; border-radius: 6px;
  touch-action: manipulation;
}
.sq-tile { box-shadow: inset 0 -3px 0 var(--sq-tile-edge); }
button.sq-tile { cursor: pointer; }
.sq-tile .sq-letter { font-size: min(1.45rem, 7.5cqw); font-weight: 800; line-height: 1; }
.sq-tile .sq-value { position: absolute; right: 8%; bottom: 6%; font-size: min(0.65rem, 3.4cqw); font-weight: 700; }
.sq-tile.picked { transform: translateY(-5px); box-shadow: 0 0 0 3px var(--accent), 0 4px 6px rgb(0 0 0 / 0.2); }
.sq-tile.marked { background: #d8cdb6; box-shadow: 0 0 0 3px var(--bad); }
.sq-slot { border: 2px dashed var(--line); }
.sq-shuffle { flex: none; min-height: 2.75rem; font-size: 1.3rem; padding: 0 0.7rem; }

/* What letter a blank stands for: the alphabet, a thumb's width each. */
.sq-blank-picker { display: flex; flex-direction: column; gap: 0.3rem; }
.sq-letters { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 0.25rem; }
.sq-letter-button {
  min-height: 2.4rem; min-width: 0; padding: 0; font: inherit; font-weight: 800; font-size: 1.1rem; cursor: pointer;
  background: var(--sq-tile); color: var(--sq-blank-ink); border: 0; border-radius: 6px;
  box-shadow: inset 0 -3px 0 var(--sq-tile-edge); touch-action: manipulation;
}

/* Exchange and Pass, under the strip. */
.sq-extras { display: flex; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.sq-extras .gn-leave { margin-top: 0; }
.sq-extras .gn-leave summary { padding: 0.45rem 0; min-height: 0; }

/* Who referees, under the board, and I'll referee for the others. */
.sq-referee { display: flex; align-items: baseline; gap: 0.3rem 1rem; flex-wrap: wrap; }
.sq-referee .gn-leave { margin-top: 0; }
.sq-referee .gn-leave summary { padding: 0.2rem 0; min-height: 0; font-size: 0.85rem; }

/* The end: what each rack added or took away. */
.sq-final { border-collapse: collapse; font-size: 0.95rem; }
.sq-final caption { text-align: left; padding-bottom: 0.3rem; color: var(--ink-soft); }
.sq-final th, .sq-final td { padding: 0.25rem 0.8rem 0.25rem 0; text-align: left; }
.sq-final th { font-size: 0.8rem; color: var(--ink-soft); font-weight: 600; }

.sq-log { font-size: 0.85rem; color: var(--ink-soft); }
.sq-log summary { cursor: pointer; padding: 0.4rem 0; }
.sq-log ol { margin: 0; padding-left: 1.2rem; }
