/* Block Drop. The well stands in the middle with a column at each side: Hold and the numbers on the left; Next, the clock,
   the best result and the pause button on the right. app.js sizes one square (--cell, shared/fit.js) to the room .table is
   given, less the two columns, so nothing scrolls; the columns sit against the well and the three are centred in the room.
   Touch screens get the buttons: in a row under the well, or at the two edges, under the thumbs, when a phone lies on its side.
   The table keeps the same left and right in Arabic and English. */
.stage {
  --gap: 12px; --rail: 140px; --key: clamp(52px, 9dvh, 80px); --cell: 24px;
  flex: 1; min-height: 0; display: flex; flex-direction: column; gap: var(--gap); overflow: hidden; direction: ltr; user-select: none; -webkit-user-select: none;
  padding: 10px max(12px, var(--gk-safe-end)) max(12px, var(--gk-safe-bottom)) max(12px, var(--gk-safe-start));
}
/* The room the well is measured in; it takes whatever the buttons leave. */
.table { flex: 1; min-width: 0; min-height: 0; display: grid; place-items: center; }
.play { display: flex; align-items: flex-start; gap: var(--gap); }
html[dir=rtl] :is(.rail, .veil, .banner) { direction: rtl; }

/* The two columns: counters as the shared stat boxes, and the previews of Hold and Next in the same boxes. */
.rail { flex: none; width: var(--rail); display: flex; flex-direction: column; gap: var(--gk-s-2); }
.rail .gk-stat { min-width: 0; padding: 6px 8px; }
.rail .gk-stat small { font-size: var(--gk-text-sm); }
.rail .gk-stat b { max-width: 100%; overflow: hidden; font-size: var(--gk-text-lg); font-variant-numeric: tabular-nums; white-space: nowrap; }
/* The previews grow with the well, so the columns are never taller than it. */
.preview canvas { display: block; width: min(100%, calc(var(--cell) * 3.2)); }
#hold { aspect-ratio: 4.4 / 2.8; } #next { aspect-ratio: 4.4 / 8.2; }
.pause { width: 100%; padding: 0; font-size: var(--gk-text-xl); line-height: 1; }

/* The well: ten squares by twenty in the dark rim with a gold line. 4px of rim and 2px for the line on each side: the 12px
   app.js leaves for the frame. The background and the grid are drawn by app.js in the same navy. */
.well {
  position: relative; flex: none; box-sizing: content-box; width: calc(var(--cell) * 10); height: calc(var(--cell) * 20); margin: 2px;
  border: 4px solid var(--gk-rim); border-radius: var(--gk-r-md); box-shadow: 0 0 0 2px var(--gk-gold-deep), var(--gk-shadow-2); background: var(--gk-night); overflow: hidden; line-height: 0;
}
#screen { display: block; width: 100%; height: 100%; touch-action: none; outline: none; cursor: pointer; -webkit-touch-callout: none; }
/* "Four lines!" and a new level, called out in the well for a moment. */
.banner {
  position: absolute; left: 0; right: 0; top: 20%; text-align: center; pointer-events: none;
  font: var(--gk-bold) clamp(var(--gk-text-lg), calc(var(--cell) * 1.1), var(--gk-text-3xl))/1.3 var(--gk-font); color: var(--gk-white); text-shadow: 0 0 16px var(--gk-gold), 0 2px 4px var(--gk-night);
  opacity: 0; scale: .8; transition: opacity var(--gk-move), scale var(--gk-move);
}
.banner.show { opacity: 1; scale: 1; }
/* "Ready?" and "Paused" lie over the whole well with one green button; a press anywhere on them carries on as well. */
.veil { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--gk-s-3); padding: var(--gk-s-2); background: var(--gk-veil); line-height: var(--gk-tight); text-align: center; cursor: pointer; }
.veil b { font-size: clamp(var(--gk-text-lg), calc(var(--cell) * 1.3), var(--gk-text-3xl)); font-weight: var(--gk-bold); color: var(--gk-gold-pale); text-shadow: var(--gk-shadow-1); }
/* The button's words grow with the well, so they fit the narrow well of a sideways phone. */
.veil .gk-btn { max-width: 100%; padding-inline: 12px; font-size: clamp(var(--gk-text-sm), calc(var(--cell) * .8), var(--gk-text-lg)); }

