/* Webgames – statische Oberfläche, dunkles Bibliothekslayout */

:root {
  --bg: #111111;
  --bg-deep: #0d0d0d;
  --panel: #191919;
  --panel-2: #222222;
  --panel-3: #292929;
  --line: #343434;
  --line-strong: #4a4a4a;
  --text: #f1eee7;
  --muted: #a5a5a5;
  --faint: #777777;
  --accent: #c49b55;
  --accent-strong: #d7b576;
  --accent-ink: #19150e;
  --accent-soft: rgba(196, 155, 85, 0.12);
  --ok: #8fd0a2;
  --ok-soft: rgba(143, 208, 162, 0.12);
  --warn: #e4c27a;
  --warn-soft: rgba(228, 194, 122, 0.12);
  --danger: #ee8f8f;
  --danger-strong: #c85a5a;
  --danger-soft: rgba(238, 143, 143, 0.12);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --shadow-soft: 0 6px 22px rgba(0, 0, 0, 0.28);
  --focus: 0 0 0 3px rgba(196, 155, 85, 0.55);
  --maxw: 1480px;
  --font: "Segoe UI", "Inter", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* The modal player occupies the viewport; the library behind it must not scroll. */
html:has(dialog.wg-player[open]),
body:has(dialog.wg-player[open]) { overflow: hidden; }

[hidden] { display: none !important; }

h1, h2, h3 { margin: 0; line-height: 1.2; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.2vw, 2.1rem); }
h2 { font-size: 1.15rem; }
h3 { font-size: 0.95rem; }
p { margin: 0; }
a { color: var(--accent); }
a:hover { color: var(--accent-strong); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); }
h1[tabindex="-1"]:focus, h2[tabindex="-1"]:focus, main:focus { box-shadow: none; outline: none; }
::selection { background: rgba(196, 155, 85, 0.32); }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon {
  width: 1.15em;
  height: 1.15em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.2em;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 12px; top: -60px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus { top: 12px; }

.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.86rem; }
.noscript { max-width: 640px; margin: 40px auto; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }

/* Kopfzeile */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(17, 17, 17, 0.86);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 10px clamp(16px, 3vw, 32px);
  display: flex;
  align-items: center;
  gap: 14px 18px;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 650;
  font-size: 1.08rem;
  letter-spacing: 0.01em;
}
.brand:hover { color: var(--text); }

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(145deg, rgba(196, 155, 85, 0.22), rgba(196, 155, 85, 0.06));
  border: 1px solid rgba(196, 155, 85, 0.3);
  color: var(--accent);
}
.brand-mark .icon { width: 20px; height: 20px; }
.brand-mark-lg { width: 46px; height: 46px; border-radius: 13px; }
.brand-mark-lg .icon { width: 26px; height: 26px; }

