/* Dominoes - the stylesheet.  One rule matters more than the rest and it is the first one:
   [hidden] must beat every class that sets display, or a panel that is logically hidden sits
   invisibly over the table and eats every click. */
[hidden] { display: none !important; }

:root {
  --ink: #e8ecf2; --dim: #93a0b4; --line: #223047; --bg: #0b1220; --panel: rgba(12,20,34,.82);
  --ivory: #f1eee5; --go: #f0ba4b; --go-ink: #241a05; --edge: #2c3b57;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); }

#app { position: relative; width: 100%; height: 100dvh; min-height: 460px; overflow: hidden; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.panel {
  position: absolute; top: 12px; left: 12px; z-index: 3;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; backdrop-filter: blur(6px); min-width: 190px; max-width: 46vw;
  font-variant-numeric: tabular-nums;
}
.panel .big { font-size: 30px; font-weight: 700; line-height: 1.05; }
.panel .big small { font-size: 12px; font-weight: 400; color: var(--dim); margin-left: 6px; }
.panel .row { font-size: 13px; margin-top: 3px; }
.panel .row small { color: var(--dim); margin-left: 5px; }
.panel .row b { color: var(--dim); font-weight: 600; margin-right: 4px; }
.panel .dim { color: var(--dim); }
.panel .msg { margin-top: 8px; color: var(--go); max-width: 34ch; min-height: 2.4em; }

#controls {
  position: absolute; right: 12px; top: 12px; bottom: 12px; z-index: 4; width: min(330px, 48vw);
  display: flex; flex-direction: column; gap: 10px; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px;
  backdrop-filter: blur(6px);
}
.tabs { display: flex; gap: 6px; }
button {
  font: inherit; font-size: 13px; color: var(--ink); background: #16233a;
  border: 1px solid var(--edge); border-radius: 7px; padding: 7px 10px; cursor: pointer;
}
button:hover:not(:disabled) { background: #1d2d49; }
button:disabled { opacity: .42; cursor: default; }
button.on { background: var(--go); color: var(--go-ink); border-color: var(--go); font-weight: 600; }
button.go { background: var(--go); color: var(--go-ink); border-color: var(--go); font-weight: 600; }
button.ghost { background: transparent; color: var(--dim); }
.tab { flex: 1; }
.ctl { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--dim); }
.ctl output { color: var(--ink); font-family: var(--mono); }
select, input[type=range] { width: 100%; font: inherit; font-size: 13px; }
select { background: #16233a; color: var(--ink); border: 1px solid var(--edge); border-radius: 7px; padding: 6px; }
input[type=range] { accent-color: var(--go); }
.btns { display: flex; flex-wrap: wrap; gap: 6px; }
.handrow { font-size: 12px; color: var(--dim); }
.handlabel { color: var(--dim); }
#hand { display: flex; flex-wrap: wrap; gap: 6px; }
button.tile { padding: 3px; line-height: 0; background: #101a2c; }
button.tile canvas { border-radius: 3px; }
button.tile.can { border-color: var(--go); }
button.tile.sel { background: var(--go); }
#endChoice { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--dim); }

#prose { max-width: 46rem; margin: 0 auto; padding: 28px 18px 70px; }
.prose h1 { font-size: 30px; margin: 26px 0 10px; }
.prose h2 { font-size: 20px; margin: 26px 0 8px; }
.prose h3 { font-size: 15px; margin: 20px 0 6px; color: var(--go); }
.prose p, .prose li { font-size: 14.5px; line-height: 1.66; color: #c8d2e0; }
.prose li { margin-bottom: 6px; }
.prose code { font-family: var(--mono); font-size: .9em; color: var(--go); }
.prose b[data-limit] { color: var(--ink); font-family: var(--mono); font-weight: 600; }
.limits { border-top: 1px solid var(--line); margin-top: 34px; padding-top: 12px; }
.foot { color: var(--dim); font-size: 12.5px; border-top: 1px solid var(--line); margin-top: 26px; padding-top: 12px; }
.foot a { color: var(--dim); }

@media (max-width: 760px) {
  /* Phones: the table takes the top of the screen and the controls sit in a sheet BELOW it,
     so nothing covers the tiles or the scoreboard. The canvas resizes itself to its box. */
  #view { bottom: auto; height: calc(100% - 44dvh); }
  #controls { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto;
    height: calc(44dvh - 16px); gap: 8px; padding: 8px; }
  #topplePanel { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
  #topplePanel .ctl:first-child, #topplePanel .btns { grid-column: 1 / -1; }
  .panel { top: 8px; left: 8px; min-width: 0; max-width: calc(100vw - 16px); padding: 6px 9px; }
  .panel .big { font-size: 20px; }
  .panel .row { font-size: 12px; margin-top: 1px; }
  .panel .msg { margin-top: 4px; min-height: 0; }
  button { padding: 6px 8px; }
  button.tile canvas { width: 30px; height: 60px; }
}
