/* Deliberately plain: browser defaults plus what the board needs. Black on white. */

:root {
  color: #000;
  background: #fff;
  font-family: "Gentium Plus", "GFS Didot", "New Athena Unicode", "Noto Serif", "Times New Roman", serif;
  line-height: 1.45;
}

body {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0.5rem 1rem 3rem;
}

a { color: #000; }

:focus-visible {
  outline: 3px solid #000;
  outline-offset: 2px;
}

button, input, textarea, select { font: inherit; }

button {
  color: #000;
  background: #fff;
  border: 1px solid #000;
  padding: 0.15rem 0.6rem;
  min-height: 2rem;
  cursor: pointer;
}
button:disabled { color: #767676; border-color: #767676; cursor: default; }
button[aria-pressed="true"] { background: #000; color: #fff; }

input, textarea { border: 1px solid #000; padding: 0.2rem 0.3rem; background: #fff; color: #000; }

fieldset { border: 1px solid #000; margin: 0.75rem 0; }

summary { cursor: pointer; }
summary h2 { display: inline; font-size: 1.25rem; }
details { margin: 1rem 0; }

.hint { font-size: 0.9rem; }
.code { font-family: ui-monospace, Consolas, monospace; letter-spacing: 0.1em; }

#error:empty, #preview:empty { display: none; }
#error { border: 2px solid #000; padding: 0.4rem 0.6rem; font-weight: bold; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip { position: absolute; left: -100vw; }
.skip:focus { left: 0.5rem; top: 0.5rem; background: #fff; padding: 0.25rem; }

/* ---- game page layout ---- */

.game-header { display: flex; flex-wrap: wrap; gap: 0 1.5rem; align-items: baseline; border-bottom: 1px solid #000; }
.game-header p { margin: 0.5rem 0; }

#layout { display: block; }
body.dict-open { max-width: 90rem; }
body.dict-open #layout { display: grid; grid-template-columns: minmax(0, 1fr) 22rem; gap: 2rem; align-items: start; }
@media (max-width: 60rem) {
  body.dict-open #layout { display: block; }
}

#dictionary { border-left: 1px solid #000; padding-left: 1rem; }
@media (max-width: 60rem) {
  #dictionary { border-left: 0; border-top: 1px solid #000; padding-left: 0; }
}
#dict-q { width: 100%; box-sizing: border-box; }
#dict-results { padding-left: 1.25rem; }
#dict-results h3 { margin: 0.75rem 0 0.25rem; font-size: 1.2rem; }
#dict-results dl { margin: 0.25rem 0; }
#dict-results dt { font-weight: bold; font-size: 0.9rem; }
#dict-results dd { margin: 0 0 0.3rem 1rem; }
#suggest textarea, #suggest input { width: 100%; box-sizing: border-box; }

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

#board {
  --cell: min(2.4rem, calc((100vw - 3rem) / 16));
  border-collapse: collapse;
  margin: 0.5rem 0;
}
#board th {
  font-weight: normal;
  font-size: 0.75rem;
  width: var(--cell);
  height: 1rem;
  padding: 0 0.15rem;
  text-align: center;
}
#board td {
  width: var(--cell);
  height: var(--cell);
  min-width: var(--cell);
  border: 1px solid #000;
  padding: 0;
  text-align: center;
  vertical-align: middle;
  position: relative;
  cursor: pointer;
  line-height: 1;
}
#board td:focus { outline: 3px solid #000; outline-offset: -4px; }
#board td.tile:focus { outline-color: #fff; }

.premium-label { font-size: calc(var(--cell) * 0.32); font-family: ui-monospace, Consolas, monospace; }
#board td.p3W { border-width: 3px; border-style: double; }
#board td.p2W { border-style: double; border-width: 3px; }
#board td.p3L .premium-label, #board td.p3W .premium-label { font-weight: bold; }
#board td.centre:not(.tile) .premium-label::before { content: "★ "; }

#board td.tile { background: #000; color: #fff; }
#board td.tile.pending { background: #fff; color: #000; outline: 2px dashed #000; outline-offset: -5px; }
#board td.tile.pending.selected { outline: 3px solid #000; outline-offset: -5px; }
#board td.last .letter { text-decoration: underline; text-underline-offset: 0.15em; }

#board .letter { font-size: calc(var(--cell) * 0.58); }
#board .pts, .rack-tile .pts {
  position: absolute;
  right: 0.12rem;
  bottom: 0.05rem;
  font-size: calc(var(--cell) * 0.26);
}

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

#rack { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.5rem 0; }
.rack-tile {
  position: relative;
  width: 2.8rem;
  height: 2.8rem;
  padding: 0;
  --cell: 2.8rem;
}
.rack-tile .letter { font-size: 1.6rem; }
.mark-symbol { font-size: 1.3rem; }
.blank-letter { min-width: 2.5rem; font-size: 1.4rem; margin: 0.1rem; }
#marks-buttons button { margin: 0.15rem 0; }
#actions button { margin: 0.15rem 0; }

#scores table { border-collapse: collapse; }
#scores th, #scores td { border: 1px solid #000; padding: 0.2rem 0.6rem; text-align: left; }

#log { max-height: 20rem; overflow-y: auto; }

dialog { border: 2px solid #000; }
dialog::backdrop { background: rgb(0 0 0 / 0.4); }

/* ---- admin ---- */
table { border-collapse: collapse; }
body > table th, body > table td, #tile-table th, #tile-table td { border: 1px solid #000; padding: 0.25rem 0.5rem; vertical-align: top; text-align: left; }

@media (forced-colors: active) {
  #board td.tile { forced-color-adjust: none; background: CanvasText; color: Canvas; }
  #board td.tile.pending { background: Canvas; color: CanvasText; }
}

/* ---- drag and drop ---- */
.rack-tile, #board td.pending, #marks-buttons button[data-mark] { touch-action: none; }
body.dragging, body.dragging * { cursor: grabbing !important; user-select: none; -webkit-user-select: none; }
.drag-ghost {
  position: fixed;
  z-index: 10;
  pointer-events: none;
  transform: translate(-50%, -50%);
  width: 2.6rem;
  height: 2.6rem;
  --cell: 2.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: #000;
  border: 2px solid #000;
  box-shadow: 3px 3px 0 #000;
}
.drag-ghost .letter { font-size: 1.5rem; }
.drag-ghost .pts { position: absolute; right: 0.15rem; bottom: 0.05rem; font-size: 0.7rem; }
.drag-source { opacity: 0.35; }
.drop-target { outline: 3px dashed #000 !important; outline-offset: -4px !important; }
#rack.drop-target { outline-offset: 2px !important; }
button[aria-disabled="true"] { color: #767676; border-color: #767676; }
