:root {
  --bg: #0a0a14;
  --bg2: #12122a;
  --panel: #16162e;
  --line: rgba(255, 255, 255, 0.09);
  --text: #eceaf6;
  --muted: #9d9bbb;
  --accent: #8b5cff;
  --accent2: #ff3d8b;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(1100px 600px at 5% -10%, rgba(90, 50, 200, 0.28), transparent 60%),
    radial-gradient(900px 500px at 110% 0%, rgba(200, 40, 140, 0.2), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button { font: inherit; }

/* ---------- Hub ---------- */
#hub { max-width: 1180px; margin: 0 auto; padding: 44px 16px 24px; }
.brand { display: flex; align-items: center; gap: 0.32em; font-size: clamp(30px, 6.4vw, 54px); font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; }
.brand-logo { width: 1.05em; height: 1.05em; flex: none; filter: drop-shadow(0 6px 18px rgba(139, 92, 255, 0.35)); }
.brand-fresh {
  background: linear-gradient(120deg, #3ee6ff, #8b5cff 45%, #ff4f9a);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-tagline { margin: 0.55em 0 0; font-size: clamp(18px, 2.6vw, 22px); font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.brand-sub { color: var(--muted); margin: 0.3em 0 0; font-size: 16px; max-width: 60ch; line-height: 1.5; }

.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 30px 0 22px; }
#search {
  flex: 1 1 220px; max-width: 340px;
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  padding: 11px 14px; border-radius: 12px; font: inherit;
}
#search:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  padding: 7px 14px; border-radius: 999px; font-size: 14px; cursor: pointer;
}
.chip:hover { color: var(--text); }
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 20px; }
.card {
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px; overflow: hidden;
  color: inherit; text-decoration: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.card:hover, .card:focus-visible {
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--c1) 55%, transparent);
  box-shadow: 0 20px 44px -22px var(--c1);
  outline: none;
}
.card-art {
  aspect-ratio: 16 / 10; position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--c1), var(--c2));
  display: grid; place-items: center;
}
.card-art img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.4s ease; }
.card:hover .card-art img { transform: scale(1.04); }
.card-icon { font-size: 64px; filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.4)); }
.badge {
  position: absolute; top: 12px; left: 12px;
  background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(6px);
  padding: 4px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
}
.card-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-body h2 { margin: 0; font-size: 21px; letter-spacing: -0.01em; }
.card-body p { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.45; }
.card-foot { margin-top: auto; padding-top: 8px; display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 12px; color: var(--muted); border: 1px solid var(--line); padding: 3px 8px; border-radius: 6px; }
.best { font-size: 13px; font-weight: 600; color: var(--c1); }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }
.hub-footer { color: var(--muted); text-align: center; margin-top: 52px; font-size: 13px; }

/* ---------- Spiel-Ansicht ---------- */
#player { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.player-bar {
  display: flex; align-items: center; gap: 14px; flex: none;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
  background: rgba(10, 10, 20, 0.85);
}
.player-bar h1 { font-size: 18px; margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back {
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px;
  padding: 7px 11px; border-radius: 9px; border: 1px solid var(--line); white-space: nowrap;
}
.back:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.player-best { color: var(--muted); font-size: 14px; white-space: nowrap; }
@media (max-width: 480px) { .player-best { display: none; } }

.stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.stage-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.loading.error { color: #ff8a8a; padding: 20px; text-align: center; }

/* Runder Aktionsknopf für Touch-Geräte (z. B. Fähigkeiten) */
.game-fab {
  position: absolute; right: 16px; bottom: 16px; z-index: 5;
  width: 76px; height: 76px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25); background: rgba(20, 20, 40, 0.7);
  color: var(--text); font-weight: 700; font-size: 14px;
  touch-action: none; user-select: none; -webkit-user-select: none;
  opacity: 0.55; transition: opacity 0.2s, border-color 0.2s;
}
.game-fab.ready { opacity: 1; border-color: var(--c1); box-shadow: 0 0 22px -4px var(--c1); }
@media (hover: hover) and (pointer: fine) { .game-fab { display: none; } }

/* ---------- Overlay ---------- */
.ov {
  position: absolute; inset: 0; z-index: 20;
  display: grid; place-items: center; padding: 16px;
  background: rgba(6, 6, 14, 0.62); backdrop-filter: blur(4px);
  animation: ov-in 0.2s ease;
}
@keyframes ov-in { from { opacity: 0; } }
.ov-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 24px; width: 100%; max-width: 460px; max-height: 100%; overflow: auto;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.8);
  animation: ov-pop 0.25s cubic-bezier(.2, 1.4, .4, 1);
}
@keyframes ov-pop { from { transform: translateY(10px) scale(0.97); } }
.ov-card h2 { margin: 0 0 10px; font-size: 26px; letter-spacing: -0.01em; }
.ov-body { color: var(--muted); line-height: 1.55; font-size: 15px; }
.ov-body p { margin: 0.55em 0; }
.ov-body b, .ov-body strong { color: var(--text); }
.ov-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; justify-content: flex-end; }
.btn {
  font-weight: 600; border-radius: 11px; padding: 10px 18px; cursor: pointer;
  border: 1px solid var(--line); background: transparent; color: var(--text);
}
.btn:hover { background: rgba(255, 255, 255, 0.06); }
.btn-primary {
  background: linear-gradient(135deg, var(--c1, var(--accent)), var(--c2, var(--accent2)));
  border-color: transparent; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--c1, var(--accent)), var(--c2, var(--accent2))); filter: brightness(1.1); }