.live-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.live-status[data-state="ok"] .live-dot { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.live-status[data-state="warn"] .live-dot { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.live-status[data-state="error"] .live-dot { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.live-status[data-state="pending"] .live-dot { animation: pulse 1.4s ease-in-out infinite; }

.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex-wrap: wrap;
}
.main-nav a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
  max-width: 220px;
}
.main-nav a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main-nav a:hover { color: var(--text); background: var(--panel); }
.main-nav a[aria-current="page"] { color: var(--text); background: var(--panel-2); box-shadow: inset 0 -2px 0 var(--accent); }

/* Hauptbereich */

main {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(20px, 3vw, 36px) clamp(16px, 3vw, 32px) 48px;
}

.view-center {
  min-height: calc(100vh - 140px);
  display: grid;
  place-items: center;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.lead { margin-top: 6px; color: var(--muted); }

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 0.82rem;
}
.site-footer p { max-width: var(--maxw); margin: 0 auto; padding: 16px clamp(16px, 3vw, 32px); }

/* Ladezustand */

.boot { display: grid; justify-items: center; gap: 16px; color: var(--muted); }

.spinner {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
.spinner-sm { width: 18px; height: 18px; border-width: 2px; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: 0.35; } }

/* Schaltflächen */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  color: var(--text);
  font-weight: 550;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
}
.btn:hover:not(:disabled) { background: var(--panel-3); border-color: #4a5566; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { cursor: not-allowed; opacity: 0.55; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-primary:disabled { background: var(--panel-3); border-color: var(--line-strong); color: var(--muted); opacity: 1; }

.btn-danger { background: var(--danger-strong); border-color: var(--danger-strong); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #d66b6b; border-color: #d66b6b; }

.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: var(--panel); border-color: var(--line); color: var(--text); }

.btn-sm { min-height: 34px; padding: 6px 11px; font-size: 0.88rem; }
.btn-lg { min-height: 48px; padding: 12px 22px; font-size: 1.02rem; }
.btn-block { width: 100%; }
.btn .spinner { width: 16px; height: 16px; border-width: 2px; border-color: currentColor; border-top-color: transparent; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(17, 17, 17, 0.8);
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { color: var(--text); border-color: var(--line-strong); background: var(--panel-2); }

/* Formulare */

.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; margin: 0; min-width: 0; }
.field > label, .field legend, .select-field label { font-size: 0.88rem; font-weight: 600; color: var(--text); }

input[type="text"],
input[type="password"],
input[type="search"],
select {
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--bg-deep);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder { color: var(--faint); }
input:hover, select:hover { border-color: #4a5566; }
input:focus-visible, select:focus-visible { border-color: var(--accent); }
input[aria-invalid="true"] { border-color: var(--danger); }
input[aria-invalid="true"]:focus-visible { box-shadow: 0 0 0 3px var(--danger-soft); }

select {
  appearance: none;
  padding-right: 38px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 19px) 50%, calc(100% - 14px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}
select option { background: var(--panel); color: var(--text); }

.check, .radio {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
  user-select: none;
}
.check input, .radio input { width: 17px; height: 17px; margin: 0; accent-color: var(--accent); cursor: pointer; flex: none; }
.check:hover, .radio:hover { color: var(--text); }

fieldset.role-field { border: 0; padding: 0; display: grid; gap: 8px; grid-template-columns: 1fr 1fr; }
fieldset.role-field legend { margin-bottom: 6px; padding: 0; }
.radio {
  align-items: flex-start;
  padding: 11px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-deep);
}
.radio input { margin-top: 2px; }
.radio span { display: grid; gap: 2px; }
.radio strong { color: var(--text); font-weight: 600; }
.radio small { color: var(--muted); font-size: 0.8rem; }
.radio:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

.form-error {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(238, 143, 143, 0.35);
  background: var(--danger-soft);
  color: #ffd2d2;
  font-size: 0.9rem;
}

/* Hinweise */

.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 0.9rem;
}
.notice .icon { margin-top: 2px; }
.notice-info { border-color: rgba(196, 155, 85, 0.28); background: var(--accent-soft); color: #cfe7ea; }
.notice-info .icon { color: var(--accent); }
.notice-warn { border-color: rgba(228, 194, 122, 0.32); background: var(--warn-soft); color: #f1dfb5; }
.notice-warn .icon { color: var(--warn); }
.notice-error { border-color: rgba(238, 143, 143, 0.35); background: var(--danger-soft); color: #ffd2d2; }
.notice-error .icon { color: var(--danger); }
.notice-ok { border-color: rgba(143, 208, 162, 0.32); background: var(--ok-soft); color: #d2f0dc; }
.notice-ok .icon { color: var(--ok); }
.notices { display: grid; gap: 10px; margin-bottom: 18px; }
.notices:empty { display: none; }

/* Anmeldung */

.auth-card {
  width: min(100%, 440px);
  padding: clamp(22px, 4vw, 34px);
  border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  box-shadow: var(--shadow);
  display: grid;
  gap: 20px;
}
.auth-brand { display: flex; align-items: center; gap: 12px; font-size: 1.25rem; font-weight: 650; }
.auth-card h1 { font-size: 1.45rem; }
.auth-card .form > .muted { margin-top: -8px; font-size: 0.92rem; }

.state-card {
  width: min(100%, 520px);
  display: grid;
  justify-items: center;
  gap: 12px;
  text-align: center;
  padding: 34px 24px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--panel);
}
.state-icon {
  display: inline-grid;
  place-items: center;
  width: 54px; height: 54px;
  border-radius: 50%;
  background: var(--panel-3);
  color: var(--muted);
}
.state-icon .icon { width: 26px; height: 26px; }
.state-icon-error { background: var(--danger-soft); color: var(--danger); }
.state-icon-warn { background: var(--warn-soft); color: var(--warn); }
.state-card h1, .state-card h2 { font-size: 1.25rem; }
.state-card p { max-width: 42ch; }
.state-card .btn { margin-top: 6px; }

/* Bibliothek: Suche und Sortierung */

.toolbar {
  display: grid;
  gap: 14px;
  margin-bottom: 24px;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
}

.search-field { position: relative; display: flex; align-items: center; }
.search-field > .icon { position: absolute; left: 16px; color: var(--muted); width: 20px; height: 20px; pointer-events: none; }
.search-field input {
  min-height: 52px;
  padding-left: 48px;
  padding-right: 52px;
  font-size: 1.04rem;
  border-radius: 12px;
}
.search-field input::-webkit-search-cancel-button { filter: invert(0.7); cursor: pointer; }
.search-field kbd {
  position: absolute;
  right: 14px;
  min-width: 24px;
  padding: 1px 7px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  color: var(--muted);
  font: 600 0.8rem/1.6 var(--font);
  text-align: center;
  pointer-events: none;
}
.search-field input:focus ~ kbd, .search-field input:not(:placeholder-shown) ~ kbd { display: none; }

.toolbar-row { display: flex; align-items: center; gap: 12px 22px; flex-wrap: wrap; }
.select-field { display: flex; align-items: center; gap: 10px; }
.select-field label { color: var(--muted); font-weight: 500; white-space: nowrap; }
.select-field select { width: auto; min-width: 190px; min-height: 40px; padding-top: 7px; padding-bottom: 7px; }
.result-count { margin-left: auto; color: var(--muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.result-count strong { color: var(--text); font-weight: 600; }

/* Bibliothek: Coverkacheln */

.game-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
  gap: clamp(14px, 1.8vw, 24px);
}

.tile { min-width: 0; }

.tile-btn {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: inherit;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.18s ease, border-color 0.18s, box-shadow 0.18s;
}
.tile-btn:hover { transform: translateY(-3px); border-color: var(--line-strong); box-shadow: var(--shadow-soft); }
.tile-btn:focus-visible { border-color: var(--accent); box-shadow: var(--focus); }

.cover {
  position: relative;
  aspect-ratio: 3 / 4;
  width: 100%;
  overflow: hidden;
  background: var(--panel-3);
}
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-btn:hover .cover img { transform: scale(1.025); }
.cover img { transition: transform 0.35s ease; }

.cover-title {
  position: absolute;
  left: 10%;
  right: 10%;
  bottom: 13%;
  color: var(--text);
  font-weight: 650;
  font-size: clamp(1rem, 0.7rem + 0.9vw, 1.35rem);
  line-height: 1.18;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}
.cover-title small { display: block; margin-top: 6px; color: var(--muted); font-size: 0.72em; font-weight: 500; }

.cover-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  max-width: calc(100% - 20px);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(17, 17, 17, 0.86);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.badge .icon { width: 13px; height: 13px; stroke-width: 2.2; }
.badge-ready { color: var(--ok); border-color: rgba(143, 208, 162, 0.45); }
.badge-waiting { color: var(--warn); border-color: rgba(228, 194, 122, 0.45); }
.badge-blocked { color: var(--muted); }

.tile-body { display: grid; gap: 4px; padding: 12px 14px 14px; }
.tile-title { font-size: 0.98rem; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.tile-meta { color: var(--muted); font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.more-wrap { display: flex; justify-content: center; margin-top: 28px; }
.more-wrap:empty { display: none; }

.skeleton .cover, .skeleton .sk-line {
  background: linear-gradient(90deg, var(--panel-2) 0%, var(--panel-3) 50%, var(--panel-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.skeleton .tile-btn { cursor: default; }
.skeleton .tile-btn:hover { transform: none; box-shadow: none; border-color: var(--line); }
.sk-line { height: 11px; border-radius: 6px; }
.sk-line + .sk-line { width: 60%; margin-top: 4px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

#library-state, #users-state { margin: 8px 0 24px; display: grid; place-items: center; }

/* Panels */

.panel {
  padding: clamp(18px, 2.4vw, 26px);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  display: grid;
  gap: 16px;
  align-content: start;
  min-width: 0;
}
.panel-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.panel-head .btn { margin-left: auto; }
.panel-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 20px; align-items: start; max-width: 1080px; }
.admin-layout { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(320px, 1fr); gap: 20px; align-items: start; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 9px 18px; margin: 0; }
.facts dt { color: var(--muted); font-size: 0.88rem; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.facts-compact { gap: 6px 16px; font-size: 0.9rem; }

.role-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}
.role-pill .icon { width: 13px; height: 13px; }
.role-admin { color: var(--accent); border-color: rgba(196, 155, 85, 0.45); background: var(--accent-soft); }

/* Benutzertabelle */

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.user-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.user-table th {
  padding: 10px 14px;
  text-align: left;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.user-table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.user-table tbody tr:last-child td { border-bottom: 0; }
.user-table tbody tr:hover { background: rgba(255, 255, 255, 0.015); }
.user-name { display: flex; align-items: center; gap: 10px; min-width: 0; font-weight: 600; }
.user-name span { overflow-wrap: anywhere; }
.avatar {
  display: inline-grid;
  place-items: center;
  width: 32px; height: 32px;
  flex: none;
  border-radius: 50%;
  background: var(--panel-3);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
}
.self-tag { color: var(--muted); font-size: 0.78rem; font-weight: 500; white-space: nowrap; }
.user-date { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.user-actions { display: flex; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
.user-actions .btn { white-space: nowrap; }
.btn-danger-ghost { color: var(--danger); }
.btn-danger-ghost:hover:not(:disabled) { background: var(--danger-soft); border-color: rgba(238, 143, 143, 0.35); color: #ffc4c4; }

/* Dialoge */

.dialog {
  width: min(calc(100% - 24px), 560px);
  max-height: calc(100vh - 32px);
  padding: 0;
  border-radius: 18px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
  overflow: auto;
}
.dialog::backdrop { background: rgba(5, 7, 10, 0.72); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.dialog[open] { animation: pop 0.16s ease-out; }
.dialog-sm { width: min(calc(100% - 24px), 460px); }
.dialog-body { display: grid; gap: 14px; padding: 24px; margin: 0; }
.dialog-body h2 { font-size: 1.2rem; }
.dialog-body > p { color: var(--muted); }
.dialog-body > p:empty { display: none; }
.dialog-body strong { color: var(--text); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.985); } }

.dialog-game { width: min(calc(100% - 24px), 920px); }
.game-detail { position: relative; display: grid; grid-template-columns: minmax(200px, 300px) minmax(0, 1fr); }
.dialog-close { position: absolute; top: 14px; right: 14px; z-index: 2; }
.game-cover { position: relative; aspect-ratio: 3 / 4; align-self: start; background: var(--panel-3); border-right: 1px solid var(--line); }
.game-cover .cover { height: 100%; }
.game-info { display: grid; gap: 14px; align-content: start; padding: 26px 28px 28px; min-width: 0; }
.game-info h2 { font-size: clamp(1.4rem, 1.1rem + 1vw, 1.9rem); padding-right: 40px; overflow-wrap: anywhere; }
.eyebrow { color: var(--accent); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.eyebrow:empty { display: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips:empty { display: none; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 0.82rem;
}
.chip .icon { width: 14px; height: 14px; color: var(--accent); }
.game-desc { color: #cfd8e3; white-space: pre-line; overflow-wrap: anywhere; }
.game-desc:empty { display: none; }
.game-controls { display: grid; gap: 8px; }
.game-controls h3 { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; }
.game-controls ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 0.9rem; }
.game-controls li { display: flex; gap: 10px; align-items: baseline; }
.game-controls kbd {
  min-width: 28px;
  padding: 1px 8px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  background: var(--panel-2);
  color: var(--text);
  font: 600 0.8rem/1.6 var(--font);
  text-align: center;
  white-space: nowrap;
}
.start-box {
  display: grid;
  gap: 10px;
  margin-top: 4px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.start-box .btn { justify-self: start; }
.start-hint { display: flex; gap: 9px; align-items: flex-start; color: var(--muted); font-size: 0.9rem; }
.start-hint:empty { display: none; }
.start-hint .icon { margin-top: 2px; }
.start-hint[data-tone="warn"] { color: #f1dfb5; }
.start-hint[data-tone="warn"] .icon { color: var(--warn); }
.start-hint[data-tone="error"] { color: #ffd2d2; }
.start-hint[data-tone="error"] .icon { color: var(--danger); }

/* Meldungen */

.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1000;
  display: grid;
  gap: 10px;
  width: min(calc(100% - 36px), 400px);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 0.92rem;
  pointer-events: auto;
  animation: pop 0.18s ease-out;
}
.toast .icon { margin-top: 2px; }
.toast p { flex: 1; overflow-wrap: anywhere; }
.toast-ok .icon { color: var(--ok); }
.toast-error { border-color: rgba(238, 143, 143, 0.45); }
.toast-error .icon { color: var(--danger); }
.toast-info .icon { color: var(--accent); }
.toast button {
  margin: -4px -6px -4px 0;
  padding: 4px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  line-height: 0;
}
.toast button:hover { color: var(--text); background: var(--panel-3); }

/* Responsiv */

@media (max-width: 1080px) {
  .admin-layout, .panel-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 760px) {
  body { font-size: 14.5px; }
  .live-status { order: 3; }
  .main-nav { order: 4; width: 100%; margin-left: 0; justify-content: flex-start; }
  #logout-btn { margin-left: auto; }
  .main-nav a { padding: 6px 10px; }
  .game-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .result-count { margin-left: 0; width: 100%; }
  .select-field select { min-width: 0; }
  .game-detail { grid-template-columns: minmax(0, 1fr); }
  .game-cover { width: min(56%, 220px); margin: 22px auto 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
  .game-info { padding: 20px; }
  .start-box .btn { justify-self: stretch; }
  fieldset.role-field { grid-template-columns: minmax(0, 1fr); }
  .user-table thead { display: none; }
  .user-table, .user-table tbody, .user-table tr, .user-table td { display: block; width: 100%; }
  .user-table tr { padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .user-table tbody tr:last-child { border-bottom: 0; }
  .user-table td { padding: 3px 0; border: 0; }
  .user-actions { justify-content: flex-start; margin-top: 8px; }
}

@media (max-width: 420px) {
  .brand-name { display: none; }
  .auth-card .brand-name { display: inline; }
  .game-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .toolbar { padding: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (forced-colors: active) {
  .tile-btn, .panel, .toolbar, .dialog, .btn { border: 1px solid CanvasText; }
  .badge, .chip, .role-pill { border: 1px solid CanvasText; }
}


/* Approved Cover Gallery: neutral shared surfaces, portrait artwork, quiet chrome. */
:root { --radius: 8px; --radius-sm: 5px; --maxw: 1540px; }
.topbar { position: static; background: var(--bg); border-bottom: 0; backdrop-filter: none; -webkit-backdrop-filter: none; }
.topbar-inner { min-height: 76px; padding-top: 12px; padding-bottom: 12px; gap: 12px 20px; }
.brand { font-size: 27px; font-weight: 650; letter-spacing: -.035em; }
.topbar .brand-mark { display: none; }
.brand-mark { background: var(--panel); border-color: var(--line); }
.live-status[data-state="ok"] { display: none; }
.main-nav { gap: 15px; }
.main-nav a { border-radius: 0; padding: 9px 2px; color: var(--text); }
.main-nav a .icon { display: none; }
.main-nav a:hover { background: transparent; color: var(--accent-strong); }
.main-nav a[aria-current="page"] { color: var(--accent); background: transparent; box-shadow: inset 0 -2px 0 var(--accent); }
.session-user { display: flex; align-items: center; gap: 9px; padding-left: 20px; border-left: 1px solid var(--line); min-width: 0; }
.session-user .icon { width: 23px; height: 23px; }
#session-username { overflow: hidden; text-overflow: ellipsis; max-width: 160px; white-space: nowrap; }
#logout-btn { min-width: 36px; width: 36px; padding: 8px; color: var(--muted); }
#logout-btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
main { padding-top: 28px; }
.library-head { display: grid; grid-template-columns: minmax(0,1fr) minmax(250px,400px); align-items: center; gap: 28px; margin-bottom: 42px; }
#library-title { font-size: clamp(44px,5.3vw,76px); font-weight: 600; letter-spacing: -.045em; }
.library-head .lead { color: var(--text); font-size: clamp(15px,1.3vw,20px); margin-top: 5px; }
#result-count strong { font-weight: inherit; }
.library-toolbar { background: transparent; border: 0; border-radius: 0; padding: 0; margin: 15px 0 0; gap: 8px; }
.library-toolbar .search-field > .icon { left: 0; width: 19px; height: 19px; }
.library-toolbar .search-field input { background: transparent; border: 0; border-bottom: 1px solid #777; border-radius: 0; padding: 9px 32px 9px 30px; min-height: 43px; font-size: 17px; }
.library-toolbar .search-field input:focus { border-bottom-color: var(--accent); box-shadow: none; }
.library-toolbar .search-field kbd { right: 2px; border: 0; background: transparent; font-weight: 400; }
.gallery-filters { position: relative; justify-self: end; color: var(--muted); font-size: 12px; z-index: 4; }
.gallery-filters summary { cursor: pointer; padding: 3px 0 3px 12px; }
.gallery-filters[open] summary { color: var(--text); }
.gallery-filters .toolbar-row { position: absolute; right: 0; top: calc(100% + 8px); min-width: 295px; max-width: calc(100vw - 40px); display: flex; align-items: stretch; flex-direction: column; gap: 16px; background: var(--panel); padding: 18px; border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow-soft); }
.gallery-filters .select-field { flex-wrap: wrap; }
.gallery-filters select { flex: 1; }
.game-grid { max-width: 1340px; margin: 0 auto; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 48px clamp(32px,4.8vw,80px); }
.tile-btn { display: block; height: auto; border: 0; border-radius: 0; background: transparent; overflow: visible; box-shadow: none; transition: none; }
.tile-btn:hover { transform: none; box-shadow: none; }
.tile-btn .cover { border-radius: 0; }
.tile-btn:hover .cover img { transform: none; filter: brightness(1.05); }
.tile-body { padding: 10px 0 0; gap: 4px; justify-items: start; }
.tile-title { font-size: clamp(20px,1.7vw,27px); font-weight: 600; letter-spacing: -.025em; }
.tile-meta { font-size: 14px; max-width: 100%; }
.tile-start { margin-top: 9px; min-height: 40px; padding: 8px 22px; border-radius: 4px; font-weight: 600; }
.gallery-placeholder { min-width: 0; color: #858585; }
.gallery-placeholder-poster { border: 1px solid #3b3b3b; aspect-ratio: 3/4; display: grid; place-items: center; }
.gallery-placeholder-content { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 20px; font-size: clamp(14px,1.3vw,19px); text-align: center; }
.gallery-placeholder .icon { width: 74px; height: 74px; stroke-width: 1.05; }
.game-cover { border-radius: 0; }
.site-footer { border-top: 0; color: var(--faint); }
.site-footer p { padding-top: 8px; }
@media(max-width:1000px) {
  .game-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 36px 32px; }
  .gallery-placeholder:last-child { display: none; }
  .topbar-inner { gap: 8px 16px; }
  .main-nav { order: 4; width: 100%; margin-left: 0; gap: 22px; }
  .session-user { margin-left: auto; border-left: 0; padding-left: 0; }
  #logout-btn { margin-left: 0; }
}
@media(max-width:600px) {
  main { padding-top: 24px; }
  .library-head { grid-template-columns: minmax(0,1fr); gap: 20px; margin-bottom: 28px; }
  .library-toolbar { margin: 0; width: 100%; }
  .game-grid { grid-template-columns: minmax(0,1fr); max-width: 440px; gap: 30px; }
  .gallery-placeholder { display: none; }
  .brand { font-size: 24px; }
  .topbar .brand-name { display: inline; }
  #session-username { max-width: 105px; font-size: 14px; }
  .session-user { gap: 6px; }
  .session-user .icon { width: 19px; height: 19px; }
  .main-nav a { padding: 6px 2px; font-size: 14px; }
  .tile-title { font-size: 25px; }
}
@media(forced-colors:active) {
  .tile-btn, .gallery-placeholder-poster { border: 1px solid CanvasText; }
  .main-nav a[aria-current="page"] { text-decoration: underline; }
}

/* Library only: fit a complete first row, including its text and launch button.
   Scale the column width so both real and empty posters keep their 3:4 shape.
   Additional rows and notices stay in normal document flow and remain scrollable. */
@media (min-width: 601px) {
  body:has(#view-library:not([hidden])) .topbar-inner {
    min-height: 56px;
    padding-top: 6px;
    padding-bottom: 6px;
  }
  body:has(#view-library:not([hidden])) main {
    padding-top: clamp(12px, 2dvh, 20px);
    padding-bottom: 16px;
  }
  #view-library .library-head { margin-bottom: clamp(16px, 2.8dvh, 28px); gap: 24px; }
  #library-title { font-size: clamp(32px, 5dvh, 52px); }
  #view-library .library-head .lead { font-size: clamp(14px, 1.9dvh, 18px); }
  #view-library .library-toolbar { margin-top: 0; }
  #view-library #game-grid {
    --gallery-poster-height: clamp(130px, calc(100dvh - 360px), 520px);
    --gallery-column-gap: clamp(28px, 4vw, 64px);
    max-width: min(1340px, calc(var(--gallery-poster-height) * 2.25 + var(--gallery-column-gap) * 2));
    gap: 32px var(--gallery-column-gap);
    align-items: start;
  }
  #view-library .tile-body { padding-top: 8px; gap: 3px; }
  #view-library .tile-title { font-size: clamp(18px, 2.7dvh, 24px); }
  #view-library .tile-meta { font-size: 13px; }
  #view-library .tile-start { max-width: 100%; margin-top: 6px; min-height: 36px; padding: 6px 12px; }
  #view-library .tile-start > span { min-width: 0; }
  #view-library .gallery-placeholder-content { gap: 12px; padding: 12px; font-size: clamp(12px, 1.8dvh, 16px); }
  #view-library .gallery-placeholder .icon { width: clamp(36px, 7dvh, 64px); height: clamp(36px, 7dvh, 64px); }
  #view-library .more-wrap:has(> button[hidden]) { display: none; }
}
@media (min-width: 601px) and (max-width: 1000px) {
  #view-library #game-grid {
    --gallery-poster-height: clamp(130px, calc(100dvh - 400px), 520px);
    max-width: calc(var(--gallery-poster-height) * 1.5 + var(--gallery-column-gap));
  }
}
@media (min-width: 601px) and (max-height: 650px) {
  body:has(#view-library:not([hidden])) .topbar-inner { min-height: 52px; padding-top: 4px; padding-bottom: 4px; }
  body:has(#view-library:not([hidden])) main { padding-top: 10px; padding-bottom: 12px; }
  #view-library .library-head { margin-bottom: 14px; }
  #library-title { font-size: 32px; }
  #view-library .library-toolbar { gap: 4px; }
  #view-library .library-toolbar .search-field input { min-height: 38px; padding-top: 6px; padding-bottom: 6px; font-size: 15px; }
  #view-library .tile-title { font-size: 18px; }
  #view-library .tile-meta { font-size: 12px; }
  #view-library .tile-start { margin-top: 4px; padding-right: 10px; padding-left: 10px; font-size: 14px; }
  body:has(#view-library:not([hidden])) .site-footer p { padding-top: 4px; padding-bottom: 8px; font-size: 12px; }
}
