@font-face {
  font-family: 'Unbounded Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 200 900;
  src: url(fonts/unbounded.woff2) format('woff2-variations'), url(fonts/unbounded.woff2) format('woff2');
}

:root {
  --bg: #0c0920;
  --bg2: #1c1640;
  --panel: rgba(33, 26, 72, .9);
  --line: rgba(170, 150, 255, .24);
  --text: #f6f1ff;
  --muted: #bdb4e6;
  --accent: #ff7a45;
  --accent2: #ffc53d;
  --ink: #170d2e;
  --good: #3ddc84;
  --bad: #ff4d6d;
  --gold: #ffd24a;
  --card: #fff6e6;
  --card-ink: #2b1d52;
  --g1: #ff7a45;
  --g2: #a66bff;
  --g3: #34e1ff;
  --radius: 18px;
  --font-display: 'Unbounded Variable', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
html, body { margin: 0; }
body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent2); outline-offset: 2px; }

/* Lebendiger Hintergrund: drei weiche Farbflächen in den Farben des Spiels. */
.backdrop { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; background: var(--bg); }
.backdrop i {
  position: absolute; width: 70vmax; height: 70vmax; border-radius: 50%;
  filter: blur(70px); opacity: .28; transition: background 1.2s;
  animation: drift 26s ease-in-out infinite alternate;
}
.backdrop i:nth-child(1) { background: var(--g1); left: -30vmax; top: -30vmax; }
.backdrop i:nth-child(2) { background: var(--g2); right: -35vmax; top: 10vh; animation-duration: 31s; animation-delay: -8s; }
.backdrop i:nth-child(3) { background: var(--g3); left: 10vw; bottom: -45vmax; opacity: .18; animation-duration: 37s; animation-delay: -15s; }
@keyframes drift {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(8vmax, 6vmax) scale(1.12); }
  100% { transform: translate(-6vmax, 10vmax) scale(.95); }
}

