/* Katsching — schlichte erste Gestaltung, mobile-first. Design kommt in Teilprojekt 2. */
:root {
  --bg: #f4f1ea;
  --paper: #fffdf7;
  --ink: #1d1d1b;
  --muted: #6b6b66;
  --accent: #1d3557;
  --accent-ink: #ffffff;
  --ok: #2a9d8f;
  --ok-bg: #d9f2ee;
  --zero-bg: #efede6;
  --line: #d9d5c9;
  --radius: 10px;
  --tap: 44px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 16px; }
.app { max-width: 640px; margin: 0 auto; padding: 12px 12px calc(16px + env(safe-area-inset-bottom)); }
h1, h2 { margin: 0 0 12px; }
h1 { font-size: 1.8rem; }
h2 { font-size: 1.25rem; }
p { line-height: 1.4; }
.muted { color: var(--muted); }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }

button, .btn {
  font: inherit; min-height: var(--tap); padding: 10px 16px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--paper); color: var(--ink); cursor: pointer;
}
button:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn-big { width: 100%; font-size: 1.15rem; min-height: 56px; }
.btn-ghost { background: transparent; }
select, input[type="text"] {
  font: inherit; min-height: var(--tap); padding: 8px 10px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--paper); color: var(--ink); width: 100%;
}
label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: 4px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.menu { display: grid; gap: 10px; }

/* Spieleinrichtung */
.player-list { display: grid; gap: 8px; }
.player-row { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; }
.player-row select { width: auto; }

/* Spiel-Kopf */
.game-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.game-head .who { font-size: 1.2rem; font-weight: 700; }

