/* ===================================================================
   Ansichten: Hochformat (Standard) · Querformat am Handy · Tablet/Desktop
   Die Seiten sind in .spalten > .spalte-a / .spalte-b aufgeteilt.
   Im Hochformat sind diese Hüllen unsichtbar (display: contents) – alles bleibt untereinander.
   Im Querformat stehen die beiden Hälften nebeneinander.
   =================================================================== */
.spalten, .spalte { display: contents; }
/* Hinweis aufs Opfer: im Hochformat über dem Grundriss, im Querformat oben rechts */
#krimiOpfer { order: -1; }

/* ---------- Querformat (Handy quer, Tablet, Desktop) ---------- */
@media (orientation: landscape) and (min-width: 700px) {
  .app { max-width: 1180px; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .spalten { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px 32px; align-items: start; }
  .spalte { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
  .farb-buehne > *, .cello-buehne > *, .ton-buehne > *, .sr-buehne > *, .takt-buehne > *, .pw-buehne > *, .fd-buehne > *, .zf-buehne > *, .zl-buehne > *, .tl-buehne > *, .pr-buehne > *, .slo-buehne > *, .sk-buehne > *, .dp-buehne > *, .lab-buehne > *, .ag-buehne > *, .kt-buehne > *, .vl-buehne > *, .tg-buehne > *, .rf-buehne > *, .krimi-buehne > *, .kl-buehne > *, .ft-buehne > * { max-width: 1100px; }
  .farb-buehne, .cello-buehne, .ton-buehne, .takt-buehne, .pw-buehne, .fd-buehne, .zf-buehne, .zl-buehne, .tl-buehne, .pr-buehne, .slo-buehne, .sk-buehne, .dp-buehne, .lab-buehne, .ag-buehne, .kt-buehne, .vl-buehne, .tg-buehne, .rf-buehne, .krimi-buehne, .kl-buehne, .ft-buehne { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }

  /* Dashboard: links die Games, rechts die Bestenliste */
  .hub-spalten .spalte-b .hub-h:first-child { margin-top: 0; }
  .hub-spalten .hub-quizzes { margin-top: 0; }
  .hub-spalten .hub-game { margin-top: 0; }
  .hub-spalten .spalte-b { gap: 10px; }
  .hub-spalten .hub-mehr { margin: 6px 0 0; }
  /* Breit: Games über die ganze Breite als Kachel-Raster, Bestenliste darunter */
  .hub-spalten { grid-template-columns: minmax(0, 1fr); }
  .hub-spalten .hub-liste { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
  .hub-spalten .hub-liste > .hub-game { height: 100%; }
  .hub-spalten .spalte-b { align-items: center; }
  .hub-spalten .hub-familie { width: 100%; max-width: 620px; }


  /* Quiz-Auswahl: alle Welten in einer Reihe */
  .hub-quiz { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .hub-card.hc-beide { grid-column: auto; min-height: 190px; }

  /* Quiz-Startseite und Stufen */
  .start-spalten .hero { padding-top: 4px; }
  .start-spalten .menu { margin-top: 0; }
  #pickList { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* Quiz: Foto links (bleibt stehen), Frage und Antworten rechts */
  .quiz-spalten { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
  .quiz-spalten .spalte-a { position: sticky; top: 8px; }
  .quiz-spalten .gallery { aspect-ratio: auto; height: min(calc(100dvh - 150px), 62vw * 0.75); }
  .quiz-spalten .q-row { margin-top: 0; }

  /* Ergebnis und Lexikon */
  .result-spalten .spalte-b .share { margin-top: 0; }
  .lex { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); align-items: start; }

  /* Farb-Gedächtnis */
  #farb-intro .spalte-a { justify-content: center; min-height: 60dvh; }
  #farb-mischen .farb-vorschau { height: calc(100dvh - 110px); max-height: 520px; }
  #farb-mischen .spalte-b { justify-content: center; min-height: calc(100dvh - 110px); }
  #farb-aufloesung .farb-vergleich { height: min(46dvh, 360px); }

  /* Cello: Noten links, Griffbrett und Tasten rechts */
  #cello-intro .spalte-a { justify-content: center; min-height: 60dvh; }
  #cello-spiel .spalten { align-items: center; }
  #cello-spiel.mit-griff .griff-svg { max-height: 62dvh; }
  #cello-spiel.mit-griff .noten-svg { max-height: 34dvh; }

  /* Ton-Gedächtnis */
  #ton-intro .spalte-a, #ton-treffen .spalte-a { justify-content: center; min-height: 55dvh; }
  #ton-treffen .spalte-b { justify-content: center; min-height: 55dvh; }

  /* Takt-Gefühl */
  #takt-intro .spalte-a { justify-content: center; min-height: 55dvh; }
  #takt-spiel.takt-mitte { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; min-height: calc(100dvh - 90px); max-width: 1000px; }
  #taktMerk { grid-column: 1 / -1; }

  /* Punktwolke */
  #pw-intro .spalte-a { justify-content: center; min-height: 55dvh; }
  .pw-spiel-spalten { align-items: center; }
  .pw-gross { max-width: min(100%, calc(100dvh - 130px)); }
  .pw-spiel-spalten:has(.pw-raster) { grid-template-columns: minmax(0, 1fr); }
  .pw-raster, .pw-raster.drei { grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: min(100%, calc((100dvh - 200px) * 4)); }
  .pw-raster.drei { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: min(100%, calc((100dvh - 200px) * 3)); }
  .pw-spiel-spalten:has(.pw-raster) .pw-aktion { grid-template-columns: 1fr 1fr; max-width: 700px; margin: 0 auto; width: 100%; }
  .pw-spiel-spalten:has(.pw-raster) .pw-pfeil { grid-column: 1 / -1; }

  /* Augenmaß und Karten-Gefühl */
  #fd-intro .spalte-a, #zf-intro .spalte-a { justify-content: center; min-height: 55dvh; }
  .fd-spiel-spalten { align-items: center; }
  .fd-gross { max-width: min(100%, calc(100dvh - 130px)); }
  .fd-spiel-spalten:has(.fd-raster) { grid-template-columns: minmax(0, 1fr); }
  .fd-raster { grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: min(100%, calc((100dvh - 220px) * 4)); }
  #ag-intro .spalte-a, #kt-intro .spalte-a { justify-content: center; min-height: 55dvh; }
  .ag-spalten { align-items: center; }
  .ag-flaeche { max-width: min(100%, calc(100dvh - 120px)); }
  #ag-aufloesung .ag-flaeche.klein { max-width: min(100%, calc(100dvh - 260px)); }
  #kt-spiel { grid-template-columns: minmax(0, 1fr) 260px; grid-template-areas: "frage frage" "karte knoepfe"; align-items: center; max-width: 1100px; }
  #ktFrage { grid-area: frage; } #ktKarte { grid-area: karte; } .kt-knoepfe { grid-area: knoepfe; }
  .kt-karte.spiel, .kt-karte.spiel.kt-deutschland { height: calc(100dvh - 120px); }

  /* Riffbau */
  .rf-brett { max-width: min(100%, calc(100dvh - 150px)); }

  /* Krimi */
  .krimi-teil > .spalten { gap: 14px 28px; }
  #krimi-intro .villa-szene { margin: 0; border-radius: 18px; }
  #krimi-intro .spalte-b .km-h { margin-top: 4px; }
  #krimi-spiel .spalte-a, #krimi-wachen .spalte-a, #krimi-alibi .spalte-a { position: sticky; top: 0; }
  .krimi-brett, .wachen-brett { max-width: min(100%, calc(100dvh - 120px), 560px); }
  #krimi-verhoer .spalten { grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); }
  #krimi-verhoer .vh-raum { position: sticky; top: 0; }
  #krimi-ende .spalte-b { align-self: center; }
  #krimi-ende .krimi-endbrett { max-width: min(100%, 300px); }
  .akte-spalten .spalte-a { position: sticky; top: 0; }
  .akte-spalten .akte-deckblatt { margin-top: 18px; }
  #krimi-setup .spalte-b { justify-content: center; min-height: 50dvh; }
  .kh-blatt { max-width: 640px; }
}

/* ---------- Handy quer: wenig Höhe – alles kompakter ---------- */
@media (orientation: landscape) and (max-height: 520px) {
  header { margin-bottom: 6px; }
  .icon-btn { width: 38px; height: 38px; }
  .buehne { height: 210px; }
  .hub-titel { font-size: 2.6rem; margin-bottom: 8px; }
  .hub-quizzes { min-height: 150px; padding: 14px 16px; }
  .hq-stapel .w-av { width: 54px; height: 54px; }
  .hq-titel { font-size: 2rem; }
  .hub-game { padding: 10px 14px; }
  .hg-av > .hg-in { width: 52px; height: 52px; }
  .hg-titel { font-size: 1.2rem; }
  .hub-card { min-height: 160px; }
  .hero .logo { width: 60px; height: 60px; }
  .hero h2 { font-size: 1.4rem; margin: 4px 0; }
  .menu-btn { padding-top: 10px; padding-bottom: 10px; }
  .quiz-spalten .gallery { height: calc(100dvh - 110px); }
  .choices { gap: 8px; }
  .choice { padding-top: 10px; padding-bottom: 10px; }
  .farb-buehne, .cello-buehne, .ton-buehne, .takt-buehne, .pw-buehne, .fd-buehne, .zf-buehne, .zl-buehne, .tl-buehne, .pr-buehne, .slo-buehne, .sk-buehne, .lab-buehne, .ag-buehne, .kt-buehne, .vl-buehne, .tg-buehne, .rf-buehne, .krimi-buehne, .kl-buehne, .ft-buehne { padding-top: calc(env(safe-area-inset-top) + 6px); }
  .farb-kopf { margin-bottom: 4px; }
  .farb-logo { height: 46px; }
  #farb-mischen .farb-vorschau { height: calc(100dvh - 80px); }
  #farb-mischen .spalte-b { min-height: calc(100dvh - 80px); }
  .ton-titel, .takt-titel { font-size: 2rem; }
  .takt-logo .metronom { height: 56px; }
  .tk-uhr, .tk-pad { width: min(52dvh, 220px); }
  .tk-lautsprecher { width: min(40dvh, 160px); }
  .takt-logo { height: 60px; }
  .ton-logo i { height: 46px; }
  .krimi-titel { font-size: 2.6rem; }
  .krimi-brett, .wachen-brett { max-width: min(100%, calc(100dvh - 118px)); }
  .krimi-sterne { font-size: 0.75rem; }
  .ks-stern { width: 16px; height: 16px; }
  .vh-raum { padding-top: 10px; }
  .vh-lampe { display: none; }
  .ks-titel { font-size: 2rem; }
  .ks-bild { width: 60px; height: 60px; }
  .krimi-taeter-fig { width: 110px; height: 110px; }
  .krimi-orden i { width: 64px; height: 64px; }
  .kh-blatt { padding: 12px 16px; }
}

/* ---------- Großer Bildschirm (Desktop, Tablet quer) ---------- */
@media (min-width: 1000px) and (min-height: 600px) {
  .hub-quiz { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
  .vh-karten { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hub-titel { font-size: 5rem; }
  #pickList { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Vollbild-Knopf */
.vollbild-btn { border: 1px solid rgba(255,255,255,0.18); border-radius: 999px; background: rgba(255,255,255,0.08); color: var(--text); font: inherit; font-size: 1.05rem; width: 40px; height: 40px; cursor: pointer; flex: none; }
.hub-knoepfe { display: flex; align-items: center; gap: 8px; min-width: 0; }


/* ===================================================================
   Startseite (Spielekiste) – Reihenfolge, Suche/Filter, Archiv, PC-Layout
   Bis 1099 px: alles untereinander (Reihenfolge über „order“).
   Ab 1100 px: links Heute + Spiele (Raster), rechts eine mitlaufende Seitenleiste.
   =================================================================== */
@media (max-width: 1099px) {
  #screen-hub .hub-spalten, #screen-hub .hub-spalten > .spalte { display: contents !important; }
}
#screen-hub > .hub-leiste { order: -10; } #installKarte { order: -9; } #skGrussBox { order: -8; } #syTop3 { order: -7; } #skStart { order: -6; }
#skFilter { order: -5; } #skUnten { order: 2; } #syBestenliste { order: 3; } #hubFamilie { order: 4; } #hubVerlauf { order: 5; } #screen-hub > .hub-ds { order: 10; }
#screen-hub .hub-mehr { display: none; }

/* Suche & Filter */
.sk-filter { display: flex; flex-direction: column; gap: 8px; margin: 18px 0 2px; }
.sk-filter input[type=search] { width: 100%; box-sizing: border-box; font: inherit; font-size: 16px; padding: 10px 14px; border-radius: 14px; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.05); color: inherit; }
.sk-filter input[type=search]:focus { outline: 2px solid rgba(167,139,250,.7); outline-offset: 1px; }
.sk-chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.sk-chips::-webkit-scrollbar { display: none; }
.sk-chips button { flex: none; font: inherit; font-weight: 700; font-size: .85rem; padding: 7px 12px; border-radius: 999px; border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.05); color: inherit; cursor: pointer; white-space: nowrap; }
.sk-chips button[aria-pressed="true"] { background: #f2f2fa; color: #12121c; border-color: transparent; }
.sk-nichts { text-align: center; padding: 24px 0; }

/* Archiv */
.sk-archiv { margin-top: 10px; border-top: 1px solid rgba(255,255,255,.08); }
.sk-archiv > summary { list-style: none; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.sk-archiv > summary::-webkit-details-marker { display: none; }
.sk-archiv > summary .hub-h { margin-bottom: 10px; }
.sk-archiv > summary small { font-weight: 600; opacity: .6; font-size: .8rem; }
.sk-archiv-pfeil { margin-left: auto; opacity: .6; transition: transform .2s; }
.sk-archiv[open] .sk-archiv-pfeil { transform: rotate(180deg); }
.sk-archiv:not([open]) > summary { opacity: .75; }
.sk-archiv .hub-game { filter: saturate(.75); }
.sk-experiment-klein { margin-top: 12px; padding: 12px 14px; }

/* ---------- PC: zwei Bereiche ---------- */
@media (min-width: 1100px) {
  .app:has(#screen-hub.active) { max-width: none; padding-left: clamp(20px, 2.4vw, 48px); padding-right: clamp(20px, 2.4vw, 48px); }
  #screen-hub.active { display: grid; grid-template-columns: minmax(0, 1fr) 340px; column-gap: 28px; row-gap: 0; align-items: start; }
  #screen-hub > .hub-leiste { grid-column: 1 / -1; grid-row: 1; }
  #screen-hub > #installKarte { grid-column: 1 / -1; grid-row: 2; }
  #screen-hub > #skStart { grid-column: 1; grid-row: 3; min-width: 0; }
  #screen-hub .hub-spalten { display: contents; }
  #screen-hub .hub-spalten > .spalte-a { display: flex; flex-direction: column; gap: 0; grid-column: 1; grid-row: 4; min-width: 0; }
  #screen-hub .hub-spalten > .spalte-b { display: flex; flex-direction: column; gap: 14px; grid-column: 2; grid-row: 3 / span 2; position: sticky; top: 12px;
    max-height: calc(100dvh - 24px); overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent; padding: 4px 4px 12px 0; align-items: stretch; }
  #screen-hub > .hub-ds { grid-column: 1; grid-row: 5; }
  #screen-hub .spalte-b > * { margin-top: 0 !important; width: auto !important; max-width: none !important; }
  #screen-hub .spalte-b .hub-h { margin-top: 0; }

  /* Filterleiste bleibt oben stehen */
  .sk-filter { position: sticky; top: 0; z-index: 4; flex-direction: row; align-items: center; margin: 14px 0 0; padding: 10px 0; background: linear-gradient(rgba(9,9,15,.94), rgba(9,9,15,.94)); backdrop-filter: blur(10px); }
  .sk-filter input[type=search] { width: 230px; flex: none; }
  .sk-chips { flex: 1; min-width: 0; flex-wrap: nowrap; }

  /* Gleichmäßiges Karten-Raster */
  #screen-hub .hub-liste { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)) !important; gap: 14px !important; }
  #screen-hub .hub-liste > .hub-game { height: 100%; min-height: 150px; }
  #screen-hub .hub-game .hg-titel { font-size: 1.28rem; line-height: 1.15; }
  #screen-hub .hub-game .hg-pfeil { display: none; }
  #screen-hub .hub-game .hg-av { zoom: .82; }
  #screen-hub .hub-liste > .hub-game { padding: 16px 18px; gap: 14px; }
  #screen-hub .hub-liste > .hub-game:hover { transform: translateY(-3px); }
  #screen-hub .hub-game .hg-sub { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  #screen-hub .hub-game .hg-best { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #screen-hub .sk-kat { margin-top: 6px; }

  /* Seitenleiste: kompaktere Bausteine */
  #syTop3 .sy-top3-liste, #syTop3 > div { gap: 8px; }
  #skGrussBox .sk-gruss { width: 100%; }
}

/* ---------- Handy: kompakte Kacheln in zwei Spalten (weniger scrollen) ---------- */
@media (max-width: 699px) {
  #screen-hub .hub-liste { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  #screen-hub .hub-liste > .hub-game { flex-direction: column; align-items: flex-start; gap: 6px; padding: 12px 12px 11px; border-radius: 18px; min-height: 0; height: 100%; box-shadow: 0 8px 26px rgba(124,58,237,0.18); }
  #screen-hub .hub-game .hg-av { zoom: .62; }
  #screen-hub .hub-game .hg-text { gap: 1px; width: 100%; min-width: 0; }
  #screen-hub .hub-game .hg-titel { font-size: 1.02rem; line-height: 1.15; overflow-wrap: anywhere; }
  #screen-hub .hub-game .hg-sub, #screen-hub .hub-game .hg-pfeil { display: none; }
  #screen-hub .hub-game .hg-best { font-size: .7rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #screen-hub .hub-game .hg-stern { top: 8px; right: 8px; }
  #screen-hub .sk-kat .hub-h { margin: 16px 0 8px; }
  .sk-filter { margin-top: 12px; }
}

/* Farb-Gedächtnis: feste, neutral gerahmte Farbprobe fürs Einprägen. */
.farb-einstellungen {
  display: grid;
  gap: 8px;
  padding: 14px;
  text-align: left;
  background: #25263b;
  border: 1px solid #a3a5ca57;
  border-radius: 13px;
}
.farb-einstellungen > label { font-weight: 650; }
.farb-einstellungen select {
  width: 100%;
  max-width: 100%;
  padding: 9px;
  border: 1px solid #a3a5ca77;
  border-radius: 8px;
  background: #191b2d;
  color: #fff;
  font: inherit;
}
.farb-einstellungen details > p, #farbKalibrierFelder > p {
  max-width: 100%;
  margin: 8px 0;
  font-size: .86rem;
}
.farb-einstellungen details summary { cursor: pointer; }
.farb-einstellungen details .btn { margin-top: 8px; }
.farb-merkflaeche {
  display: grid;
  place-items: center;
  width: min(76vw, 640px);
  height: clamp(150px, 34dvh, 330px);
  border: 1px solid #c3caec60;
  border-radius: 21px;
}
.farb-mitte .farb-countdown {
  font-size: clamp(2.3rem, 7vw, 4.4rem);
  line-height: 1.1;
}
.farb-palettenrunde { min-height: 70dvh; align-content: center; text-align: center; }
.farb-palettenrunde h3 { margin: 0; font-size: clamp(1.35rem, 3vw, 2.1rem); }
.farb-felder { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.farb-felder button {
  display: grid;
  place-items: center;
  min-height: clamp(88px, 16dvh, 160px);
  padding: 8px;
  border: 1px solid #d5d9ec75;
  border-radius: 14px;
  cursor: pointer;
}
.farb-felder button:focus-visible { outline: 2px solid white; outline-offset: 3px; }
.farb-prueffelder { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.farb-prueffelder button { min-height: clamp(44px, 9dvh, 76px); }
.farb-felder button span, #farbMerkSymbol, #farbZielSymbol, #farbDeinSymbol, .farb-liste :is(.fz, .fd) {
  color: #fff;
  text-shadow: 0 1px 3px #090c19, 0 0 7px #090c19;
}
.farb-felder button span, #farbMerkSymbol { font-size: clamp(2.1rem, 7vw, 4.6rem); }
#farbZielSymbol, #farbDeinSymbol { margin-inline-start: auto; font-size: 1.6rem; }
@media (min-width: 960px) {
  #farb-intro, #farb-mischen, #farb-aufloesung, #farb-ende { max-width: 1120px; }
  #farb-intro > .spalten, #farb-mischen > .spalten, #farb-aufloesung > .spalten {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    gap: clamp(28px, 4vw, 64px);
    align-items: center;
  }
  #farb-intro h2 { font-size: clamp(3rem, 5vw, 5.25rem); }
  #farb-intro .spalte-b, #farb-mischen .spalte-b, #farb-aufloesung .spalte-b {
    min-height: 0;
    padding: 24px;
    background: #1b1d30;
    border: 1px solid #a3a5ca45;
    border-radius: 20px;
  }
  #farb-waehlen { max-width: 760px; }
  #farb-waehlen .farb-felder { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
