/* ======================================================================
   Knister
   ====================================================================== */

:root { --ks-hand: "Marker Felt", "Chalkboard SE", "Segoe Print", "Comic Sans MS", cursive; }

/* Black dice with white pips (like the original) */
.die.ks-black {
  background: radial-gradient(circle at 30% 25%, #3a3a3e, #121214 70%);
  --pip: #f4f4f4;
}

/* ---------- Menu card & logo ---------- */
.gc-ks { background: radial-gradient(circle at 50% 40%, #b8191c, #5d0709 80%); }
.gc-ks-grid { display: grid; grid-template-columns: repeat(5, 11px); gap: 1.5px; }
.gc-ks-grid i {
  width: 11px; height: 11px; border-radius: 2px; background: #d8edf8; font-style: normal;
  font: 700 7px/11px var(--ks-hand); color: #1b2230; text-align: center;
}
.gc-ks-grid i.d { background: #8cc8e6; }
.ks-logo { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.ks-logo-word {
  font-weight: 900; font-size: 52px; letter-spacing: 2px; line-height: 1; text-transform: uppercase;
  background: linear-gradient(180deg, #ffe08a 0%, #ff9b2f 45%, #d9381e 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 10px rgba(255, 120, 40, .55)) drop-shadow(0 3px 0 #3a0705);
}
.ks-logo-dice { display: flex; gap: 10px; }
.ks-bdie { width: 30px !important; height: 30px !important; border-radius: 7px !important; filter: invert(1) drop-shadow(0 0 8px rgba(0, 200, 255, .0)); box-shadow: 0 0 14px rgba(255, 90, 40, .6) !important; }
.ks-bdie:first-child { transform: rotate(-12deg); }
.ks-bdie:last-child { transform: rotate(10deg) translateY(4px); }

/* ---------- Block ---------- */
.ks-board-area { grid-area: board; min-width: 0; min-height: 0; display: flex; align-items: flex-start; justify-content: center; }
.ks-board {
  --ks-gap: 3px;
  display: grid;
  grid-template-columns: calc(var(--ks-cell) * 1.85) repeat(6, var(--ks-cell));
  grid-template-rows: repeat(6, var(--ks-cell));
  gap: var(--ks-gap);
  padding: 10px;
  border-radius: 16px;
  background:
    radial-gradient(circle at 60% 45%, rgba(255, 70, 50, .35), transparent 60%),
    linear-gradient(160deg, #a5161a, #6d0a0c);
  border: 2px solid #3d0405;
  box-shadow: 0 10px 26px rgba(0,0,0,.45), inset 0 0 30px rgba(0,0,0,.35);
}
.ks-cell {
  appearance: none; border: 0; padding: 0; margin: 0;
  display: grid; place-items: center; border-radius: 3px;
  background: #d8edf8; color: #18202c;
  font: 700 calc(var(--ks-cell) * .52)/1 var(--ks-hand);
  box-shadow: inset 0 0 0 1px rgba(40, 70, 100, .25);
  cursor: default; position: relative;
}
.ks-cell.ks-dg { background: #8cc8e6; box-shadow: inset 0 0 0 calc(var(--ks-cell) * .09) #d8edf8, inset 0 0 0 calc(var(--ks-cell) * .09 + 1px) rgba(40, 70, 100, .2); }
.ks-board.can-place .ks-cell.ks-free { cursor: pointer; }
.ks-board.can-place .ks-cell.ks-free:hover { background: #eef8fd; }
.ks-board.can-place .ks-cell.ks-dg.ks-free:hover { background: #a9d7ee; }
.ks-cell.ks-sel { box-shadow: inset 0 0 0 3px var(--accent), 0 0 12px rgba(255, 210, 63, .7); z-index: 2; }
.ks-cell.ks-sel span { color: #b45309; animation: ks-ghost 900ms ease-in-out infinite alternate; }
@keyframes ks-ghost { from { opacity: .55; } to { opacity: 1; } }
.ks-score {
  display: grid; place-items: center; border-radius: 7px; position: relative;
  background: #fff; color: #18202c;
  font: 700 calc(var(--ks-cell) * .46)/1 var(--ks-hand);
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.12), 0 2px 4px rgba(0,0,0,.3);
}
.ks-score.ks-zero { color: #9aa3b0; }
.ks-score.ks-prev { color: #d97706; box-shadow: inset 0 0 0 2px #f59e0b, 0 2px 4px rgba(0,0,0,.3); }
.ks-score.ks-d { background: #fff7e0; }
.ks-score.ks-d::after {
  position: absolute; top: 2px; font: 800 calc(var(--ks-cell) * .17)/1 system-ui, sans-serif; color: #b45309;
}
.ks-score.d1::after { content: "↘×2"; left: 3px; }
.ks-score.d2::after { content: "↙×2"; right: 3px; }
.ks-board.peek { opacity: .92; }
.ks-board.peek .ks-cell { cursor: default; }

/* ---------- Info: current number, round, total, legend ---------- */
.ks-info { grid-area: info; display: flex; flex-wrap: wrap; align-items: center; align-content: center; gap: 8px 10px; min-width: 0; }
.ks-now { display: flex; flex-direction: column; align-items: center; }
.ks-now-lab, .ks-round span, .ks-total span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.ks-now-num {
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center;
  font: 900 34px/1 system-ui, sans-serif; color: var(--muted);
  background: rgba(255,255,255,.05); border: 2px solid var(--line);
}
.ks-now-num.live { color: #fff; background: radial-gradient(circle at 40% 35%, #ff8a3d, #c2261b 75%); border-color: #ffb36b; box-shadow: 0 0 22px rgba(255, 110, 40, .55); }
.ks-round, .ks-total { display: flex; flex-direction: column; align-items: center; padding: 6px 10px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.ks-round b, .ks-total b { font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums; }
.ks-round small { font-size: 12px; color: var(--muted); font-weight: 700; }
.ks-total b { font-family: var(--ks-hand); }

/* Chips */
.ks-chip .ks-tick { font-size: 12px; color: var(--muted); }
.ks-chip.done .ks-tick { color: #4ade80; font-weight: 900; }
.chip.viewing { box-shadow: 0 0 0 2px var(--text); }
.ks-flash-card .sf-num { color: #c2261b; }
.ks-rules-table td:last-child { text-align: right; font-weight: 800; }

/* ---------- Layout ---------- */
#screen-ks-game.active {
  display: grid;
  --ks-tray: clamp(110px, 34vw, 170px);
  --ks-cell: clamp(30px, min(calc((100vw - 58px) / 7.85), calc((100dvh - 470px - var(--safe-top) - var(--safe-bottom)) / 6)), 64px);
  grid-template-columns: var(--ks-tray) minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  grid-template-areas: "top top" "dice info" "board board" "status status" "act act";
  column-gap: 12px; row-gap: 8px;
  padding: var(--safe-top) max(10px, var(--safe-right)) 0 max(10px, var(--safe-left));
}
#screen-ks-game .topbar { grid-area: top; padding: 8px 0 0; }
#ks-dice.dice-tray { grid-area: dice; --bowl-size: var(--ks-tray); width: var(--ks-tray); }
#screen-ks-game .status { grid-area: status; display: block; text-align: left; font-size: 14px; line-height: 1.35; min-height: 2.7em; padding: 0 2px; }
#screen-ks-game .actionbar { grid-area: act; padding-left: 0; padding-right: 0; }
#ks-actions .btn.main { flex: 1; }
#screen-ks-game .toasts { top: auto; bottom: calc(var(--safe-bottom) + 84px); flex-direction: column-reverse; }
.ks-board-area { padding-top: 4px; align-items: center; }

/* Landscape: block on the right, dice + info + buttons on the left */
@media (min-aspect-ratio: 4001/3000) {
  #screen-ks-game.active {
    --ks-cell: clamp(30px, calc((100dvh - 70px - var(--safe-top) - var(--safe-bottom)) / 6), 88px);
    --ks-tray: clamp(110px, calc(100dvh - 236px - var(--safe-top) - var(--safe-bottom)), 260px);
    grid-template-columns: var(--ks-tray) minmax(0, 1fr) auto;
    grid-template-rows: auto auto minmax(0, 1fr) auto auto;
    grid-template-areas: "top top board" "dice info board" ". . board" "status status board" "act act board";
    column-gap: 14px; row-gap: 6px;
    padding: max(6px, var(--safe-top)) max(12px, var(--safe-right)) max(8px, var(--safe-bottom)) max(12px, var(--safe-left));
  }
  #screen-ks-game .topbar { padding: 0; min-width: 0; }
  .ks-board-area { align-items: center; padding: 0; }
  .ks-info { flex-direction: column; align-items: flex-start; }
  #screen-ks-game .status { font-size: 13px; min-height: 0; }
  #screen-ks-game .actionbar { padding: 0; background: none; }
  #screen-ks-game .actionbar .main { height: 50px; font-size: 16px; }
  #screen-ks-game .toasts { left: 0; right: auto; width: min(50vw, 420px); top: max(50px, var(--safe-top)); bottom: auto; flex-direction: column; }
}
@media (min-aspect-ratio: 4001/3000) and (min-height: 560px) {
  .ks-info { flex-direction: row; align-items: center; }
}
@media (min-aspect-ratio: 4001/3000) and (min-width: 1000px) and (min-height: 620px) {
  #screen-ks-game.active { --ks-cell: clamp(48px, calc((100dvh - 90px) / 6), 96px); --ks-tray: clamp(180px, 22vw, 280px); column-gap: 28px; row-gap: 12px; padding: 22px 32px; }
  #screen-ks-game .status { font-size: 15px; }
  .ks-board { padding: 14px; --ks-gap: 4px; }
}
/* Tall phones: legend under the info */
@media (max-aspect-ratio: 4/3) and (min-height: 760px) {
  .ks-now-num { width: 70px; height: 70px; font-size: 38px; }
}

/* Points table on the block (left column, like the original) */
.ks-legend {
  grid-column: 1; grid-row: 2 / span 5;
  display: grid; grid-template-columns: 1fr auto; align-content: center; gap: 0 4px;
  padding: 2px 4px 2px 0;
  font: 700 clamp(9px, calc(var(--ks-cell) * .235), 15px)/1.55 system-ui, sans-serif; color: #f6e3e3;
}
.ks-legend .lg-n { white-space: nowrap; }
.ks-legend .lg-n s { text-decoration: line-through; text-decoration-color: #ff4d4d; text-decoration-thickness: 2px; }
.ks-legend .lg-p { white-space: nowrap; text-align: right; font-weight: 900; color: #fff; font-variant-numeric: tabular-nums; }
.ks-legend .lg-p::before { content: "= "; font-weight: 400; color: #e0b4b4; }
.ks-legend .lg-dx {
  grid-column: 1 / -1; margin-top: .35em; font-weight: 900; letter-spacing: 0; text-transform: uppercase;
  color: #7cc8f0; font-size: .95em; white-space: nowrap;
}
