/* Einzelspieler-Spiele (js/sologames.js). Alle Klassen beginnen mit sg-, damit nichts kollidiert.
   Ausgelegt aufs Handy im Hochformat (360–520 px), funktioniert aber auch am Computer.
   Kein Spiel wird gescrollt: .sg füllt die Höhe von #cmenu, .sg-body bekommt den Rest unter der Kopfzeile
   und ist ein Größen-Container – Spielfelder rechnen ihre Breite aus dessen Höhe (cqh), damit Tastatur,
   Ziffern und Knöpfe darunter immer auf dem Bildschirm bleiben. */

.sg { width: 100%; max-width: 520px; height: 100%; margin: 0 auto; padding: 0; display: flex; flex-direction: column; text-align: center; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
.sg button { font-family: inherit; touch-action: manipulation; }
.sg-top { flex: none; display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.sg .sg-top .sg-back { min-height: 38px; flex: none; font-size: .85rem; padding: .4em .8em; }
/* Sicherheitsnetz wie im Menü: Passt doch einmal etwas nicht, lässt es sich ohne sichtbare Leiste schieben. */
.sg-body { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; position: relative; container-type: size; overflow: hidden auto; scrollbar-width: none; }
.sg-body::-webkit-scrollbar { display: none; }
.sg-body > * { flex: none; }
.sg-body p { margin-top: 0; }
.sg-title { flex: 1; font-size: 1.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sg-bank { flex: none; background: var(--panel2); border-radius: 999px; padding: .3em .8em; white-space: nowrap; }
.sg-bank b { color: var(--gold); }
.sg-note { flex: none; margin: 4px 0 0; opacity: .8; font-size: .72rem; }
.sg-center { text-align: center; }
.sg-msg { min-height: 1.5em; margin: 6px 0; color: var(--dim); }
.sg-msg.sg-ok { color: var(--ok); }
.sg-msg.sg-no { color: var(--bad); }
.sg-msg b { color: var(--ink); }
.sg-gold { color: var(--gold) !important; white-space: nowrap; }
.sg-limit { display: inline-block; background: var(--panel2); color: var(--dim); border-radius: 999px; padding: .1em .7em; font-size: .85rem; white-space: nowrap; }
.sg-end { background: var(--panel); border-radius: 16px; padding: 10px 12px; margin-top: 6px; animation: sg-in .25s ease-out; }
.sg-end p { margin: 0 0 4px; }
.sg-end .row { margin-top: 6px; }
.sg .sg-end .btn { min-height: 44px; min-width: 150px; padding: .4em 1em; }
.sg-sol { letter-spacing: .15em; color: var(--gold); font-size: 1.2em; }
@keyframes sg-in { from { opacity: 0; transform: translateY(8px); } }

/* Fünf Buchstaben */
/* Breite aus der Höhe: sechs Zeilen plus Hinweis und drei Tastenreihen (oder die Auswertung) müssen darunter passen. */
.sg-wgrid { --kh: min(52px, 8.5cqh); display: grid; gap: 5px; width: min(100%, 350px, calc((100cqh - 3 * var(--kh) - 60px) * 5 / 6)); margin: 0 auto; container-type: inline-size; }
.sg-wrow { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.sg-wrow i { aspect-ratio: 1; display: grid; place-items: center; font-style: normal; font-weight: 700; font-size: 11cqw; border: 2px solid var(--panel2); border-radius: 8px; }
.sg-wrow i.sg-fill { border-color: var(--dim); }
.sg-wrow i.sg-s0, .sg-key.sg-s0 { background: #4a4766; border-color: #4a4766; color: #cfcbe6; }
.sg-wrow i.sg-s1, .sg-key.sg-s1 { background: #d9a400; border-color: #d9a400; color: #fff; }
.sg-wrow i.sg-s2, .sg-key.sg-s2 { background: #2f9e44; border-color: #2f9e44; color: #fff; }
.sg-wrow.sg-new i { animation: sg-turn .35s ease-out backwards; animation-delay: calc(var(--n) * 90ms); }
@keyframes sg-turn { from { transform: rotateX(90deg); background: transparent; border-color: var(--dim); } }
.sg-kb { display: grid; gap: 5px; margin-top: 0; }
.sg-krow { display: flex; gap: 4px; justify-content: center; }
.sg-key { flex: 1 1 0; min-width: 0; height: min(52px, 8.5cqh); padding: 0; border: 0; border-radius: 8px; background: var(--panel2); color: var(--ink); font-weight: 700; font-size: 1.05rem; cursor: pointer; }
.sg-key.sg-wide { flex: 1.6 1 0; font-size: .85rem; }
.sg-key:active { filter: brightness(1.3); }

/* Sudoku */
.sg-levels { display: grid; gap: 10px; margin: 8px auto; width: 100%; max-width: 320px; }
.sg-level { flex-direction: column; gap: 2px; min-height: 60px; }
.sg-level small { color: var(--dim); font-weight: 400; }
.sg-sgrid { display: grid; grid-template-columns: repeat(9, 1fr); gap: 2px; width: min(100%, 460px, calc(100cqh - 160px)); margin: 0 auto; background: var(--panel2); border: 3px solid var(--panel2); border-radius: 10px; overflow: hidden; container-type: inline-size; }
.sg-c { aspect-ratio: 1; min-width: 0; padding: 0; border: 0; border-radius: 0; background: var(--panel); color: #8ce99a; font-weight: 600; font-size: 6.2cqw; cursor: pointer; }
.sg-c.sg-giv { color: var(--ink); background: #1f184f; font-weight: 700; }
.sg-c.sg-br { margin-right: 3px; }
.sg-c.sg-bb { margin-bottom: 3px; }
.sg-c.sg-peer { background: #33297a; }
.sg-c.sg-giv.sg-peer { background: #2a2168; }
.sg-c.sg-same { background: #4c3fa8; }
.sg-c.sg-selc { background: var(--pri); color: #fff; }
.sg-c.sg-err { color: #fff; background: #c92a2a; }
.sg-c.sg-err.sg-selc { box-shadow: inset 0 0 0 3px var(--pri); }
.sg-digits { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; width: 100%; max-width: 400px; margin: 0 auto; }
.sg-dig { height: 44px; border: 0; border-radius: 10px; background: var(--panel2); color: var(--ink); font-weight: 700; font-size: 1.35rem; cursor: pointer; box-shadow: 0 3px 0 rgba(0, 0, 0, .35); }
.sg-dig:active { transform: translateY(2px); box-shadow: none; }

/* Länderkunde */
.sg-q { margin: 2px 0 8px; min-height: 2.5em; line-height: 1.25; }
.sg-q b { color: var(--gold); }
.sg-opts { display: grid; gap: 8px; }
.sg .sg-opt { width: 100%; min-height: min(52px, 9cqh); font-size: 1.05rem; padding: .3em .6em; }
.sg-opt:disabled { opacity: .55; cursor: default; }
.sg-opt.sg-good:disabled { background: #2f9e44; opacity: 1; }
.sg-opt.sg-wrong:disabled { background: #c92a2a; opacity: 1; }
.sg-info { margin-top: 8px; padding: 7px 10px; border-radius: 12px; background: var(--panel); text-align: left; font-size: .86rem; line-height: 1.3; border-left: 5px solid var(--dim); }
.sg-info.sg-ok { border-color: var(--ok); }
.sg-info.sg-no { border-color: var(--bad); }
.sg .sg-next { min-height: 44px; min-width: 150px; padding: .4em 1em; }
.sg-body > .row { margin-top: 8px; }

/* Juwelenreihe */
.sg-mhud { display: flex; justify-content: space-between; margin: 0 4px 6px; color: var(--dim); }
.sg-mhud b { color: var(--ink); font-size: 1.2rem; margin-left: .3em; }
/* Quadratisch und nie höher als der Platz zwischen Punktestand und Hinweiszeile. */
.sg-mgrid { width: min(100%, calc(100cqh - 84px)); margin: 0 auto; container-type: inline-size; display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; padding: 6px; background: var(--panel); border-radius: 14px; touch-action: none; overflow: hidden; }
.sg-gem { aspect-ratio: 1; display: grid; place-items: center; font-style: normal; font-size: 8.6cqw; line-height: 1; background: rgba(255, 255, 255, .06); border-radius: 10px; cursor: pointer; }
/* Die Auswertung legt sich über das Feld, statt es nach unten zu verlängern. */
.sg-mend:not(:empty) { position: absolute; left: 8%; right: 8%; top: 50%; transform: translateY(-50%); }
.sg-mend .sg-end { margin: 0; box-shadow: 0 10px 40px rgba(0, 0, 0, .7), 0 0 0 3px var(--gold); }
.sg-gem.sg-sel { background: rgba(255, 212, 59, .3); box-shadow: inset 0 0 0 3px var(--gold); }
.sg-gem.sg-pop { animation: sg-pop .26s ease-in forwards; }
.sg-gem.sg-fall { animation: sg-fall .3s ease-out; }
.sg-gem.sg-shake { animation: sg-shake .25s ease-in-out; }
@keyframes sg-pop { 40% { transform: scale(1.15); } to { transform: scale(.2); opacity: 0; } }
@keyframes sg-fall { from { transform: translateY(calc(var(--d) * -105%)); } }
@keyframes sg-shake { 30% { transform: translateX(-4px); } 70% { transform: translateX(4px); } }

/* Casino: gemeinsame Teile */
.sg-ctl.sg-busy { opacity: .5; pointer-events: none; }
.sg-ctl { display: flex; flex-direction: column; }
.sg-ctl > * { flex: none; }
.sg-chips { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 4px 0 8px; }
.sg-chip { width: 44px; height: 44px; padding: 0; border-radius: 50%; border: 3px dashed rgba(255, 255, 255, .5); background: var(--panel2); color: var(--ink); font-weight: 700; font-size: 1.05rem; cursor: pointer; }
.sg-chip.sg-on { background: var(--gold); color: #222; border-color: #fff; border-style: solid; }
.sg-bet { min-height: 44px; padding: 2px; border: 3px solid transparent; border-radius: 12px; background: var(--panel2); color: var(--ink); font-weight: 600; font-size: 1rem; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.sg-bet small { color: var(--dim); font-weight: 400; }
.sg-bet.sg-on { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }
.sg .sg-go, .sg .sg-deal, .sg .sg-hit, .sg .sg-stand { min-height: 48px; padding: .4em .6em; }
.sg-rules { font-size: .74rem; line-height: 1.25; margin: 6px 0; }
.sg-go, .sg-deal { width: 100%; }
.sg-hit, .sg-stand { flex: 1; font-size: 1.15rem; }

/* Roulette */
.sg-strip { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 5px 6px; background: #14301f; border: 3px solid #8a6a2f; border-radius: 16px; }
.sg-rn { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; font-style: normal; font-weight: 700; color: #fff; opacity: .55; flex: none; }
.sg-rn.sg-mid { width: 52px; height: 52px; font-size: 1.5rem; opacity: 1; box-shadow: 0 0 0 3px var(--gold); }
.sg-r { background: #c92a2a; }
.sg-b { background: #212529; }
.sg-g { background: #2f9e44; }
.sg-bets { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-bottom: 6px; }
.sg-bets .sg-bet { font-size: .88rem; }
.sg-b-rot { background: #c92a2a; }
.sg-b-schwarz { background: #212529; }
/* Zehn Spalten, die 0 über vier: 37 Zahlen in vier Reihen. Die Reihen teilen sich die Höhe, die übrig bleibt. */
.sg-ctl:has(.sg-nums) { flex: 1 1 0; min-height: 0; }
.sg-ctl > .sg-nums { flex: 1 1 0; min-height: 112px; max-height: 190px; display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); gap: 4px; }
.sg-num { min-width: 0; min-height: 0; padding: 0; border: 2px solid transparent; border-radius: 8px; color: #fff; font-weight: 700; font-size: 1rem; cursor: pointer; }
.sg-num.sg-on { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }
.sg-num:first-child { grid-column: span 4; }
.sg-ctl > .row { margin-top: 8px; }

/* Blackjack */
.sg-hand { background: #14301f; border-radius: 14px; padding: 5px 10px 8px; margin-bottom: 6px; min-height: 104px; }
.sg-hand.sg-empty { display: grid; place-items: center; font-size: 4rem; color: rgba(255, 255, 255, .25); min-height: min(180px, 34cqh); }
/* Karten brechen nie um (das würde die Hand höher machen) – ab der sechsten schieben sie sich übereinander. */
.sg-cards { display: flex; flex-wrap: nowrap; justify-content: center; gap: 6px; margin-top: 4px; }
.sg-cards:has(.sg-card:nth-child(6)) .sg-card + .sg-card { margin-left: -24px; }
.sg-card { flex: none; width: 48px; height: 68px; border-radius: 8px; background: #fff; color: #222; display: flex; flex-direction: column; align-items: center; justify-content: center; font-style: normal; line-height: 1.05; box-shadow: 0 3px 6px rgba(0, 0, 0, .4); animation: sg-in .2s ease-out; }
.sg-card b { font-size: 1.4rem; }
.sg-card span { font-size: 1.5rem; }
.sg-card.sg-redc { color: #e03131; }
.sg-card.sg-cback { background: repeating-linear-gradient(45deg, #5f3dc4, #5f3dc4 6px, #7950f2 6px, #7950f2 12px); border: 3px solid #fff; }

/* Würfelbude */
.sg-dice { display: flex; justify-content: center; gap: 20px; padding: 12px 0 6px; }
.sg-die { width: min(84px, 17cqh); height: min(84px, 17cqh); padding: 12%; background: #fff; border-radius: 16px; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); place-items: center; box-shadow: 0 5px 0 rgba(0, 0, 0, .35); }
.sg-die i { width: 70%; height: 70%; border-radius: 50%; }
.sg-die i.sg-pip { background: #222; }
.sg-rolling .sg-die { animation: sg-roll .17s linear infinite alternate; }
@keyframes sg-roll { from { transform: rotate(-7deg) translateY(-3px); } to { transform: rotate(7deg) translateY(1px); } }
.sg-tips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sg-tips .sg-bet { min-height: 56px; }

@media (prefers-reduced-motion: reduce) {
  .sg *, .sg { animation-duration: .01s !important; }
}