#app { max-width: 560px; margin: 0 auto; min-height: 100dvh; }
.screen { min-height: 100dvh; display: flex; flex-direction: column; padding-top: var(--safe-top); animation: screen-in .35s ease-out; }
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* --- Bausteine --- */
.card-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 18px 40px -28px #000, inset 0 1px 0 rgba(255, 255, 255, .06);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
.label { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.hint { color: var(--muted); text-align: center; font-size: 14px; margin: 8px 0 0; min-height: 1.4em; }

.btn {
  display: block; width: 100%;
  padding: 13px 16px; border-radius: 14px;
  border: 1px solid var(--line); background: rgba(28, 22, 64, .9);
  font-weight: 700; cursor: pointer; touch-action: manipulation;
  transition: transform .08s, filter .15s, opacity .15s, box-shadow .2s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn.primary {
  border: 0; color: var(--ink);
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  box-shadow: 0 10px 26px -10px var(--accent), inset 0 1px 0 rgba(255, 255, 255, .35);
}
.btn.primary:not(:disabled):hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.big { padding: 16px; font-size: 18px; font-weight: 800; }
.icon-btn {
  background: none; border: 0; font-size: 20px; width: 44px; height: 44px;
  border-radius: 12px; cursor: pointer; display: grid; place-items: center;
}
.icon-btn:active { background: var(--bg2); }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field span { font-size: 14px; color: var(--muted); }
input {
  width: 100%; padding: 13px 14px; border-radius: 14px;
  border: 1px solid var(--line); background: rgba(10, 7, 26, .85); outline: none;
}
input:focus { border-color: var(--accent2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent2) 25%, transparent); }

.bar {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 6px 10px; min-height: 54px;
}
.bar-title { font-family: var(--font-display); font-weight: 800; letter-spacing: .08em; font-size: 14px; }
.bar-left { font-size: 14px; color: var(--muted); }
.bar-right { justify-self: end; display: flex; align-items: center; gap: 4px; }
.bar > :last-child { justify-self: end; }
.my-score { font-weight: 800; font-variant-numeric: tabular-nums; }

.tag { flex: none; font-size: 11px; padding: 2px 7px; border-radius: 999px; background: #3b3373; color: #ece8ff; font-weight: 700; }
.tag.me { background: var(--accent2); color: var(--ink); }
.tag.off { background: #4a2433; color: #ffb3c1; }

.timer { height: 5px; margin-top: 10px; border-radius: 3px; background: rgba(0, 0, 0, .3); overflow: hidden; }
.timer span { display: block; height: 100%; width: 100%; background: var(--accent2); transform-origin: left; }
.timer.low span { background: var(--bad); }
.timer.off { visibility: hidden; }

.pips { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; max-width: 130px; }
.pip {
  height: 19px; border-radius: 4px; font-size: 11px; font-weight: 800;
  display: grid; place-items: center; background: var(--card); color: var(--card-ink);
}
.pip.used { background: transparent; color: #6f66a3; box-shadow: inset 0 0 0 1px #3f3676; }

/* Spielkarten (LIMIT, KRAFTPROBE) */
.hand-area {
  padding: 8px 12px calc(12px + var(--safe-bottom));
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, .4) 30%);
}
.hand-hint { margin: 0 0 6px; text-align: center; font-size: 13px; color: var(--muted); min-height: 1.4em; }
.hcard {
  aspect-ratio: 5 / 7; border-radius: 12px; border: 0; cursor: pointer; touch-action: manipulation;
  background: linear-gradient(160deg, #fffaf0, var(--card) 60%, #f3e4c8);
  color: var(--card-ink);
  font-family: var(--font-display); font-size: clamp(20px, 6.5vw, 32px); font-weight: 800;
  box-shadow: 0 4px 0 #d9c7a6, 0 10px 18px -8px #000;
  transition: transform .18s cubic-bezier(.2, .9, .3, 1.3), box-shadow .15s, opacity .2s;
  position: relative;
}
.hcard:active { transform: translateY(1px); }
.hcard.sel { transform: translateY(-12px) rotate(-2deg); box-shadow: 0 0 0 3px var(--accent2), 0 16px 24px -10px #000; }
.hcard.used { background: transparent; color: #5e5590; box-shadow: inset 0 0 0 2px #3a3170; cursor: default; }
.hcard.chosen { box-shadow: 0 0 0 3px var(--good), 0 10px 18px -8px #000; transform: translateY(-6px); }
.locked .hcard:not(.chosen) { opacity: .5; }

@keyframes pop { from { transform: scale(.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-8px); } 40%, 60% { transform: translateX(8px); }
}
@keyframes blink { 50% { opacity: .2; } }

/* --- Start / Spielauswahl --- */
.hub { padding: 26px 16px calc(28px + var(--safe-bottom)); display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.series { margin: 0; text-align: center; color: var(--muted); letter-spacing: .2em; text-transform: uppercase; font-size: 12px; }
.hub-head { display: grid; gap: 8px; text-align: center; }
.brand { margin: 0; font-family: var(--font-display); font-weight: 900; line-height: .95; display: grid; justify-content: center; gap: 4px; }
.brand-row { display: flex; justify-content: center; gap: .06em; font-size: clamp(36px, 12.5vw, 64px); }
.brand-row b {
  display: inline-block; font-weight: 900;
  background: linear-gradient(180deg, #ffffff 25%, var(--accent2) 70%, var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: card-in .6s cubic-bezier(.2, .9, .3, 1.25) both;
  filter: drop-shadow(0 6px 16px color-mix(in srgb, var(--accent) 45%, transparent));
}
.brand-row:first-child b { font-size: .78em; }
.brand-row b:nth-child(2) { animation-delay: .05s; } .brand-row b:nth-child(3) { animation-delay: .1s; }
.brand-row b:nth-child(4) { animation-delay: .15s; } .brand-row b:nth-child(5) { animation-delay: .2s; }
.brand-row b:nth-child(6) { animation-delay: .25s; } .brand-row b:nth-child(7) { animation-delay: .3s; }
.brand-row:last-child b { animation-delay: calc(.12s + var(--d, 0s)); }
@keyframes card-in { from { transform: rotateY(90deg) translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
.tagline { margin: 0; font-size: 17px; font-weight: 600; }

.me-panel { display: grid; gap: 4px; }
.join-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.join-row input { text-transform: uppercase; letter-spacing: .3em; text-align: center; font-weight: 800; }
.join-row .btn { width: auto; }
.invite-box {
  display: grid; gap: 8px; margin-bottom: 10px; padding: 12px; border-radius: 16px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--g1, #ff7a45) 22%, #120c2a), color-mix(in srgb, var(--g2, #a66bff) 18%, #120c2a));
  border: 1px solid rgba(255, 255, 255, .14);
}
.invite-text { margin: 0; text-align: center; font-weight: 700; min-height: 1.4em; }

.section-title { margin: 6px 4px -4px; font-family: var(--font-display); font-size: 15px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.games { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.game-card {
  position: relative; display: grid; grid-template-columns: clamp(86px, 27vw, 140px) minmax(0, 1fr); gap: 4px;
  border-radius: 24px; overflow: hidden;
  background:
    radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--g1) 20%, transparent), transparent 55%),
    linear-gradient(150deg, color-mix(in srgb, var(--g1) 14%, #130e2c), color-mix(in srgb, var(--g2) 14%, #100b25));
  border: 1px solid color-mix(in srgb, var(--g1) 40%, transparent);
  box-shadow: 0 22px 40px -30px var(--g1), inset 0 1px 0 rgba(255, 255, 255, .07);
  animation: rise .5s ease-out both;
}
.game-card:nth-child(2) { animation-delay: .07s; } .game-card:nth-child(3) { animation-delay: .14s; } .game-card:nth-child(4) { animation-delay: .21s; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.game-card::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background: linear-gradient(110deg, transparent 40%, rgba(255, 255, 255, .08) 50%, transparent 60%);
  background-size: 250% 100%; animation: sheen 7s ease-in-out infinite;
}
@keyframes sheen { 0%, 70% { background-position: 120% 0; } 100% { background-position: -120% 0; } }
.gc-art { display: grid; place-items: center; padding: 14px 0 14px 12px; }
.gc-art svg { width: 100%; overflow: visible; filter: drop-shadow(0 10px 18px rgba(0, 0, 0, .45)); }
.gc-body { padding: 16px 16px 14px 8px; display: grid; gap: 6px; align-content: start; min-width: 0; }
.gc-no { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.gc-name {
  margin: 0; font-family: var(--font-display); font-weight: 900; font-size: clamp(20px, 6.2vw, 28px); line-height: 1.05;
  background: linear-gradient(90deg, #fff, color-mix(in srgb, var(--g1) 60%, #fff)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.gc-tag { margin: 0; font-size: 14px; color: #ebe5ff; }
.gc-chips { margin: 2px 0 4px; display: flex; flex-wrap: wrap; gap: 6px; }
.gc-chips span { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .12); }
.btn.gc-play { background: linear-gradient(135deg, var(--g1), var(--g2)); color: var(--ink); border: 0; font-weight: 800; box-shadow: 0 10px 24px -12px var(--g1), inset 0 1px 0 rgba(255, 255, 255, .35); }
.btn.gc-play:hover { filter: brightness(1.08); }
.footnote { text-align: center; color: var(--muted); font-size: 13px; margin: 0; }

.rules summary { cursor: pointer; font-weight: 700; padding: 4px 0; }
.rules ol { padding-left: 20px; margin: 10px 0 8px; display: grid; gap: 6px; font-size: 14px; }
.rules p { margin: 0; color: var(--muted); font-size: 13px; }
.game-card .rules { font-size: 14px; }

/* SVG-Illustrationen leben ein bisschen */
.art-la-fill { animation: la 4s ease-in-out infinite; transform-origin: left; }
@keyframes la { 0%, 100% { transform: scaleX(.35); } 60% { transform: scaleX(.95); } 75% { transform: scaleX(1.08); } }
.art-kp-knot { animation: kp 3s ease-in-out infinite; }
@keyframes kp { 0%, 100% { transform: translateX(-14px); } 50% { transform: translateX(10px); } }
.art-mw-eye { animation: mweye 3.2s ease-in-out infinite; }
@keyframes mweye { 0%, 40%, 100% { transform: translateX(0); } 55%, 85% { transform: translateX(5px); } }
.art-pk-pop { transform-origin: center; transform-box: fill-box; animation: pkpop 2.4s ease-in-out infinite; }
.art-pk-pop:nth-of-type(2) { animation-delay: .3s; } .art-pk-pop:nth-of-type(3) { animation-delay: .6s; }
@keyframes pkpop { 0%, 60%, 100% { transform: scale(1); } 70% { transform: scale(1.25) rotate(-6deg); } }

/* --- Lobby --- */
.lobby { padding: 4px 16px calc(24px + var(--safe-bottom)); display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.lobby-tagline { margin: -4px 0 0; text-align: center; color: #ebe5ff; font-weight: 600; }
.room-code { text-align: center; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.code {
  font-family: var(--font-display); font-size: clamp(36px, 12vw, 52px); letter-spacing: .2em; font-weight: 900; padding-left: .2em; line-height: 1.15;
  background: linear-gradient(180deg, #fff 30%, var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.invite-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.qr { background: #fff; border-radius: 14px; padding: 12px; justify-self: center; }
.qr img, .qr svg { display: block; width: 200px; height: 200px; image-rendering: pixelated; }
.list-head { display: flex; justify-content: space-between; margin-bottom: 8px; font-weight: 700; }
.seats { list-style: none; margin: 0 0 12px; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.seat {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  border-radius: 12px; background: rgba(12, 9, 32, .55); animation: pop .3s ease-out;
}
.seat .dot { width: 14px; height: 14px; border-radius: 50%; flex: none; box-shadow: 0 0 10px currentColor; }
.seat .name { flex: 1; min-width: 0; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat .kick { background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; padding: 0 6px; min-height: 28px; }
.settings { display: grid; gap: 14px; }
.segmented { display: grid; grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); gap: 6px; margin-top: 8px; }
.segmented button {
  padding: 10px 0; border-radius: 12px; border: 1px solid var(--line); background: rgba(12, 9, 32, .55);
  font-weight: 700; cursor: pointer; min-width: 0; overflow: hidden; text-overflow: ellipsis;
}
.segmented button[aria-checked="true"] { background: var(--accent2); color: var(--ink); border-color: transparent; }
.segmented button:disabled { cursor: default; }
.wins { margin: 0; text-align: center; font-weight: 700; color: var(--gold); }

/* --- Spiel --- */
#screen-game { height: 100dvh; min-height: 0; }
.game-root { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* --- Ende --- */
.over { padding: 8px 18px calc(24px + var(--safe-bottom)); display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.over-title {
  margin: 0; text-align: center; font-family: var(--font-display); font-size: clamp(22px, 7vw, 32px); font-weight: 900; line-height: 1.15;
  animation: pop .5s cubic-bezier(.2, .9, .3, 1.3);
}
.ranking { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.ranking li {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px;
  background: var(--panel); border: 1px solid var(--line); animation: rise .45s ease-out both;
}
.ranking li:nth-child(2) { animation-delay: .08s; } .ranking li:nth-child(3) { animation-delay: .16s; } .ranking li:nth-child(n+4) { animation-delay: .24s; }
.ranking li.first { background: linear-gradient(135deg, #5c3d00, #2d2000); border-color: var(--gold); box-shadow: 0 0 30px -10px var(--gold); }
.ranking .place { width: 30px; text-align: center; font-size: 22px; font-weight: 900; }
.ranking .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.ranking .name { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranking .pts { font-family: var(--font-display); font-weight: 800; font-size: 19px; font-variant-numeric: tabular-nums; }
.stats { text-align: center; color: var(--muted); margin: 0; }
#over-host { display: grid; gap: 8px; }

/* --- Meldungen & Effekte --- */
.conn, .toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 20;
  max-width: min(92vw, 480px); padding: 10px 16px; border-radius: 14px; font-weight: 650; font-size: 14px;
  box-shadow: 0 10px 30px -10px #000; text-align: center;
}
.conn { top: calc(8px + var(--safe-top)); background: #5a2236; }
.toast { bottom: calc(24px + var(--safe-bottom)); background: #f6f1ff; color: #24113d; animation: pop .25s; }
.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 30; }
.float-text {
  position: fixed; z-index: 25; pointer-events: none; transform: translate(-50%, 0);
  font-family: var(--font-display); font-weight: 900; font-size: 18px; color: var(--bad);
  animation: float-up 1.1s ease-out forwards;
}
@keyframes float-up { to { transform: translate(-50%, -46px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
