/*
 * Gestalt der Web-App. Werte gespiegelt aus
 * apps/ios/LuvianoDesignKit/Sources/LuvianoDesignKit/LuvianoDesign.swift;
 * scripts/tests/web-gestalt-paritaet.test.mjs hält die Farben gleich.
 * Die App ist nur dunkel, wie auf iOS.
 */
:root {
  /* quelle: apps/ios/LuvianoDesignKit/Sources/LuvianoDesignKit/LuvianoDesign.swift */
  --brand: #A36EF5;
  --brand-secondary: #F15FB4;
  --brand-foreground: #FFFFFF;
  --accent: #E7BE6B;
  --action-fill: #6C35C1;
  --background: #0E0A1C;
  --background-elevated: #171227;
  --surface: #1C1633;
  --surface-elevated: #241D3F;
  --field: #241D3B;
  --text-primary: #F4F1FB;
  --text-secondary: #B7B0D2;
  --text-tertiary: #8B85A5;
  --separator: #2C2447;
  --danger: #FF7DA3;
  --success: #6FE3AC;
  --score-paper: #F4EFE4;
  /* quelle: apps/ios/LuvianoPlayUI/Sources/LuvianoPlayUI/TastaturPalette.swift */
  --elfenbein-hell: #FBF8F1;
  --elfenbein: #EFEADD;
  --elfenbein-tief: #CFC7B5;
  --ebenholz-hell: #3B3648;
  --ebenholz: #1E1A2A;
  --ebenholz-tief: #0C0A14;
  /* quelle: apps/ios/LuvianoPlayUI/Sources/LuvianoPlayUI/LuvianoLearning.swift */
  --hit: #30D158;
  --miss: #7D7195;
  /* quelle: ende */
  --text-muted: var(--text-tertiary);

  --xxs: 4px; --xs: 8px; --sm: 12px; --md: 16px; --lg: 24px; --xl: 32px; --xxl: 48px;
  --radius-sm: 8px; --radius-md: 12px; --radius-lg: 20px; --radius-xl: 28px;
  --treffflaeche: 44px;

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: ui-serif, "New York", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--background);
  color: var(--text-primary);
  font: 17px/1.4 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { cursor: default; }