/* Wuerfel (schlichter Renderer) */
.dice { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.die {
  aspect-ratio: 1; display: grid; place-items: center; font-size: clamp(1.6rem, 8vw, 2.4rem); font-weight: 700;
  background: var(--paper); border: 2px solid var(--line); border-radius: 12px; cursor: pointer; user-select: none;
  min-height: var(--tap); padding: 0;
}
.die.held { border-color: var(--accent); background: #e6ecf5; box-shadow: inset 0 0 0 2px var(--accent); }
.die.blank { color: var(--muted); }
.die:disabled { cursor: default; opacity: 1; }  /* Ergebnis bleibt nach dem 3. Wurf voll sichtbar */
.held-hint { font-size: .85rem; color: var(--muted); text-align: center; margin-top: 4px; }

/* Wuerfelbecher v1 */
.cup-stage { position: relative; height: 112px; }
.slots { display: grid; grid-template-columns: repeat(3, 1fr); height: 100%; }
.slot { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; padding-bottom: 2px; }
.slot .disc { width: 72%; height: 16px; border-radius: 50%; background: #ddd8c8; border: 1px solid #cfc9b8; }
.slot.used .disc { background: #ebe7db; border-style: dashed; }
.slot.active .disc { background: #d2cbb6; }
.cup {
  position: absolute; top: 0; left: 0; width: 33.333%; height: 104px; padding: 0; border: 0; background: transparent;
  display: grid; place-items: center; cursor: grab; touch-action: none; -webkit-tap-highlight-color: transparent; user-select: none;
  transition: transform .5s cubic-bezier(.3,.9,.3,1.1);
}
.cup:disabled { cursor: default; opacity: 1; }
.cup.empty .cup-body { transform: rotate(180deg); opacity: .45; }  /* liegt umgedreht auf dem Platz */
.cup-body { display: block; transform-origin: 50% 50%; transition: transform .35s; will-change: transform; color: var(--ink); }
.cup.holding { cursor: grabbing; }
.cup.holding .cup-body { transition: none; }
.cup-svg { width: 66px; height: 86px; filter: drop-shadow(0 3px 3px rgba(0,0,0,.14)); }
.cup:focus-visible .cup-svg { outline: 3px solid var(--accent); outline-offset: 4px; border-radius: 12px; }
.cup-hint { text-align: center; font-size: .85rem; min-height: 1.2em; margin-top: 4px; }
@media (prefers-reduced-motion: reduce) { .cup { transition: none; } .cup-body { transition: none; } }

/* Spielblock v2: Karten */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.tab { flex: 0 0 auto; min-height: 36px; padding: 6px 12px; border-radius: 999px; font-size: .9rem; background: transparent; }
.tab.active { background: var(--paper); border-color: var(--ink); }
.tab.current { font-weight: 600; }
.tab.current::before { content: '▶ '; font-size: .7em; color: var(--accent); }
.block { display: grid; gap: 10px; }
.block.readonly .card-field { opacity: .8; }
.small { font-size: .85rem; margin: 0; }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.card-field {
  display: grid; grid-template-columns: 44px 1fr auto; grid-template-areas: "icon name val"; align-items: center; gap: 8px;
  min-height: 60px; padding: 8px 10px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--paper);
  color: var(--ink); text-align: left; font: inherit; position: relative;
}
.card-field .icon { grid-area: icon; width: 44px; height: 44px; display: grid; place-items: center; color: var(--ink); }
.card-field .icon .pips { width: 40px; height: 40px; }
.card-field .name { grid-area: name; font-size: .82rem; color: var(--muted); line-height: 1.15; }
.card-field .val { grid-area: val; font-size: 1.35rem; font-variant-numeric: tabular-nums; min-width: 1.6em; text-align: right; color: var(--ink); }
.card-field .val.dot { color: var(--accent); }
.card-field .val.strong { font-weight: 700; }
.card-field .lock { position: absolute; right: 6px; bottom: 5px; width: 12px; height: 12px; color: var(--muted); }
.card-field.filled { background: #f1eee6; border-color: #c9c4b6; }
.card-field.filled .val { font-weight: 800; }
.card-field.struck .val { color: var(--muted); }
.card-field.struck .icon { color: #b9b4a6; }
.card-field.option .val, .card-field.option-zero .val { font-weight: 400; }
.card-field.option-zero .val { color: var(--muted); }
.card-field.selectable { cursor: pointer; border-color: #bdb8aa; }
.card-field.selectable:active { transform: scale(.98); }
.card-field:disabled { cursor: default; opacity: 1; }
.card-field.info { background: transparent; border-style: dashed; }
.sumline { display: flex; justify-content: space-between; gap: 8px; padding: 4px 6px; font-size: .9rem; flex-wrap: wrap; }
.sumline b { font-variant-numeric: tabular-nums; }
.sumline.total { border-top: 2px solid var(--line); padding-top: 8px; font-size: 1rem; }
.sumline .grand { font-size: 1.1rem; }
@media (min-width: 480px) { .grid.upper { grid-template-columns: repeat(3, 1fr); } .grid.lower { grid-template-columns: repeat(4, 1fr); }
  .card-field { grid-template-columns: 1fr; grid-template-areas: "icon" "val" "name"; text-align: center; justify-items: center; min-height: 110px; }
  .card-field .val { text-align: center; } }

/* Wuerfel-Augen */
.die.tumble { color: var(--muted); border-style: dashed; }
.die.tumble .pips { opacity: .8; }
.die .pips { width: 78%; height: 78%; }
.die .blank-dot { color: var(--muted); }

/* Ergebnis-Tabelle (Details) */
.sheet { width: 100%; border-collapse: collapse; background: var(--paper); border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line); font-size: .95rem; }
.sheet th, .sheet td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: center; }
.sheet th.name, .sheet td.name { text-align: left; }
.sheet tr.calc td { background: #f7f4ec; font-weight: 600; }

/* Ergebnis */
.ranking { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.ranking li { display: flex; justify-content: space-between; align-items: center; }
.ranking .place { font-weight: 700; min-width: 2.2em; }
.ranking .points { font-weight: 700; font-size: 1.2rem; }

/* Zugübergabe */
.handover .card.last { font-size: 1.05rem; line-height: 1.4; }
.ranking li.current { background: #e6ecf5; margin: 0 -8px; padding: 4px 8px; border-radius: 6px; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: .95rem; max-width: 90vw;
  box-shadow: 0 4px 16px rgba(0,0,0,.25); z-index: 10; }
.toast[hidden] { display: none; }

.shake { animation: shake .3s linear; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@media (prefers-reduced-motion: reduce) { .shake { animation: none; } }
