/* ===========================================================
   10K TAVERN — Sudoku
   Builds on /styles.css (felt, brass, bone, the two themes).
   The board is a bone card laid on the felt, like the scoreboard
   plaques; the number pad is a row of bone tiles, like the dice.
   =========================================================== */

/* -------------------- difficulty picker -------------------- */
.sd-levels{ grid-template-columns: repeat(4, 1fr); }
@media (max-width: 860px){ .sd-levels{ grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px){ .sd-levels{ grid-template-columns: minmax(0,1fr); } }
.sd-level-best{
  font-family: var(--mono);
  font-size: 0.75rem;
  color: rgba(var(--fg-rgb),0.45);
  margin-top: auto;
  padding-top: 6px;
}
.sd-resume{ text-align:center; margin-top: 24px; }

/* -------------------- ledger -------------------- */
.sd-level{ font-family: var(--display) !important; font-size: 1.45rem !important; }
.plaque .p-name{ justify-content: space-between; }
.sd-pause{
  font-family: var(--body);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--pine);
  background: rgba(var(--pine-rgb),0.14);
  border: none;
  border-radius: 4px;
  padding: 3px 8px;
}
.sd-pause:hover{ background: rgba(var(--pine-rgb),0.24); }

/* On narrow screens the three plaques sit side by side above the board. */
@media (max-width: 860px){
  .felt .ledger{ flex-direction: row; gap: 8px; }
  .felt .ledger .plaque{ flex: 1; min-width: 0; padding: 10px 12px; }
  .felt .ledger .p-name{ font-size: 0.85rem; }
  .felt .ledger .p-score{ font-size: 1.2rem; }
  .sd-level{ font-size: 1.1rem !important; }
  .sd-pause-word{ display: none; }
  .sd-pause{ padding: 2px 6px; }
  .felt .ledger .p-onboard{ font-size: 0.64rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

/* -------------------- board -------------------- */
.sd-tray{
  min-height: 0;
  padding: 18px;
  align-items: center;
  justify-content: center;
}
@media (max-width: 640px){ .sd-tray{ padding: 10px; border-radius: 12px; } }

.sd-board-wrap{
  position: relative;
  width: 100%;
  max-width: 540px;
}
/* On a laptop screen, size the board so the number pad and buttons still
   fit without scrolling. Phones scroll anyway, so they keep the full width. */
@media (min-width: 861px){
  .sd-board-wrap{ max-width: min(540px, max(360px, calc(100vh - 360px))); }
}
.sd-board{
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  aspect-ratio: 1 / 1;
  width: 100%;
  background: linear-gradient(180deg, var(--bone-light), var(--bone));
  border: 3px solid var(--ink);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 3px 0 rgba(0,0,0,0.18), 0 10px 24px rgba(0,0,0,0.3);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.sd-board.is-paused{ filter: blur(9px); pointer-events: none; }

.sd-cell{
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-right: 1px solid rgba(var(--ink-rgb),0.16);
  border-bottom: 1px solid rgba(var(--ink-rgb),0.16);
  background: transparent;
  padding: 0;
  margin: 0;
  color: var(--ink);
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(1.15rem, 5.6vw, 1.9rem);
  line-height: 1;
  cursor: pointer;
  min-width: 0;
  -webkit-tap-highlight-color: transparent;
}
/* Heavier ink lines between the 3×3 boxes */
.sd-cell.c-2, .sd-cell.c-5{ border-right: 2px solid var(--ink); }
.sd-cell.c-8{ border-right: none; }
.sd-cell.r-2, .sd-cell.r-5{ border-bottom: 2px solid var(--ink); }
.sd-cell.r-8{ border-bottom: none; }

.sd-cell:focus{ outline: none; }

/* Givens are printed in ink; your numbers are written in pine,
   hints in brass, wrong ones in clay. */
.sd-cell.given{ font-weight: 700; cursor: default; }
.sd-cell.entered{ color: var(--pine); font-family: var(--body); font-weight: 600; }
.sd-cell.hinted{ color: var(--brass); font-family: var(--body); font-weight: 700; }
[data-theme="casino"] .sd-cell.hinted{ color: var(--brass-bright); }
.sd-cell.wrong{ color: var(--clay); }
.sd-cell.clash{ background: rgba(166,61,47,0.14); }
[data-theme="casino"] .sd-cell.clash{ background: rgba(230,57,70,0.2); }

/* Highlights: the selected square's row/column/box, matching numbers,
   then the selected square itself on top. */
.sd-cell.peer{ background: rgba(var(--ink-rgb),0.06); }
.sd-cell.same{ background: rgba(var(--brass-rgb),0.24); }
.sd-cell.selected{
  background: rgba(var(--brass-rgb),0.42);
  box-shadow: inset 0 0 0 2px var(--brass);
}
.sd-cell.clash.selected{ background: rgba(166,61,47,0.28); }

/* Pencil marks: a tiny 3×3 grid inside the square */
.sd-notes{
  position: absolute;
  inset: 2px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  font-family: var(--mono);
  font-weight: 500;
  font-size: clamp(0.46rem, 1.9vw, 0.68rem);
  color: rgba(var(--ink-rgb),0.62);
  pointer-events: none;
}
.sd-notes span{ display:flex; align-items:center; justify-content:center; }
.sd-notes span.lit{ color: var(--ink); background: rgba(var(--brass-rgb),0.45); border-radius: 3px; font-weight: 700; }

/* A finished row, column or box gives a quick brass shimmer */
.sd-cell.flash{ animation: sd-flash 0.7s ease-out; }
@keyframes sd-flash{
  0%{ background: rgba(var(--brass-rgb),0.6); }
  100%{ background: transparent; }
}
.sd-board.solved .sd-cell{ cursor: default; }

/* Paused cover */
.sd-paused{
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.sd-paused span{
  font-family: var(--display);
  font-size: 2rem;
  font-weight: 600;
  color: var(--fg);
  text-shadow: 0 2px 10px rgba(0,0,0,0.6);
}

/* -------------------- number pad (bone tiles, like dice) -------------------- */
.sd-pad{
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 576px;
  align-self: center;
}
.sd-key{
  position: relative;
  aspect-ratio: 1 / 1.12;
  border: 1px solid rgba(var(--ink-rgb),0.15);
  border-radius: 10px;
  background: linear-gradient(180deg, var(--bone-light), var(--bone));
  color: var(--ink);
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.1rem, 5vw, 1.7rem);
  box-shadow: 0 3px 0 rgba(0,0,0,0.22), 0 6px 12px rgba(0,0,0,0.2);
  transition: transform 0.12s ease, background 0.12s ease;
  padding: 0;
  min-width: 0;
  -webkit-tap-highlight-color: transparent;
}
.sd-key:hover:not(:disabled){ transform: translateY(-2px); }
.sd-key:active:not(:disabled){ transform: translateY(1px); box-shadow: 0 1px 0 rgba(0,0,0,0.22); }
.sd-key small{
  position: absolute;
  right: 6px;
  bottom: 4px;
  font-family: var(--mono);
  font-size: clamp(0.5rem, 1.8vw, 0.66rem);
  font-weight: 500;
  color: rgba(var(--ink-rgb),0.45);
}
.sd-key.active{ background: linear-gradient(180deg, var(--brass-bright), var(--brass)); color: var(--felt-deep); }
.sd-key.active small{ color: rgba(0,0,0,0.5); }
.sd-key.done{ opacity: 0.28; }
.sd-pad.notes-mode .sd-key{ font-family: var(--mono); font-weight: 500; font-size: clamp(0.9rem, 3.8vw, 1.25rem); }
@media (max-width: 640px){ .sd-pad{ gap: 5px; } .sd-key{ border-radius: 8px; } .sd-key small{ right: 3px; bottom: 2px; } }

/* -------------------- controls -------------------- */
.sd-controls{
  justify-content: center;
  flex-wrap: wrap;
}
.sd-controls .btn-secondary{ padding: 11px 20px; }
.sd-toggle[aria-pressed="true"]{
  border-color: var(--brass-bright);
  color: var(--brass-bright);
  background: rgba(var(--brass-rgb),0.12);
}
@media (max-width: 640px){
  .sd-controls{ gap: 6px; display: grid; grid-template-columns: repeat(4, 1fr); }
  .sd-controls .btn-secondary{ padding: 10px 4px; font-size: 0.8rem; white-space: nowrap; }
}

/* -------------------- modals -------------------- */
.sd-howto{
  font-size: 0.88rem;
  line-height: 1.6;
  color: rgba(var(--ink-rgb),0.8);
  padding-left: 20px;
  margin: 0 0 18px;
}
#solved-body{ font-size: 0.95rem; line-height: 1.6; }
#solved-body .sd-solved-time{
  font-family: var(--mono);
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--pine);
  line-height: 1.2;
}
#solved-body .sd-solved-best{ font-weight: 700; color: var(--brass); }
#solved-body table{ width:100%; border-collapse:collapse; margin-top:12px; font-family: var(--mono); font-size:0.85rem; }
#solved-body td{ padding:6px 4px; border-bottom:1px solid rgba(var(--ink-rgb),0.1); }
#solved-body td:last-child{ text-align:right; }
