/* ==========================================================================
   Kniffel – Würfel rollen direkt auf dem Tisch, Spielblock aus Papier
   ========================================================================== */
.kn { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 8px; padding: 0 12px 12px; overflow: hidden; }
.kn-rail { margin: 0 -4px; }
.kn-rail .rail-chip { cursor: pointer; }

/* Würfelfläche: kein Kasten – die Würfel liegen auf dem Tisch (unsichtbare Bande am Rand) */
.kn-tray { flex: 1 0 auto; position: relative; min-height: clamp(200px, 35dvh, 320px); margin: 0 -6px; }
/* Halteleiste: weiche Mulde ohne Kante, nur sichtbar, wenn gehalten werden kann */
.kn-tray .dt-hold { background: radial-gradient(closest-side, rgba(0, 0, 0, .16), rgba(0, 0, 0, .08) 70%, transparent); box-shadow: none; border-radius: 50%; opacity: 0; transition: opacity .35s; }
.kn-tray.holding .dt-hold { opacity: 1; }

/* Aktionen: feste Höhe, damit der Block darunter nie springt */
.kn-action { flex: none; display: flex; gap: 8px; height: 54px; }
.kn-action .btn { flex: 1; font-size: 17px; padding: 12px 14px; animation: popIn .3s var(--spring) both; }
.kn-action.still .btn { animation: none; }
.kn-action.two .roll { flex: none; gap: 0; }
.kn-action .btn b { margin-left: 6px; font: 800 20px var(--display); }
.kn-pips { display: inline-flex; gap: 4px; margin-left: 8px; }
.kn-pips i { width: 9px; height: 9px; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(255, 246, 234, .6); }
.kn-pips i.on { background: #fff6ea; box-shadow: none; }

/* Spielblock */
.kn-sheet { flex: 0 1 auto; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; align-content: start; padding: 10px 12px 8px; border-radius: 6px; color: var(--ink);
  background: var(--grain), var(--card); box-shadow: var(--shadow-1); position: relative; overflow: hidden; }
.kn-sheet:empty { display: none; }
.kn-sheet::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 5px; background: var(--red); }
.kn-col { display: grid; grid-template-rows: repeat(7, minmax(28px, 44px)); }
.kn-cell { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 0 6px; border-bottom: 1px solid var(--line); min-width: 0; transition: background .15s; border-radius: 3px; }
.kn-cell .lb { min-width: 0; font: 700 12.5px var(--text); color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kn-cell .lb small { font-weight: 600; color: var(--ink-3); }
.kn-cell .cv { font: 700 26px/1 var(--hand); min-width: 28px; text-align: right; color: #1f3b8f; }
.kn-cell.open { cursor: pointer; }
.kn-cell.fill.z .cv { color: var(--ink-3); text-decoration: line-through; }
.kn-cell.pot .cv { color: var(--ink-3); font: 700 15px var(--display); opacity: .75; }
.kn-cell.pot.z .cv { opacity: .3; }
.kn-cell.good { background: rgba(217, 162, 58, .16); }
.kn-cell.good .cv { color: var(--mustard-d); opacity: 1; }
.kn-cell.sel { background: rgba(217, 162, 58, .26); box-shadow: inset 3px 0 0 var(--mustard); }
.kn-cell.sel .cv { color: var(--ink); opacity: 1; }
.kn-cell.write .cv, table.kn-tb td.write { animation: knWrite .9s ease-out both; }
@keyframes knWrite { from { clip-path: inset(0 100% 0 0); transform: rotate(-4deg) scale(1.2); } to { clip-path: inset(0 0 0 0); } }
.kn-cell.bonus { border-bottom: 1.5px solid var(--ink); }
.kn-cell.bonus .cv { font-size: 20px; }
.kn-cell.bonus.got .cv { color: var(--teal); }

/* Punktetabelle */
.kn-layer:empty { display: none; }
.kn-over { position: absolute; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 14px; background: rgba(14, 8, 4, .6); animation: fadeIn .2s; }
.kn-over .sheet { position: relative; max-width: 560px; padding: 14px 8px; }
table.kn-tb { width: 100%; border-collapse: collapse; color: var(--ink); }
table.kn-tb th { font: 700 18px/1 var(--hand); padding: 6px 3px; text-align: center; border-bottom: 1.5px solid var(--ink); max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.kn-tb th .av { --s: 28px; margin: 0 auto 4px; }
table.kn-tb th:first-child, table.kn-tb td:first-child { text-align: left; padding-left: 6px; color: var(--ink-2); white-space: nowrap; font: 700 12.5px var(--text); }
table.kn-tb td { padding: 4px 3px; text-align: center; border-bottom: 1px solid var(--line); font: 700 22px/1 var(--hand); color: #1f3b8f; }
table.kn-tb td.bn small { font: 700 11px var(--text); color: var(--ink-3); }
table.kn-tb tr.sep td { border-top: 1.5px solid var(--ink); }
table.kn-tb tr.sum td { font: 800 18px var(--display); color: var(--red); }
table.kn-tb .cur { background: color-mix(in srgb, var(--turn-ring) 14%, transparent); }
table.kn-tb th.cur { box-shadow: inset 0 0 0 3px var(--turn-ring); border-radius: 8px 8px 0 0; }

/* Tisch */
.kn.table { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); grid-template-rows: auto minmax(0, 1fr); gap: 18px 22px; padding: 4px 22px 22px; }
.kn.table .kn-rail { grid-column: 1 / -1; }
.kn.table .kn-left { display: flex; flex-direction: column; justify-content: center; gap: 14px; min-height: 0; }
.kn.table .kn-tray { flex: none; min-height: 0; height: min(64vh, 540px); margin: 0; }
.kn.table .kn-board { min-height: 0; overflow: auto; padding: 12px; display: flex; color: var(--ink); background: var(--grain), var(--card); border-radius: 6px; box-shadow: var(--shadow-1); }
.kn.table table.kn-tb { height: 100%; }
.kn.table table.kn-tb td { font-size: clamp(16px, 2.6vh, 26px); padding: .15vh 4px; }
.kn.table table.kn-tb td:first-child { font-size: clamp(11px, 1.8vh, 15px); }
.kn.table table.kn-tb th { font-size: clamp(16px, 2.4vh, 24px); }
.kn.table table.kn-tb th .av { --s: clamp(28px, 5vh, 44px); }
.kn-last { min-height: 40px; text-align: center; font: 700 clamp(22px, 2.4vw, 30px)/1.2 var(--hand); color: var(--on-wood-2); }
.kn-last b { color: var(--mustard); font-family: var(--display); }
.kn-last .pop { display: inline-block; animation: popIn .45s var(--spring); }
@media (max-width: 900px) { .kn.table { grid-template-columns: 1fr; overflow-y: auto; } }

@media (max-height: 720px) {
  .kn-tray { min-height: clamp(170px, 30dvh, 250px); }
  .kn-col { grid-template-rows: repeat(7, minmax(24px, 34px)); }
}
