/* several blocks below set display, which would otherwise beat the hidden attribute */
[hidden] {
  display: none !important;
}

/* scrabble game UI — deliberately plain; colours come from /style.css tokens.
   Nothing here is precious: it exists so the game is playable before the page
   is designed. */

:root {
  --sc-square: #efe7ea;
  --sc-square-line: #d8ccd3;
  --sc-dl: #cfe0ef;
  --sc-tl: #a9c6e4;
  --sc-dw: #f2d4de;
  --sc-tw: #e7a8b8;
  --sc-tile: #f3e2c7;
  --sc-tile-line: #b99f77;
  --sc-tile-fg: #2a1f14;
  --sc-fresh: #8a3a78;
}

[data-theme="dark"], [data-theme="synthwave"], [data-theme="dusk-rose"], [data-theme="terminal"] {
  --sc-square: #2b2430;
  --sc-square-line: #3d3444;
  --sc-dl: #2f4a63;
  --sc-tl: #3a6288;
  --sc-dw: #5c2f43;
  --sc-tw: #86364f;
  --sc-tile: #d9c3a0;
  --sc-tile-line: #8a7050;
  --sc-tile-fg: #241a12;
  --sc-fresh: #f0a8dc;
}

body.scrabble-play article { display: none; }

.sc-stage {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.75rem 0.75rem 2rem;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 300px;
  gap: 1rem;
  align-items: start;
  font-family: var(--ui-font);
  font-size: 0.9rem;
}

@media (max-width: 820px) {
  .sc-stage {
    grid-template-columns: 1fr;
    gap: 0.75rem;
    padding: 0.5rem 0.5rem 2rem;
  }
}

/* ----- board ----- */

/* Gridlines are each cell's own top and left border, not gaps in a
   background: a 1px gap between fractional rows can round away entirely. */
.sc-board {
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  grid-template-rows: repeat(15, 1fr);
  border-right: 1px solid var(--sc-square-line);
  border-bottom: 1px solid var(--sc-square-line);
  aspect-ratio: 1;
  width: 100%;
  touch-action: manipulation;
}

.sc-cell {
  background: var(--sc-square);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(0.4rem, 1.6vw, 0.8rem);
  line-height: 1;
  color: var(--muted);
  padding: 0;
  border: 0;
  border-top: 1px solid var(--sc-square-line);
  border-left: 1px solid var(--sc-square-line);
  min-height: 0;
  cursor: pointer;
  overflow: hidden;
}

.sc-cell[data-premium="d"] { background: var(--sc-dl); }
.sc-cell[data-premium="t"] { background: var(--sc-tl); }
.sc-cell[data-premium="D"] { background: var(--sc-dw); }
.sc-cell[data-premium="T"] { background: var(--sc-tw); }

.sc-cell.sc-target { outline: 2px solid var(--sc-fresh); outline-offset: -2px; }

.sc-cell .sc-onboard {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sc-tile);
  color: var(--sc-tile-fg);
  border: 1px solid var(--sc-tile-line);
  font-weight: 600;
}

.sc-cell .sc-onboard { position: relative; }
.sc-cell .sc-onboard sub {
  position: absolute;
  right: 1px;
  bottom: 1px;
  font-size: 0.65em;
  font-weight: 400;
  font-style: normal;
  line-height: 1;
}

.sc-cell .sc-onboard.sc-blank { font-style: italic; opacity: 0.85; }

/* An either-or tile: shows the sound it was played as, with a corner notch to
   say the tile underneath is the two-way one. */
.sc-cell .sc-onboard.sc-either {
  background-image: linear-gradient(135deg, transparent 72%, var(--sc-tile-line) 72%);
}
.sc-cell .sc-onboard.sc-pending { box-shadow: inset 0 0 0 2px var(--sc-fresh); }

/* ----- rack ----- */

.sc-rack {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0.5rem 0;
}

.sc-tile {
  min-width: 2.2rem;
  height: 2.4rem;
  padding: 0 0.35rem;
  background: var(--sc-tile);
  color: var(--sc-tile-fg);
  border: 1px solid var(--sc-tile-line);
  border-radius: 3px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.15rem;
}

.sc-tile sub { font-size: 0.6em; font-weight: 400; }
.sc-tile[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--sc-fresh); }
.sc-tile.sc-used { opacity: 0.35; }
.sc-tile.sc-picked { box-shadow: 0 0 0 2px var(--accent); }

/* ----- controls ----- */

.sc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.5rem 0;
}

.sc-actions button, .sc-form button {
  font-family: var(--ui-font);
  font-size: 0.85rem;
  padding: 0.4rem 0.7rem;
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--rule);
  border-radius: 3px;
  cursor: pointer;
}

.sc-actions button:hover:not(:disabled), .sc-form button:hover { border-color: var(--fg); }
.sc-actions button:disabled { opacity: 0.4; cursor: default; }
.sc-actions button.sc-primary { border-color: var(--accent); color: var(--accent); }

