:root{
    --ink:        #12151c;
    --ink-2:      #1a1f2b;
    --rule:       #2f3849;
    --paper:      #e9e5db;
    --paper-dim:  #9aa3b4;
    --richtig:    #3c6b4f;
    --enthalten:  #e8a33d;
    --fehlt:      #252932;
    --taste:      #454e61;
    --focus:      #7fb2ff;
    --absenden:   #4571c4;

    --gap: clamp(4px, 1.2vw, 7px);
  }

  *{ box-sizing: border-box; margin: 0; padding: 0; }

  html, body{ height: 100%; }

  body{
    background: var(--ink);
    color: var(--paper);
    font-family: 'IBM Plex Sans', system-ui, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    padding: 0 8px env(safe-area-inset-bottom, 8px);
  }

  /* ---------- Kopfzeile ---------- */

  header{
    width: 100%;
    max-width: 520px;
    border-bottom: 1px solid var(--rule);
    padding: 10px 2px 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex: none;
  }

  /* Logo + Titelblock als Einheit oben links */
  .marke{
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
  }

  .logo{
    /* Hoehe orientiert sich an den zwei Textzeilen daneben */
    height: clamp(34px, 9vw, 44px);
    width: auto;
    flex: none;
    display: block;
  }

  .titelblock{
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  /* ---------- Punkteanzeige ---------- */

  .punkte{
    margin-left: auto;
    margin-right: 14px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1;
    font-variant-numeric: tabular-nums;
  }

  #punkte-wert{
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(20px, 5.5vw, 26px);
    font-weight: 700;
    color: var(--paper);
    transition: color 200ms;
  }

  .punkte-label{
    font-size: 9.5px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--paper-dim);
    margin-top: 3px;
  }

  /* Kurzes Aufleuchten bei Abzug */
  #punkte-wert.abzug{
    color: var(--enthalten);
  }

  #punkte-wert.bonus{
    color: var(--richtig);
  }

  h1{
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(20px, 5.5vw, 27px);
    letter-spacing: 0.16em;
    font-weight: 700;
    line-height: 1;
  }

  .untertitel{
    font-size: 11px;
    color: var(--paper-dim);
    letter-spacing: 0.06em;
  }

  /* ---------- Zahnrad und Dialog ---------- */

  .ikons{
    display: flex;
    align-items: center;   /* Avatar-Kreis und Burger auf einer Mittellinie */
    gap: 4px;
    /* Nur aussen zurueckziehen, damit das Zahnrad buendig zur Headerkante
       sitzt. Frueher hatte jeder Knopf margin:-6px ringsum - das zog auch
       die Tap-Flaechen ineinander. */
    margin-right: -6px;
  }

  .ikon{
    background: none;
    border: none;
    padding: 6px;
    margin: -6px 0;          /* senkrecht: Polster soll den Header nicht aufblasen */
    color: var(--paper-dim);
    cursor: pointer;
    display: grid;
    place-items: center;
    border-radius: 4px;
    transition: color 120ms, transform 200ms;
  }

  .ikon:hover{ color: var(--paper); }

  /* Burger so gross wie der Avatar-Kreis (30px): die Striche fuellen nur
     16/24 der viewBox, deshalb braucht das SVG 45px, damit das sichtbare
     Symbol auf ~30px kommt */
  #burger svg{ width: 45px; height: 45px; }

  /* Aufklappmenue unter dem Burger-Knopf, rechtsbuendig zum Header */
  .ikons{ position: relative; }

  /* gilt fuer Hauptmenue (Burger) UND Kontomenue (Avatar-Kreis) */
  .aufklapp{
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 180px;
    background: var(--ink-2);
    border: 1px solid var(--rule);
    border-radius: 6px;
    padding: 6px;
    box-shadow: 0 10px 28px rgba(0,0,0,.45);
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .menue-punkt{
    background: none;
    border: none;
    color: var(--paper);
    text-align: left;
    padding: 10px 12px;
    border-radius: 4px;
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    display: block;           /* auch fuer <a>-Menuepunkte */
    text-decoration: none;
  }

  .menue-punkt:hover{ background: var(--taste); }

  /* hidden-Attribut muss gegen das display:flex gewinnen */
  .aufklapp[hidden]{ display: none; }

  /* ---------- Konto ---------- */

  /* Eingeloggt: Initialen-Avatar statt Personen-Icon */
  .konto-avatar{
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--richtig);
    color: #fff;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 15px;
    text-transform: uppercase;
    display: grid;
    place-items: center;
    padding: 0;
    position: relative;
  }

  .konto-avatar:hover{ filter: brightness(1.12); color: #fff; }

  /* Ausgeloggt: gleicher Kreis, nur neutral grau mit Personen-Symbol */
  .konto-gast{
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--taste);
    display: grid;
    place-items: center;
    padding: 0;
  }

  .konto-gast:hover{ filter: brightness(1.2); }

  /* E-Mail noch nicht bestaetigt: dezenter oranger Punkt am Avatar */
  .konto-avatar.unbestaetigt::after{
    content: '';
    position: absolute;
    top: -1px;
    right: -1px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--enthalten);
    border: 2px solid var(--ink);
  }

  .menue-kopf{
    padding: 8px 12px 4px;
    font-size: 11.5px;
    color: var(--paper-dim);
    white-space: nowrap;
  }

  .menue-trenner{
    border: none;
    border-top: 1px solid var(--rule);
    margin: 6px 0;
  }

  .menue-form{ margin: 0; }
  .menue-form .menue-punkt{ width: 100%; }

  /* Formularfelder in den Login/Registrieren-Dialogen */
  .feld{
    display: block;
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--paper-dim);
    text-align: left;
  }

  .feld input{
    display: block;
    width: 100%;
    margin-top: 5px;
    background: var(--ink);
    color: var(--paper);
    border: 1px solid var(--rule);
    border-radius: 4px;
    padding: 9px 10px;
    font-size: 14px;
    font-family: inherit;
  }

  .feld input:focus{ outline: 2px solid var(--focus); border-color: transparent; }

  .haken{
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 13px;
    color: var(--paper-dim);
    margin: 2px 0 4px;
  }

  .feld-fehler{
    display: block;
    color: #e07070;
    font-size: 12px;
    margin-top: 4px;
    min-height: 0;
  }

  .wechsel{
    margin-top: 12px;
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--paper-dim);
    text-align: left;
  }

  .wechsel a{ color: var(--paper); }

  /* Schliessen-X oben rechts in den Login/Registrieren-Dialogen */
  .dialog-x{
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    color: var(--paper-dim);
    font-size: 17px;
    line-height: 1;
    padding: 7px;
    cursor: pointer;
    border-radius: 4px;
    z-index: 1;
  }

  .dialog-x:hover{ color: var(--paper); }

  /* Platz-Hinweis in der Endmeldung */
  .platz-hinweis{ margin: 8px 0 2px; font-size: 13px; color: #2c7a4b; font-weight: 600; }
  .platz-hinweis a{ color: inherit; }

  /* ---------- Hilfen-Leiste unter dem Header ---------- */

  /* Sitzt IN main direkt ueber dem Brett - der Abstand nach unten kommt
     aus dem gap von main plus dieser kleinen Zugabe und ist damit konstant,
     egal wie hoch das Fenster ist. */
  #hilfen-leiste{
    width: 100%;
    max-width: 520px;
    display: flex;
    justify-content: center;
    gap: 26px;
    padding: 0;
    margin-bottom: 4px;
    flex: none;
  }

  .hilfe-symbol{
    background: none;
    border: none;
    padding: 4px;
    line-height: 0;
    cursor: pointer;
    border-radius: 6px;
    transition: filter 250ms, opacity 250ms, transform 120ms;
  }

  .hilfe-symbol:hover{ transform: scale(1.15); }

  .hilfe-symbol:focus-visible{
    outline: 2px solid var(--focus);
    outline-offset: 1px;
  }

  /* verbraucht bzw. gerade nicht einsetzbar: farblos und gedimmt */
  .hilfe-symbol:disabled{
    filter: grayscale(1);
    opacity: .35;
    cursor: default;
    transform: none;
  }

  .ikon:focus-visible{
    outline: 2px solid var(--focus);
    outline-offset: 1px;
  }

  dialog{
    /* Browser zentriert <dialog> per inset:0 + margin:auto im Fenster.
       Wir wollen die Brettmitte, die wegen der Tastatur hoeher liegt:
       waagerecht weiter auto-zentriert, senkrecht setzt JS das top. */
    top: 50%;
    bottom: auto;
    left: 0;
    right: 0;
    margin: 0 auto;
    transform: translateY(-50%);
    width: min(320px, 86vw);
    max-height: calc(100dvh - 24px);
    overflow: hidden;

    border: 1px solid var(--rule);
    border-radius: 5px;
    background: var(--ink-2);
    color: var(--paper);
    padding: 0;
    font-family: 'IBM Plex Sans', sans-serif;
  }

  /* Flex-Spalte nur im offenen Zustand - sonst wuerde display:flex das
     native display:none des geschlossenen <dialog> ueberschreiben und ihn
     hinter dem Spielfeld sichtbar machen. */
  dialog[open]{
    display: flex;
    flex-direction: column;
  }

  /* Scrollender Inhaltsbereich - nimmt das Padding des Dialogs auf. Der
     Footer liegt ausserhalb und bleibt dadurch immer sichtbar, ohne sticky
     (das mit dem transform des Dialogs unzuverlaessig war). */
  .dialog-inhalt{
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 22px 16px;
  }

  /* Die Spielanleitung darf breiter sein: 90% des Inhalts-Schlauchs
     (Header-Breite 520px), auf schmalen Schirmen 90% der Fensterbreite */
  #anleitung{
    width: min(468px, 90vw);
  }

  dialog::backdrop{
    background: rgba(8, 10, 15, .68);
  }

  dialog h2{
    font-family: 'Space Grotesk', sans-serif;
    font-size: 16px;
    letter-spacing: 0.1em;
    margin-bottom: 10px;
  }

  dialog p{
    font-size: 13px;
    color: var(--paper-dim);
    margin-bottom: 16px;
  }

  /* Basis fuer alle Knoepfe; Farbe und Platzierung je Kontext darunter. */
  .knopf{
    border: none;
    border-radius: 3px;
    padding: 7px 15px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
  }

  dialog .wahl{
    border: 1px solid var(--rule);
    border-radius: 4px;
    padding: 10px 12px 12px;
    margin-bottom: 14px;
  }

  dialog legend{
    font-size: 10.5px;
    color: var(--paper-dim);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0 5px;
  }

  dialog label{
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 6px 2px;
    font-size: 14px;
    cursor: pointer;
  }

  dialog label span{
    margin-left: auto;
    font-size: 11px;
    color: var(--paper-dim);
    font-variant-numeric: tabular-nums;
  }

  dialog input[type=radio],
  dialog input[type=checkbox]{
    accent-color: var(--richtig);
    width: 15px;
    height: 15px;
    cursor: pointer;
  }

  .dialog-fuss{
    flex: none;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    background: var(--ink-2);
    padding: 12px 22px 18px;
    border-top: 1px solid var(--rule);
    border-radius: 0 0 5px 5px;
  }

  dialog .knopf{
    display: block;
    margin: 0;
    background: var(--paper);
    color: var(--ink);
  }

  /* ---------- Spielfeld ---------- */

  main{
    flex: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--gap);
    min-height: 0;
    padding: 8px 0;
    /* Reicht die Hoehe trotz geschrumpfter Kacheln nicht (echtes Querformat),
       darf das Feld scrollen, statt unten abgeschnitten zu werden. */
    overflow-y: auto;
  }

  #brett{
    --spalten: 5;              /* wird von JS gesetzt */
    --zeilen: 5;               /* wird von JS gesetzt */
    display: grid;
    grid-template-rows: repeat(var(--zeilen), 1fr);
    gap: var(--gap);
  }

  .zeile{
    display: grid;
    grid-template-columns: repeat(var(--spalten), 1fr);
    gap: var(--gap);
  }

  .kachel{
    /* Zwei Fesseln, die engere gewinnt:
       - Breite:  78vw aufgeteilt auf die Spalten
       - Hoehe:  verfuegbare Resthoehe (Fenster minus Header ~52 und
                 Tastatur ~190) aufgeteilt auf die Zeilen
       So passt auch das 7x7-Brett auf kleine Handys, ohne dass unten
       etwas abgeschnitten wird. */
    --seite: clamp(28px, min(
                calc(78vw / var(--spalten)),
                calc((100dvh - 304px) / var(--zeilen))
             ), 62px);
    position: relative;
    width:  var(--seite);
    height: var(--seite);
    display: grid;
    place-items: center;
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    font-weight: 600;
    font-size: calc(var(--seite) * 0.5);
    line-height: 1;
    border: 1.5px solid var(--rule);
    border-radius: 3px;
    background: var(--ink);
    color: var(--paper);
    user-select: none;
    transition: transform 90ms ease-out, border-color 90ms ease-out;
  }

  .kachel.gefuellt{
    border-color: var(--taste);
    transform: scale(1.05);
  }

  /* Fokusrand: nur die laufende Zeile, deren Kacheln immer dunkel sind -
     ein Blau-Konflikt mit .richtig kann hier also nicht auftreten. */
  .kachel.fokus{
    border-color: var(--focus);
    box-shadow: 0 0 0 3px rgba(127, 178, 255, .22);
  }

  .zeile.aktiv .kachel{ cursor: pointer; }

  .kachel.dreht{ animation: dreh 560ms ease forwards; }

  @keyframes dreh{
    0%   { transform: rotateX(0deg);  }
    50%  { transform: rotateX(90deg); }
    100% { transform: rotateX(0deg);  }
  }

  .zeile.wackelt{ animation: wackel 480ms ease; }

  @keyframes wackel{
    10%, 90% { transform: translateX(-2px); }
    20%, 80% { transform: translateX(4px);  }
    30%, 50%, 70% { transform: translateX(-7px); }
    40%, 60% { transform: translateX(7px);  }
  }

  .kachel.huepft{ animation: huepf 520ms ease; }

  @keyframes huepf{
    0%,100% { transform: translateY(0);     }
    35%     { transform: translateY(-22px); }
    60%     { transform: translateY(3px);   }
    80%     { transform: translateY(-3px);  }
  }

  /* Zustände — geteilt von Kacheln und Tasten */

  .richtig{
    background: var(--richtig) !important;
    border-color: var(--richtig) !important;
    color: #fff !important;
  }

  .enthalten{
    background: var(--enthalten) !important;
    border-color: var(--enthalten) !important;
    color: var(--ink) !important;
  }

  .fehlt{
    background: var(--fehlt) !important;
    border-color: var(--fehlt) !important;
    color: var(--paper-dim) !important;
  }

  /* ---------- Hilfen ---------- */

  .hilfe-zeile{
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 0;
    border-top: 1px solid var(--rule);
  }

  .hilfe-zeile:last-of-type{ border-bottom: 1px solid var(--rule); }

  .hilfe-text{ flex: 1; min-width: 0; }

  .hilfe-text b{
    display: block;
    font-size: 13.5px;
    color: var(--paper);
    margin-bottom: 2px;
  }

  .hilfe-preis{
    display: inline;
    font-weight: 600;
    font-size: 12px;
    color: var(--enthalten);
    font-variant-numeric: tabular-nums;
  }

  .hilfe-text span{
    font-size: 11.5px;
    color: var(--paper-dim);
    line-height: 1.4;
  }

  .hilfe-zeile .knopf{
    flex: none;
    background: var(--richtig);
    color: #fff;
  }

  .hilfe-zeile .knopf:disabled{
    background: var(--fehlt);
    color: var(--paper-dim);
    cursor: not-allowed;
  }

  /* ---------- Beispielkacheln in der Anleitung ---------- */

  .beispiel{ margin-bottom: 13px; }

  .beispiel-zeile{
    display: flex;
    gap: 3px;
    margin-bottom: 6px;
  }

  .mini{
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    font-weight: 600;
    font-size: 13px;
    line-height: 1;
    border: 1.5px solid var(--rule);
    border-radius: 2px;
    color: var(--paper);
  }

  /* Loesungswort als Kaestchenreihe im Kopf der Zusammenfassung */
  .wort-kaestchen{
    display: flex;
    justify-content: center;
    gap: 4px;
    margin: 10px 0 4px;
  }

  dialog .beispiel p{
    margin-bottom: 0;
    font-size: 12.5px;
    line-height: 1.45;
  }

  dialog .beispiel b{ color: var(--paper); }

  dialog .fussnote{
    font-size: 12px;
    line-height: 1.5;
    padding-top: 12px;
    border-top: 1px solid var(--rule);
  }

  /* ---------- Punktesystem in der Anleitung ---------- */
  dialog .abschnitt-titel{
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--rule);
  }

  /* Zwischenueberschrift der drei Punktesystem-Bloecke - kleiner als die
     Abschnittsueberschrift, gedaempft, als ruhige Marke. */
  .block-titel{
    margin: 16px 0 9px;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--paper-dim);
  }

  .punkte-liste{
    list-style: none;
    margin: 0 0 16px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 9px;
  }

  .punkte-liste li{
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--paper-dim);
  }

  /* Der Text als eigenes Flex-Kind - nimmt die Restbreite und bricht sauber
     um, statt als lose Textknoten neben dem Chip zu zerfasern. */
  .pkt-text{
    flex: 1;
    min-width: 0;
  }

  /* Farbiger Punkte-Chip, feste Breite fuer saubere Ausrichtung. */
  .pkt{
    flex: none;
    min-width: 34px;
    text-align: center;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--enthalten);
    color: var(--ink);
    font-family: 'Space Grotesk', sans-serif;
    font-size: 12px;
    font-weight: 700;
  }

  .pkt.plus{
    background: var(--richtig);
    color: #fff;
  }

  /* ---------- Tastatur ---------- */

  #tastatur{
    width: 100%;
    max-width: 520px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 10px 0 12px;
    border-top: 1px solid var(--rule);
    flex: none;
  }

  /* Muss die display:flex-Regel oben schlagen - sonst ignoriert das
     hidden-Attribut sie und die Tastatur bleibt sichtbar. */
  #tastatur[hidden]{ display: none; }

  /* ---------- Pruefen-Button unter der Eingabe ----------
     Sitzt im Fluss zwischen Brett und Tastatur. Der Slot hat feste Hoehe und
     ist immer da - so springt beim Ein-/Ausblenden nichts. Nur der Button
     darin wird sichtbar/unsichtbar (visibility + opacity, nicht display). */
  #pruefen-slot{
    width: 100%;
    max-width: 520px;
    height: 46px;
    flex: none;
    display: grid;
    place-items: center;
  }

  #pruefen-schwebend{
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px 9px 15px;
    background: var(--absenden);
    color: #fff;
    border: none;
    border-radius: 999px;
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.02em;
    box-shadow: 0 4px 16px rgba(0,0,0,.4);
    cursor: pointer;
    opacity: 1;
    transition: opacity 150ms ease-out, transform 90ms;
  }

  /* Versteckt: Platz bleibt reserviert (kein display:none), damit nichts
     springt. hidden-Attribut steuert nur die Sichtbarkeit. */
  #pruefen-schwebend[hidden]{
    display: inline-flex;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
  }

  #pruefen-schwebend:hover{ filter: brightness(1.08); }
  #pruefen-schwebend:active{ transform: scale(0.96); }

  /* Endzustand: ersetzt die Tastatur an gleicher Stelle */
  #endaktionen{
    width: 100%;
    max-width: 520px;
    display: flex;
    gap: 10px;
    padding: 10px 0 12px;
    border-top: 1px solid var(--rule);
    flex: none;
  }

  #endaktionen[hidden]{ display: none; }

  .knopf.gross{
    height: clamp(48px, 8vh, 60px);
    font-size: 15px;
    border-radius: 5px;
    background: var(--richtig);
    color: #fff;
  }

  #neues-spiel{ flex: 1; }

  .ikon-knopf{
    flex: none;
    width: clamp(56px, 16vw, 76px);
    display: grid;
    place-items: center;
    background: var(--taste);
    color: var(--paper);
  }

  .ikon-knopf:hover{ filter: brightness(1.12); }

  .tastenzeile{
    display: flex;
    gap: 4px;
    justify-content: center;
  }

  .taste{
    flex: 1 1 0;
    min-width: 0;
    height: clamp(42px, 7vh, 56px);
    border: none;
    border-radius: 4px;
    background: var(--taste);
    color: var(--paper);
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: clamp(12px, 3.6vw, 15px);
    font-weight: 600;
    cursor: pointer;
    box-shadow: inset 0 -2px 0 rgba(0,0,0,.28);
    transition: background 120ms, transform 60ms;
  }

  .taste:hover{ filter: brightness(1.12); }

  .taste:active{
    transform: translateY(2px);
    box-shadow: inset 0 -1px 0 rgba(0,0,0,.28);
  }

  .taste.breit{
    flex: 1.6 1 0;
    font-size: clamp(10px, 2.7vw, 12px);
    letter-spacing: 0.05em;
  }

  .taste:focus-visible,
  .knopf:focus-visible{
    outline: 2px solid var(--focus);
    outline-offset: 2px;
  }

  /* ---------- Meldung ---------- */

  #meldung{
    position: fixed;
    top: 14%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--paper);
    color: var(--ink);
    padding: 11px 18px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms;
    z-index: 10;
    max-width: 88vw;
  }

  #meldung.sichtbar{ opacity: 1; }

  #meldung .knopf{
    display: block;
    margin: 9px auto 0;
    background: var(--ink);
    color: var(--paper);
    pointer-events: auto;
  }

  #meldung.mit-knopf{ pointer-events: auto; }

  /* ---------- Rundenabrechnung ---------- */

  #abrechnung{
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.96);
    background: var(--ink-2);
    color: var(--paper);
    border: 1px solid var(--rule);
    padding: 14px 18px;
    border-radius: 5px;
    font-size: 12.5px;
    text-align: left;
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms, transform 200ms;
    z-index: 9;
    max-width: 88vw;
    box-shadow: 0 8px 28px rgba(0,0,0,.45);
  }

  #abrechnung.sichtbar{
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }

  #abrechnung .summe{
    position: relative;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--rule);
  }

  /* Timer-Linie: liegt auf der Trennlinie und faerbt von rechts nach links
     in die Ruhefarbe ab - die amberne Restbreite zeigt, wie lange der Toast
     noch bleibt. Dauer kommt als --toast-dauer aus dem JS. */
  #abrechnung.sichtbar .summe::after{
    content: "";
    position: absolute;
    left: 0;
    bottom: -1px;
    height: 1px;
    width: 100%;
    background: var(--enthalten);
    transform-origin: left center;
    animation: toast-ablauf var(--toast-dauer, 2500ms) linear forwards;
  }

  @keyframes toast-ablauf{
    from{ transform: scaleX(1); }
    to{ transform: scaleX(0); }
  }

  @media (prefers-reduced-motion: reduce){
    #abrechnung.sichtbar .summe::after{ animation: none; opacity: 0; }
  }

  #abrechnung .summe.sauber{ color: var(--richtig); }
  #abrechnung .summe.teuer{ color: var(--enthalten); }

  #abrechnung .posten{
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    padding: 3px 0;
    color: var(--paper-dim);
    line-height: 1.35;
  }

  #abrechnung .posten b{
    color: var(--enthalten);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }

  /* Abrechnung eingebettet in die Endmeldung */
  .end-abrechnung{
    margin: 10px 0 4px;
    padding-top: 10px;
    border-top: 1px solid rgba(0,0,0,.15);
    text-align: left;
    font-weight: 400;
  }

  .end-abrechnung .summe{
    font-family: 'Space Grotesk', sans-serif;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 6px;
  }

  .end-abrechnung .summe.sauber{ color: #2c7a4b; }
  .end-abrechnung .summe.teuer{ color: #b5701a; }

  .end-abrechnung .posten{
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 14px;
    padding: 2px 0;
    font-size: 11.5px;
    color: #555;
    line-height: 1.35;
  }

  .end-abrechnung .posten b{
    color: #b5701a;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }

  /* Gesamtabrechnung: mehrere Runden, ggf. scrollbar. Der eigene schmale
     Scrollbalken (statt des Windows-Overlay-Balkens) bekommt eine feste
     eigene Spur und kann die Punktwerte dadurch nicht mehr verdecken. */
  .end-abrechnung.gesamt{
    max-height: 42vh;
    overflow-y: auto;
    padding-right: 6px;
    scrollbar-width: thin;                       /* Firefox */
    scrollbar-color: rgba(0,0,0,.3) transparent;
  }
  .end-abrechnung.gesamt::-webkit-scrollbar{ width: 8px; }
  .end-abrechnung.gesamt::-webkit-scrollbar-track{ background: transparent; }
  .end-abrechnung.gesamt::-webkit-scrollbar-thumb{
    background: rgba(0,0,0,.3);
    border-radius: 4px;
  }

  .end-abrechnung .runde-titel{
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #333;
    margin-top: 9px;
    margin-bottom: 2px;
  }

  .end-abrechnung .runde-titel:first-of-type{ margin-top: 4px; }

  .end-abrechnung .posten.leer{
    color: #8a9a7d;
    font-style: italic;
  }

  .end-abrechnung .posten.bonus{ color: #2c7a4b; }
  .end-abrechnung .posten.bonus b{ color: #2c7a4b; }

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