.setup { display: grid; gap: 10px; margin-bottom: 14px; }
.opt { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.opt[hidden] { display: none; }
.lbl { width: 64px; font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }

.scores { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.score { display: flex; align-items: center; gap: 10px; padding: 7px 14px; border-radius: 14px; background: var(--surface); border: 2px solid var(--line); box-shadow: var(--shadow); flex: 1 1 120px; }
.score.turn { border-color: var(--gold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 28%, transparent), var(--shadow); }
.score .nm { font-weight: 700; font-size: 0.88rem; }
.score b { margin-left: auto; font-size: 1.35rem; font-variant-numeric: tabular-nums; }

.board-wrap { position: relative; display: grid; place-items: center; margin-top: 6px; }
/* on a phone the 15x15 board has small squares: Zoom makes them bigger and lets the board scroll inside its frame */
#zoomBtn { display: none; }
@media (max-width: 600px) {
  #zoomBtn { display: inline-flex; }
  .board-wrap.zoom { place-items: start; overflow: auto; max-height: 72vh; padding: 8px; margin-inline: -8px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .board-wrap.zoom .board { --cell: 34px; touch-action: pan-x pan-y; }
}
.board {
  --cell: min(calc((100vw - 72px) / 15), 40px); /* 15 cells + gaps + padding inside the 16px page gutters */
  display: grid;
  grid-template-columns: repeat(15, var(--cell));
  grid-template-rows: repeat(15, var(--cell));
  gap: 2px;
  padding: 6px;
  border-radius: 14px;
  background: #1f6b4a;
  box-shadow: 0 0 0 5px #4a2e17, 0 20px 40px rgba(0, 0, 0, 0.45), inset 0 0 14px rgba(0, 0, 0, 0.45);
  touch-action: manipulation;
}
.sq {
  position: relative;
  display: grid;
  place-items: center;
  padding: 0;
  font: 800 calc(var(--cell) * 0.3) var(--font);
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.92);
  background: #2a8a62;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
  touch-action: manipulation;
}
.sq.TW { background: #c0352f; }
.sq.DW { background: #e98aa0; color: #5a1426; }
.sq.TL { background: #3569c9; }
.sq.DL { background: #8fc3ee; color: #0e3354; }
.sq.star { background: #e98aa0; color: #5a1426; font-size: calc(var(--cell) * 0.6); }
.sq:disabled { cursor: default; }
.sq:focus-visible { outline: 3px solid #fff; outline-offset: -2px; z-index: 3; }
.sq.live:not(.has):hover { filter: brightness(1.18); }

.tile {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  font: 800 calc(var(--cell) * 0.56) var(--font);
  color: #2b1d0b;
  background: linear-gradient(160deg, #fbe7b0, #e4c378);
  border-radius: 5px;
  box-shadow: 0 2px 0 #a47a2c, 0 3px 5px rgba(0, 0, 0, 0.4);
  text-transform: uppercase;
}
.tile sub { position: absolute; right: 12%; bottom: 6%; font-size: 0.4em; font-weight: 700; vertical-align: baseline; }
.tile.blank { color: #3c4f9c; }
.tile.blank sub { display: none; }
.sq.last .tile { box-shadow: 0 0 0 2px var(--gold), 0 2px 0 #a47a2c, 0 0 10px rgba(255, 210, 90, 0.9); }
.sq.staged .tile { background: linear-gradient(160deg, #e5f0ff, #b9d2f5); outline: 2px dashed #3569c9; outline-offset: -2px; }
.sq.hinted .tile { animation: hintPulse 1s ease-in-out infinite; }
@keyframes hintPulse { 50% { filter: brightness(1.25); } }
html[data-saver="on"] .sq.hinted .tile { animation: none; }

.cover { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; text-align: center; border-radius: 14px; background: rgba(10, 14, 26, 0.88); backdrop-filter: blur(6px); color: #fff; padding: 20px; }
.cover[hidden] { display: none; }
.cover p { font-size: 1.15rem; font-weight: 700; margin: 0 0 14px; }
.preview { min-height: 1.6em; margin: 8px 0 0; text-align: center; font-weight: 700; color: var(--muted); }
.preview.ok { color: var(--green); }
.preview.bad { color: var(--red); }

.rackbar { display: grid; gap: 10px; justify-items: center; margin-top: 4px; }
.rack { --rt: min(calc((100vw - 96px) / 7), 56px); display: flex; gap: 6px; padding: 10px 14px; border-radius: 14px; background: #6a4524; box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.5), 0 0 0 3px #4a2e17; min-height: calc(var(--rt) + 20px); }
.rt { position: relative; width: var(--rt); height: var(--rt); padding: 0; font: 800 calc(var(--rt) * 0.55) var(--font); color: #2b1d0b; background: linear-gradient(160deg, #fbe7b0, #e4c378); border: 0; border-radius: 7px; box-shadow: 0 3px 0 #a47a2c, 0 5px 8px rgba(0, 0, 0, 0.4); cursor: pointer; touch-action: manipulation; transition: transform 0.12s; }
.rt sub { position: absolute; right: 10%; bottom: 6%; font-size: 0.38em; font-weight: 700; }
.rt:hover:not(:disabled) { transform: translateY(-3px); }
.rt.sel { transform: translateY(-8px); box-shadow: 0 0 0 3px var(--gold), 0 3px 0 #a47a2c, 0 8px 10px rgba(0, 0, 0, 0.4); }
.rt.marked { opacity: 0.55; transform: translateY(6px); box-shadow: 0 0 0 3px var(--red), 0 2px 0 #a47a2c; }
.rt.used { visibility: hidden; }
.rt:disabled { cursor: default; filter: saturate(0.6); }
.rt:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.rack.dim { opacity: 0.6; }
.acts { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.bagnote { text-align: center; color: var(--muted); font-size: 0.85rem; margin: 10px 0 0; }

.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(6, 10, 22, 0.7); backdrop-filter: blur(4px); }
.modal[hidden] { display: none; }
.modal .box { width: min(420px, 100%); display: grid; gap: 14px; justify-items: center; padding: 22px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line-strong); box-shadow: var(--shadow-lg); text-align: center; }
.modal h2 { margin: 0; font-size: 1.3rem; }
.letters { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; width: 100%; }
.letters button { font: 800 1.1rem var(--font); padding: 9px 0; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 10px; cursor: pointer; }
.letters button:hover { background: var(--gold-soft); border-color: var(--gold); }
#endBody { width: 100%; display: grid; gap: 6px; }
#endBody .row { display: flex; justify-content: space-between; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); font-weight: 700; }
#endBody .row.win { background: var(--gold-soft); box-shadow: 0 0 0 2px var(--gold) inset; }

.rules { margin: 20px 0 0; }
.rules summary { cursor: pointer; font-weight: 800; }
.rules ul { margin: 10px 0 0; padding-left: 20px; color: var(--muted); line-height: 1.6; }
@media (max-width: 520px) { .acts .g-btn { padding-left: 12px; padding-right: 12px; } }