.sc-side > section {
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.6rem;
  margin-bottom: 0.6rem;
}

.sc-side h3 {
  font-size: 0.75rem;
  text-transform: lowercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 0.35rem;
  font-family: var(--ui-font);
  font-weight: 500;
}

.sc-scores { list-style: none; margin: 0; padding: 0; }
.sc-scores li { display: flex; justify-content: space-between; gap: 0.5rem; padding: 0.1rem 0; }
.sc-scores li.sc-active { font-weight: 700; color: var(--accent); }
.sc-scores .sc-meta { color: var(--muted); font-size: 0.8em; }

.sc-note { color: var(--muted); margin: 0.2rem 0; }
.sc-error { color: #b3324b; margin: 0.2rem 0; }

.sc-llm {
  display: inline-block;
  font-size: 0.65rem;
  padding: 0 0.3rem;
  border: 1px solid var(--rule);
  border-radius: 2px;
  color: var(--muted);
  vertical-align: 0.1em;
}

/* ----- word lookup ----- */

.sc-lookup {
  /* the site paints an overlay over the body; sit above it, as .sc-guide does */
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 0.75rem 0.75rem;
  font-family: var(--ui-font);
  font-size: 0.9rem;
}

.sc-lookup h3 {
  font-size: 0.75rem;
  text-transform: lowercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 0.35rem;
  font-weight: 500;
}

.sc-lookup-row {
  display: flex;
  gap: 0.35rem;
  max-width: 28rem;
}

.sc-lookup-row input {
  flex: 1;
  min-width: 0;
  font-family: var(--ui-font);
  font-size: 0.9rem;
  padding: 0.35rem;
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--rule);
  border-radius: 3px;
}

.sc-lookup-row button, .sc-lookup-more {
  font-family: var(--ui-font);
  font-size: 0.85rem;
  padding: 0.35rem 0.7rem;
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--rule);
  border-radius: 3px;
  cursor: pointer;
}

.sc-lookup-row button:hover, .sc-lookup-more:hover { border-color: var(--fg); }

.sc-lookup-out { margin-top: 0.4rem; color: var(--muted); }

.sc-lookup-plays {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  margin-bottom: 0.35rem;
}

.sc-lookup-play {
  color: var(--fg);
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.sc-lookup-more { padding: 0.15rem 0.5rem; font-size: 0.75rem; }

.sc-phony {
  display: inline-block;
  font-size: 0.65rem;
  padding: 0 0.3rem;
  border: 1px solid #b3324b;
  border-radius: 2px;
  color: #b3324b;
  vertical-align: 0.1em;
}

.sc-log { list-style: none; margin: 0; padding: 0; max-height: 16rem; overflow-y: auto; }
.sc-log li { cursor: pointer; }
.sc-log li.sc-log-at { background: color-mix(in srgb, var(--accent) 14%, transparent); border-left: 3px solid var(--accent); padding-left: 0.3rem; }
.sc-log li { padding: 0.15rem 0; border-bottom: 1px dotted var(--rule); }
.sc-log .sc-word { font-weight: 600; }

.sc-form { display: flex; flex-direction: column; gap: 0.5rem; max-width: 26rem; }
.sc-form label { display: flex; flex-direction: column; gap: 0.2rem; color: var(--muted); font-size: 0.8rem; }
.sc-form select, .sc-form input {
  font-family: var(--ui-font);
  font-size: 0.9rem;
  padding: 0.35rem;
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--rule);
  border-radius: 3px;
}

.sc-share { display: flex; gap: 0.3rem; }
.sc-share input { flex: 1; min-width: 0; }

.sc-blank-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0.4rem 0;
  max-height: 40vh;
  overflow-y: auto;
}

.sc-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  padding: 1rem;
}

.sc-modal > div {
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.75rem;
  max-width: 24rem;
  font-family: var(--ui-font);
}

/* ----- tile guide ----- */

.sc-guide {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 0.75rem 2rem;
  font-family: var(--ui-font);
  font-size: 0.85rem;
}

.sc-guide h3 {
  font-size: 0.75rem;
  text-transform: lowercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 0.5rem;
  font-weight: 500;
}

.sc-guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr));
  gap: 0.5rem;
}

.sc-guide-card {
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.45rem 0.55rem;
}

.sc-guide-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}

.sc-guide-head .sc-tile { cursor: default; }

.sc-guide-ex {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.05rem 0;
}

.sc-guide-ipa { color: var(--muted); white-space: nowrap; }
.sc-guide-ipa b { color: var(--accent); font-weight: 700; }

/* the guide card of the tile under the pointer */
.sc-tip {
  position: fixed;
  z-index: 20;
  pointer-events: none;
  background: var(--bg);
  border-radius: 4px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
  font-family: var(--ui-font);
  font-size: 0.85rem;
  min-width: 11.5rem;
}

