/* ladi play – neue-spiele-rahmen (ab 2.47)
   Gemeinsamer Rahmen für neue Spiele im Sammlungsdialog (#collection-dialog).
   Alle Regeln hängen an .ns-… Klassen bzw. [data-neue-spiele] – bestehende Spiele bleiben unberührt. */

/* Nur Stufe 1–3 (Leicht, Mittel, Schwer) anbieten, solange ein neues Spiel offen ist. */
#collection-dialog[data-neue-spiele] .challenge-levels [data-challenge-level="master"],
#collection-dialog[data-neue-spiele] .challenge-levels [data-challenge-level="legend"] { display: none !important; }

/* Panel: randlos, die Hülle .ns-wrap trägt die Gestaltung. */
#collection-dialog .collection-stage > .collection-panel.ns-panel {
  width: 100% !important; max-width: 1180px; margin: 0 auto; padding: 0 !important; border: 0 !important;
  background: none !important; box-shadow: none !important; border-radius: 20px;
}
.ns-wrap {
  --ns-a: #1d4ed8; --ns-b: #14b8a6; --ns-ink: #0f2547; --ns-soft: #eef4ff;
  --ns-top: 8px; --ns-bot: 8px; --ns-l: 8px; --ns-r: 8px; --ns-reserve: 0px;
  position: relative; display: flex; flex-direction: column; width: 100%;
  height: var(--ns-h, 600px); min-height: 300px; overflow: hidden; border-radius: 20px;
  background: radial-gradient(120% 90% at 15% 0%, color-mix(in srgb, var(--ns-b) 22%, #fff) 0%, transparent 55%),
              linear-gradient(160deg, color-mix(in srgb, var(--ns-a) 14%, #f5f8ff), color-mix(in srgb, var(--ns-b) 12%, #eaf2fb));
  box-shadow: inset 0 0 0 1px rgba(15, 37, 71, .1), 0 14px 34px rgba(15, 37, 71, .14);
  color: var(--ns-ink); font-family: Inter, system-ui, sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation;
}
.ns-wrap *, .ns-wrap *::before, .ns-wrap *::after { box-sizing: border-box; }

/* Kopfzeile: Werte links, Werkzeuge rechts */
.ns-kopf { position: relative; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px;
  padding: var(--ns-top) calc(var(--ns-r) + var(--ns-reserve)) 4px var(--ns-l); }
.ns-werte { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; flex: 1 1 auto; }
.ns-chip { display: flex; flex-direction: column; justify-content: center; min-width: 64px; min-height: 44px; padding: 3px 12px;
  border-radius: 14px; background: rgba(255, 255, 255, .92); box-shadow: 0 2px 0 rgba(15, 37, 71, .1), 0 4px 12px rgba(15, 37, 71, .08); line-height: 1.1; }
.ns-chip small { font-size: 10.5px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: #5b6b86; white-space: nowrap; }
.ns-chip b { font-size: 19px; font-weight: 900; font-variant-numeric: tabular-nums; color: var(--ns-ink); white-space: nowrap; }
.ns-chip.ns-hell { background: linear-gradient(135deg, #fff6d6, #ffe3a3); }
.ns-chip.ns-puls b { animation: nsPuls .45s ease-out; }
@keyframes nsPuls { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }
.ns-werkzeug { display: flex; gap: 6px; margin-left: auto; }
.ns-knopf { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 44px; min-height: 44px; padding: 0 12px;
  border: 0; border-radius: 14px; background: #fff; color: var(--ns-ink); font: 800 15px/1 Inter, system-ui, sans-serif; cursor: pointer;
  box-shadow: 0 3px 0 rgba(15, 37, 71, .16), 0 6px 14px rgba(15, 37, 71, .1); touch-action: manipulation; }
.ns-knopf:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(15, 37, 71, .16); }
.ns-knopf:focus-visible { outline: 3px solid var(--ns-a); outline-offset: 2px; }
.ns-knopf:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.ns-knopf svg { width: 20px; height: 20px; flex: 0 0 auto; }
.ns-knopf[aria-pressed="false"].ns-ton { color: #8a97ad; }
.ns-knopf.ns-haupt { background: linear-gradient(180deg, color-mix(in srgb, var(--ns-a) 80%, #fff), var(--ns-a)); color: #fff; box-shadow: 0 3px 0 color-mix(in srgb, var(--ns-a) 60%, #000), 0 6px 14px rgba(15, 37, 71, .18); }
.ns-knopf.ns-aktiv { background: linear-gradient(180deg, #ffd45b, #ffb020); color: #3b2500; }
.ns-knopf .ns-zahl { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: rgba(15, 37, 71, .12); font-size: 12px; line-height: 22px; }

/* Bühne: hier zeichnet das Spiel */
.ns-buehne { position: relative; flex: 1 1 auto; min-height: 0; margin: 0 var(--ns-r) 0 var(--ns-l); touch-action: none; }
.ns-buehne > canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.ns-laden { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; color: #5b6b86; }

/* Knopfleiste unten (spieleigene Knöpfe) */
.ns-leiste { position: relative; z-index: 5; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; padding: 6px var(--ns-r) var(--ns-bot) var(--ns-l); }
.ns-leiste:empty { display: none; }
#collection-dialog footer.ns-leiste, footer.ns-leiste { flex-direction: row; border-top: 0; }

/* Meldung (Toast) */
.ns-toast { position: absolute; z-index: 8; left: 50%; bottom: calc(var(--ns-bot) + 64px); transform: translate(-50%, 12px); max-width: min(92%, 520px);
  padding: 9px 16px; border-radius: 14px; background: rgba(15, 37, 71, .9); color: #fff; font-weight: 800; font-size: 15px; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .25s ease, transform .25s ease; }
.ns-toast.ns-an { opacity: 1; transform: translate(-50%, 0); }

/* Überlagerung: Start, Ergebnis, Hilfe */
.ns-overlay { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; overflow: auto;
  padding: calc(var(--ns-top) + 8px) calc(var(--ns-r) + 8px) calc(var(--ns-bot) + 8px) calc(var(--ns-l) + 8px);
  background: rgba(10, 24, 52, .42); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.ns-overlay[hidden] { display: none; }
.ns-karte { width: min(100%, 470px); padding: 20px 22px; border-radius: 22px; background: #fff; color: var(--ns-ink);
  box-shadow: 0 20px 50px rgba(5, 15, 40, .35); text-align: center; animation: nsAuf .28s ease-out; }
@keyframes nsAuf { from { transform: translateY(14px) scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
.ns-karte h3 { margin: 0 0 6px; font-size: clamp(22px, 4.5vw, 30px); font-weight: 900; color: var(--ns-a); letter-spacing: -.01em; }
.ns-karte p { margin: 0 0 12px; font-size: 15px; line-height: 1.45; color: #34445f; }
.ns-karte .ns-icon { width: 88px; height: 56px; margin: 0 auto 6px; border-radius: 14px; overflow: hidden; box-shadow: 0 4px 12px rgba(15, 37, 71, .18); }
.ns-karte .ns-icon img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ns-stufen { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 6px 0 14px; }
.ns-stufen button { min-height: 56px; padding: 6px 4px; border: 2px solid #dbe4f3; border-radius: 14px; background: #f7f9fd; color: var(--ns-ink);
  font: 800 15px/1.15 Inter, system-ui, sans-serif; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.ns-stufen button small { font-size: 11px; font-weight: 700; color: #5b6b86; }
.ns-stufen button[aria-pressed="true"] { border-color: var(--ns-a); background: color-mix(in srgb, var(--ns-a) 12%, #fff); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ns-a) 22%, transparent); }
.ns-aktionen { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.ns-aktionen .ns-knopf { min-height: 52px; padding: 0 22px; font-size: 17px; }
.ns-sterne { font-size: 34px; letter-spacing: 4px; color: #f5a400; margin: 2px 0 4px; }
.ns-sterne i { font-style: normal; color: #d7dfec; }
.ns-ergebnis { display: flex; justify-content: center; gap: 10px; margin: 6px 0 12px; }
.ns-ergebnis div { min-width: 110px; padding: 8px 12px; border-radius: 14px; background: var(--ns-soft); }
.ns-ergebnis small { display: block; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: #5b6b86; }
.ns-ergebnis b { font-size: 24px; font-weight: 900; font-variant-numeric: tabular-nums; }
.ns-neu-rekord { display: inline-block; margin: 0 0 10px; padding: 4px 12px; border-radius: 999px; background: linear-gradient(135deg, #ffe27a, #ffb648); color: #4a2a00; font-weight: 900; font-size: 14px; }
.ns-hilfe-text { text-align: left; }
.ns-hilfe-text p { margin: 0 0 8px; }

/* Randloses Vollbild (fullscreen-fit.js setzt .fs-fill): Hülle füllt den Bildschirm, Kopfzeile lässt rechts Platz für Pause/Vollbild/Schließen. */
.fs-fill .ns-wrap { position: absolute; inset: 0; height: auto; min-height: 0; border-radius: 0; box-shadow: none;
  --ns-top: var(--fs-t, 8px); --ns-bot: var(--fs-b, 8px); --ns-l: var(--fs-l, 8px); --ns-r: var(--fs-r, 8px); --ns-reserve: 176px; }

/* Kleine Flächen: kompaktere Werte */
@container ns (max-width: 560px) {
  .ns-chip { min-width: 54px; padding: 2px 9px; }
  .ns-chip b { font-size: 16px; }
  .ns-chip small { font-size: 9.5px; }
  .ns-knopf { padding: 0 10px; font-size: 14px; }
  .ns-lang { display: none; }
}
/* Schmales Vollbild (Handy hoch): Werkzeuge unter die Portal-Knöpfe, Werte nutzen links zwei Zeilen. */
@container ns (max-width: 599px) {
  .fs-fill .ns-kopf { min-height: calc(var(--ns-top) + 104px); align-content: flex-start; }
  .fs-fill .ns-werkzeug { position: absolute; right: var(--ns-r); top: calc(var(--ns-top) + 56px); }
  .fs-fill .ns-werte { gap: 6px 5px; }
}
@container ns (max-height: 460px) {
  .ns-chip { min-height: 40px; }
  .ns-leiste { padding-top: 3px; }
  .ns-karte { padding: 12px 16px; }
  .ns-karte .ns-icon { display: none; }
  .ns-karte p { margin-bottom: 8px; font-size: 14px; }
  .ns-stufen button { min-height: 48px; }
}
.ns-wrap { container: ns / size; }

html.reduced-motion .ns-karte, html.reduced-motion .ns-chip.ns-puls b { animation: none; }
html.reduced-motion .ns-toast { transition: none; }
html.high-contrast .ns-wrap { --ns-ink: #000; }
html.high-contrast .ns-chip, html.high-contrast .ns-knopf { box-shadow: 0 0 0 2px #000; }