a { color: var(--brand); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
[hidden] { display: none !important; }

#app { min-height: 100%; }

/* ── Bausteine ─────────────────────────────────────────── */
.karte {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 0.5px solid color-mix(in srgb, var(--separator) 80%, transparent);
  box-shadow: 0 8px 18px rgb(0 0 0 / 45%);
  padding: var(--lg);
}
.knopf {
  display: flex; align-items: center; justify-content: center; gap: var(--xs);
  width: 100%; min-height: 52px; padding: 0 var(--md);
  border-radius: var(--radius-md);
  background: var(--action-fill); color: var(--brand-foreground);
  font-weight: 600;
  box-shadow: 0 6px 12px color-mix(in srgb, var(--brand) 35%, transparent);
}
.knopf svg { width: 20px; height: 20px; flex: none; }
a.knopf { text-decoration: none; }
.knopf:disabled { opacity: 0.45; box-shadow: none; }
.knopf.ruhig { background: var(--surface-elevated); box-shadow: none; color: var(--text-primary); }
.text-knopf { color: var(--brand); min-height: var(--treffflaeche); padding: 0 var(--xs); }
.feld {
  width: 100%; min-height: 48px; padding: var(--sm);
  background: var(--field); border-radius: var(--radius-md);
  border: 0.5px solid var(--separator);
}
.feld::placeholder { color: var(--text-muted); }
.feld.code { font: 600 22px var(--mono); letter-spacing: 0.2em; }
.fehlertext { color: var(--danger); font-size: 15px; margin: 0; }
.leise { color: var(--text-secondary); }
.klein { font-size: 13px; }
.zustand { padding: var(--xxl) var(--lg); text-align: center; color: var(--text-secondary); }
.zustand h2 { font: 600 22px var(--serif); color: var(--text-primary); margin: 0 0 var(--xs); }
.zustand .knopf { width: auto; margin: var(--md) auto 0; }

/* ── Start ─────────────────────────────────────────────── */
.start {
  min-height: 100dvh; max-width: 460px; margin: 0 auto; padding: var(--xl) var(--lg);
  display: flex; flex-direction: column; gap: var(--lg);
}
.start-kopf { text-align: center; padding-top: var(--lg); }
.start-kopf img { width: 148px; height: 148px; filter: drop-shadow(0 12px 22px rgb(155 130 255 / 45%)); }
.wortmarke { font: 500 34px var(--serif); letter-spacing: 2.38px; margin: var(--sm) 0 var(--xs); }
.claim { color: var(--text-secondary); margin: 0; }
.anmeldung { display: flex; flex-direction: column; gap: var(--md); }
.anmeldung h1 { font: 600 22px var(--serif); margin: 0; }
.anmeldung label { font-size: 15px; color: var(--text-secondary); display: block; margin-bottom: var(--xs); }
.anmeldung .kopfzeile { display: flex; align-items: center; gap: var(--xs); }
.rund {
  width: var(--treffflaeche); height: var(--treffflaeche); border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  color: var(--text-primary);
}
.rund:hover { background: var(--surface-elevated); }
.rund svg { width: 20px; height: 20px; }
.rechtliches { margin-top: auto; text-align: center; }
.rechtliches h2 { font: 400 13px var(--sans); color: var(--text-muted); margin: 0 0 var(--xxs); }
.rechtliches nav { display: flex; gap: var(--md); justify-content: center; flex-wrap: wrap; }
.rechtliches a { font-size: 13px; min-height: var(--treffflaeche); display: inline-flex; align-items: center; }

/* ── Home ──────────────────────────────────────────────── */
.home { max-width: 1040px; margin: 0 auto; padding: var(--lg) var(--md) 120px; }
.home > h1 { font: 500 34px var(--serif); margin: var(--xs) 0 var(--lg); }
.tabs {
  position: fixed; left: 50%; bottom: calc(var(--md) + env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; gap: var(--xxs); padding: var(--xxs);
  background: color-mix(in srgb, var(--surface-elevated) 82%, transparent);
  -webkit-backdrop-filter: blur(22px) saturate(1.4); backdrop-filter: blur(22px) saturate(1.4);
  border: 0.5px solid var(--separator); border-radius: 999px;
  box-shadow: 0 8px 18px rgb(0 0 0 / 45%);
}
.tabs button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-width: 92px; min-height: 54px; border-radius: 999px;
  color: var(--text-secondary); font-size: 11px; font-weight: 500;
}
.tabs button svg { width: 24px; height: 24px; }
.tabs button[aria-current="page"] { color: var(--text-primary); background: color-mix(in srgb, var(--text-primary) 12%, transparent); }

.hero {
  position: relative; overflow: hidden; min-height: 300px; border-radius: var(--radius-xl);
  display: flex; flex-direction: column; justify-content: flex-end; gap: var(--xs);
  padding: var(--lg); margin-bottom: var(--xl); text-align: left; width: 100%;
  color: #fff; box-shadow: 0 8px 18px rgb(0 0 0 / 45%);
}
.hero::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgb(0 0 0 / 0%), rgb(0 0 0 / 15%) 45%, rgb(0 0 0 / 72%));
}
.hero > * { position: relative; z-index: 1; }
.hero img.bild { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; }
.hero .tipp { font-size: 12px; font-weight: 600; letter-spacing: 1.5px; color: rgb(255 255 255 / 85%); }
.hero h2 { font: 500 34px/1.1 var(--serif); margin: 0; text-shadow: 0 1px 2px rgb(0 0 0 / 62%); }
.hero p { margin: 0; color: rgb(255 255 255 / 85%); }
.hero .knopf {
  width: auto; align-self: flex-start; margin-top: var(--xs); padding: 0 var(--lg);
  background: var(--text-primary); color: var(--action-fill);
  box-shadow: 0 6px 12px color-mix(in srgb, var(--brand) 40%, transparent);
}

