body { min-height: 100vh; display: flex; flex-direction: column; }

.timer { font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums; }

.pips {
  flex: 1;
  display: flex;
  gap: 40px;
  justify-content: center;
  align-items: flex-start;
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
  padding: 12px 16px 40px;
}
.board-col { display: flex; justify-content: center; flex: 0 1 auto; min-width: 0; }

/* ---------- Board ---------- */
.board {
  position: relative;
  width: min(calc(100vw - 32px), calc(var(--W) * 68px));
  aspect-ratio: var(--W) / var(--H);
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
.cells {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(var(--W), 1fr);
  grid-template-rows: repeat(var(--H), 1fr);
}
.sq { position: relative; }
.sq.on {
  background: var(--fill, #e6e4dc);
  border: 2px solid transparent;
  cursor: pointer;
  /* white gutters between squares */
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.85);
}
.sq.on.none { --fill: #e6e4dc; }
.sq.t { border-top-color: var(--edge, #c9c6ba); border-top-style: dashed; }
.sq.r { border-right-color: var(--edge, #c9c6ba); border-right-style: dashed; }
.sq.b { border-bottom-color: var(--edge, #c9c6ba); border-bottom-style: dashed; }
.sq.l { border-left-color: var(--edge, #c9c6ba); border-left-style: dashed; }
.sq.bad { animation: badflash 1.2s ease-out; }
@keyframes badflash { 0%, 60% { box-shadow: inset 0 0 0 3px #e63333; } }

.badge {
  position: absolute;
  z-index: 3;
  width: calc(100% / var(--W) * 0.52);
  aspect-ratio: 1;
  transform: translate(-50%, -50%) rotate(45deg);
  background: var(--edge);
  border: 2px solid #fff;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
.badge span { transform: rotate(-45deg); color: #fff; font-weight: 800; font-size: clamp(11px, 3.2vw, 17px); line-height: 1; white-space: nowrap; }
.badge.ok { background: #2e9e57; }
.badge.ok span::after { content: " ✓"; font-size: 0.7em; }
.badge.wrong { background: #e63333; }

/* ---------- Dominoes ---------- */
.domino {
  display: flex;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 0 var(--ink);
}
.domino.v { flex-direction: column; }
.domino .half { flex: 1; display: flex; }
.domino .half + .half { border-left: 1.5px solid #c8c8c8; }
.domino.v .half + .half { border-left: 0; border-top: 1.5px solid #c8c8c8; }
.domino svg { width: 100%; height: 100%; display: block; }

.placed {
  position: absolute;
  z-index: 2;
  padding: 3px;
  cursor: pointer;
}
.placed.new { animation: drop 0.18s ease-out; }
.placed .domino { width: 100%; height: 100%; }
@keyframes drop { from { transform: scale(1.12); opacity: 0.4; } }
.ghost { position: absolute; z-index: 2; padding: 3px; pointer-events: none; opacity: 0.45; }
.ghost .domino { width: 100%; height: 100%; }

/* ---------- Tray ---------- */
.side { display: flex; flex-direction: column; gap: 14px; width: 340px; flex-shrink: 0; }
.tray {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-content: flex-start;
  min-height: 120px;
  padding: 14px;
  background: #f4f3ee;
  border-radius: 14px;
}
.slot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 96px;
  height: 96px;
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
  border-radius: 12px;
}
.slot .domino { width: 88px; height: 44px; transition: transform 0.2s; }
.slot .domino.v { width: 44px; height: 88px; }
.slot.sel .domino { box-shadow: 0 0 0 3px #ffda00, 0 0 0 5px var(--ink); transform: translateY(-2px); }
.slot.used { visibility: hidden; }
.slot:focus-visible { outline: 3px solid #3a86ff; }

.side-actions { display: flex; gap: 10px; justify-content: center; }
.side-actions .pill { display: inline-flex; align-items: center; gap: 6px; }
.side-actions svg { width: 17px; height: 17px; }
.tip { margin: 0; text-align: center; font-size: 14px; color: var(--muted); min-height: 1.4em; }
.links { display: flex; justify-content: center; gap: 18px; }
.link-btn { background: none; border: 0; padding: 4px; font-size: 14px; font-weight: 600; text-decoration: underline; cursor: pointer; }

.rules { text-align: left; padding-left: 4px; list-style: none; margin: 0 0 12px; font-size: 16px; line-height: 1.4; }
.rules li { margin-bottom: 10px; }
.chip { display: inline-block; min-width: 34px; text-align: center; padding: 2px 6px; border-radius: 6px; background: #8e62d0; color: #fff; margin-right: 4px; }
.modal p.small { font-size: 14px; color: var(--muted); }

@media (max-width: 820px) {
  .pips { flex-direction: column; align-items: center; gap: 18px; padding-top: 4px; }
  .side { width: min(100%, 560px); }
  .slot { width: 76px; height: 76px; }
  .slot .domino { width: 70px; height: 35px; }
  .slot .domino.v { width: 35px; height: 70px; }
  .tray { gap: 6px; padding: 10px; min-height: 0; }
}
@media (max-width: 420px) {
  .topbar .home-label { display: none; }
  .levels button { padding: 6px 10px; font-size: 13px; }
  .slot { width: 64px; height: 64px; }
  .slot .domino { width: 60px; height: 30px; border-radius: 7px; }
  .slot .domino.v { width: 30px; height: 60px; }
}