/* ----- unseen tiles ----- */

.sc-unseen {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.6rem;
  line-height: 1.5;
}

.sc-unseen-item { white-space: nowrap; color: var(--muted); }
.sc-unseen-item b { color: var(--fg); font-weight: 600; }

/* ----- clocks, and the play that was just made ----- */

.sc-clock { font-variant-numeric: tabular-nums; color: var(--muted); }
.sc-scores li.sc-active .sc-clock { color: var(--accent); }
.sc-clock.sc-clock-low { color: #b3324b !important; font-weight: 700; }

.sc-cell .sc-onboard.sc-last { box-shadow: inset 0 0 0 2px var(--accent); filter: brightness(1.1); }
/* a ring sits where the value does: move the value inside it */
.sc-cell .sc-onboard.sc-last sub, .sc-cell .sc-onboard.sc-pending sub { right: 3px; bottom: 3px; }

/* ----- history ----- */

.sc-history { display: flex; gap: 0.3rem; margin-bottom: 0.35rem; }
.sc-history button {
  font-family: var(--ui-font);
  font-size: 0.8rem;
  padding: 0.1rem 0.55rem;
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--rule);
  border-radius: 3px;
  cursor: pointer;
}
.sc-history button:hover { border-color: var(--fg); }
.sc-board.sc-past { filter: saturate(0.6); }

/* ----- analysis ----- */

.sc-analyze {
  font-family: var(--ui-font);
  font-size: 0.8rem;
  padding: 0.25rem 0.6rem;
  margin-bottom: 0.35rem;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 3px;
  cursor: pointer;
}
.sc-engine { font-size: 0.8em; color: var(--muted); }
.sc-engine-best { cursor: pointer; text-decoration: underline dotted; }
.sc-engine-best:hover { color: var(--fg); }
.sc-engine-bad { color: #b3324b; }
.sc-cell .sc-onboard.sc-ghost { opacity: 0.55; box-shadow: inset 0 0 0 2px var(--accent); }

.sc-chart { margin-bottom: 0.5rem; }
.sc-chart svg { width: 100%; height: 90px; display: block; }
.sc-chart-label { font-size: 9px; fill: var(--muted); font-family: var(--ui-font); }
.sc-chart-top { fill: var(--accent); opacity: 0.06; }
.sc-chart-area { fill: var(--accent); opacity: 0.18; }
.sc-chart-mid { stroke: var(--rule); stroke-width: 1; }
.sc-chart-line { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.sc-chart-pt { fill: transparent; cursor: pointer; }
.sc-chart-pt.sc-chart-at { fill: var(--accent); }
.sc-chart-legend { display: flex; justify-content: space-between; font-size: 0.7rem; color: var(--muted); }

.sc-engine-panel h3 { margin-bottom: 0.3rem; }
.sc-engine-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.sc-engine-table td { padding: 0.12rem 0.25rem; white-space: nowrap; cursor: pointer; border-bottom: 1px dotted var(--rule); }
.sc-engine-table tr:hover td { color: var(--accent); }
.sc-engine-rank, .sc-engine-pos, .sc-engine-leave { color: var(--muted); }
.sc-engine-word { font-weight: 600; }
.sc-engine-score, .sc-engine-eq { text-align: right; font-variant-numeric: tabular-nums; }
.sc-engine-eq { font-weight: 600; }
.sc-engine-table tr.sc-engine-played td { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.sc-engine-table tr.sc-engine-shown td { outline: 1px solid var(--accent); }
.sc-chart { --p0: var(--accent); --p1: #4a90d9; --p2: #4caf50; --p3: #d9a000; }
.sc-chart-p0 { stroke: var(--p0); } .sc-chart-p1 { stroke: var(--p1); }
.sc-chart-p2 { stroke: var(--p2); } .sc-chart-p3 { stroke: var(--p3); }
.sc-chart-key { display: flex; flex-wrap: wrap; gap: 0.1rem 0.8rem; font-size: 0.7rem; color: var(--muted); margin-top: 0.15rem; }
.sc-chart-key i { display: inline-block; width: 0.8rem; height: 2px; margin-right: 0.3rem; vertical-align: middle; }
.sc-chart-key-p0 i { background: var(--p0); } .sc-chart-key-p1 i { background: var(--p1); }
.sc-chart-key-p2 i { background: var(--p2); } .sc-chart-key-p3 i { background: var(--p3); }
.sc-engine-spell { font-weight: 400; color: var(--muted); margin-left: 0.3rem; }
.sc-form input[type="range"] { border: none; padding: 0; accent-color: var(--fg); }
.sc-bot-difficulties { display: flex; flex-direction: column; gap: 0.5rem; }
.sc-bot-difficulties:empty { display: none; }