/* The touch buttons: gold, as every action in a game. Only a touch screen has them; a mouse and keyboard get the larger well. */
.pads { display: none; flex: none; align-self: center; gap: var(--gap); width: min(100%, 680px); height: var(--key); }
.pad { flex: 1; display: flex; gap: var(--gk-s-2); min-width: 0; }
.key { flex: 1; min-width: 0; min-height: var(--gk-tap); height: 100%; padding: 0; touch-action: none; -webkit-touch-callout: none; }
.key svg { width: min(34px, 62%); aspect-ratio: 1; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.key.down { filter: brightness(1.12); transform: scale(.95); }
@media (pointer: coarse) { .pads { display: flex; } }

/* A phone: narrow columns, so the well keeps as much of the width as it can. */
@media (max-width: 599px) {
  .stage { --gap: 6px; --rail: 64px; padding: 8px max(6px, var(--gk-safe-end)) max(8px, var(--gk-safe-bottom)) max(6px, var(--gk-safe-start)); }
  .rail { gap: 6px; }
  .rail .gk-stat { padding: 4px 3px; border-radius: var(--gk-r-sm); }
  .rail .gk-stat small { font-size: var(--gk-text-xs); line-height: 1.3; white-space: normal; text-align: center; }
  .rail .gk-stat b { font-size: var(--gk-text-sm); }
  .pause { font-size: var(--gk-text-lg); }
  .pad { gap: 6px; }
}
/* A tablet. */
@media (min-width: 600px) and (max-width: 1023px) {
  .stage { --gap: 14px; --rail: 128px; padding-top: 14px; }
}
/* Desktop: wider columns and larger numbers. */
@media (min-width: 1024px) {
  .stage { --gap: 18px; --rail: 164px; padding-top: 14px; }
  .rail { gap: 10px; }
  .rail .gk-stat b { font-size: var(--gk-text-xl); }
}
/* A sideways phone: the well takes the height, with small columns. */
@media (orientation: landscape) and (max-height: 560px) {
  .stage { --gap: 8px; --rail: 84px; --key: clamp(48px, 17dvh, 72px); padding-top: 6px; padding-bottom: max(6px, var(--gk-safe-bottom)); }
  .rail { gap: var(--gk-s-1); }
  .rail .gk-stat { padding: 2px 4px; border-radius: var(--gk-r-sm); }
  .rail .gk-stat small { font-size: var(--gk-text-xs); line-height: 1.3; }
  .rail .gk-stat b { font-size: var(--gk-text-sm); }
  .pause { font-size: var(--gk-text-lg); }
}
/* ...and on a touch screen the buttons stand at its two edges: moving under the left thumb, turning and dropping under the right. */
@media (orientation: landscape) and (max-height: 560px) and (pointer: coarse) {
  .stage { flex-direction: row; align-items: stretch; }
  .pads { display: contents; }
  .pad { flex: 0 1 clamp(112px, 20vw, 240px); display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: var(--key); align-content: end; gap: var(--gk-s-2); }
  .pad-move { order: -1; grid-template-areas: "left right" "down down"; }
  .pad-act { grid-template-areas: "hold turn" "drop drop"; }
  .key { height: auto; }
  [data-act=left] { grid-area: left; } [data-act=right] { grid-area: right; } [data-act=down] { grid-area: down; }
  [data-act=turn] { grid-area: turn; } [data-act=drop] { grid-area: drop; } [data-act=hold] { grid-area: hold; }
}
