:root {
  color-scheme: dark;
  --bg: #090b10;
  --panel: #11141b;
  --text: #f7f8fb;
  --muted: #8e94a3;
  --line: rgba(255,255,255,.1);
  --green: #22df88;
  --red: #ff4e68;
  --yellow: #ffcf45;
  --blue: #4285ff;
  --vph: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; background: var(--bg); }
body {
  min-height: var(--vph);
  color: var(--text);
  background: radial-gradient(circle at 50% 42%, rgba(66,133,255,.08), transparent 40%), linear-gradient(180deg,#0b0e14,#080a0e);
}
button, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { font: inherit; cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, a:focus-visible { outline: 3px solid white; outline-offset: 4px; }
.game-shell {
  width: min(100%,470px);
  min-height: var(--vph);
  margin: 0 auto;
  padding: max(20px,env(safe-area-inset-top)) 22px max(20px,env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}
.topbar { display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--text); font-size: 1.15rem; font-weight: 900; letter-spacing: .16em; text-decoration: none; }
.brand-mark { width: 24px; height: 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 2px; transform: rotate(45deg); }
.brand-mark i { border-radius: 2px; background: var(--green); }
.brand-mark i:nth-child(2) { background: var(--red); }
.brand-mark i:nth-child(3) { background: var(--yellow); }
.brand-mark i:nth-child(4) { background: var(--blue); }
.icon-button { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line); color: #cdd1db; background: rgba(255,255,255,.04); }
.icon-button svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sound-off, [aria-pressed="false"] .sound-on { display: none; }
[aria-pressed="false"] .sound-off { display: block; }
.status { min-height: 114px; display: grid; grid-template-columns: 84px 1fr 84px; align-items: end; padding: 24px 2px 18px; text-align: center; gap: 6px; }
.status > div { display: grid; gap: 2px; text-align: left; }
.status .score-block { text-align: right; }
.eyebrow { color: var(--muted); font-size: .66rem; font-weight: 800; letter-spacing: .14em; }
.status strong { font-size: 1.65rem; font-variant-numeric: tabular-nums; letter-spacing: .025em; white-space: nowrap; }
.target { color: var(--muted); font-size: .9rem; }
.status p { margin: 0 0 3px; color: #d3d6de; font-size: .88rem; line-height: 1.4; }
.mode-switch { display: grid; grid-template-columns: repeat(3,1fr); gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 14px; background: #0b0e14; }
.mode-switch button { min-height: 37px; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--muted); font-size: .77rem; font-weight: 750; }
.mode-switch button[aria-pressed="true"] { color: var(--text); background: #242935; border-color: rgba(255,255,255,.08); box-shadow: 0 3px 8px #0003; }
.mode-switch button:disabled { opacity: .45; }
.mode-switch button[aria-pressed="true"]:disabled { opacity: 1; }
.mode-note { color: var(--muted); font-size: .71rem; text-align: center; margin: 11px 0 8px; min-height: 20px; }
.board-wrap { flex: 1; display: grid; align-content: center; position: relative; padding: 18px 0 24px; isolation: isolate; }
.board-wrap::before, .board-wrap::after { content: ""; position: absolute; width: 140px; height: 140px; border-radius: 50%; filter: blur(65px); opacity: .1; z-index: -1; pointer-events: none; }
.board-wrap::before { background: var(--green); left: 0; top: 20%; }
.board-wrap::after { background: var(--blue); right: 0; bottom: 20%; }
.metrics { display: grid; grid-template-columns: repeat(3,1fr); padding: 17px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.metrics > div { display: grid; gap: 5px; text-align: center; }
.metrics > div + div { border-left: 1px solid var(--line); }
.metrics strong { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.primary { width: 100%; min-height: 52px; border: 0; border-radius: 15px; background: var(--text); color: #0a0c11; font-weight: 850; }
.primary:hover { background: #dfe5f1; }
.primary:active { transform: scale(.985); }
.primary.secondary-style { background: #171c26; color: #c8cdd8; border: 1px solid var(--line); }
footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 2px 0; }
footer p { display: flex; align-items: center; gap: 9px; margin: 0; color: #898f9d; font-size: .71rem; line-height: 1.4; }
.pulse-dot { flex: 0 0 7px; height: 7px; border-radius: 50%; background: #626876; box-shadow: 0 0 0 4px #ffffff09; }
.pulse-dot.live { background: var(--green); box-shadow: 0 0 0 4px #22df881a,0 0 12px #22df8870; }
.how-button { flex-shrink: 0; min-height: 44px; border: 0; color: #a8adba; background: transparent; font-size: .75rem; padding: 8px 0 8px 8px; }
.how-button span { display: inline-grid; place-items: center; width: 18px; height: 18px; margin-left: 5px; border: 1px solid #555b68; border-radius: 50%; }
.overlay { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 16px; background: rgba(2,4,7,.8); backdrop-filter: blur(8px); overflow-y: auto; }
.overlay > .dialog-card { width: min(100%,420px); max-height: 100%; overflow-y: auto; border: 1px solid var(--line); border-radius: 26px; background: #151922; box-shadow: 0 24px 90px #0008; }
.dialog-card { position: relative; padding: 30px 26px 24px; }
.dialog-card h2 { margin: 7px 0 20px; font-size: 1.9rem; line-height: 1.15; letter-spacing: -.035em; }
.dialog-card p { color: #bec3ce; line-height: 1.55; font-size: .92rem; }
.dialog-card ol { list-style: none; padding: 0; margin: 0 0 25px; display: grid; gap: 17px; counter-reset: steps; }
.dialog-card li { display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: 12px; color: #bec3ce; line-height: 1.45; font-size: .9rem; counter-increment: steps; }
.dialog-card li::before { content: counter(steps); width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: #242936; color: white; font-weight: 800; }
.dialog-close { position: absolute; right: 12px; top: 10px; width: 44px; height: 44px; border: 0; background: transparent; color: #9298a6; font-size: 1.8rem; }
.dialog-card .primary + .primary { margin-top: 10px; }
.result-icon { display: grid; place-items: center; width: 62px; height: 62px; border: 1px solid #22df8833; border-radius: 20px; background: #22df8812; color: var(--green); font-size: 1.9rem; margin-bottom: 22px; }
.result-icon.failed { color: var(--yellow); border-color: #ffcf4533; background: #ffcf4512; }
.result-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 20px 0 24px; }
.result-stats > div { display: grid; gap: 6px; background: #0c1018; border-radius: 12px; padding: 14px; }
.result-stats strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
body.embedded .brand { display: none; }
body.embedded .topbar { justify-content: flex-end; }
body.paused .board-wrap { visibility: hidden; }
/* MEMORY */
.memory-board { display: grid; grid-template-columns: repeat(var(--columns,4),1fr); gap: 9px; padding: 10px; border: 1px solid #ffffff08; border-radius: 24px; background: #07090d; box-shadow: 0 25px 65px #0006; }
.card { position: relative; aspect-ratio: 1; padding: 0; border: 0; border-radius: 13px; background: transparent; perspective: 650px; -webkit-appearance: none; appearance: none; }
/* Offene Karten sind gesperrt. Mobile Browser sollen ihre Emojis dabei nicht abdunkeln. */
.card, .card:disabled { color: var(--text); -webkit-text-fill-color: var(--text); opacity: 1; }
.card-inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform 340ms cubic-bezier(.2,.7,.2,1); }
.card.open .card-inner, .card.matched .card-inner { transform: rotateY(180deg); }
.card-back, .card-front { position: absolute; inset: 0; display: grid; place-items: center; border: 1px solid #ffffff0c; border-radius: 13px; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.card-back { background: linear-gradient(145deg,#222936,#131822); color: #454f62; }
.card-back::after { content: ""; width: 18%; height: 18%; border: 2px solid currentColor; border-radius: 3px; transform: rotate(45deg); box-shadow: 4px 4px 0 -1px #222936,5px 5px 0 0 currentColor; }
.card-front { background: linear-gradient(145deg,#283142,#19202c); transform: rotateY(180deg); font-size: clamp(1.3rem,7vw,2.1rem); }
.card:not(:disabled):hover .card-back { border-color: #ffffff35; background: linear-gradient(145deg,#2d3747,#1b2230); }
.card.matched .card-front { background: linear-gradient(145deg,#15372c,#10221e); border-color: #22df8866; box-shadow: inset 0 0 20px #22df8809; }
.memory-board.large { gap: 6px; padding: 8px; border-radius: 19px; }
.large .card, .large .card-front, .large .card-back { border-radius: 9px; }
.large .card-front { font-size: clamp(1.15rem,5vw,1.6rem); }
.memory-board.idle .card:nth-child(5n + 1) .card-back { color: #4285ff70; }
.memory-board.idle .card:nth-child(5n + 3) .card-back { color: #22df8850; }
.memory-board.idle .card:nth-child(5n + 4) .card-back { color: #ffcf4550; }
@media (min-width: 760px) {
  body { display: grid; place-items: center; padding: 20px 0; }
  .game-shell { min-height: min(860px,calc(var(--vph) - 40px)); border: 1px solid #ffffff12; border-radius: 34px; box-shadow: 0 30px 100px #0008; }
}
@media (max-width: 360px) {
  .game-shell { padding-left: 14px; padding-right: 14px; }
  .status { grid-template-columns: 72px 1fr 74px; }
  .status p { font-size: .77rem; }
  .memory-board { gap: 7px; }
  .choice { padding: 0 12px; }
  .eyebrow { font-size: .6rem; }
}
@media (min-height: 300px) and (max-height: 900px) {
  .game-shell { padding-top: 12px; padding-bottom: 10px; }
  .status { min-height: 76px; padding-top: 14px; padding-bottom: 10px; }
  .board-wrap { padding-top: 10px; padding-bottom: 15px; }
  .memory-board { width: min(100%,calc(var(--vph) - 450px)); min-width: min(100%,260px); margin: auto; }
  .word-stage { min-height: 178px; gap: 19px; }
  .metrics { padding: 8px 0; margin-bottom: 12px; }
  footer { padding-top: 6px; }
}
@media (min-width: 760px) and (max-height: 900px) {
  body { padding: 12px 0; }
  .game-shell { min-height: calc(var(--vph) - 24px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
