/* Chat (Übersicht und Spiel-Räume) */
.chat-kopf{display:flex;align-items:center;justify-content:space-between;gap:10px}
.chat-kopf small{color:var(--muted);font-size:13px}
.chat-liste{list-style:none;margin:0;padding:12px 2px;display:flex;flex-direction:column;gap:10px;overflow-y:auto;overscroll-behavior:contain;border-top:1px solid var(--line);border-bottom:1px solid var(--line)}
.chat-liste .leer{margin:auto;text-align:center;font-size:14px;color:var(--muted)}
.nachricht{display:flex;align-items:flex-start;gap:8px;min-width:0}
.nachricht.folge{margin-top:-6px;padding-left:32px}
.nachricht .av{margin-top:2px}
.blase{min-width:0;max-width:min(560px,100%);display:flex;flex-direction:column;gap:2px;text-align:left}
.von{display:flex;align-items:baseline;gap:8px;font-size:14px}
.von time{color:var(--muted);font-size:12px}
.blase .x{background:var(--face);border:1px solid var(--line);border-radius:4px 12px 12px 12px;padding:7px 11px;white-space:pre-wrap;overflow-wrap:anywhere;font-size:15px}
.nachricht.folge .x{border-radius:12px}
.nachricht.ich .x{background:color-mix(in srgb,var(--accent) 12%,var(--surface));border-color:color-mix(in srgb,var(--accent) 30%,var(--line))}
.blase .x a{color:var(--accent)}
.nachricht .weg{flex:none;align-self:center;border:0;background:none;color:var(--muted);font-size:18px;line-height:1;min-width:32px;min-height:32px;border-radius:8px;opacity:0;padding:0 6px}
.nachricht:hover .weg,.nachricht .weg:focus-visible,.nachricht .weg.sicher{opacity:1}
.nachricht .weg.sicher{color:var(--danger);font-size:13px;font-weight:700}
@media (hover:none){.nachricht .weg{opacity:.6}}
.chat-form{display:flex;gap:8px;align-items:flex-end}
.chat-form textarea{flex:1;min-width:0;font:inherit;font-size:16px;line-height:1.4;padding:10px 12px;border-radius:9px;border:1px solid var(--line);background:var(--face);color:var(--ink);resize:none;max-height:140px}
.chat-form textarea:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.chat-form .btn{min-height:44px}
.chat-msg:empty,#chatMsg:empty{display:none}
/* Knopf in der Kopfzeile der Spiele */
.chatknopf{position:relative;width:44px;height:44px;flex:none;border-radius:50%;border:1px solid var(--line);background:var(--surface);color:var(--ink);display:grid;place-items:center;padding:0}
.chatknopf:hover,.chatknopf[aria-expanded="true"]{border-color:var(--accent)}
.chatknopf svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:2;stroke-linejoin:round}
.chatknopf .zahl{position:absolute;top:-4px;right:-4px;min-width:20px;height:20px;padding:0 5px;border-radius:999px;background:var(--danger);color:#fff;font:700 12px/20px var(--f-body,system-ui);text-align:center;box-shadow:0 0 0 2px var(--bg)}
.chatknopf.ping{animation:chatping .6s ease}
@keyframes chatping{30%{transform:scale(1.15)}60%{transform:scale(.95)}}
.chatknopf.schwebend{position:fixed;top:calc(env(safe-area-inset-top,0px) + 12px);right:12px;z-index:40}
/* Chat-Fenster: am PC rechts am Rand, am Handy von unten */
.chatfenster{position:fixed;z-index:50;top:12px;right:12px;bottom:12px;width:min(380px,calc(100vw - 24px));background:var(--surface);color:var(--ink);border:1px solid var(--line);border-radius:14px;box-shadow:0 12px 40px rgba(0,0,0,.22);padding:14px;display:flex;flex-direction:column;gap:10px;font-family:var(--f-body,system-ui)}
.chatfenster h3{font-family:var(--f-display,system-ui);font-weight:800;font-size:19px;margin:0}
.chatfenster .raumcode{font-family:var(--f-mono,monospace);font-size:13px;font-weight:500;color:var(--muted);margin-left:4px;letter-spacing:.05em}
.chatfenster .zu{border:0;background:none;color:var(--muted);font-size:26px;line-height:1;width:44px;height:44px;margin:-8px -8px -8px 0;border-radius:10px}
.chatfenster .zu:hover{color:var(--ink)}
.chatfenster .chat-liste{flex:1;min-height:0}
.chatfenster .toast{min-height:0;margin:0;color:var(--danger);font-size:14px}
@media (max-width:600px){
  .chatfenster{top:auto;left:0;right:0;bottom:0;width:auto;height:min(72dvh,560px);border-radius:16px 16px 0 0;border-bottom:0;padding-bottom:calc(14px + env(safe-area-inset-bottom,0px))}
}
@media (prefers-reduced-motion: reduce){.chatknopf.ping{animation:none}}
/* allgemeiner Chat in der Startansicht der Spiele */
#lobbyChat{min-width:0}
.lobby-chat .chat-liste{height:min(360px,48vh)}
.lobby-chat .chat-kopf small{color:var(--muted);font-size:13px}
.lobby-chat{border-color:color-mix(in srgb,var(--accent) 45%,var(--line))}
/* „● 3 online ▾“ im Chat-Kopf */
.chat-online{position:relative;flex:none}
.online-menue > summary{list-style:none;display:flex;align-items:center;gap:4px;min-height:36px;padding:0 10px;border:1px solid var(--line);border-radius:999px;background:var(--surface);font-size:13px;font-weight:700;color:var(--muted);cursor:pointer}
.online-menue > summary::-webkit-details-marker{display:none}
.online-menue > summary:hover,.online-menue[open] > summary{border-color:var(--accent)}
.online-menue .pfeil{font-size:11px;margin-left:2px}
.online-menue .dot{display:inline-block;width:9px;height:9px;border-radius:50%;background:#3fbf6a;margin-right:4px;flex:none}
.online-liste{position:absolute;right:0;top:calc(100% + 6px);z-index:25;width:min(300px,calc(100vw - 48px));max-height:min(60vh,420px);overflow-y:auto;background:var(--surface);border:1px solid var(--line);border-radius:12px;box-shadow:0 12px 40px rgba(0,0,0,.22);padding:12px 14px;display:flex;flex-direction:column;gap:8px}
.online-liste .titel{font-family:var(--f-display,system-ui);font-weight:800;font-size:16px}
.online-liste ul{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:8px}
.online-liste li{display:flex;align-items:center;gap:8px;font-size:14px;line-height:1.3}
.online-liste li > span:last-child{display:flex;flex-direction:column;min-width:0}
.online-liste small{color:var(--muted);font-size:12px}
.chat-kopf h3 .fuer{font-family:var(--f-body,system-ui);font-weight:400;font-size:13px;color:var(--muted);margin-left:4px}

/* ---- Startansicht der Spiele: links Neues Spiel + Offene Räume, rechts der Chat; passt in den Bildschirm ---- */
.lobby{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.1fr);gap:20px;align-items:stretch}
.lobby-links{display:flex;flex-direction:column;gap:20px;min-width:0;min-height:0}
.lobby-neu .toast:empty{display:none}
.lobby-raeume{min-height:0}
.lobby-raeume > ul{min-height:0;overflow-y:auto;overscroll-behavior:contain;padding:2px}
.regeln-klapp{border-top:1px solid var(--line);padding-top:10px}
.regeln-klapp > summary{cursor:pointer;font-weight:700;font-size:14px;color:var(--accent);list-style:none;display:flex;align-items:center;gap:6px;min-height:32px}
.regeln-klapp > summary::-webkit-details-marker{display:none}
.regeln-klapp > summary::after{content:"▾";font-size:12px;transition:transform .15s}
.regeln-klapp[open] > summary::after{transform:rotate(180deg)}
.regeln-klapp .regeln{margin-top:8px}
#lobbyChat{display:flex;flex-direction:column;min-width:0;min-height:0}
#lobbyChat > .lobby-chat{flex:1;min-height:0}
.lobby-chat .chat-liste{flex:1;height:auto;min-height:180px}
html.lobby-ansicht body{height:100vh;height:100dvh}
html.lobby-ansicht .app{height:100%;padding-bottom:16px}
html.lobby-ansicht #main{flex:1;min-height:0;display:flex;flex-direction:column}
html.lobby-ansicht .lobby{flex:1;min-height:0;grid-template-rows:minmax(0,1fr)}
html.lobby-ansicht .lobby-links{overflow-y:auto}
html.lobby-ansicht .lobby-raeume{flex:1;display:flex;flex-direction:column}
html.lobby-ansicht .lobby-chat .chat-liste{min-height:0}
@media (max-width:860px){
  .lobby{grid-template-columns:minmax(0,1fr);gap:12px}
  .lobby-links{gap:12px}
  .lobby-neu > p,.lobby-neu > .eyebrow{display:none}
  .lobby .panel{padding:14px;gap:10px}
  html.lobby-ansicht .app{gap:12px;padding-top:10px;padding-bottom:10px}
  html.lobby-ansicht .lobby{grid-template-rows:auto minmax(260px,1fr)}
  html.lobby-ansicht .lobby-links{overflow:visible}
  html.lobby-ansicht .lobby-raeume{flex:none}
  .lobby-raeume > ul{max-height:28vh}
}
/* Raum-Chat fest in der rechten Spalte (breite Bildschirme) */
.spalte-rechts{display:flex;flex-direction:column;gap:16px;min-width:0}
#raumChat:empty{display:none}
.chatfenster.inline{position:static;inset:auto;width:auto;height:min(460px,calc(100dvh - 300px));min-height:280px;box-shadow:none;border-radius:14px;z-index:auto}
.chatfenster.inline .zu{display:none}
@media (min-width:861px){.spalte-rechts{position:sticky;top:16px;align-self:start}}
/* Glocke: Benachrichtigungen an/aus */
.chat-aktionen{display:flex;align-items:center;gap:6px;flex:none}
.glocke{position:relative;width:36px;height:36px;border-radius:50%;border:1px solid var(--line);background:var(--surface);color:var(--muted);display:grid;place-items:center;padding:0;cursor:pointer}
.glocke:hover{border-color:var(--accent);color:var(--ink)}
.glocke svg{width:17px;height:17px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.glocke.an{color:var(--accent);border-color:color-mix(in srgb,var(--accent) 50%,var(--line))}
.glocke.an svg{fill:color-mix(in srgb,var(--accent) 25%,transparent)}
.glocke.offen{border-style:dashed}   /* woanders eingeschaltet, hier fehlt noch die Erlaubnis des Browsers */
.glocke-platz{display:flex;gap:6px}
.glocke.ton.an svg{fill:none}.glocke.ton.an svg path:first-child{fill:color-mix(in srgb,var(--accent) 25%,transparent)}
.glocke.ton:not(.an) .welle{display:none}
/* Lautstärke-Regler: klappt unter dem Lautsprecher auf */
.ton-regler{position:relative;display:flex}
.ton-feld{position:absolute;right:0;top:calc(100% + 6px);z-index:60;width:min(250px,calc(100vw - 48px));background:var(--surface);color:var(--ink);border:1px solid var(--line);border-radius:12px;box-shadow:0 12px 40px rgba(0,0,0,.22);padding:12px 14px;display:flex;flex-direction:column;gap:8px;text-align:left}
.ton-titel{display:flex;align-items:baseline;justify-content:space-between;gap:8px}
.ton-titel b{font-family:var(--f-display,system-ui);font-weight:800;font-size:16px}
.ton-zahl{font-size:13px;color:var(--muted);font-variant-numeric:tabular-nums}
.ton-zeile{display:flex;align-items:center;gap:10px}
.ton-zeile input{flex:1;min-width:0;height:36px;margin:0;accent-color:var(--accent);cursor:pointer}
.ton-feld small{color:var(--muted);font-size:12px}
.glocke .strich{position:absolute;width:22px;height:2px;background:currentColor;transform:rotate(-45deg);border-radius:2px}
.chatfenster .chat-aktionen .zu{margin:-8px -8px -8px 0}
/* Handy: passt die Startansicht nicht auf den Bildschirm (z. B. mehrere offene Räume), wird die Seite länger
   statt den oberen Teil zusammenzupressen – sonst schiebt sich der Chat über die Raumliste */
@media (max-width:860px){
  html.lobby-ansicht body{height:auto;min-height:100vh;min-height:100dvh}
  html.lobby-ansicht .app{height:auto;min-height:calc(100dvh - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px))}
  html.lobby-ansicht #main,html.lobby-ansicht .lobby,html.lobby-ansicht .lobby-links{min-height:auto}
}
/* …dabei darf der Chat nicht mit seinen Nachrichten in die Länge wachsen: er füllt den restlichen Platz,
   mindestens ~60 % der Bildschirmhöhe, und scrollt innen (contain:size = Inhalt bestimmt die Höhe nicht) */
@media (max-width:860px){
  html.lobby-ansicht .lobby{grid-template-rows:auto minmax(min(62dvh,440px),1fr)}
  html.lobby-ansicht #lobbyChat{contain:size}
}
/* ---- Raum am breiten Bildschirm: passt in den Bildschirm wie die Startansicht ----
   Links scrollt der Raum (Warteraum, Spiel, Ergebnis) für sich, rechts „Im Raum“ und darunter der Chat bis zum unteren Rand.
   Gilt für alle Spiele: Raum-Spiele (.raum), Innere Uhr (.raum), Wortduell (.play); gesetzt von chat.js, sobald der Chat fest in der Spalte steht. */
html.raum-ansicht body{height:100vh;height:100dvh}
html.raum-ansicht .app{height:100%;padding-bottom:16px;box-sizing:border-box}
html.raum-ansicht #main{flex:1;min-height:0;display:flex;flex-direction:column}
html.raum-ansicht #main > :is(.raum,.play){flex:1;min-height:0;grid-template-rows:minmax(0,1fr);align-items:stretch}
html.raum-ansicht #main > :is(.raum,.play) > :first-child{min-height:0;overflow-y:auto;overscroll-behavior:contain;padding:2px 24px 24px;margin-inline:-24px}   /* Rand, damit Schatten nicht abgeschnitten werden */
html.raum-ansicht .spalte-rechts{position:static;align-self:stretch;min-height:0}
html.raum-ansicht .spalte-rechts > .panel{flex:none;max-height:45%;overflow-y:auto}
html.raum-ansicht #raumChat{flex:1;min-height:0;display:flex;flex-direction:column}
html.raum-ansicht .chatfenster.inline{flex:1;height:auto;min-height:200px}
/* …und gleich breit wie die Startansicht (.lobby): links wie „Neues Spiel“, rechts wie der Chat; Kästen links nutzen die ganze Spalte */
html.raum-ansicht #main > :is(.raum,.play){grid-template-columns:minmax(0,1fr) minmax(0,1.1fr);gap:20px}
html.raum-ansicht #main > :is(.raum,.play) > :first-child :is(.box,.raumbox,.btn.gross){width:100%;max-width:760px;box-sizing:border-box}

/* Laptop mit wenig Höhe (z. B. 1366×768 mit Browserleisten): während der Runde Kopfzeile knapper, damit das Spiel ganz zu sehen ist */
@media (min-width:881px) and (max-height:820px){
  html.raum-ansicht :is(.laeuft,.imspiel) > .kopfzeile .sub{display:none}
  html.raum-ansicht .kopfzeile h2{font-size:21px}
  html.raum-ansicht :is(.spiel.laeuft,.spiel.imspiel){gap:10px}
  html.raum-ansicht :is(.laeuft,.imspiel) .btn.gross{padding-block:10px}
}
/* ======== PC: Leiste fest am rechten Bildschirmrand – Startansicht: Chat mit allen; Räume: „Im Raum“ + Raum-Chat ========
   Standardmäßig offen (html.rand-an), per Lasche zuklappbar (html.rand-zu). Der Platz am Rand ist immer reserviert – beim Zuklappen fährt
   nur die Leiste hinaus, die Seite selbst verschiebt sich nicht. */
@media (min-width:861px){
  /* Breite der Leiste; Höhe 50 % des Bildschirms (mind. 360 px) – mittig am Rand, damit der Weg mit der Maus kurz bleibt */
  html{--rand:clamp(320px,26vw,400px);--rand-h:min(calc(100dvh - 24px),max(50dvh,360px))}
  /* rechts immer Platz für die Leiste; links genauso viel, damit die Seite genau mittig steht – auf breiten Bildschirmen.
     Wird es enger (Seite unter ~1000 px), gibt zuerst der linke Rand nach: die Seite rückt stufenlos nach links.
     Beim Auf-/Zuklappen bewegt sich nichts. */
  html:is(.rand-an,.rand-zu):has(#lobbyChat,#main .spalte-rechts,body:not(.abgemeldet) .raster > .spalte-klein) body{padding-right:var(--rand);
    padding-left:max(0px,min(var(--rand),calc(100vw - 1000px - 2 * var(--rand) + var(--rand))))}
  html:is(.rand-an,.rand-zu) #main .spalte-rechts,html:is(.rand-an,.rand-zu) #lobbyChat,html:is(.rand-an,.rand-zu) body:not(.abgemeldet) .raster > .spalte-klein{position:fixed !important;top:calc((100dvh - var(--rand-h)) / 2) !important;right:0 !important;bottom:auto !important;left:auto !important;
    width:var(--rand) !important;height:var(--rand-h) !important;max-height:none !important;margin:0 !important;z-index:30;display:flex !important;flex-direction:column;gap:12px;
    padding:14px;box-sizing:border-box;background:var(--bg);border:1px solid var(--line);border-right:0;border-radius:18px 0 0 18px;box-shadow:-10px 0 30px rgba(0,0,0,.10);
    overflow:hidden;transition:transform .25s ease,visibility .25s}
  html:is(.rand-an,.rand-zu) #main > :is(.raum,.play,.lobby),html:is(.rand-an,.rand-zu) .raster{grid-template-columns:minmax(0,1fr) !important}
  /* Übersicht petkovic.at: der Chat füllt die Leiste */
  html:is(.rand-an,.rand-zu) body:not(.abgemeldet) .raster > .spalte-klein > #chat{flex:1;min-height:0;display:flex;flex-direction:column;margin:0}
  html:is(.rand-an,.rand-zu) body:not(.abgemeldet) .raster > .spalte-klein #chatListe{flex:1;min-height:0;height:auto}
  /* Räume: der Chat sitzt genau dort, wo er auch auf den Startseiten sitzt (mittig, 60 %); „Im Raum“ ist eine eigene Karte
     im Platz darüber und scrollt, wenn der nicht reicht */
  html:is(.rand-an,.rand-zu) #main .spalte-rechts{top:12px !important;bottom:12px !important;height:auto !important;justify-content:flex-start;gap:0;
    padding:0;background:none;border:0;border-radius:0;box-shadow:none;overflow:visible}
  html:is(.rand-an,.rand-zu) .spalte-rechts > .panel{position:absolute;left:0;right:0;bottom:calc((100dvh + var(--rand-h)) / 2);   /* sitzt direkt über dem Chat */
    flex:none;min-height:0;max-height:max(56px,calc((100dvh - var(--rand-h)) / 2 - 24px));overflow-y:auto;margin:0;
    border-radius:18px 0 0 18px;border-right:0;box-shadow:-10px 0 30px rgba(0,0,0,.10)}
  /* „Im Raum“ in der Leiste kompakt: kleine Köpfe, enge Zeilen, ohne Erklärtext – so passen über dem Chat mehr Spieler hin */
  html:is(.rand-an,.rand-zu) .spalte-rechts > .panel{padding:12px 14px !important;gap:8px !important}
  html:is(.rand-an,.rand-zu) .spalte-rechts > .panel h3{font-size:16px !important;margin:0}
  html:is(.rand-an,.rand-zu) .spalte-rechts > .panel :is(ul,ol){gap:4px !important}
  html:is(.rand-an,.rand-zu) .spalte-rechts > .panel li{min-height:0 !important;column-gap:8px !important}
  html:is(.rand-an,.rand-zu) .spalte-rechts > .panel .av{width:26px !important;height:26px !important;font-size:12px !important}
  html:is(.rand-an,.rand-zu) .spalte-rechts > .panel :is(.nm,.nm *){font-size:14px}
  html:is(.rand-an,.rand-zu) .spalte-rechts > .panel .mini{display:none}
  html:is(.rand-an,.rand-zu) .spalte-rechts > .panel > p{display:none}
  html:is(.rand-an,.rand-zu) #raumChat{position:absolute;left:0;right:0;top:calc((100dvh - var(--rand-h)) / 2 - 12px);height:var(--rand-h);min-height:0;display:flex;flex-direction:column}
  html:is(.rand-an,.rand-zu) #raumChat .chatfenster.inline{border-radius:18px 0 0 18px;border-right:0;box-shadow:-10px 0 30px rgba(0,0,0,.10)}
  html:is(.rand-an,.rand-zu) #raumChat .chatfenster.inline{flex:1;min-height:0;height:auto}
  /* Warteraum: „Im Raum“ ist dort ausgeblendet (geraet.css, die Sitzplätze zeigen schon, wer da ist) – dann nimmt der Chat die ganze Höhe der Leiste */
  html:is(.rand-an,.rand-zu) #main > .raum:has(> .spiel .sitze) #raumChat{top:0;height:100%}
  html:is(.rand-an,.rand-zu) #lobbyChat > .lobby-chat{flex:1;min-height:0;display:flex;flex-direction:column}
  html:is(.rand-an,.rand-zu) #lobbyChat .chat-liste{flex:1;height:auto;min-height:0}
  /* zugeklappt: die Leiste fährt nach rechts hinaus (Platz bleibt frei), der Raum-Chat kommt per Knopf oben als Fenster */
  html.rand-zu #main .spalte-rechts,html.rand-zu #lobbyChat,html.rand-zu body:not(.abgemeldet) .raster > .spalte-klein{transform:translateX(100%);visibility:hidden}
  /* Lasche zum Auf- und Zuklappen, an der Kante der Leiste */
  .rand-lasche{position:fixed;z-index:31;top:50%;right:var(--rand);transform:translateY(-50%);display:flex;align-items:center;justify-content:center;gap:6px;
    min-width:22px;height:64px;padding:0 4px;border:1px solid var(--line);border-right:0;border-radius:10px 0 0 10px;background:var(--surface);color:var(--muted);
    font:700 18px/1 var(--f-body,system-ui);cursor:pointer;box-shadow:-4px 0 12px rgba(0,0,0,.06);transition:right .25s ease}
  .rand-lasche:hover{color:var(--ink);border-color:var(--accent)}
  .rand-lasche svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:2;stroke-linejoin:round}
  /* zugeklappt: gut sichtbare Lasche in der Spielfarbe – Sprechblase, „Chat“, Zähler für neue Nachrichten */
  html.rand-zu .rand-lasche{right:0;height:auto;padding:14px 10px 16px;flex-direction:column;gap:8px;font-size:14px;font-weight:800;letter-spacing:.04em;
    background:var(--accent);color:var(--on-accent,#fff);border-color:transparent;box-shadow:-6px 0 18px color-mix(in srgb,var(--accent) 35%,transparent)}
  html.rand-zu .rand-lasche:hover{filter:brightness(1.08);color:var(--on-accent,#fff)}
  html.rand-zu .rand-lasche svg{width:24px;height:24px;stroke-width:2.2}
  html.rand-zu .rand-lasche span{writing-mode:vertical-rl}
  .rand-lasche .zahl{position:absolute;top:-8px;left:-8px;min-width:22px;height:22px;padding:0 5px;border-radius:999px;background:var(--danger);color:#fff;font:700 12px/22px var(--f-body,system-ui);font-style:normal;text-align:center;box-shadow:0 0 0 2px var(--bg)}
  .rand-lasche .zahl[hidden]{display:none}
  html:not(:has(#lobbyChat,#main .spalte-rechts,body:not(.abgemeldet) .raster > .spalte-klein)) .rand-lasche{display:none}
}
@media (max-width:860px){.rand-lasche{display:none}}
@media (prefers-reduced-motion: reduce){.rand-lasche,#lobbyChat,.spalte-rechts,.spalte-klein{transition:none !important}}
