/* Cubie Stack. Builds on game.css (title, coach, modal, bands). */
.cs-title__art { display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(9, 1fr); gap: 4px; aspect-ratio: 8 / 9;
  max-width: 400px; width: 100%; margin: auto; padding: 14px; border-radius: 28px; background: #1b2150; box-shadow: var(--shadow); }
.cs-title__art span { border-radius: 6px; background: var(--b); box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .22), inset 0 3px 0 rgba(255, 255, 255, .3); }
.cs-title__best { margin: 6px 0 0; font-weight: 800; color: var(--ink-2); }

/* HUD */
.cs-hud { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 12px; }
.cs-stat { margin: 0; display: inline-flex; align-items: baseline; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--bg); border: 2px solid var(--line); font-weight: 700; color: var(--ink-2); }
.cs-stat b { font-size: 1.35rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.cs-time.is-low { border-color: var(--red); }
.cs-time.is-low b { color: #b4232a; }
.cs-timer { margin-left: auto; }
.cs-timer[aria-pressed="false"] { opacity: .85; }

/* Board: 8 columns x 9 rows (from the variant), sized to fit phones without scrolling sideways. */
.cs-stage { display: grid; grid-template-columns: minmax(0, auto) minmax(260px, 1fr); gap: 18px; align-items: start; }
.cs-play { display: grid; gap: 14px; justify-items: center; }
.cs-board { --gap: 3px; display: grid; grid-template-columns: repeat(var(--cols, 8), 1fr); grid-template-rows: repeat(var(--rows, 9), 1fr); gap: var(--gap);
  width: min(92vw, 460px, calc((100dvh - 290px) * 8 / 9)); min-width: 280px; aspect-ratio: var(--cols, 8) / var(--rows, 9);
  padding: 8px; border-radius: 20px; background: #1b2150; box-shadow: var(--shadow); touch-action: none; user-select: none; -webkit-user-select: none; }
.cs-board:focus-visible { outline: 4px solid #ffd23f; outline-offset: 3px; }
.cs-cell { position: relative; border-radius: 6px; background: #2b3270; display: grid; place-items: center; }
.cs-cell.is-full { background: var(--b); box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .22), inset 0 3px 0 rgba(255, 255, 255, .3); }
.cs-cell.is-full::after { content: attr(data-s); color: rgba(20, 24, 60, .55); font-size: clamp(.55rem, 2.4vw, .95rem); line-height: 1; }
.cs-cell.is-ghost { background: var(--g); opacity: .55; box-shadow: inset 0 0 0 3px #fff; }
.cs-cell.is-bad { background: #6b2b3a; box-shadow: inset 0 0 0 3px #ff9aa8; }
.cs-cell.is-cursor { box-shadow: inset 0 0 0 3px #ffd23f; }
.cs-cell.is-clear { animation: cs-clear .45s ease; }
@keyframes cs-clear { 0% { background: #fff; transform: scale(1.12); } 100% { transform: none; } }
.cs-board.is-shake { animation: cs-shake .3s; }
@keyframes cs-shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* Tray: three big buttons, each holding one piece (kid-size targets). */
.cs-tray { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: min(92vw, 460px); min-width: 280px; touch-action: none; }
.cs-slot { position: relative; display: grid; place-items: center; min-height: 104px; padding: 10px; border-radius: 18px; cursor: grab;
  border: 3px solid var(--line); background: var(--bg); }
.cs-slot:hover:not(:disabled) { border-color: var(--blue); }
.cs-slot.is-on { border-color: var(--blue); background: rgba(47, 111, 224, .12); box-shadow: 0 0 0 3px rgba(47, 111, 224, .35); }
.cs-slot:disabled { cursor: default; background: transparent; border-style: dashed; }
.cs-slot__k { position: absolute; top: 4px; left: 8px; font-size: .8rem; font-weight: 800; color: var(--ink-2); }
.cs-piece { --cell: 18px; display: grid; grid-template-columns: repeat(var(--pc), var(--cell)); grid-template-rows: repeat(var(--pr), var(--cell)); gap: 2px; pointer-events: none; }
.cs-piece .cs-cell { border-radius: 4px; }
.cs-piece .cs-cell.is-full::after { font-size: .6rem; }
.cs-float { position: fixed; left: 0; top: 0; z-index: 70; pointer-events: none; opacity: .9; }
.cs-float .cs-piece { --cell: var(--fcell, 36px); gap: 3px; }

.cs-panel .td-row { margin-top: 12px; }
.cs-end { text-align: center; }
.cs-end__score { font-size: 1.6rem; font-weight: 900; margin: 6px 0; }
.cs-end__best { font-weight: 900; color: var(--magenta); }

@media (max-width: 860px) {
  .cs-stage { grid-template-columns: 1fr; }
  .cs-timer { margin-left: 0; }
}
@media (max-width: 420px) {
  .cs-hud { gap: 6px; }
  .cs-stat { padding: 4px 9px; }
  .cs-slot { min-height: 88px; }
  .cs-piece { --cell: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .cs-cell.is-clear, .cs-board.is-shake { animation: none; }
}
[data-theme="dark"] .cs-stat, [data-theme="dark"] .cs-slot:not(:disabled) { background: var(--surface); }
[data-theme="dark"] .cs-time.is-low b { color: #ff9aa8; }
