:root {
  --ink: #2b2150;
  --muted: #6f6792;
  --brand: #34106c;
  --line: #e2dcf3;
  --floor: #efeaf9;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  display: flex; flex-direction: column; height: 100vh; height: 100dvh; height: var(--hoehe, 100dvh); overflow: hidden; /* --hoehe = innerHeight из app.js (старый Safari: vh больше видимого окна) */
  background: #fff; color: var(--ink);
  font: 500 16px/1.4 "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none;
  overscroll-behavior: none;
}
button { font: inherit; cursor: default; touch-action: manipulation; }
[hidden] { display: none !important; }


.btn { display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 10px; padding: 9px 16px; font-weight: 700; font-size: 15px; background: #fff; color: var(--ink); white-space: nowrap; }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.btn--small { padding: 6px 12px; font-size: 14px; background: #f1eefc; color: var(--brand); }
.btn--small:hover { background: #e6e0fa; }
.btn--primary { background: var(--brand); color: #fff; padding: 13px 22px; font-size: 17px; }
.btn--primary:hover { background: #4a1d94; }

.stage { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; padding: 10px 16px 12px; gap: 8px; }
.info { display: flex; align-items: center; gap: 12px; width: 100%; max-width: 1100px; }
.clock, .zuege { font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.zuege b { color: var(--ink); }
.stats { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; font-size: 14px; font-weight: 600; color: var(--muted); }
.stats b { color: var(--ink); font-size: 16px; margin-right: 4px; }
.st { padding: 3px 10px; border-radius: 8px; font-size: 13px; font-weight: 700; }
.bildwahl { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.vorschau { display: inline-flex; align-items: center; gap: 6px; border: 2px solid var(--line); background: #fff; border-radius: 10px; padding: 2px 10px 2px 2px; font-size: 14px; font-weight: 700; color: var(--brand); }
.vorschau img { width: 30px; height: 30px; border-radius: 7px; object-fit: cover; display: block; }
.vorschau[aria-pressed="true"] { border-color: var(--brand); }

/* поле: картинка-квадрат --s (px, считает app.js по месту в .feld — без aspect-ratio/cqw, как в Schiebepuzzle для старых iPad)
   + справа столбик ответов --cw (только «Rechnen») */
.feld { flex: 1; min-height: 0; width: 100%; max-width: 1100px; display: grid; place-items: center; }
#brett { --n: 4; --s: min(80vw, 60vh); --cw: 0px; --schrift: 20px; display: flex; gap: 10px; }
.bildfeld { position: relative; width: var(--s); height: var(--s); background: var(--floor); border-radius: 6px; touch-action: none;
  box-shadow: 0 6px 22px rgba(52, 16, 108, .16); }
.streifen { position: absolute; left: 0; top: 0; width: 100%; height: calc(100% / var(--n));
  background-size: 100% calc(var(--n) * 100%); background-color: #ddd; outline: none;
  transition: transform .2s cubic-bezier(.3, .7, .4, 1), box-shadow .2s; will-change: transform; }
.bildfeld.ohne-anim .streifen { transition: none; }
/* шов между полосками; в «Bild» исчезает, когда соседи подходят друг к другу */
.streifen::before { content: ""; position: absolute; left: 0; right: 0; top: -2px; height: 4px; background: #fff; z-index: 1; transition: opacity .35s; pointer-events: none; }
.streifen.oben::before, .streifen.verbunden::before { opacity: 0; }
/* Zahlen / Rechnen: картинки нет — пастельная полоска (--farbe ставит app.js) с лёгким узором из точек */
.verdeckt .streifen { background-color: var(--farbe, #e9e3f8);
  background-image: radial-gradient(rgba(255, 255, 255, .55) 1.6px, transparent 1.8px) !important; background-size: 16px 16px !important; background-position: 0 0 !important; }
.streifen.gewaehlt { z-index: 3; box-shadow: inset 0 0 0 4px #f5b400, 0 6px 18px rgba(20, 10, 60, .35); }
.streifen.zieht { transition: box-shadow .2s; z-index: 4; box-shadow: 0 14px 30px rgba(20, 10, 60, .45); }
.streifen:focus-visible { box-shadow: inset 0 0 0 3px var(--brand); }
.etikett { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 2; pointer-events: none;
  padding: .08em .5em; border-radius: .45em; background: rgba(255, 255, 255, .93); color: var(--brand);
  font-weight: 800; font-size: var(--schrift); line-height: 1.2; font-variant-numeric: tabular-nums; white-space: nowrap;
  box-shadow: 0 1px 4px rgba(52, 16, 108, .2); transition: opacity .5s; }
.spalte { width: var(--cw); height: var(--s); display: flex; flex-direction: column; }
.spalte:empty { display: none; }
.ziel { flex: 1; display: flex; align-items: center; font-weight: 800; font-size: var(--schrift); color: var(--ink); font-variant-numeric: tabular-nums;
  white-space: nowrap; border-top: 2px dashed var(--line); }
.ziel:first-child { border-top: 0; }
.ziel.stimmt { color: #1f7a5a; }

/* Rechenpuzzle: полоска на своём месте закреплена (Лина 09.11.2026) — пример зелёный с галочкой, ответ справа тоже зелёный;
   сдвинуть нельзя — при попытке покачивается */
.streifen.fest .etikett { color: #1f7a5a; }
.streifen.fest .etikett::after { content: ' ✓'; }
.ziel.fest { color: #1f7a5a; }
.streifen.wackelt .etikett { animation: wackeln .35s ease; }
@keyframes wackeln { 25% { transform: translate(calc(-50% - 5px), -50%); } 75% { transform: translate(calc(-50% + 5px), -50%); } }

/* мелкие эффекты: полоска встала после перетаскивания — короткая вспышка */
.streifen.abgelegt { animation: abgelegt .45s ease-out; }
@keyframes abgelegt { 0% { filter: brightness(1.25); } 100% { filter: none; } }

/* собрано: швы и метки исчезают — картинка целиком (и проявляется, если была скрыта) */
.bildfeld.fertig .streifen::before { opacity: 0; }
.bildfeld.fertig .etikett { opacity: 0; transition-delay: .5s; }
.bildfeld.fertig.verdeckt .streifen { animation: zeigen .8s ease forwards; }
@keyframes zeigen { from { filter: brightness(1.6) saturate(0); } to { filter: none; } }
.bildfeld.fertig .streifen { box-shadow: none; }
/* поверх полосок — целая картинка (без тонких швов от дробных пикселей) */
#vorschauGross.ganz { box-shadow: none; animation: einblenden .6s ease .45s both; }
@keyframes einblenden { from { opacity: 0; } }
/* Rechenpuzzle (09.11.2026, Лина: картинка в конце не нужна): всё верно — полоски сверху вниз становятся зелёными,
   у примера галочка и «прыжок», ответы справа зеленеют следом; потом конфетти и окно «Alles richtig!» */
.bildfeld.richtig .streifen { background-color: #c9ecc4 !important; box-shadow: none;
  transition: transform .2s, background-color .35s ease calc(var(--i, 0) * 110ms); }
.bildfeld.richtig .etikett { color: #1f7a5a; animation: hupf .5s ease calc(var(--i, 0) * 110ms) both; }
.bildfeld.richtig .etikett::after { content: ' ✓'; }
@keyframes hupf { 50% { transform: translate(-50%, -50%) scale(1.2); } }
.ziel.stimmt { transition: color .3s ease calc(var(--i, 0) * 110ms); }
@media (prefers-reduced-motion: reduce) { .bildfeld.richtig .etikett { animation: none; } }

#vorschauGross { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 6px; z-index: 6; box-shadow: 0 8px 30px rgba(20, 10, 60, .35); pointer-events: none; }
/* подсказка под полем: заметная плашка с отступом от картинки (Лина 02.11: сливалась) */
.hint { margin: 8px 0 0; padding: 8px 18px; border-radius: 12px; background: #f1eefc; border: 1px solid var(--line);
  font-size: 16px; font-weight: 700; line-height: 1.35; color: var(--brand); text-align: center; max-width: 760px; }
.hint:empty { display: none; }
@media (max-width: 640px) { .hint { margin-top: 4px; padding: 6px 12px; font-size: 14px; } }

/* ── стартовый экран: три карточки режимов (Bild legen / Zahlen ordnen / Rechnen) ── */
.start { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; align-items: center; padding: 28px 16px 32px; background: #f7f5fd; }
/* вид карточек — как у общего экрана «Freies Spiel / Reise» (.kl-start в kl-leiste.css) */
.start h2 { margin: 0; font-size: 26px; font-weight: 800; color: var(--ink); text-align: center; }
.start__unter { margin: 6px 0 24px; font-size: 16px; color: var(--muted); text-align: center; }
.karten { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; width: 100%; max-width: 980px; align-items: start; }
.karte { background: #fff; border: 3px solid var(--line); border-radius: 22px; overflow: hidden; box-shadow: 0 10px 30px rgba(60, 30, 120, .14);
  transition: border-color .15s, box-shadow .15s, transform .15s; }
.karte.offen { border-color: #5b2fc9; }
.karte__knopf { width: 100%; border: 0; background: none; color: var(--ink); padding: 22px 18px 18px; display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.karte__text { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.karte__text b { font-size: 24px; font-weight: 800; color: var(--ink); }
.karte__text span { font-size: 15px; font-weight: 600; color: var(--muted); line-height: 1.35; }
.karte__text small { margin-top: 6px; padding: 3px 12px; border-radius: 999px; background: #f1eefc; color: var(--brand); font-size: 13px; font-weight: 700; }
@media (hover: hover) {
  .karte:not(.offen):hover { transform: translateY(-3px); box-shadow: 0 16px 36px rgba(60, 30, 120, .2); }
  .karte:not(.offen):hover .mini__s { transform: none !important; }
}
.karte__knopf:focus-visible { outline: 3px solid var(--brand); outline-offset: -5px; border-radius: 18px; }

/* картинка на карточке: 4 полоски вперемешку, у Rechnen справа столбик «= 7» */
.mini { display: flex; gap: 6px; height: 132px; }
.mini__feld { position: relative; width: 132px; height: 132px; }
.mini__s { position: absolute; left: 0; width: 100%; height: 25%; background-size: 100% 400%; border-top: 2px solid #fff;
  border-radius: 3px; box-shadow: 0 2px 6px rgba(52, 16, 108, .18); transition: transform .3s ease; }
.mini__s i, .mini__spalte i { font-style: normal; font-weight: 800; font-size: 13px; color: var(--brand); font-variant-numeric: tabular-nums; white-space: nowrap; }
.mini__s i { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 0 5px; border-radius: 5px; background: rgba(255, 255, 255, .93); }
/* Zahlen / Rechnen: полоски без картинки, как в самой игре */
.mini__s--leer { background-color: var(--farbe, #e9e3f8); background-image: radial-gradient(rgba(255, 255, 255, .6) 1px, transparent 1.2px); background-size: 8px 8px; }
.mini__spalte { display: flex; flex-direction: column; width: 34px; }
.mini__spalte i { flex: 1; display: flex; align-items: center; color: var(--ink); border-top: 1px dashed var(--line); }
.mini__spalte i:first-child { border-top: 0; }

/* выбор заданий под карточкой (Zahlen / Rechnen) */
.karte__wahl { display: none; flex-wrap: wrap; justify-content: center; gap: 8px; padding: 14px 16px 18px; border-top: 2px solid var(--line); background: #faf9fe; }
.karte.offen .karte__wahl { display: flex; }
.karte__wahl p { flex-basis: 100%; margin: 0 0 2px; text-align: center; font-size: 14px; font-weight: 700; color: var(--muted); }
.karte__wahl button { border: 0; background: #5b2fc9; color: #fff; border-radius: 999px; padding: 9px 18px; font-size: 15px; font-weight: 800; white-space: nowrap; }
@media (hover: hover) { .karte__wahl button:hover { background: #4a1fb0; } }
.karte__wahl button:active { transform: translateY(1px); }
/* Rechenpuzzle (09.11.2026): четыре режима — сеткой 2×2; под вариантом — класс; «Einmaleins-Reihen» — кнопки сеткой */
.karten--vier { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 760px; }
.karte__wahl button { display: inline-flex; flex-direction: column; align-items: center; line-height: 1.2; }
.karte__wahl button small { font-size: 12px; font-weight: 700; opacity: .8; margin-top: 2px; }
.karte__wahl--raster { display: none; }
.karte.offen .karte__wahl--raster { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.karte__wahl--raster p { grid-column: 1 / -1; }
.karte__wahl--raster button { padding: 9px 8px; }
.karte__wahl--raster button:last-child { grid-column: 1 / -1; } /* «Alle Reihen gemischt» — во всю ширину под рядами */
.mini--spalte .mini__spalte { width: auto; min-width: 34px; }

/* в игре: «‹ Rechnen · Plus bis 10» — назад к выбору */
.art-knopf { display: inline-flex; align-items: center; gap: 4px; height: 36px; padding: 0 14px 0 8px; border: 0; border-radius: 10px;
  background: rgba(255, 255, 255, .13); color: #fff; font-size: 15px; font-weight: 700; white-space: nowrap; }
.art-knopf span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.art-knopf svg { flex: none; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) { .art-knopf:hover { background: rgba(255, 255, 255, .24); } }

/* телефон и планшет стоя: карточки друг под другом, картинка слева, текст справа */
@media (max-width: 720px) {
  .start { padding: 18px 12px 24px; }
  .start h2 { font-size: 24px; }
  .start__unter { margin-bottom: 16px; font-size: 15px; }
  .karten { grid-template-columns: 1fr; gap: 12px; max-width: 520px; }
  .karte__knopf { flex-direction: row; align-items: center; gap: 16px; padding: 14px; text-align: left; }
  .karte__text { align-items: flex-start; }
  .karte__text b { font-size: 20px; }
  .karte__text span { font-size: 14px; }
  .mini { height: 92px; flex: none; }
  .mini__feld { width: 92px; height: 92px; }
  .mini__s i, .mini__spalte i { font-size: 10px; }
  .mini__s i { padding: 0 3px; }
  .mini__spalte { width: 26px; }
}
/* телефон: «‹ Rechnen · …» — отдельной строкой над «Leicht ▾» и «Neu mischen» (сетка полосы — в kl-leiste.css) */
@media (max-width: 560px) {
  .kl-spielleiste > .art-knopf { order: -3; grid-column: 1 / -1; height: 40px; }
}
@media (prefers-reduced-motion: reduce) { .mini__s, .karte { transition: none; } }

/* окна */
.modal { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(27, 20, 70, .45); z-index: 10; padding: 16px; }
.modal__card { position: relative; background: #fff; border-radius: 22px; padding: 28px 32px; text-align: center; width: min(400px, 100%); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow: auto;
  box-shadow: 0 24px 60px rgba(20, 10, 60, .3); animation: pop .35s cubic-bezier(.2, .9, .25, 1.3); }
.modal__card--breit { width: min(760px, 100%); }
.modal__zu { position: absolute; right: 12px; top: 12px; border: 0; background: #f1eefc; color: var(--brand); width: 34px; height: 34px; border-radius: 10px; font-weight: 800; }
.modal h2 { margin: 6px 0 12px; font-size: 26px; }
.win__star { font-size: 54px; color: #f5b400; line-height: 1; }
.win h2 { font-size: 30px; margin-bottom: 4px; }
.win p { margin: 0 0 20px; color: var(--muted); }
.win__knoepfe { display: flex; flex-direction: column; align-items: center; gap: 10px; }
@keyframes pop { from { transform: scale(.7); opacity: 0; } }
.galerie { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.galerie__bild { border: 3px solid transparent; background: #f7f5fd; border-radius: 14px; padding: 6px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 700; color: var(--ink); }
.galerie__bild img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 9px; display: block; }
.galerie__bild.aktiv { border-color: var(--brand); }
.galerie__titel { grid-column: 1 / -1; margin: 6px 0 -2px; font-size: 17px; font-weight: 800; color: var(--ink); }
.galerie__titel:first-child { margin-top: 0; }
.galerie__bild:hover { background: #efeaf9; }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 11; }


.st--4 { background: #dcf3ea; color: #1f7a5a; }
.st--6 { background: #fff1c9; color: #8a5a00; }
.st--10 { background: #fde0e6; color: #b3264f; }
@media (max-width: 760px) {
  .info { flex-wrap: wrap; justify-content: center; gap: 8px 12px; }
  .stats { order: 5; flex-basis: 100%; }
}
@media (max-width: 640px) {
  .modal__card { padding: 24px 18px; }
  .galerie { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { .streifen { transition: none; } .modal__card { animation: none; } }

/* Online-Adventskalender (26.10.2026): картинку дня задаёт календарь — без выбора картинки и смены вида игры (kl-leiste.js klAdvent) */
.kl-advent #btnBilder, .kl-advent #btnAnderes, .kl-advent #btnArt { display: none; }


/* ── Reise (02.11.2026): строка этапа; размер и «назад к карточкам» задаёт этап — прячем ── */
.reise-info { flex: 1; min-width: 0; text-align: center; font-size: 15px; font-weight: 700; color: var(--muted); }
.reise-info b { color: var(--ink); }
.reise-info[hidden] { display: none; }
.kl-in-reise #btnArt, .kl-in-reise #groesse, .kl-in-reise .stats { display: none; }
#winKarte { margin: -4px 0 18px; }
/* стартовые карточки: в полосе снизу только «Freies Spiel | Reise» */
.auf-start #btnArt, .auf-start #btnNew, .auf-start .kl-optionen, .auf-start .kl-opt-knopf { display: none !important; }
@media (max-width: 640px) { .reise-info { font-size: 13px; white-space: normal; } }