.sektion { margin-bottom: var(--xl); }
.sektion > header { display: flex; align-items: center; gap: var(--xs); margin-bottom: var(--sm); }
.sektion h2 { font: 600 22px var(--serif); margin: 0; }
.abzeichen {
  font-size: 11px; font-weight: 700; letter-spacing: 0.5px; padding: 2px var(--xs); border-radius: 999px;
  background: var(--brand-secondary); color: var(--background);
}
.reihe { display: flex; gap: var(--md); overflow-x: auto; padding-bottom: var(--xs); scrollbar-width: none; }
.reihe::-webkit-scrollbar { display: none; }
.stueck-karte { width: 152px; flex: none; text-align: left; }
.stueck-karte .titel { font-weight: 600; font-size: 15px; margin: var(--xs) 0 0; }
.stueck-karte .zeile { font-size: 13px; color: var(--text-secondary); margin: 2px 0 0; }
.titel, .zeile { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cover {
  position: relative; aspect-ratio: 1; border-radius: var(--radius-lg); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font: 600 44px var(--serif); color: rgb(255 255 255 / 92%);
}
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover .premium {
  position: absolute; top: var(--xs); right: var(--xs);
  font: 700 11px var(--sans); padding: 2px var(--xs); border-radius: 999px;
  background: rgb(0 0 0 / 45%); color: #fff;
}
.cover.klein { width: 56px; border-radius: var(--radius-md); font-size: 20px; flex: none; }
.cover.gross { width: min(280px, 70vw); border-radius: var(--radius-xl); font-size: 88px; margin: 0 auto; }

.suchfeld { position: relative; margin-bottom: var(--lg); }
.suchfeld .feld { padding-right: 48px; }
.suchfeld .feld::-webkit-search-cancel-button { display: none; }
.suchfeld .rund { position: absolute; right: 2px; top: 2px; }
.treffer-liste { display: flex; flex-direction: column; }
.treffer {
  display: flex; align-items: center; gap: var(--sm); padding: var(--xs) 0; text-align: left; width: 100%;
  border-bottom: 0.5px solid var(--separator);
}
.treffer > div:last-child { min-width: 0; }

.profil { display: flex; flex-direction: column; gap: var(--md); max-width: 560px; }
.profil .konto p { margin: 0; }
.profil .rechts-liste { display: flex; flex-direction: column; padding: 0 var(--lg); }
.profil .rechts-liste h2 { font: 400 13px var(--sans); color: var(--text-muted); margin: var(--md) 0 0; }
.profil .rechts-liste a {
  min-height: var(--treffflaeche); display: flex; align-items: center; color: var(--text-primary);
  text-decoration: none; border-bottom: 0.5px solid var(--separator);
}
.profil .rechts-liste a:last-child { border-bottom: 0; }

.detail { max-width: 560px; margin: 0 auto; padding: var(--md) var(--lg) var(--xxl); text-align: center; }
.detail .kopfzeile { display: flex; }
.detail h1 { font: 500 34px var(--serif); margin: var(--lg) 0 var(--xxs); }
.detail .fakten { color: var(--text-secondary); margin: var(--xs) 0 var(--lg); }

dialog.blatt {
  border: 0; padding: var(--lg); max-width: 420px; width: calc(100% - 2 * var(--md));
  background: var(--background-elevated); color: var(--text-primary);
  border-radius: var(--radius-lg); text-align: center;
}
dialog.blatt::backdrop { background: rgb(0 0 0 / 55%); }
dialog.blatt h2 { font: 600 22px var(--serif); margin: 0 0 var(--xs); }
dialog.blatt p { margin: 0 0 var(--md); color: var(--text-secondary); }

/* ── Player ────────────────────────────────────────────── */
.spieler {
  height: 100dvh; display: flex; flex-direction: column; gap: var(--sm);
  padding: var(--md); max-width: 1100px; margin: 0 auto;
}
.spieler-kopf { display: flex; align-items: center; gap: var(--xs); }
.spieler-kopf .titelblock { flex: 1; min-width: 0; }
.spieler-kopf h1 { font: 700 20px var(--sans); margin: 0; }
.spieler-kopf p { font-size: 12px; color: var(--text-secondary); margin: 0; }
.kopf-knopf {
  min-height: var(--treffflaeche); padding: 0 var(--sm); border-radius: 999px;
  background: var(--surface-elevated); font-size: 13px; display: inline-flex; align-items: center; gap: var(--xxs);
}
.kopf-knopf svg { width: 18px; height: 18px; }
.banner {
  background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger);
  border-radius: var(--radius-md); padding: var(--sm); font-size: 15px;
}
.blatt-karte {
  position: relative; flex: 1; min-height: 120px; overflow: hidden;
  background: var(--score-paper); border-radius: var(--radius-lg);
  box-shadow: 0 8px 18px rgb(0 0 0 / 35%);
}
.blatt-rolle { position: absolute; inset: 0; overflow-y: auto; }
.blatt-meldung {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #5b5470; font-size: 15px;
}
.seite { position: relative; width: 100%; }
.seite canvas { display: block; width: 100%; height: auto; mix-blend-mode: multiply; }
.kasten {
  position: absolute; pointer-events: none;
  background: rgb(255 209 38 / 30%); border: 1px solid rgb(255 209 38 / 54%);
}
.fortschritt { height: 4px; border-radius: 2px; background: var(--surface-elevated); overflow: hidden; flex: none; }
.fortschritt > div { height: 100%; width: 0; background: var(--brand); }

