/* Dominoes. The felt with the chain and the boneyard; your tiles in one row under it; the players (each with their face-down
   tiles), whose turn it is, what just happened and the buttons in a rail beside it (desktop, and a tablet or phone on its
   side). Upright phones and tablets: the players above the felt, then the felt, the turn line with the buttons, and your tiles.
   app.js measures the room (shared/fit.js): --felt-w and --felt-h are the felt's size, --tile-width and --tile-step the width
   and spacing of your tiles. The chain is laid out by app.js inside the felt, clear of the boneyard. */
/* The tiles are drawn by art.js (faces) and here (backs, in the site's navy and gold). */

.stage { flex: 1; min-height: 0; display: flex; justify-content: center; gap: 16px; padding: 12px max(12px, var(--gk-safe-end)) max(12px, var(--gk-safe-bottom)) max(12px, var(--gk-safe-start)); }
.table { flex: 1; min-width: 0; min-height: 0; max-width: 1180px; display: flex; flex-direction: column; gap: 10px; }
.felt-wrap { flex: 1; min-width: 0; min-height: 0; display: grid; place-items: center; }
/* --back is the width of a tile in the boneyard, which follows the felt; --pile-room is what the boneyard takes on the left. */
.felt { --felt-w: 360px; --felt-h: 240px; --back: clamp(14px, min(var(--felt-w) * .06, var(--felt-h) * .07), 32px); --pile-room: calc(var(--back) * 2 + 33px);
  position: relative; width: var(--felt-w); height: var(--felt-h); direction: ltr; overflow: hidden;
  border: 6px solid var(--gk-rim); border-radius: calc(var(--gk-r-lg) + 6px);
  background: radial-gradient(ellipse at 50% 42%, color-mix(in srgb, var(--gk-felt) 86%, var(--gk-white)) 0, var(--gk-felt) 42%, var(--gk-felt-deep) 100%);
  box-shadow: 0 0 0 3px var(--gk-rim-light), var(--gk-shadow-2), inset 0 0 0 2px var(--gk-line-soft), inset 0 0 60px color-mix(in srgb, var(--gk-night) 50%, transparent); }
.felt.no-pile { --pile-room: 6px; }

/* The chain and the open ends share one box, clear of the boneyard. Tiles on the table and the open ends share one drawing
   size and are placed, turned and scaled by a transform. */
.chain, .slots { position: absolute; top: 6px; right: 6px; bottom: 6px; left: var(--pile-room); }
.slots { z-index: 2; pointer-events: none; }
.piece, .slot { position: absolute; left: 0; top: 0; width: 60px; height: 120px; transform-origin: center; }
.piece { border-radius: 9px; background: none; box-shadow: var(--gk-shadow-2); transition: transform var(--gk-slow) cubic-bezier(.2, .72, .3, 1), opacity var(--gk-move); }
.piece svg, .domino svg { display: block; width: 100%; height: 100%; pointer-events: none; }
.piece.flying { z-index: 4; }
.piece.recent { box-shadow: 0 0 0 4px var(--gk-gold), var(--gk-shadow-2); }
.slot { pointer-events: auto; padding: 0; border-radius: 9px; border: 4px dashed color-mix(in srgb, var(--gk-white) 85%, transparent); background: color-mix(in srgb, var(--gk-gold) 28%, transparent);
  box-shadow: 0 0 22px color-mix(in srgb, var(--gk-gold) 60%, transparent); transition: transform var(--gk-move) cubic-bezier(.2, .72, .3, 1), background var(--gk-fast); animation: slot-ready 1s ease-in-out infinite alternate; }
.slot.near, .slot:hover { background: color-mix(in srgb, var(--gk-gold) 65%, transparent); border-color: var(--gk-white); }
@keyframes slot-ready { to { box-shadow: 0 0 34px color-mix(in srgb, var(--gk-gold) 88%, transparent); } }

/* The boneyard: two columns of face-down tiles on the left of the felt, one for every tile left, with the number underneath.
   It glows while the game draws for you. */
.pile { position: absolute; z-index: 3; left: 6px; top: 50%; translate: 0 -50%; max-height: calc(100% - 12px); width: calc(var(--back) * 2 + 21px); display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 8px 8px 6px;
  border-radius: var(--gk-r-md); border: 1px solid var(--gk-line-soft); background: color-mix(in srgb, var(--gk-night) 35%, transparent); transition: box-shadow var(--gk-move), border-color var(--gk-move); }