.btn:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

.kbd {
  display: inline-block; padding: 1px 6px; margin: 1px 0;
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px;
  font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text);
}
.stat-row { display: flex; gap: 10px; margin: 14px 0; }
.stat { flex: 1; background: var(--bg2); border-radius: 12px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 24px; color: var(--text); }
.stat span { font-size: 12px; }
.new-record { color: #ffd166; font-weight: 700; }

/* ---------- Anleitung ---------- */
.help-btn {
  display: flex; align-items: center; gap: 7px; flex: none;
  background: transparent; color: var(--text); cursor: pointer;
  border: 1px solid var(--line); border-radius: 9px; padding: 6px 11px; font-size: 14px; font-weight: 600;
}
.help-btn b {
  display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%;
  background: linear-gradient(135deg, var(--c1, var(--accent)), var(--c2, var(--accent2))); color: #fff; font-size: 13px;
}
.help-btn:hover { background: rgba(255, 255, 255, 0.06); }
@media (max-width: 480px) { .help-btn span { display: none; } }
.ov-help .ov-card { max-width: 580px; }
.ov-help h3 { margin: 18px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text); }
.ov-help ol, .ov-help ul { margin: 0; padding-left: 1.3em; }
.ov-help li { margin: 5px 0; }
.howto-goal {
  background: var(--bg2); border-left: 3px solid var(--c1, var(--accent));
  padding: 10px 12px; border-radius: 8px; color: var(--text);
}
.howto-keys { display: grid; grid-template-columns: max-content 1fr; gap: 7px 14px; margin: 0; align-items: baseline; }
.howto-keys dt { text-align: right; }
.howto-keys dd { margin: 0; }
@media (max-width: 480px) {
  .howto-keys { grid-template-columns: 1fr; gap: 2px; }
  .howto-keys dt { text-align: left; margin-top: 6px; }
}

/* ---------- Sprachauswahl ---------- */
.hub-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.lang-select {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239d9bbb'/%3E%3C/svg%3E") no-repeat right 11px center;
  border: 1px solid var(--line); color: var(--text); border-radius: 10px;
  padding: 8px 30px 8px 12px; font: inherit; font-size: 14px; font-weight: 600;
}
.lang-select:hover { border-color: rgba(255, 255, 255, 0.25); }
.lang-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.lang-select option { background: var(--panel); color: var(--text); }
.lang-compact { flex: none; padding: 6px 26px 6px 10px; }
.back { display: inline-flex; gap: 6px; align-items: center; }
@media (max-width: 480px) {
  .player-bar { gap: 8px; padding: 8px 10px; }
  .back-label { display: none; }
  .back { padding: 7px 12px; }
}
@media (max-width: 600px) {
  #hub { padding-top: 16px; }
  .hub-top { flex-direction: column-reverse; align-items: stretch; gap: 14px; }
  .hub-top .lang-select { align-self: flex-end; }
}