.streifen {
  position: relative; height: 44px; flex: none; display: flex; align-items: center; cursor: pointer;
}
.streifen .bahn {
  position: relative; width: 100%; height: 30px; border-radius: 6px; overflow: hidden;
  background: repeating-linear-gradient(to right, var(--elfenbein-tief) 0, var(--elfenbein-tief) calc(100% / 52 - 1px), var(--background) calc(100% / 52 - 1px), var(--background) calc(100% / 52));
  opacity: 0.9;
}
.streifen .fenster {
  position: absolute; top: 0; bottom: 0; border-radius: 6px;
  background: color-mix(in srgb, var(--brand) 16%, transparent); border: 1.5px solid var(--brand);
  transition: left 0.3s ease, width 0.3s ease;
}
.klaviatur { position: relative; height: 96px; flex: none; overflow: hidden; border-radius: var(--radius-sm); background: var(--background); touch-action: none; }
.klaviatur .band { position: absolute; top: 0; left: 0; height: 100%; transition: transform 0.5s cubic-bezier(0.2, 0.9, 0.3, 1); }
.taste { position: absolute; display: block; }
.taste.weiss {
  background: linear-gradient(to bottom, var(--elfenbein-hell), var(--elfenbein) 70%, var(--elfenbein-tief));
  border-right: 1px solid var(--background); border-radius: 0 0 4px 4px;
}
.taste.schwarz {
  background: linear-gradient(to bottom, var(--ebenholz-hell), var(--ebenholz) 30%, var(--ebenholz-tief));
  border-radius: 0 0 3px 3px; z-index: 1;
}
.taste::after {
  content: ""; position: absolute; left: 50%; bottom: 10%; width: 44%; max-width: 14px; aspect-ratio: 1;
  transform: translateX(-50%); border-radius: 50%; background: transparent;
}
.taste.erwartet::after { background: var(--brand); box-shadow: 0 0 10px var(--brand); }
.taste.weiss.erwartet { background: linear-gradient(to bottom, var(--elfenbein-hell), color-mix(in srgb, var(--brand) 38%, var(--elfenbein))); }
.taste.schwarz.erwartet { background: linear-gradient(to bottom, var(--ebenholz-hell), color-mix(in srgb, var(--brand) 60%, var(--ebenholz))); }
.taste.weiss.treffer { background: linear-gradient(to bottom, var(--elfenbein-hell), color-mix(in srgb, var(--hit) 42%, var(--elfenbein))); }
.taste.schwarz.treffer { background: linear-gradient(to bottom, var(--ebenholz-hell), color-mix(in srgb, var(--hit) 60%, var(--ebenholz))); }
.taste.weiss.fehler { background: linear-gradient(to bottom, var(--elfenbein-hell), color-mix(in srgb, var(--miss) 55%, var(--elfenbein))); }
.taste.schwarz.fehler { background: linear-gradient(to bottom, var(--ebenholz-hell), color-mix(in srgb, var(--miss) 70%, var(--ebenholz))); }

.hinweis { font-size: 13px; color: var(--text-secondary); margin: 0; min-height: 18px; }
.tempo-zeile { display: flex; align-items: center; gap: var(--sm); }
.tempo-zeile input { flex: 1; accent-color: var(--brand); min-height: var(--treffflaeche); }
.tempo-zeile output { font: 600 15px var(--mono); min-width: 56px; text-align: right; }
.transport { display: flex; align-items: center; gap: var(--md); }
.umschalter { display: inline-flex; padding: 2px; border-radius: var(--radius-md); background: var(--surface-elevated); }
.umschalter button { min-height: 40px; padding: 0 var(--md); border-radius: 10px; font-size: 15px; color: var(--text-secondary); }
.umschalter button[aria-pressed="true"] { background: var(--surface); color: var(--text-primary); font-weight: 600; box-shadow: 0 1px 3px rgb(0 0 0 / 40%); }
.transport .luecke { flex: 1; }
.kreis { border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.kreis.neustart { width: 44px; height: 44px; background: var(--surface-elevated); }
.kreis.spiel { width: 60px; height: 60px; background: var(--action-fill); color: #fff; box-shadow: 0 6px 12px color-mix(in srgb, var(--brand) 35%, transparent); }
.kreis.spiel:disabled { opacity: 0.45; }
.kreis svg { width: 22px; height: 22px; }
.kreis.spiel svg { width: 26px; height: 26px; }

@media (max-height: 520px) {
  .spieler { gap: var(--xs); padding: var(--xs) var(--md); }
  .spieler .hinweis, .spieler .streifen { display: none; }
  .klaviatur { height: 72px; }
}
.klaviatur.sofort .band, [data-testuhr] .band, [data-testuhr] .fenster { transition: none; }
@media (prefers-reduced-motion: reduce) {
  .klaviatur .band, .streifen .fenster { transition: none; }
}