.pile.needed { border-color: var(--gk-gold); animation: pile-ready 1s ease-in-out infinite alternate; }
@keyframes pile-ready { to { box-shadow: 0 0 0 3px color-mix(in srgb, var(--gk-gold) 50%, transparent), 0 0 22px color-mix(in srgb, var(--gk-gold) 60%, transparent); } }
.pile-line { min-height: 0; display: grid; grid-template-columns: repeat(2, var(--back)); grid-auto-rows: calc(var(--back) / 2); gap: 3px; overflow: hidden; }
.pile-line .tile-back { width: auto; height: auto; border-radius: 2px; }
.pile.empty .pile-line { display: none; }
.pile-copy { flex: none; text-align: center; line-height: 1.2; }
.pile-copy b { display: block; font-size: var(--gk-text-md); font-weight: var(--gk-number); color: var(--gk-gold); }
.pile-copy small { display: block; font-size: var(--gk-text-xs); color: var(--gk-ink-soft); white-space: nowrap; }

/* A face-down tile: in the boneyard, on a player's plate, and flying from the boneyard to a plate. */
.tile-back { flex: none; display: block; width: var(--back-w, 11px); height: calc(var(--back-w, 11px) * 2); border-radius: 3px;
  background: radial-gradient(circle, var(--gk-gold) 0 14%, transparent 17%), linear-gradient(160deg, var(--gk-raise), var(--gk-panel-deep) 55%, var(--gk-rim));
  box-shadow: inset 0 0 0 1px var(--gk-gold-deep), inset 0 0 0 2px color-mix(in srgb, var(--gk-gold) 28%, transparent), var(--gk-shadow-1); }
.flying-back { --back-w: 18px; position: fixed; z-index: var(--gk-z-menu); pointer-events: none; }

/* Your tiles: one row that narrows, then overlaps, as it grows (app.js sets --tile-width and --tile-step); it never wraps. */
.hand { flex: none; height: clamp(112px, 17dvh, 150px); display: flex; justify-content: center; align-items: flex-end; direction: ltr; padding-bottom: 2px; }
.domino { flex: none; position: relative; width: var(--tile-width, 44px); aspect-ratio: 1 / 2; padding: 0; border: 0; border-radius: 13% / 6.5%; background: none;
  box-shadow: var(--gk-shadow-1); touch-action: none; user-select: none; -webkit-user-select: none; transition: translate var(--gk-fast), box-shadow var(--gk-fast), filter var(--gk-fast); }
.hand > .domino + .domino { margin-left: var(--tile-step, 6px); }
.domino.dim { filter: brightness(.72) saturate(.7); }
.domino.playable { cursor: grab; box-shadow: 0 0 0 2px color-mix(in srgb, var(--gk-gold) 70%, transparent), var(--gk-shadow-1); }
.domino.selected { z-index: 1; translate: 0 -12%; box-shadow: 0 0 0 3px var(--gk-white), 0 0 18px var(--gk-white), var(--gk-shadow-2); }
@media (hover: hover) { .domino:hover:not(.dragging):not(.ghost) { z-index: 1; translate: 0 -8%; } .domino.selected:hover { translate: 0 -12%; } }
/* While a tile is carried, its place in the hand is a dashed gap and a lifted copy follows the pointer. */
.domino.dragging { background: var(--gk-line-soft); box-shadow: none; outline: 2px dashed color-mix(in srgb, var(--gk-white) 55%, transparent); outline-offset: -2px; filter: none; }
.domino.dragging svg { visibility: hidden; }
.domino.ghost { position: fixed; z-index: var(--gk-z-menu); margin: 0; pointer-events: none; cursor: grabbing; transition: none; filter: none; box-shadow: var(--gk-shadow-3); will-change: transform; }
body.dragging { cursor: grabbing; } body.dragging .domino { transition: none; translate: none; }

