/* ======================================================================
   Kniffel
   ====================================================================== */

/* ---------- Small dice icons (block, menu, logo) ---------- */
.mini-die {
  display: inline-block; width: 16px; height: 16px; border-radius: 4px; flex: none;
  background: #fff no-repeat center/100%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.25);
  vertical-align: -3px; font-style: normal;
}
.mini-die.big { width: 22px; height: 22px; border-radius: 5px; box-shadow: 0 2px 0 rgba(0,0,0,.25), inset 0 0 0 1px rgba(0,0,0,.15); }
.mini-die[data-face="1"] { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2320242c'%3E%3Ccircle cx='12' cy='12' r='2.4'/%3E%3C/svg%3E"); }
.mini-die[data-face="2"] { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2320242c'%3E%3Ccircle cx='6.5' cy='6.5' r='2.3'/%3E%3Ccircle cx='17.5' cy='17.5' r='2.3'/%3E%3C/svg%3E"); }
.mini-die[data-face="3"] { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2320242c'%3E%3Ccircle cx='6.5' cy='6.5' r='2.3'/%3E%3Ccircle cx='12' cy='12' r='2.3'/%3E%3Ccircle cx='17.5' cy='17.5' r='2.3'/%3E%3C/svg%3E"); }
.mini-die[data-face="4"] { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2320242c'%3E%3Ccircle cx='6.5' cy='6.5' r='2.3'/%3E%3Ccircle cx='17.5' cy='6.5' r='2.3'/%3E%3Ccircle cx='6.5' cy='17.5' r='2.3'/%3E%3Ccircle cx='17.5' cy='17.5' r='2.3'/%3E%3C/svg%3E"); }
.mini-die[data-face="5"] { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2320242c'%3E%3Ccircle cx='6.5' cy='6.5' r='2.3'/%3E%3Ccircle cx='17.5' cy='6.5' r='2.3'/%3E%3Ccircle cx='12' cy='12' r='2.3'/%3E%3Ccircle cx='6.5' cy='17.5' r='2.3'/%3E%3Ccircle cx='17.5' cy='17.5' r='2.3'/%3E%3C/svg%3E"); }
.mini-die[data-face="6"] { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2320242c'%3E%3Ccircle cx='6.5' cy='6' r='2.2'/%3E%3Ccircle cx='17.5' cy='6' r='2.2'/%3E%3Ccircle cx='6.5' cy='12' r='2.2'/%3E%3Ccircle cx='17.5' cy='12' r='2.2'/%3E%3Ccircle cx='6.5' cy='18' r='2.2'/%3E%3Ccircle cx='17.5' cy='18' r='2.2'/%3E%3C/svg%3E"); }

/* ---------- Menu card & logo ---------- */
.gc-kn { background: linear-gradient(160deg, #d8232a, #a3151b); display: flex; align-items: center; justify-content: center; gap: 3px; }
.gc-kn .mini-die.big { width: 16px; height: 16px; border-radius: 4px; }
.gc-kn .mini-die:nth-child(odd) { transform: rotate(-8deg); }
.gc-kn .mini-die:nth-child(even) { transform: rotate(7deg) translateY(2px); }
.kn-logo span {
  display: inline-block; font-weight: 900; font-size: 52px; letter-spacing: 3px; line-height: 1;
  color: #e5242b; text-shadow: 0 3px 0 #7a0e12, 0 0 0 #fff;
  -webkit-text-stroke: 2px #fff; paint-order: stroke fill;
  transform: rotate(-3deg);
}
.kn-logo-dice { display: flex; justify-content: center; gap: 8px; margin: 12px 0 2px; }
.kn-logo-dice .mini-die { width: 28px; height: 28px; border-radius: 7px; }
.kn-logo-dice .mini-die:nth-child(odd) { transform: rotate(-9deg); }
.kn-logo-dice .mini-die:nth-child(even) { transform: rotate(8deg) translateY(3px); }

/* ---------- Game screen: layout ---------- */
#screen-kn-game.active { display: grid; }
#screen-kn-game .kn-left { display: contents; }
.kn-sheet-area { grid-area: sheet; min-height: 0; min-width: 0; overflow: auto; display: flex; justify-content: center; align-items: flex-start; }
.kn-rolls { grid-area: rolls; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); padding-top: 8px; }
.kn-dots { display: inline-flex; gap: 4px; }
.kn-dots i { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--muted); }
.kn-dots i.on { background: var(--accent); border-color: var(--accent); }
#screen-kn-game .status { grid-area: status; display: block; text-align: left; line-height: 1.35; }

/* Held dice: yellow frame + small lock */
#kn-dice .die.held {
  box-shadow: 0 0 0 0.8cqw #fff, 0 0 0 2.4cqw var(--accent), 0 1.4cqw 3cqw rgba(0,0,0,.5);
  z-index: 3;
}
#kn-dice .die.held::after {
  content: ""; position: absolute; right: -9%; top: -9%; width: 34%; height: 34%; border-radius: 50%;
  background: var(--accent) no-repeat center/62% url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232a2100' stroke-width='3' stroke-linecap='round'%3E%3Crect x='5' y='11' width='14' height='10' rx='2'/%3E%3Cpath d='M8 11V8a4 4 0 0 1 8 0v3'/%3E%3C/svg%3E");
  box-shadow: 0 1px 3px rgba(0,0,0,.4);
}
#kn-dice .die.pickable { cursor: pointer; }

/* ---------- Kniffel block: game board like the other games ----------
   Gray-green board (as in "Noch mal so gut!"), colored rows with light boxes (as in Qwixx) */
.kn-sheet {
  --kn-label: minmax(0, 1.6fr);
  background: #c7cfce;
  border-radius: 14px;
  padding: 8px;
  box-shadow: 0 12px 30px rgba(0,0,0,.4);
  color: #1d1f22;
  width: 100%; max-width: 980px;
  font-variant-numeric: tabular-nums;
}
.kn-secs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kn-sec { min-width: 0; }
.kn-row {
  display: grid;
  grid-template-columns: var(--kn-label) repeat(var(--n), minmax(0, 1fr));
  gap: 3px;
  align-items: stretch;
  padding: 3px;
  border-radius: 10px;
  margin-bottom: 3px;
  background: var(--tile);
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.12);
}
.kn-row.kniffel { background: linear-gradient(90deg, #ffc734, #ffdf6e 50%, #ffc734); }

/* Header: player names as small labels */
.kn-head { background: none; box-shadow: none; padding: 0 3px 2px; margin-bottom: 1px; }
.kn-pl {
  text-align: center; font-size: 11px; font-weight: 800; color: #3a3f48;
  background: rgba(255,255,255,.7); border-radius: 6px; padding: 2px 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kn-pl.colact { background: var(--accent); color: var(--accent-text); box-shadow: 0 2px 6px rgba(0,0,0,.2); }

/* Category label (white tile like the column letters / bonus fields of the other games) */
.kn-lab {
  display: flex; align-items: center; gap: 6px; min-width: 0;
  background: #fff; border-radius: 7px; padding: 0 7px;
  height: var(--kn-row);
  font-size: 13px; font-weight: 800; white-space: nowrap; overflow: hidden;
}
.kn-lab .ls { display: none; }
.kn-lab small { display: none; font-weight: 500; color: #8a91a0; font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
.kn-lab .mini-die { width: 17px; height: 17px; }
.kn-ic {
  font-style: normal; flex: none;
  display: inline-grid; place-items: center; min-width: 22px; height: 17px; padding: 0 3px;
  border-radius: 5px; background: var(--tile); color: #fff;
  font-size: 10px; font-weight: 900; letter-spacing: -.3px;
}
.kn-ic.star { background: #1d1f22; color: #ffc734; font-size: 12px; }

/* Boxes */
.kn-c {
  position: relative;
  height: var(--kn-row);
  display: grid; place-items: center;
  border-radius: 7px;
  background: color-mix(in srgb, var(--tile-l) 45%, #fff);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.06), 0 1px 0 rgba(0,0,0,.12);
  font-size: 15px; font-weight: 900; color: #1d1f22;
  transition: transform 90ms, box-shadow 140ms, background 140ms;
}
.kn-c.colact { background: color-mix(in srgb, var(--tile-l) 25%, #fff); }
.kn-c.blocked { opacity: .45; }
.kn-c.cand {
  cursor: pointer; background: #fff; z-index: 1;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #1d1f22, 0 3px 8px rgba(0,0,0,.25);
  animation: kn-cand 1.4s ease-in-out infinite;
}
@keyframes kn-cand {
  0%, 100% { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #1d1f22, 0 3px 8px rgba(0,0,0,.25); }
  50% { box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgba(29,31,34,.35), 0 3px 8px rgba(0,0,0,.25); }
}
.kn-c.cand:active { transform: scale(.94); }
.kn-c.cand .pv { color: #6b7385; font-weight: 700; font-style: italic; }
.kn-c.cand .pv.z { color: #b9bec6; }
.kn-c.sel {
  cursor: pointer; background: #fff; z-index: 2;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4.5px var(--accent), 0 3px 10px rgba(0,0,0,.3);
}
.kn-c.sel b { font-size: 17px; }
/* Crossed out = X like on the other boards */
.kn-c.zero::after {
  content: ""; position: absolute; inset: 14% 22%;
  background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231b2130' stroke-width='3.4' stroke-linecap='round'%3E%3Cpath d='M5 5l14 14M19 5L5 19'/%3E%3C/svg%3E");
  opacity: .75;
}
.kn-xb {
  position: absolute; right: 2px; top: 1px;
  font-style: normal; font-size: 9px; font-weight: 900; color: #fff;
  background: #e5242b; border-radius: 4px; padding: 0 3px; line-height: 13px;
}

/* Total rows: white boxes with a colored frame (like the Qwixx total row) */
.kn-sum { background: rgba(255,255,255,.35); box-shadow: none; }
.kn-sum .kn-lab { background: transparent; font-size: 12px; padding-left: 4px; }
.kn-box {
  height: var(--kn-row);
  display: grid; place-items: center; position: relative;
  background: #fff; border-radius: 7px;
  border: 2.5px solid #9aa0a6;
  font-size: 15px; font-weight: 900;
  overflow: hidden;
}
.kn-sum.blue .kn-box { border-color: #52d3f7; }
.kn-sum.orange .kn-box { border-color: #ff8726; }
.kn-sum.bonus .kn-box { border-color: #88c946; }
.kn-box.colact { box-shadow: 0 0 0 2px var(--accent); }
.kn-bar { position: absolute; left: 4px; right: 4px; bottom: 3px; height: 4px; border-radius: 3px; background: #e3e7ea; overflow: hidden; }
.kn-bar i { display: block; height: 100%; background: linear-gradient(90deg, #88c946, #4fae2f); border-radius: 3px; }
.kn-miss { font-size: 11px; font-weight: 800; color: #3d6b22; white-space: nowrap; }
.kn-bonus-got { color: #2f8a1f; }
.kn-bonus-lost { color: #b9bec6; }
.kn-sum.grand { margin-top: 6px; background: #1d1f22; padding: 4px; }
.kn-sum.grand .kn-lab { color: #fff; font-size: 14px; }
.kn-sum.grand .kn-box { border: 0; font-size: 18px; color: #e5242b; height: calc(var(--kn-row) + 4px); }
.kn-sum.grand .kn-box.colact { box-shadow: inset 0 0 0 3px var(--accent); }

/* Narrow: short names; many players: sections stacked */
.kn-sheet:not(.few) .kn-secs { grid-template-columns: 1fr; }

/* Kniffel celebration */
.kn-flash-card .kn-word { font-size: clamp(54px, 15vmin, 110px); color: #e5242b; letter-spacing: 1px; }

/* ---------- Layouts ---------- */
#screen-kn-game { --kn-row: 28px; }
/* Short names by default (phone), long ones with hints on large screens */
.kn-lab .ln { display: none; }
.kn-lab .ls { display: inline; }

/* Landscape (phone held sideways, tablet, PC) */
@media (min-aspect-ratio: 4001/3000) {
  #screen-kn-game.active {
    --left-w: clamp(160px, min(28vw, calc(100dvh - 165px - var(--safe-bottom))), 360px);
    --kn-row: clamp(18px, calc((100dvh - 198px - var(--safe-bottom)) / 9), 46px);
    grid-template-columns: var(--left-w) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto auto auto;
    grid-template-areas:
      "dice   top"
      "dice   sheet"
      "rolls  sheet"
      "status sheet"
      "act    sheet";
    column-gap: 14px;
    padding: max(6px, var(--safe-top)) max(12px, var(--safe-right)) max(8px, var(--safe-bottom)) max(12px, var(--safe-left));
  }
  #screen-kn-game .status { font-size: 13px; padding-top: 4px; }
  .kn-sheet .kn-c, .kn-sheet .kn-box { font-size: clamp(12px, calc(var(--kn-row) * .55), 19px); }
  .kn-sheet .kn-lab { font-size: clamp(11px, calc(var(--kn-row) * .5), 15px); }
}
@media (min-aspect-ratio: 4001/3000) and (max-height: 520px) {
  .kn-row { padding: 2px; margin-bottom: 2px; gap: 2px; border-radius: 8px; }
  .kn-lab { padding: 0 5px; gap: 4px; }
  .kn-lab .mini-die { width: 14px; height: 14px; }
  .kn-ic { min-width: 19px; height: 14px; font-size: 9px; }
  .kn-pl { font-size: 10px; padding: 1px 2px; }
  .kn-sum.grand { margin-top: 3px; padding: 3px; }
}
@media (min-aspect-ratio: 4001/3000) and (min-width: 1000px) and (min-height: 620px) {
  #screen-kn-game.active {
    --left-w: clamp(260px, 24vw, 380px);
    --kn-row: clamp(28px, calc((100dvh - 230px) / 9), 46px);
    grid-template-rows: auto auto auto auto auto minmax(0, 1fr);
    grid-template-areas:
      "dice   top"
      "dice   sheet"
      "rolls  sheet"
      "status sheet"
      "act    sheet"
      ".      sheet";
    column-gap: 32px;
    padding: 22px 32px;
  }
  .kn-sheet-area { align-items: center; }
  .kn-sheet { padding: 12px; }
  .kn-secs { gap: 12px; }
  .kn-lab .ln { display: inline; }
  .kn-lab .ls { display: none; }
  .kn-lab small { display: inline; }
  .kn-pl { font-size: 13px; padding: 3px 4px; }
  #screen-kn-game .status { font-size: 15px; }
}

/* Portrait (phone upright) */
@media (max-aspect-ratio: 4/3) {
  #screen-kn-game.active {
    --bowl: clamp(130px, min(44vw, 24dvh), 280px);
    --kn-row: clamp(22px, calc((100dvh - 400px - var(--safe-top) - var(--safe-bottom)) / 9), 38px);
    grid-template-columns: var(--bowl) minmax(0, 1fr);
    grid-template-rows: auto auto auto minmax(0, 1fr) auto;
    grid-template-areas:
      "top   top"
      "dice  status"
      "dice  rolls"
      "sheet sheet"
      "act   act";
    column-gap: 12px;
    padding: var(--safe-top) max(8px, var(--safe-right)) 0 max(8px, var(--safe-left));
  }
  #screen-kn-game .status { align-self: end; font-size: 14px; }
  #screen-kn-game .kn-rolls { align-self: start; }
  .kn-sheet-area { padding: 10px 0 2px; }
  .kn-sheet { padding: 6px; }
  .kn-secs { gap: 5px; }
  .kn-row { padding: 2px; gap: 2px; margin-bottom: 2px; border-radius: 8px; }
  .kn-lab { padding: 0 4px; gap: 3px; font-size: 11.5px; border-radius: 6px; }
  .kn-lab .mini-die { width: 13px; height: 13px; }
  .kn-ic { min-width: 18px; height: 13px; font-size: 8.5px; padding: 0 2px; }
  .kn-c, .kn-box { font-size: 14px; border-radius: 6px; }
  .kn-pl { font-size: 10px; }
  .kn-sum .kn-lab { font-size: 10.5px; }
  .kn-sum .kn-lab small { display: none; }
  /* more room for the names, numbers stay readable */
  .kn-sheet { --kn-label: minmax(0, 2.5fr); }
  .kn-miss .w { display: none; }
  .kn-lab .mini-die { width: 12px; height: 12px; }
  /* More than 3 players: stacked → scroll */
  .kn-sheet:not(.few) { --kn-row: 26px; }
}
#kn-btn-main { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
