/* Padající kostky: a retro arcade on a dark night-blue ground. The status and the rivals' miniatures on top, the
   field as tall as the phone allows (blocks with a raised 3-D edge, a faint grid, the ghost of the landing place),
   beside it the next pieces, the piece put aside, score, lines and level, and five big buttons at the bottom for the
   thumbs: move left / right with the left one, drop and turn with the right one. */
.kst{
  --kst-bg:#11132b;--kst-bg2:#070815;--kst-edge:#2c3170;--kst-glow:#5b6cff;--kst-ink:#e9ecff;--kst-mist:#9aa3d6;
  --kst-gold:#ffd34d;--kst-cell:24px;--kst-side:76px;
  position:absolute;inset:0;
  display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:auto minmax(0,1fr) auto;
  overflow:hidden;color:var(--kst-ink);
  background:radial-gradient(120% 70% at 50% 0%,#1d2150 0%,var(--kst-bg) 45%,var(--kst-bg2) 100%);
  -webkit-user-select:none;user-select:none;-webkit-touch-callout:none;
}
.kst-top{display:grid;justify-items:center;gap:4px;padding:6px 8px 2px}
.kst-status{margin:0;padding:.35em .9em;font-size:.9rem}

/* ── the rivals ─────────────────────────────────────────────────────── */
.kst-rivals{display:flex;justify-content:center;gap:8px;max-width:100%;overflow:hidden}
.kst-rivals[hidden]{display:none}
.kst-rv{
  display:grid;grid-template-columns:auto;justify-items:center;gap:1px;padding:3px 4px 2px;min-width:0;
  border:1.5px solid var(--kst-edge);border-radius:8px;background:rgba(5,6,20,.55);
}
.kst-rv.out{opacity:.55}
.kst-rv.best{border-color:var(--kst-gold);box-shadow:0 0 0 1px var(--kst-gold)}
.kst-mini{display:block;border-radius:2px;image-rendering:pixelated}
.kst-rvn{max-width:72px;font-size:.68rem;font-weight:600;line-height:1.15;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.kst-rvn i{font-style:normal;color:var(--kst-mist);font-weight:400}
.kst-rvs{font-size:.74rem;color:var(--kst-gold);font-variant-numeric:tabular-nums;line-height:1.1}

/* ── the field and the side ─────────────────────────────────────────── */
.kst-main{display:flex;align-items:center;justify-content:center;gap:8px;min-height:0;min-width:0;padding:4px 8px}
.kst-wrap{
  position:relative;flex:none;line-height:0;
  border:3px solid var(--kst-edge);border-radius:6px;
  box-shadow:0 0 0 1px #000,0 0 22px -4px rgba(91,108,255,.55),inset 0 0 0 1px rgba(255,255,255,.05);
}
.kst-field{display:block;touch-action:none;border-radius:3px}
.kst.watch .kst-field{touch-action:auto}
.kst-side{
  flex:none;width:var(--kst-side);align-self:stretch;
  display:flex;flex-direction:column;gap:6px;justify-content:flex-start;padding-top:2px;
  font-variant-numeric:tabular-nums;
}
.kst-box{
  display:grid;justify-items:center;gap:2px;padding:4px 2px 5px;margin:0;
  border:1.5px solid var(--kst-edge);border-radius:8px;background:rgba(5,6,20,.6);color:inherit;font:inherit;line-height:1;
}
.kst-holdb{cursor:pointer;touch-action:none;min-height:44px}
.kst-holdb.down{border-color:var(--kst-glow)}
.kst-nx,.kst-hold{display:block}
.kst-lb{font-size:.62rem;letter-spacing:.08em;text-transform:uppercase;color:var(--kst-mist);font-weight:700}
.kst-stat{display:grid;gap:1px;padding:0 2px}
.kst-stat b{font-size:1.02rem;font-weight:800;color:var(--kst-ink);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
  font-family:ui-monospace,'Courier New',monospace;text-shadow:0 0 6px rgba(91,108,255,.6)}
.kst-score{color:var(--kst-gold)!important;text-shadow:0 0 6px rgba(255,211,77,.45)!important}
.kst-trow[hidden]{display:none}
.kst-trow.soon b{color:#ff7a7a;text-shadow:0 0 8px rgba(255,80,80,.7)}
.kst-pause{
  margin-top:auto;min-height:44px;border-radius:10px;border:1.5px solid var(--kst-edge);background:rgba(5,6,20,.6);
  color:var(--kst-ink);font-size:1.1rem;cursor:pointer;touch-action:none;
}
.kst-pause[hidden]{display:none}

/* what lies over the field: the countdown, the pause, the end */
.kst-over{
  position:absolute;inset:0;display:grid;place-content:center;justify-items:center;gap:10px;padding:10px;text-align:center;
  background:rgba(4,5,16,.62);line-height:1.25;border-radius:3px;
}
.kst-over[hidden]{display:none}
.kst-over b{font-size:1.35rem;letter-spacing:.04em;text-shadow:0 0 10px rgba(91,108,255,.9)}
.kst-over span{font-size:.85rem;color:var(--kst-mist)}
.kst-over .kst-count{font-size:4.2rem;color:var(--kst-gold);font-family:ui-monospace,'Courier New',monospace;text-shadow:0 0 18px rgba(255,211,77,.7)}
.kst-over .btn{min-height:44px}

/* a short word over the field: lines, a level */
.kst-pop{
  position:absolute;left:50%;top:38%;transform:translate(-50%,-50%);pointer-events:none;white-space:nowrap;
  font:800 1.25rem/1 ui-monospace,'Courier New',monospace;color:#fff;letter-spacing:.04em;
  text-shadow:0 0 8px #5b6cff,0 2px 0 #000;animation:kst-pop 1.2s ease-out forwards;
}
.kst-pop.big{font-size:1.7rem;color:var(--kst-gold);text-shadow:0 0 12px #ff9f1c,0 2px 0 #000}
.kst-pop.lvl{top:55%;color:#7dffb0;text-shadow:0 0 10px #18c964,0 2px 0 #000}
@keyframes kst-pop{0%{opacity:0;transform:translate(-50%,-30%) scale(.7)}15%{opacity:1;transform:translate(-50%,-50%) scale(1.08)}70%{opacity:1}100%{opacity:0;transform:translate(-50%,-90%) scale(1)}}
.still .kst-pop{animation:none;opacity:0}

/* ── the buttons ────────────────────────────────────────────────────── */
.kst-pad{
  display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:6px;padding:6px 8px calc(8px + env(safe-area-inset-bottom,0px));
  max-width:520px;width:100%;margin:0 auto;box-sizing:border-box;
}
.kst.watch .kst-pad{display:none}
.kst-b{
  min-height:58px;padding:0;border-radius:14px;border:2px solid var(--kst-edge);
  background:linear-gradient(#262b66,#161a45);color:var(--kst-ink);font-size:1.5rem;line-height:1;cursor:pointer;
  box-shadow:0 4px 0 #090a1f,inset 0 1px 0 rgba(255,255,255,.18);touch-action:none;-webkit-tap-highlight-color:transparent;
}
.kst-b.hard{background:linear-gradient(#5a3a92,#2e1d58)}
.kst-b.rot{background:linear-gradient(#2f7a5c,#18432f)}
.kst-b.down,.kst-b:active{transform:translateY(3px);box-shadow:0 1px 0 #090a1f,inset 0 1px 0 rgba(255,255,255,.12)}
.kst-b:focus-visible,.kst-box:focus-visible,.kst-pause:focus-visible{outline:2px solid var(--kst-gold);outline-offset:2px}

.kst-sum{margin:0 0 4px;color:var(--mist,#9aa3d6);font-size:.85rem}
.kst-sum-me{margin:0 0 6px;font-weight:600}

@media (max-height:600px){
  .kst-b{min-height:46px;font-size:1.25rem}
  .kst-top{padding-top:3px}
}
@media (min-width:700px){
  .kst-pad{max-width:440px}
}