/* The rail: the players in play order from you, then the turn line, the last event and the buttons. */
/* It stands in the middle of its height; when it is taller than the room (a sideways phone with four players) it starts at the top. */
.rail { flex: none; width: 300px; min-height: 0; display: flex; flex-direction: column; gap: 14px; }
@media (orientation: landscape) { .rail > :first-child { margin-top: auto; } .rail > :last-child { margin-bottom: auto; } }
.seats { display: grid; gap: 8px; }
.gk-seat { --back-w: 11px; position: relative; }
.gk-seat .gk-seat-text { flex: 0 1 auto; max-width: 62%; }
.gk-seat.me .gk-seat-text { flex: 1; max-width: none; }
.rack { flex: 1 1 0; min-width: 22px; height: calc(var(--back-w) * 2 + 4px); display: flex; align-items: center; overflow: hidden; }
.rack .tile-back + .tile-back { margin-inline-start: var(--step, 3px); }
/* A short note over a player when they pass. */
.gk-seat.bubble::after { content: attr(data-bubble); position: absolute; left: 50%; top: 50%; translate: -50% -50%; padding: 4px 12px; border-radius: var(--gk-r-pill); white-space: nowrap;
  font-size: var(--gk-text-xs); font-weight: var(--gk-bold); color: var(--gk-on-gold); background: var(--gk-gold); box-shadow: var(--gk-shadow-2); pointer-events: none; opacity: 0; animation: bubble 1.5s ease-out; }
@keyframes bubble { 0% { opacity: 0; scale: .8; } 15% { opacity: 1; scale: 1; } 80% { opacity: 1; } 100% { opacity: 0; } }
.turn { display: flex; flex-direction: column; gap: 10px; }
.turn-text { min-width: 0; }
.tools { display: flex; gap: 10px; min-height: var(--gk-tap); }
.tools .gk-btn { flex: 1; }
/* A clear table behind New game and while a room waits for its people. */
html.gk-clear :is(#chain > *, #hand > *, .rack > *, .pile, #slots) { visibility: hidden; }

/* Upright phones and tablets: the players above the felt, then the felt, the turn line and the buttons, and your tiles.
   The rail and the table give their parts to the page's column, in that order. */
@media (orientation: portrait) {
  .stage { flex-direction: column; gap: 8px; padding-top: 8px; }
  .table, .rail { display: contents; }
  .seats { order: 1; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; }
  .felt-wrap { order: 2; } .turn { order: 3; } .hand { order: 4; }
  .turn { flex-direction: row; align-items: center; justify-content: center; gap: 12px; min-height: var(--gk-tap); }
  .turn-text { flex: 1; }
  .turn-text p { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tools { flex: none; } .tools .gk-btn { flex: none; }
  .hand { height: clamp(92px, 14dvh, 132px); }
}
/* An upright phone: the plates two to a row (a last odd one takes the whole row), with the name, the face-down tiles and the score. */
@media (max-width: 599px) and (orientation: portrait) {
  .seats { grid-auto-flow: row; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .seats > :last-child:nth-child(odd) { grid-column: 1 / -1; }
}
/* A phone: small plates. */
@media (max-width: 599px) {
  .gk-seat { --back-w: 8px; padding: 6px 9px; gap: 7px; border-radius: var(--gk-r-md); } .gk-seat-note { display: none; }
  .gk-seat-score { min-width: 28px; font-size: var(--gk-text-md); }
  .tools .gk-btn { padding: 8px 14px; }
  .pile-copy small { display: none; }
}
/* An upright tablet: more room between the parts, and taller tiles. */
@media (min-width: 600px) and (max-width: 1023px) and (orientation: portrait) {
  .stage { gap: 12px; padding-top: 12px; } .seats { gap: 10px; } .gk-turn { font-size: var(--gk-text-lg); }
  .hand { height: clamp(120px, 14dvh, 168px); }
}
/* A tablet on its side: a narrower rail. */
@media (min-width: 600px) and (max-width: 1023px) and (orientation: landscape) { .rail { width: 248px; } }
@media (min-width: 1024px) { .stage { gap: 20px; padding-top: 16px; } }
/* A sideways phone: a narrow rail with small plates, a lower row of tiles and a thinner rim. */
@media (orientation: landscape) and (max-height: 560px) {
  .stage { gap: 12px; padding-top: 6px; padding-bottom: max(6px, var(--gk-safe-bottom)); }
  .table { gap: 6px; } .rail { width: 220px; gap: 8px; } .seats { gap: 5px; } .turn { gap: 6px; }
  .gk-seat { --back-w: 7px; padding: 5px 10px; } .gk-seat-note { display: none; } .gk-seat-score { min-width: 28px; font-size: var(--gk-text-md); }
  .gk-turn { font-size: var(--gk-text-sm); } .gk-event { font-size: var(--gk-text-xs); }
  .hand { height: clamp(72px, 22dvh, 96px); }
  .felt { border-width: 4px; }
  .pile-copy small { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .piece, .slot, .domino, .pile { transition: none; }
  .slot, .pile.needed, .gk-seat.bubble::after { animation: none; }
}
