:root {
  color-scheme: dark;
  --bg: #050816;
  --bg-2: #0c1230;
  --panel: rgba(17, 25, 62, 0.82);
  --panel-soft: rgba(24, 34, 82, 0.72);
  --panel-bright: rgba(45, 65, 150, 0.58);
  --panel-deep: rgba(8, 12, 34, 0.88);
  --text: #f7f9ff;
  --muted: #b9c4ef;
  --muted-2: #8390c5;
  --accent: #a78bfa;
  --accent-strong: #7c3aed;
  --accent-2: #38bdf8;
  --accent-3: #60a5fa;
  --danger: #fb7185;
  --success: #4ade80;
  --warning: #f5d76e;
  --border: rgba(191, 219, 254, 0.18);
  --border-strong: rgba(167, 139, 250, 0.48);
  --shadow: 0 30px 90px rgba(0, 0, 0, 0.42);
  --glow-blue: 0 0 32px rgba(56, 189, 248, 0.26);
  --glow-purple: 0 0 42px rgba(124, 58, 237, 0.32);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 12% 8%, rgba(56, 189, 248, 0.28), transparent 28rem),
    radial-gradient(circle at 88% 2%, rgba(124, 58, 237, 0.42), transparent 32rem),
    radial-gradient(circle at 50% 100%, rgba(37, 99, 235, 0.25), transparent 35rem),
    linear-gradient(135deg, #030712 0%, #08112e 44%, #180f35 100%);
  color: var(--text);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,0.7), transparent 86%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  transition: transform 150ms ease, opacity 150ms ease, border-color 150ms ease, box-shadow 150ms ease, filter 150ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.06);
}

button:active:not(:disabled) {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(8, 13, 37, 0.72);
  color: var(--text);
  padding: 13px 14px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(56, 189, 248, 0.72);
  box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.13), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

select option {
  color: #0f172a;
}

textarea {
  resize: vertical;
  min-height: 96px;
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
}

.app-shell {
  width: min(1600px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.topbar,
.section-header,
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
}

.topbar {
  margin-bottom: 18px;
  padding: 10px 0 4px;
  overflow: visible;
}

.topbar > div:first-child {
  min-width: 0;
  overflow: visible;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  padding-bottom: 0.12em;
  font-size: clamp(2.35rem, 5.1vw, 5.35rem);
  line-height: 1.06;
  letter-spacing: -0.06em;
  background: linear-gradient(90deg, #eff6ff, #93c5fd 35%, #c4b5fd 72%, #f5d0fe);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 18px 70px rgba(124, 58, 237, 0.35);
  overflow: visible;
}

h2 {
  margin-bottom: 8px;
  font-size: clamp(1.45rem, 2.4vw, 2.55rem);
  letter-spacing: -0.045em;
}

h3 {
  margin-bottom: 14px;
  letter-spacing: -0.02em;
}

.eyebrow {
  width: max-content;
  margin-bottom: 10px;
  border: 1px solid rgba(56, 189, 248, 0.32);
  border-radius: 999px;
  padding: 6px 10px;
  color: #bfdbfe;
  background: rgba(56, 189, 248, 0.09);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  font-weight: 900;
}

.muted {
  color: var(--muted);
}

.connection,
.code-card,
.share-box {
  border: 1px solid var(--border);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.095), rgba(255, 255, 255, 0.045));
  padding: 12px 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.connection {
  min-width: 112px;
  text-align: center;
  font-weight: 900;
}

.connection.online {
  color: var(--success);
  border-color: rgba(74, 222, 128, 0.34);
  box-shadow: 0 0 28px rgba(74, 222, 128, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.connection.offline {
  color: var(--danger);
  border-color: rgba(251, 113, 133, 0.34);
}

.panel {
  border: 1px solid rgba(191, 219, 254, 0.14);
  border-radius: 24px;
  background: rgba(9, 14, 36, 0.78);
  box-shadow: 0 18px 58px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.055);
  padding: 22px;
  backdrop-filter: blur(14px);
}

.hero-panel {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(340px, 0.82fr);
  gap: 24px;
  align-items: stretch;
  overflow: hidden;
}

.hero-panel::after {
  content: "";
  position: absolute;
  width: 420px;
  height: 420px;
  right: -140px;
  top: -160px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(167, 139, 250, 0.24), transparent 68%);
  pointer-events: none;
}

.hero-copy {
  position: relative;
  min-height: 360px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  border-radius: 28px;
  padding: clamp(24px, 4vw, 44px);
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.34), rgba(124, 58, 237, 0.28)),
    radial-gradient(circle at 18% 24%, rgba(56, 189, 248, 0.34), transparent 17rem);
  border: 1px solid rgba(147, 197, 253, 0.22);
}

.hero-copy::before {
  content: "JEOPARDY";
  position: absolute;
  left: -14px;
  top: 18px;
  color: rgba(255, 255, 255, 0.045);
  font-size: clamp(4.5rem, 11vw, 10rem);
  font-weight: 1000;
  letter-spacing: -0.08em;
  line-height: 0.85;
}

.hero-copy > * {
  position: relative;
}

.hero-copy p {
  max-width: 780px;
  margin-bottom: 0;
  color: #dbeafe;
  font-size: 1.03rem;
  line-height: 1.6;
}

.form-card {
  display: grid;
  gap: 16px;
  padding: 18px;
  border-radius: 20px;
  background: rgba(7, 12, 34, 0.54);
  border: 1px solid rgba(191, 219, 254, 0.13);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.045);
}

.form-card.compact {
  align-content: start;
}

.split-row,
.inline-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.danger-btn,
.success-btn {
  min-height: 44px;
  border-radius: 12px;
  padding: 0 16px;
  font-weight: 850;
  letter-spacing: -0.01em;
  border: 1px solid transparent;
  box-shadow: none;
}

.primary-btn {
  border-color: rgba(167, 139, 250, 0.62);
  background: #6d28d9;
  color: #fff;
}

.secondary-btn {
  border-color: rgba(96, 165, 250, 0.62);
  background: #1d4ed8;
  color: #f8fbff;
}

.ghost-btn {
  border-color: rgba(147, 197, 253, 0.28);
  background: rgba(15, 23, 42, 0.42);
  color: #dbeafe;
}

.danger-btn {
  border-color: rgba(251, 113, 133, 0.58);
  background: #be123c;
  color: #fff;
}

.success-btn {
  border-color: rgba(74, 222, 128, 0.48);
  background: #15803d;
  color: #ecfdf5;
}

.primary-btn:hover:not(:disabled),
.secondary-btn:hover:not(:disabled),
.ghost-btn:hover:not(:disabled),
.danger-btn:hover:not(:disabled),
.success-btn:hover:not(:disabled) {
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.12);
}

.full-width {
  width: 100%;
}

.hidden {
  display: none !important;
}

.template-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 20px;
}

.builder-toolbar {
  display: grid;
  grid-template-columns: 2fr 0.8fr 0.8fr auto auto;
  gap: 14px;
  align-items: end;
  margin: 22px 0;
  padding: 18px;
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--border);
}

.builder-grid {
  display: grid;
  gap: 16px;
}

.category-builder {
  border: 1px solid var(--border);
  border-radius: 26px;
  overflow: hidden;
  background: rgba(9, 14, 40, 0.58);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.055);
}

.category-builder-header {
  padding: 16px;
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.24), rgba(124, 58, 237, 0.22));
  border-bottom: 1px solid var(--border);
}

.question-builder-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 14px;
  padding: 16px;
}

.question-builder {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 20px;
  background: rgba(13, 20, 54, 0.74);
  border: 1px solid rgba(191, 219, 254, 0.15);
}

.points-pill {
  width: max-content;
  border-radius: 999px;
  padding: 6px 11px;
  background: rgba(124, 58, 237, 0.22);
  border: 1px solid rgba(167, 139, 250, 0.36);
  color: #ddd6fe;
  font-weight: 950;
}

.media-note {
  color: var(--muted-2);
  font-size: 0.82rem;
  word-break: break-word;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(330px, 380px);
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}

.game-header {
  position: relative;
  overflow: hidden;
}

.game-header::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(56, 189, 248, 0.06), rgba(124, 58, 237, 0.1));
  pointer-events: none;
}

.game-header > * {
  position: relative;
  z-index: 1;
}

.code-card {
  min-width: 190px;
  text-align: center;
}

.code-card span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.code-card strong {
  display: block;
  font-size: 2rem;
  letter-spacing: 0.18em;
  color: #dbeafe;
  text-shadow: 0 0 28px rgba(56, 189, 248, 0.42);
}

.host-lobby-settings {
  min-width: min(100%, 360px);
}

.lobby-settings-menu {
  position: relative;
  border: 1px solid rgba(147, 197, 253, 0.22);
  border-radius: 16px;
  background: rgba(8, 13, 37, 0.54);
  padding: 10px;
}

.lobby-settings-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  color: #e0e7ff;
  font-weight: 900;
}

.lobby-settings-toggle {
  width: 38px;
  min-height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(167, 139, 250, 0.46);
  border-radius: 10px;
  background: rgba(109, 40, 217, 0.24);
  color: #ede9fe;
  padding: 0;
}

.lobby-settings-toggle .chevron {
  display: block;
  line-height: 1;
  transition: transform 180ms ease;
}

.lobby-settings-menu.open .lobby-settings-toggle .chevron {
  transform: rotate(180deg);
}

.lobby-settings-content {
  display: grid;
  gap: 12px;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-6px);
  transition: max-height 240ms ease, opacity 180ms ease, transform 180ms ease, visibility 180ms ease, margin-top 180ms ease;
  min-width: min(78vw, 520px);
}

.lobby-settings-menu.open .lobby-settings-content {
  max-height: 620px;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
  margin-top: 12px;
}

.checkbox-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 0;
  padding: 12px;
  border: 1px solid rgba(191, 219, 254, 0.13);
  border-radius: 16px;
  background: rgba(8, 13, 37, 0.38);
  color: #dbeafe;
}

.checkbox-row input {
  width: auto;
  accent-color: #7c3aed;
  transform: scale(1.12);
}

.settings-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.host-transfer-box {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(191, 219, 254, 0.13);
  border-radius: 16px;
  background: rgba(8, 13, 37, 0.38);
}

.small-note {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.35;
}

.board-panel {
  position: relative;
  min-height: 560px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% -10%, rgba(56, 189, 248, 0.18), transparent 24rem),
    linear-gradient(145deg, rgba(16, 27, 74, 0.86), rgba(9, 13, 38, 0.9));
}

.side-panel {
  position: sticky;
  top: 18px;
  background:
    linear-gradient(160deg, rgba(22, 30, 75, 0.92), rgba(11, 15, 42, 0.95));
}

.game-board {
  display: grid;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-color: rgba(167, 139, 250, 0.72) rgba(255, 255, 255, 0.05);
}

.board-cell,
.category-cell {
  min-height: 86px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 12px;
  border: 1px solid rgba(191, 219, 254, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.09), 0 16px 35px rgba(0, 0, 0, 0.18);
}

.category-cell {
  position: relative;
  min-height: 96px;
  background:
    linear-gradient(145deg, rgba(59, 130, 246, 0.64), rgba(91, 33, 182, 0.7)),
    #1d2b7a;
  color: #fff;
  font-weight: 1000;
  text-transform: uppercase;
  letter-spacing: 0.035em;
  overflow: hidden;
}

.category-cell::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 20%, rgba(255,255,255,0.12), transparent 58%);
  transform: translateX(-100%);
  animation: categoryShine 7s infinite;
}

@keyframes categoryShine {
  0%, 72% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.board-cell {
  background:
    radial-gradient(circle at 50% 0%, rgba(56, 189, 248, 0.22), transparent 75%),
    linear-gradient(145deg, #1e3a8a, #312e81 56%, #581c87);
  color: #e0f2fe;
  font-weight: 1000;
  font-size: clamp(1.25rem, 2vw, 2.15rem);
  text-shadow: 0 0 18px rgba(56, 189, 248, 0.34), 0 2px 0 rgba(0, 0, 0, 0.25);
  flex-direction: column;
  gap: 5px;
}

.cell-points {
  display: block;
}

.cell-meta {
  display: block;
  max-width: 100%;
  color: rgba(219, 234, 254, 0.78);
  font-size: 0.72rem;
  font-weight: 850;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: none;
  white-space: nowrap;
}

.cell-history {
  display: grid;
  gap: 4px;
  width: 100%;
  color: #dbeafe;
  font-size: clamp(0.72rem, 1vw, 0.92rem);
  line-height: 1.15;
  text-shadow: none;
}

.cell-history strong {
  color: #a7f3d0;
  font-size: clamp(0.78rem, 1.12vw, 1rem);
}

.cell-penalty {
  color: #fecdd3;
  font-size: 0.72rem;
}

.board-cell.selectable {
  color: #ffffff;
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.22), 0 0 35px rgba(124, 58, 237, 0.19), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.board-cell.selectable:hover {
  outline: 3px solid rgba(56, 189, 248, 0.9);
  box-shadow: 0 0 0 5px rgba(56, 189, 248, 0.12), 0 0 42px rgba(124, 58, 237, 0.32);
}

.board-cell.answered {
  background:
    linear-gradient(145deg, rgba(15, 23, 42, 0.86), rgba(30, 27, 75, 0.72));
  color: rgba(219, 234, 254, 0.84);
  text-shadow: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.board-cell.active {
  outline: 3px solid rgba(167, 139, 250, 0.95);
  box-shadow: 0 0 0 7px rgba(167, 139, 250, 0.16), 0 0 60px rgba(56, 189, 248, 0.28);
}

.score-list {
  display: grid;
  gap: 10px;
}

.score-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 13px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.062);
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.055);
}

.score-row.current {
  border-color: rgba(56, 189, 248, 0.64);
  outline: 2px solid rgba(124, 58, 237, 0.38);
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.18), rgba(124, 58, 237, 0.15));
}

.score-name {
  font-weight: 950;
}

.score-points {
  min-width: 70px;
  text-align: right;
  color: #93c5fd;
  font-size: 1.25rem;
  font-weight: 1000;
  text-shadow: 0 0 18px rgba(56, 189, 248, 0.26);
}

.host-controls,
.player-controls {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.manual-score-menu {
  border: 1px solid rgba(147, 197, 253, 0.18);
  border-radius: 16px;
  background: rgba(8, 13, 37, 0.42);
  padding: 12px;
}

.manual-score-menu summary {
  cursor: pointer;
  color: #dbeafe;
  font-weight: 950;
}

.manual-score-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.manual-score-row {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) minmax(88px, 0.65fr) auto minmax(72px, 0.55fr) auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid rgba(191, 219, 254, 0.12);
  border-radius: 16px;
  background: rgba(8, 13, 37, 0.36);
}

.manual-score-row strong,
.manual-score-row span {
  display: block;
}

.manual-score-row input {
  min-width: 0;
  padding: 10px;
  border-radius: 12px;
}

.manual-score-row button {
  padding: 10px 11px;
  border-radius: 12px;
  font-size: 0.84rem;
}

.question-panel {
  position: absolute;
  inset: 18px;
  z-index: 8;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.question-panel::before {
  content: "";
  position: absolute;
  inset: -18px;
  background: radial-gradient(circle at 50% 35%, rgba(3, 7, 18, 0.16), rgba(3, 7, 18, 0.58));
  pointer-events: none;
}

.question-overlay-card {
  position: relative;
  width: min(100%, 1040px);
  max-height: none;
  overflow: visible;
  border: 1px solid rgba(147, 197, 253, 0.28);
  border-radius: 34px;
  background:
    radial-gradient(circle at 20% 0%, rgba(56, 189, 248, 0.2), transparent 20rem),
    linear-gradient(145deg, rgba(10, 17, 48, 0.96), rgba(28, 18, 65, 0.95));
  box-shadow: 0 38px 110px rgba(0, 0, 0, 0.58), 0 0 65px rgba(124, 58, 237, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  padding: clamp(20px, 3vw, 42px);
  pointer-events: auto;
}

.question-content {
  display: grid;
  gap: clamp(10px, 1.4vw, 16px);
}

.question-turn {
  width: max-content;
  max-width: 100%;
  margin-bottom: 14px;
  border-radius: 999px;
  padding: 9px 13px;
  color: #dbeafe;
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.32), rgba(124, 58, 237, 0.28));
  border: 1px solid rgba(147, 197, 253, 0.28);
  font-size: clamp(1rem, 1.6vw, 1.35rem);
  font-weight: 950;
}

.question-big {
  font-size: clamp(1.55rem, 3.2vw, 3.45rem);
  line-height: 1.1;
  font-weight: 1000;
  white-space: pre-wrap;
  letter-spacing: -0.04em;
}

.answer-box {
  padding: clamp(12px, 1.4vw, 16px);
  border-radius: 18px;
  border: 1px solid rgba(74, 222, 128, 0.45);
  background: linear-gradient(135deg, rgba(74, 222, 128, 0.11), rgba(14, 165, 233, 0.09));
}

.player-answer-box {
  border-color: rgba(250, 204, 21, 0.55);
  background: linear-gradient(135deg, rgba(250, 204, 21, 0.14), rgba(124, 58, 237, 0.10));
}

.question-media {
  width: min(100%, 900px);
  max-height: clamp(180px, 40vh, 460px);
  object-fit: contain;
  border-radius: 22px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

.question-audio {
  width: min(100%, 760px);
  accent-color: #7c3aed;
}

.host-audio-box,
.player-audio-box {
  display: grid;
  gap: 12px;
  width: min(100%, 780px);
  border: 1px solid rgba(147, 197, 253, 0.22);
  border-radius: 24px;
  padding: 16px;
  background: rgba(8, 13, 37, 0.62);
}

.player-audio-box audio {
  display: none;
}

.volume-label {
  margin: 0;
  color: #dbeafe;
  font-size: 1rem;
}

.volume-slider {
  padding: 8px 0;
  accent-color: #38bdf8;
  background: transparent;
  box-shadow: none;
}

.turn-banner {
  margin: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.065);
  color: var(--text);
  font-weight: 950;
  text-align: center;
}

.turn-banner.active-turn {
  border-color: rgba(56, 189, 248, 0.68);
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.24), rgba(124, 58, 237, 0.2));
  color: #e0f2fe;
  box-shadow: var(--glow-blue);
}

.buzz-button {
  min-height: 100px;
  border-radius: 28px;
  font-size: 1.72rem;
  background: linear-gradient(135deg, #f43f5e, #7c3aed 68%, #2563eb);
  color: #fff;
  font-weight: 1000;
  box-shadow: 0 18px 60px rgba(124, 58, 237, 0.33), 0 0 42px rgba(244, 63, 94, 0.22);
}

.buzz-button small {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.78rem;
}

.buzz-button.ready {
  animation: pulse 1s infinite alternate ease-in-out;
}

@keyframes pulse {
  from { transform: scale(1); box-shadow: 0 18px 60px rgba(124, 58, 237, 0.28); }
  to { transform: scale(1.018); box-shadow: 0 22px 72px rgba(244, 63, 94, 0.34), 0 0 45px rgba(56, 189, 248, 0.23); }
}

.buzz-list {
  display: grid;
  gap: 8px;
}

.buzz-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.064);
  border: 1px solid rgba(191, 219, 254, 0.13);
}

.lobby-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.lobby-player {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(167, 139, 250, 0.32);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: 420px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(8, 13, 37, 0.96);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: var(--shadow), var(--glow-purple);
}

.toast.error {
  border-color: rgba(251, 113, 133, 0.55);
}

@media (max-width: 1180px) {
  .game-layout {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: static;
    order: -1;
  }
}

@media (max-width: 980px) {
  .hero-panel,
  .template-actions,
  .builder-toolbar {
    grid-template-columns: 1fr;
  }

  .split-row,
  .inline-actions {
    grid-template-columns: 1fr;
  }

  .topbar,
  .section-header,
  .game-header {
    align-items: stretch;
    flex-direction: column;
  }

  .code-card {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 18px, 1600px);
    padding-top: 14px;
  }

  .panel {
    border-radius: 24px;
    padding: 16px;
  }

  .hero-copy {
    min-height: 280px;
  }

  .board-cell,
  .category-cell {
    min-height: 76px;
    border-radius: 15px;
  }

  .question-panel {
    inset: 10px;
  }

  .question-overlay-card {
    border-radius: 24px;
    padding: 14px;
  }

  .question-big {
    font-size: clamp(1.35rem, 8vw, 2.2rem);
  }

.question-media {
    max-height: 34vh;
  }

  .question-host-actions {
    border-radius: 18px;
  }

  .manual-score-row {
    grid-template-columns: 1fr;
  }
}


@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 1600px);
  }

  .topbar h1 {
    font-size: clamp(2.1rem, 13vw, 3.6rem);
    letter-spacing: -0.045em;
  }

  .game-header {
    gap: 14px;
  }

  .host-lobby-settings,
  .lobby-settings-menu,
  .lobby-settings-content {
    width: 100%;
    min-width: 0;
  }

  .settings-actions,
  .host-transfer-box .inline-actions,
  .buzz-row {
    grid-template-columns: 1fr;
  }

  .builder-toolbar {
    padding: 14px;
    border-radius: 18px;
  }

  .hero-panel {
    gap: 16px;
  }

  .hero-copy {
    padding: 22px;
    border-radius: 20px;
  }

  .side-panel {
    padding: 16px;
  }

  .host-controls,
  .player-controls {
    gap: 9px;
    margin-top: 14px;
  }

  .score-row {
    border-radius: 14px;
    padding: 11px;
  }

  .question-content {
    padding: 18px;
    gap: 16px;
  }

  .question-big {
    font-size: clamp(1.35rem, 8vw, 2.35rem);
  }

  .primary-btn,
  .secondary-btn,
  .ghost-btn,
  .danger-btn,
  .success-btn {
    width: 100%;
  }
}

/* UI polish step: safer header, smoother lobby settings, cleaner spacing */
.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: clamp(12px, 2vw, 24px);
  margin-bottom: 22px;
  padding: 8px 0 10px;
}

.topbar-title {
  min-width: 0;
  max-width: 100%;
  overflow: visible;
  padding-right: 0.35em;
}

.site-logo {
  display: block;
  width: min(100%, 760px);
  height: auto;
  max-height: 220px;
  object-fit: contain;
}

@media (max-width: 980px) {
  .site-logo {
    width: min(100%, 620px);
    max-height: 180px;
  }
}

@media (max-width: 760px) {
  .site-logo {
    width: min(100%, 520px);
    max-height: 140px;
  }
}

.topbar h1 {
  display: block;
  max-width: 100%;
  margin: 0;
  padding: 0 0.08em 0.18em 0;
  font-size: clamp(2.1rem, 4.45vw, 4.85rem);
  line-height: 1.16;
  letter-spacing: -0.045em;
  overflow: visible;
  text-wrap: balance;
}

.game-header {
  margin-bottom: 18px;
}

#lobbyPanel {
  margin: 18px 0;
}

.game-layout {
  margin-top: 18px;
}

#lobbyPanel.hidden + .game-layout {
  margin-top: 0;
}

.template-actions {
  gap: 18px;
  margin-bottom: 18px;
}

.form-card,
.panel:not(.board-panel) {
  background: rgba(9, 14, 36, 0.68);
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.danger-btn,
.success-btn {
  border-width: 1px;
  box-shadow: none;
  text-shadow: none;
}

.primary-btn {
  border-color: rgba(167, 139, 250, 0.72);
  background: rgba(109, 40, 217, 0.92);
}

.secondary-btn {
  border-color: rgba(96, 165, 250, 0.72);
  background: rgba(29, 78, 216, 0.9);
}

.ghost-btn {
  border-color: rgba(147, 197, 253, 0.42);
  background: rgba(15, 23, 42, 0.34);
}

.lobby-settings-menu {
  overflow: hidden;
  transition: border-color 180ms ease, background 180ms ease;
}

.lobby-settings-content {
  display: grid;
  grid-template-rows: 0fr;
  gap: 0;
  max-height: none;
  min-width: min(78vw, 520px);
  opacity: 0;
  overflow: hidden;
  visibility: visible;
  pointer-events: none;
  transform: none;
  margin-top: 0;
  transition: grid-template-rows 320ms cubic-bezier(.22, 1, .36, 1), opacity 220ms ease, margin-top 320ms cubic-bezier(.22, 1, .36, 1);
}

.lobby-settings-content-inner {
  min-height: 0;
  overflow: hidden;
  display: grid;
  gap: 12px;
}

.lobby-settings-menu.open .lobby-settings-content {
  grid-template-rows: 1fr;
  opacity: 1;
  pointer-events: auto;
  margin-top: 12px;
}

.lobby-settings-toggle .chevron {
  transition: transform 260ms cubic-bezier(.22, 1, .36, 1);
}

@media (max-width: 980px) {
  .topbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-title {
    padding-right: 0;
  }

  .topbar h1 {
    font-size: clamp(2rem, 10.5vw, 4rem);
    letter-spacing: -0.035em;
  }

  .connection {
    width: 100%;
  }
}

@media (max-width: 760px) {
  .topbar h1 {
    font-size: clamp(1.95rem, 11.5vw, 3.3rem);
    line-height: 1.18;
  }

  .game-header,
  #lobbyPanel,
  .game-layout {
    margin-top: 14px;
    margin-bottom: 14px;
  }
}

/* Rejoin + validation polish */
.template-error-box {
  display: grid;
  gap: 12px;
  text-align: left;
}

.template-error-box > strong {
  color: #fecdd3;
  font-size: 1rem;
}

.template-error-groups {
  display: grid;
  gap: 12px;
  max-height: 360px;
  overflow: auto;
  padding-right: 4px;
}

.template-error-group {
  padding: 12px;
  border: 1px solid rgba(251, 113, 133, 0.28);
  border-radius: 16px;
  background: rgba(127, 29, 29, 0.14);
}

.template-error-group h4 {
  margin: 0 0 8px;
  color: #fecdd3;
  font-size: 0.95rem;
}

.template-error-group ul {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 18px;
  color: #ffe4e6;
  line-height: 1.38;
}

.rejoin-box {
  display: block;
}

.rejoin-card {
  display: grid;
  gap: 12px;
  margin-top: 2px;
  padding: 14px;
  border: 1px solid rgba(167, 139, 250, 0.36);
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.52);
}

.rejoin-card strong {
  color: #ddd6fe;
}

.rejoin-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.lobby-list {
  margin-bottom: 18px;
}

#startGameBtn {
  margin-top: 2px;
}

.lobby-player.disconnected,
.score-row.disconnected {
  opacity: 0.52;
  filter: grayscale(0.45);
}

.lobby-player.disconnected {
  border-color: rgba(148, 163, 184, 0.32);
  background: rgba(30, 41, 59, 0.42);
}

.score-row.disconnected {
  border-style: dashed;
  background: rgba(30, 41, 59, 0.34);
}

.score-row.disconnected .score-name::after {
  content: " offline";
  display: inline-block;
  margin-left: 8px;
  padding: 2px 7px;
  border: 1px solid rgba(148, 163, 184, 0.34);
  border-radius: 999px;
  color: #cbd5e1;
  font-size: 0.72rem;
  font-weight: 800;
  vertical-align: middle;
}

/* Smoother measured-height lobby dropdown */
.lobby-settings-content {
  display: block;
  max-height: 0;
  min-width: min(78vw, 520px);
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  transform: translateY(-4px);
  margin-top: 0;
  transition:
    max-height 360ms cubic-bezier(.22, 1, .36, 1),
    opacity 220ms ease,
    transform 260ms cubic-bezier(.22, 1, .36, 1),
    margin-top 320ms cubic-bezier(.22, 1, .36, 1);
}

.lobby-settings-menu.open .lobby-settings-content {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
  margin-top: 12px;
}

.lobby-settings-content-inner {
  min-height: 0;
  overflow: hidden;
}

.chevron-icon {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  transition: transform 260ms cubic-bezier(.22, 1, .36, 1);
}

.chevron-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lobby-settings-menu.open .chevron-icon {
  transform: rotate(180deg);
}

.toast {
  white-space: pre-line;
}

@media (max-width: 760px) {
  .rejoin-actions {
    grid-template-columns: 1fr;
  }

  .template-error-groups {
    max-height: 300px;
  }
}

/* Board name + double-board creation polish */
.second-board-option {
  margin: 18px 0 20px;
  align-items: flex-start;
}

.second-board-option small {
  display: block;
  margin-top: 3px;
  color: var(--muted-2);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.35;
}

.builder-grid {
  display: grid;
  gap: 22px;
}

.builder-board-section {
  display: grid;
  gap: 16px;
  border: 1px solid rgba(147, 197, 253, 0.16);
  border-radius: 24px;
  padding: clamp(14px, 2vw, 22px);
  background: rgba(9, 14, 36, 0.52);
}

.builder-board-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
}

.builder-board-heading h3 {
  margin-bottom: 6px;
}

.builder-grid-inner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

/* Board hover should have room for its glow/outline on all edges. */
.board-panel {
  overflow: visible;
}

.game-board {
  padding: 12px;
  margin: -12px;
}

/* Offline should only be shown once. */
.score-row.disconnected .score-name::after {
  content: none;
}

.offline-pill {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 7px;
  border: 1px solid rgba(148, 163, 184, 0.34);
  border-radius: 999px;
  color: #cbd5e1;
  font-size: 0.72rem;
  font-weight: 800;
  vertical-align: middle;
}

@media (max-width: 760px) {
  .builder-board-heading {
    display: block;
  }

  .game-board {
    padding: 10px;
    margin: -10px;
  }
}

/* Layout pass: move player/control area into the top game card and keep the board full-width. */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

.app-shell,
main,
#gameView,
.game-layout,
.game-header,
.board-panel {
  min-width: 0;
  max-width: 100%;
}

.game-header {
  display: grid;
  gap: 18px;
  align-items: stretch;
  overflow: visible;
}

.game-header::after {
  border-radius: inherit;
}

.game-header-main {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(160px, auto) minmax(260px, 520px);
  gap: 18px;
  align-items: center;
  min-width: 0;
}

.game-title-block {
  min-width: 0;
}

.game-title-block h2,
.game-title-block p {
  overflow-wrap: anywhere;
}

.game-header-tools {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(240px, 0.9fr) minmax(280px, 1.1fr);
  gap: 16px;
  align-items: stretch;
  min-width: 0;
}

.top-game-card {
  min-width: 0;
  border: 1px solid rgba(147, 197, 253, 0.18);
  border-radius: 20px;
  background: #080d25;
  padding: 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.055);
}

.top-game-card.hidden {
  display: none !important;
}

.players-card h3,
.top-game-card h3 {
  margin-bottom: 12px;
}

.players-card .score-list {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  align-items: stretch;
}

.players-card .score-row {
  min-width: 0;
}

.players-card .score-points {
  min-width: 48px;
  font-size: 1.05rem;
}

.host-controls,
.player-controls {
  margin-top: 0;
  gap: 12px;
  align-self: stretch;
}

.host-controls:not(.hidden),
.player-controls:not(.hidden) {
  display: grid;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  width: 100%;
}

.side-panel {
  display: none;
}

.board-panel {
  width: 100%;
  overflow: hidden;
  min-height: 560px;
}

.game-board {
  --board-cell-min: 128px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  padding: 14px;
  margin: 0;
  overscroll-behavior-x: contain;
  scroll-padding: 14px;
}

.board-cell,
.category-cell {
  min-width: 0;
}

.board-cell.selectable:hover,
.board-cell.active {
  position: relative;
  z-index: 2;
}

/* Keep dropdowns inside the viewport and animate height without clipping in the header. */
.host-lobby-settings,
.lobby-settings-menu,
.lobby-settings-content,
.lobby-settings-content-inner,
.host-transfer-box,
.inline-actions,
.settings-actions {
  min-width: 0;
  max-width: 100%;
}

.host-lobby-settings {
  width: 100%;
}

.lobby-settings-menu {
  overflow: visible;
  background: #080d25;
}

.lobby-settings-content {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.lobby-settings-content-inner {
  background: #080d25;
  border: 1px solid rgba(147, 197, 253, 0.12);
  border-radius: 16px;
  padding: 10px;
}

.settings-actions button,
.host-transfer-box button,
.host-transfer-box select {
  min-width: 0;
  white-space: normal;
}

/* Manual score tool should be a solid card, not translucent over another border. */
.manual-score-menu {
  background: #080d25;
  border-color: rgba(147, 197, 253, 0.26);
}

.manual-score-menu[open] {
  background: #080d25;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.24);
}

.manual-score-list {
  background: #080d25;
}

.manual-score-row {
  background: #0b1230;
  grid-template-columns: minmax(120px, 1fr) minmax(86px, 120px) auto minmax(86px, 120px) auto;
}

.manual-score-row > *,
.buzz-row > *,
.score-row > * {
  min-width: 0;
}

/* Avoid viewport-level horizontal scrolling caused by long labels/buttons. */
.primary-btn,
.secondary-btn,
.ghost-btn,
.danger-btn,
.success-btn,
.score-name,
.manual-score-row strong,
.manual-score-row span,
.buzz-row span {
  overflow-wrap: anywhere;
}

@media (max-width: 1180px) {
  .game-header-main {
    grid-template-columns: minmax(220px, 1fr) minmax(150px, auto);
  }

  .host-lobby-settings {
    grid-column: 1 / -1;
  }

  .game-header-tools {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .game-header-main {
    grid-template-columns: 1fr;
  }

  .code-card {
    width: 100%;
  }

  .game-board {
    --board-cell-min: 96px;
    padding: 12px;
  }

  .manual-score-row {
    grid-template-columns: 1fr 1fr;
  }

  .manual-score-row > div,
  .manual-score-row button {
    grid-column: span 2;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 14px, 1600px);
  }

  .game-header {
    gap: 14px;
  }

  .game-header-main,
  .game-header-tools {
    gap: 12px;
  }

  .top-game-card {
    padding: 13px;
    border-radius: 18px;
  }

  .players-card .score-list {
    grid-template-columns: 1fr;
  }

  .game-board {
    --board-cell-min: 74px;
    gap: 8px;
    padding: 10px;
  }

  .board-cell,
  .category-cell {
    min-height: 70px;
    padding: 8px;
  }

  .category-cell {
    font-size: clamp(0.72rem, 3.2vw, 0.9rem);
    letter-spacing: 0.015em;
  }

  .board-cell {
    font-size: clamp(1rem, 6vw, 1.55rem);
  }

  .cell-history {
    font-size: 0.64rem;
  }

  .cell-history strong,
  .cell-penalty {
    font-size: 0.65rem;
  }

  .settings-actions,
  .host-transfer-box .inline-actions,
  .manual-score-row {
    grid-template-columns: 1fr;
  }

  .manual-score-row > div,
  .manual-score-row button {
    grid-column: auto;
  }

  .lobby-settings-content-inner {
    padding: 8px;
  }
}

/* Header compaction: move the lobby code into the Online card and use the full top-card width. */
.app-shell {
  width: min(1760px, calc(100% - 24px));
}

.game-header {
  width: 100%;
}

.game-header-main {
  grid-template-columns: minmax(240px, 0.72fr) minmax(360px, 1.28fr);
  gap: 20px;
  width: 100%;
}

.host-lobby-settings {
  justify-self: stretch;
  width: 100%;
  max-width: none;
}

.lobby-settings-menu {
  width: 100%;
}

.game-header-tools {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
  align-items: stretch;
}

.top-game-card {
  width: 100%;
}

.players-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.players-card-header h3 {
  margin: 8px 0 0;
}

.code-card-inline {
  width: auto;
  min-width: 160px;
  max-width: 230px;
  padding: 9px 12px;
  border-radius: 16px;
  text-align: right;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.035));
}

.code-card-inline span {
  font-size: 0.72rem;
}

.code-card-inline strong {
  font-size: clamp(1.25rem, 2.1vw, 1.75rem);
  letter-spacing: 0.16em;
  line-height: 1.05;
}

@media (max-width: 1180px) {
  .game-header-main,
  .game-header-tools {
    grid-template-columns: 1fr;
  }

  .host-lobby-settings {
    grid-column: auto;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 12px, 1760px);
  }

  .players-card-header {
    align-items: stretch;
    flex-direction: column;
  }

  .code-card-inline {
    width: 100%;
    max-width: none;
    text-align: left;
  }
}

/* Final header + full-width game layout correction */
.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  width: 100%;
  gap: 18px;
}

.topbar-title {
  min-width: 0;
  overflow: visible;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-width: 0;
}

.topbar-code-card {
  min-width: 230px;
  padding: 10px 14px;
  border-radius: 18px;
  text-align: center;
  background: linear-gradient(180deg, rgba(30, 41, 86, 0.92), rgba(11, 18, 48, 0.88));
}

.topbar-code-card span {
  font-size: 0.75rem;
}

.topbar-code-card strong {
  font-size: clamp(1.35rem, 2vw, 1.85rem);
  line-height: 1.05;
}

.game-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
  align-items: stretch;
}

.game-header-main,
.game-header-tools {
  width: 100%;
  max-width: none;
}

.game-header-main {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 1fr);
  align-items: start;
}

.game-header-tools {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.host-lobby-settings,
.host-lobby-settings .lobby-settings-menu {
  justify-self: stretch;
  width: 100%;
  max-width: none;
}

.players-card-header {
  margin-bottom: 12px;
}

.players-card-header h3 {
  margin: 0;
}

.code-card-inline {
  display: none !important;
}

#lobbyPanel {
  display: grid;
  gap: 16px;
  margin: 18px 0;
  background:
    radial-gradient(circle at 90% 0%, rgba(124, 58, 237, 0.18), transparent 22rem),
    rgba(9, 14, 36, 0.76);
}

#lobbyPanel.hidden {
  display: none !important;
}

.lobby-card-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(147, 197, 253, 0.14);
}

.lobby-card-head h3 {
  margin-bottom: 4px;
}

.lobby-card-head p {
  margin-bottom: 0;
}

.lobby-start-btn {
  min-width: 180px;
}

#lobbyPanel .lobby-list {
  margin: 0;
  gap: 10px;
}

/* Collapsed question editor cards with completion state */
.question-builder {
  display: block;
  padding: 0;
  overflow: hidden;
  border-radius: 18px;
  background: rgba(13, 20, 54, 0.82);
}

.question-builder summary {
  list-style: none;
}

.question-builder summary::-webkit-details-marker {
  display: none;
}

.question-builder-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 12px;
  cursor: pointer;
}

.question-builder-summary::after {
  content: "";
  width: 9px;
  height: 9px;
  justify-self: end;
  border-right: 2px solid rgba(219, 234, 254, 0.8);
  border-bottom: 2px solid rgba(219, 234, 254, 0.8);
  transform: rotate(0deg);
  transition: transform 180ms ease;
}

.question-builder[open] .question-builder-summary::after {
  transform: rotate(180deg);
}

.builder-status {
  display: inline-flex;
  align-items: center;
  justify-self: end;
  gap: 6px;
  min-width: 0;
  border-radius: 999px;
  padding: 5px 9px;
  border: 1px solid currentColor;
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.builder-status.complete {
  color: #86efac;
  background: rgba(22, 101, 52, 0.22);
}

.builder-status.incomplete {
  color: #fca5a5;
  background: rgba(127, 29, 29, 0.22);
}

.builder-media-status {
  display: inline-grid;
  place-items: center;
  justify-self: end;
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  border-radius: 999px;
  border: 1px solid currentColor;
  font-size: 0.82rem;
  font-weight: 1000;
  line-height: 1;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.builder-media-status.missing-media {
  color: #fde68a;
  background: rgba(161, 98, 7, 0.24);
}

.builder-media-status.has-media {
  color: #86efac;
  background: rgba(22, 101, 52, 0.26);
}

.builder-media-status.has-media:hover,
.builder-media-status.missing-media:hover {
  transform: translateY(-1px);
}

.question-builder-body {
  display: grid;
  gap: 10px;
  padding: 0 14px 14px;
  border-top: 1px solid rgba(191, 219, 254, 0.12);
}

.question-builder-body label:first-child {
  margin-top: 14px;
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .topbar-actions {
    justify-content: stretch;
  }

  .topbar-actions > * {
    flex: 1 1 0;
  }

  .game-header-main,
  .game-header-tools,
  .lobby-card-head {
    grid-template-columns: 1fr;
  }

  .lobby-start-btn {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .topbar-actions {
    flex-direction: column;
  }

  .topbar-code-card,
  .connection {
    width: 100%;
  }

  .question-builder-summary {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .builder-status {
    justify-self: start;
  }

  .question-builder-summary::after {
    position: absolute;
    right: 18px;
    top: 24px;
  }
}

.question-builder-summary {
  position: relative;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
}

@media (max-width: 640px) {
  .question-builder-summary {
    grid-template-columns: 1fr auto auto;
  }
  .question-builder-summary .points-pill,
  .question-builder-summary .builder-status {
    grid-column: 1;
  }
  .question-builder-summary .builder-media-status {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
  }
  .question-builder-summary::after {
    grid-column: 3;
    grid-row: 1 / span 2;
    position: static;
    align-self: center;
  }
}

@media (max-width: 980px) and (min-width: 901px) {
  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    flex-direction: initial;
  }
  .connection {
    width: auto;
  }
}


/* Player score grid + winner celebration */
.players-card .score-list,
.score-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: stretch;
}

.score-list > .muted {
  grid-column: 1 / -1;
}

.score-row {
  min-width: 0;
}

.winner-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: radial-gradient(circle at 50% 45%, rgba(124, 58, 237, 0.32), rgba(3, 7, 18, 0.78) 62%, rgba(3, 7, 18, 0.92));
  backdrop-filter: blur(2px);
}

.winner-overlay.hidden {
  display: none !important;
}

.winner-popup {
  position: relative;
  z-index: 2;
  display: grid;
  justify-items: center;
  gap: 10px;
  width: min(92vw, 720px);
  padding: clamp(20px, 5vw, 56px);
  border: 0;
  background: transparent;
  color: #fff;
  text-align: center;
  box-shadow: none;
  text-shadow: 0 8px 32px rgba(0, 0, 0, 0.62);
  cursor: pointer;
  animation: winnerPop 720ms cubic-bezier(.18, 1.25, .28, 1) both;
}

.winner-popup:hover:not(:disabled) {
  transform: none;
  filter: none;
}

.winner-trophy {
  font-size: clamp(5rem, 18vw, 11rem);
  line-height: 1;
  filter: drop-shadow(0 22px 38px rgba(0, 0, 0, 0.42));
  animation: trophyFloat 2200ms ease-in-out infinite;
}

.winner-title {
  color: #bfdbfe;
  font-size: clamp(1.1rem, 3.5vw, 2rem);
  font-weight: 950;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.winner-popup strong {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: clamp(2.3rem, 9vw, 5.8rem);
  line-height: 0.96;
  letter-spacing: -0.06em;
}

.winner-popup span:not(.winner-trophy):not(.winner-title) {
  color: #dbeafe;
  font-size: clamp(1.1rem, 3vw, 1.75rem);
  font-weight: 900;
}

.winner-popup small {
  margin-top: 8px;
  color: rgba(219, 234, 254, 0.72);
  font-weight: 750;
}

.confetti-field {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.confetti-field span {
  position: absolute;
  top: -12vh;
  left: calc(var(--x) * 1%);
  width: 10px;
  height: 18px;
  border-radius: 4px;
  background: hsl(calc(var(--i) * 47), 92%, 66%);
  transform: rotate(var(--r));
  animation: confettiFall var(--d) linear infinite;
  animation-delay: calc(var(--i) * -0.095s);
  opacity: 0.92;
}

.confetti-field span:nth-child(3n) {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.confetti-field span:nth-child(4n) {
  width: 14px;
  height: 7px;
}

@keyframes confettiFall {
  0% {
    translate: 0 -12vh;
    rotate: 0deg;
  }
  100% {
    translate: calc((50 - var(--x)) * 0.5vw) 122vh;
    rotate: 760deg;
  }
}

@keyframes winnerPop {
  from {
    opacity: 0;
    scale: 0.78;
  }
  to {
    opacity: 1;
    scale: 1;
  }
}

@keyframes trophyFloat {
  0%, 100% {
    transform: translateY(0) rotate(-2deg);
  }
  50% {
    transform: translateY(-10px) rotate(2deg);
  }
}

@media (max-width: 760px) {
  .players-card .score-list,
  .score-list {
    grid-template-columns: 1fr;
  }

  .winner-popup small {
    display: none;
  }
}

.question-host-actions {
  display: grid;
  gap: 10px;
  margin-top: 0;
  padding: clamp(12px, 1.6vw, 16px);
  border: 1px solid rgba(147, 197, 253, 0.22);
  border-radius: 22px;
  background: #080d25;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.055);
}

.question-host-actions-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: #dbeafe;
}

.question-host-actions-head strong {
  font-size: 1rem;
  font-weight: 1000;
}

.question-host-actions-head span {
  color: #b8c7ee;
  font-size: 0.92rem;
}

.question-action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.question-action-grid.compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.question-action-grid button,
.question-buzz-row button {
  min-height: 46px;
}

.question-buzz-list {
  display: grid;
  gap: 10px;
}

.question-buzz-row {
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(147, 197, 253, 0.14);
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.72);
}

.question-buzz-row > strong {
  color: #93c5fd;
}

.question-buzz-row > span {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 900;
}

@media (max-width: 820px) {
  .question-host-actions-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .question-action-grid,
  .question-action-grid.compact,
  .question-buzz-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .question-builder-summary {
    grid-template-columns: 1fr auto auto;
  }

  .question-builder-summary .points-pill {
    grid-column: 1 / -1;
    width: max-content;
  }

  .builder-status {
    justify-self: start;
  }
}

/* Host + player emoji polish */
.players-card .score-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.score-row.host-row {
  border-color: rgba(245, 215, 110, 0.72);
  background: linear-gradient(135deg, rgba(245, 215, 110, 0.18), rgba(124, 58, 237, 0.12));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 0 28px rgba(245, 215, 110, 0.10);
}

.score-row.host-row .score-name {
  color: #fff7cc;
}

.host-crown,
.player-round-emoji {
  display: inline-block;
  margin-left: 0.45rem;
  line-height: 1;
  vertical-align: -0.08em;
}

.score-subline {
  display: block;
  margin-top: 3px;
  color: #f8e9a1;
  font-size: 0.76rem;
  font-weight: 800;
}

.score-points.host-label {
  min-width: auto;
  color: #f8e9a1;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.lobby-player .player-round-emoji {
  margin-left: 0.25rem;
}

@media (max-width: 760px) {
  .players-card .score-list {
    grid-template-columns: 1fr;
  }
}

/* Viewport-centered question modal: grow as needed, scroll only above 90vh. */
.question-panel {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: clamp(12px, 2.2vw, 28px);
  pointer-events: none;
}

.question-panel::before {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 35%, rgba(3, 7, 18, 0.18), rgba(3, 7, 18, 0.66));
}

.question-overlay-card {
  width: min(1040px, calc(100vw - clamp(24px, 4.4vw, 56px)));
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.question-content {
  align-items: center;
}

.question-media {
  width: min(100%, 900px);
  max-height: min(52vh, 520px);
}

@media (max-height: 760px) {
  .question-overlay-card {
    padding: clamp(14px, 2vh, 24px);
  }

  .question-big {
    font-size: clamp(1.35rem, 4.8vh, 2.5rem);
  }

.question-media {
    max-height: 42vh;
  }
}

@media (max-width: 640px) {
  .question-panel {
    padding: 10px;
  }

  .question-overlay-card {
    width: calc(100vw - 20px);
    max-height: 90vh;
    border-radius: 22px;
  }

.question-media {
    max-height: 36vh;
  }
}

/* Advanced question types + true viewport modal */
.question-panel {
  position: fixed !important;
  inset: 0 !important;
  z-index: 950 !important;
  display: grid !important;
  place-items: center !important;
  padding: clamp(12px, 2vw, 28px) !important;
  pointer-events: none;
}

.question-panel.hidden {
  display: none !important;
}

.question-panel::before {
  content: "";
  position: fixed !important;
  inset: 0 !important;
  background: radial-gradient(circle at 50% 40%, rgba(9, 14, 36, 0.38), rgba(3, 7, 18, 0.76));
  backdrop-filter: blur(2px);
  pointer-events: none;
}

.question-overlay-card {
  position: relative !important;
  width: min(1080px, calc(100vw - clamp(24px, 4vw, 56px))) !important;
  max-height: 90vh !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  border-radius: clamp(22px, 3vw, 34px) !important;
  padding: clamp(16px, 2.4vw, 32px) !important;
  pointer-events: auto;
  scrollbar-gutter: stable;
}

.question-content {
  padding: 0 !important;
  align-items: stretch !important;
  gap: clamp(10px, 1.35vw, 16px) !important;
}

.question-headline-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
}

.question-timer {
  min-width: 124px;
  border: 1px solid rgba(245, 215, 110, 0.42);
  border-radius: 999px;
  padding: 9px 12px;
  background: rgba(245, 215, 110, 0.12);
  color: #fde68a;
  font-weight: 1000;
  text-align: center;
  white-space: nowrap;
}

.question-waiting {
  border: 1px dashed rgba(245, 215, 110, 0.42);
  border-radius: 18px;
  padding: 13px 14px;
  background: rgba(245, 215, 110, 0.10);
  color: #fde68a;
  font-weight: 900;
  text-align: center;
}

.question-waiting.subtle {
  border-color: rgba(147, 197, 253, 0.24);
  background: rgba(56, 189, 248, 0.08);
  color: #bfdbfe;
}

.question-hidden-text {
  color: rgba(219, 234, 254, 0.72);
  font-size: clamp(1.2rem, 3vw, 2.2rem) !important;
}

.question-media {
  justify-self: center;
  width: min(100%, 920px) !important;
  max-height: min(44vh, 430px) !important;
  object-fit: contain !important;
}

.question-media.pixelate-strong {
  filter: blur(26px) contrast(1.2);
  image-rendering: pixelated;
}

.question-media.pixelate-medium {
  filter: blur(14px) contrast(1.16);
  image-rendering: pixelated;
}

.question-media.pixelate-light {
  filter: blur(6px) contrast(1.1);
  image-rendering: pixelated;
}

.media-progress {
  justify-self: center;
  width: max-content;
  border: 1px solid rgba(147, 197, 253, 0.28);
  border-radius: 999px;
  padding: 5px 10px;
  color: #bfdbfe;
  background: rgba(56, 189, 248, 0.08);
  font-weight: 850;
}

.question-release-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.audio-filter-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.compact-checkbox {
  padding: 9px 10px;
  margin: 0;
  border-radius: 12px;
}

.category-cooldown-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
  gap: 10px;
  align-items: end;
  margin-top: 12px;
}

.cooldown-seconds-label {
  margin: 0;
}

.cooldown-seconds-label input {
  margin-top: 8px;
  padding: 9px 10px;
  border-radius: 12px;
}

.audio-filter-badges {
  width: max-content;
  max-width: 100%;
  border: 1px solid rgba(167, 139, 250, 0.34);
  border-radius: 999px;
  padding: 6px 10px;
  color: #ddd6fe;
  background: rgba(124, 58, 237, 0.16);
  font-weight: 850;
  font-size: 0.86rem;
}

.text-answer-monitor,
.player-text-input-box,
.revealed-submissions {
  display: grid;
  gap: 10px;
  border: 1px solid rgba(147, 197, 253, 0.22);
  border-radius: 18px;
  padding: 14px;
  background: #080d25;
}

.text-answer-row {
  display: grid;
  grid-template-columns: minmax(90px, 0.35fr) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border-radius: 12px;
  background: rgba(255,255,255,0.055);
}

.text-answer-row span {
  color: #bfdbfe;
  font-weight: 850;
}

.text-answer-row b {
  overflow-wrap: anywhere;
}

@media (max-height: 760px) {

.question-media {
    max-height: min(34vh, 320px) !important;
  }
  .question-big {
    font-size: clamp(1.25rem, 4.8vh, 2.4rem) !important;
  }
}

@media (max-width: 720px) {
  .question-panel {
    padding: 10px !important;
  }
  .question-overlay-card {
    width: calc(100vw - 20px) !important;
    max-height: 90vh !important;
  }
  .question-headline-row,
  .category-cooldown-row,
  .text-answer-row {
    grid-template-columns: 1fr;
  }
  .question-timer {
    justify-self: start;
  }
  .question-release-actions,
  .question-release-actions button {
    width: 100%;
  }
  .audio-filter-options {
    grid-template-columns: 1fr;
  }

.question-media {
    max-height: 32vh !important;
  }
}

/* Release visibility indicators, reveal review flow, and draggable multi-image ordering */
.released-section {
  position: relative;
  min-width: 0;
}

.question-text-released-section {
  border-radius: 22px;
}

.release-eye {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  color: #dbeafe;
  background: rgba(15, 23, 42, 0.84);
  border: 1px solid rgba(147, 197, 253, 0.36);
  box-shadow: 0 12px 28px rgba(0,0,0,0.28);
  font-size: 0.95rem;
  pointer-events: none;
}

.question-text-released-section .release-eye {
  top: 6px;
  right: 6px;
}

.question-text-released-section .question-big {
  padding-right: 42px;
}

.media-released-section {
  display: grid;
  justify-items: center;
}

.media-released-section .release-eye {
  top: 12px;
  right: max(12px, calc((100% - min(100%, 920px)) / 2 + 12px));
}

.question-overlay-card {
  max-height: 90vh !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

.question-media {
  max-height: min(38vh, 380px) !important;
}

.question-release-actions {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.question-release-actions .release-left,
.question-release-actions .release-right {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
}

.question-release-actions .release-right {
  justify-content: flex-end;
}

.resolve-btn {
  appearance: none;
  border: 1px solid rgba(253, 224, 71, 0.58);
  border-radius: 14px;
  padding: 12px 16px;
  color: #111827;
  background: linear-gradient(135deg, #fde047, #facc15);
  font-weight: 950;
  cursor: pointer;
  box-shadow: 0 14px 34px rgba(250, 204, 21, 0.18);
}

.resolve-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

.audio-filter-badges.clean {
  border-color: rgba(74, 222, 128, 0.44);
  color: #bbf7d0;
  background: rgba(34, 197, 94, 0.16);
}

.review-actions {
  border-color: rgba(253, 224, 71, 0.34) !important;
  background: rgba(253, 224, 71, 0.08) !important;
}

.media-sort-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
  padding: 10px;
  border: 1px solid rgba(147, 197, 253, 0.18);
  border-radius: 16px;
  background: rgba(8, 13, 37, 0.48);
}

.media-sort-item {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(167, 139, 250, 0.22);
  background: #080d25;
  cursor: grab;
  user-select: none;
}

.media-sort-item:active {
  cursor: grabbing;
}

.media-sort-item.dragging {
  opacity: 0.55;
}

.media-sort-item.drag-over {
  border-color: rgba(56, 189, 248, 0.7);
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.32);
}

.drag-handle {
  color: #a78bfa;
  font-weight: 900;
}

.media-sort-order {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: rgba(124, 58, 237, 0.25);
  color: #ddd6fe;
  font-weight: 950;
}

.media-sort-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #dbeafe;
  font-weight: 800;
}

@media (max-width: 720px) {
  .question-release-actions {
    grid-template-columns: 1fr;
  }
  .question-release-actions .release-left,
  .question-release-actions .release-right,
  .question-release-actions button,
  .resolve-btn {
    width: 100%;
  }

.question-media {
    max-height: min(32vh, 320px) !important;
  }
  .release-eye {
    width: 28px;
    height: 28px;
    font-size: 0.86rem;
  }
}

.custom-audio-player {
  max-width: 100%;
}

.custom-audio-controls {
  display: grid;
  grid-template-columns: auto auto minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
}

.compact-audio-btn {
  min-height: 38px;
  padding: 9px 13px;
  white-space: nowrap;
}

.audio-seek {
  width: 100%;
  min-width: 0;
  accent-color: #8b5cf6;
  background: transparent;
  box-shadow: none;
  padding: 0;
}

.audio-time {
  color: #dbeafe;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  white-space: nowrap;
}

@media (max-width: 700px) {
  .custom-audio-controls {
    grid-template-columns: 1fr 1fr;
  }

  .audio-seek,
  .audio-time {
    grid-column: 1 / -1;
  }

  .compact-audio-btn {
    width: 100%;
  }
}

/* Host hash + board test mode + host volume */
.topbar-template-hash {
  display: block;
  margin-top: 7px;
  font-size: 0.7rem;
  line-height: 1.25;
  color: rgba(219, 234, 254, 0.82);
  word-break: break-all;
}

.topbar-template-hash.hidden {
  display: none;
}

.topbar-template-hash b {
  display: inline-block;
  max-width: 155px;
  overflow-wrap: anywhere;
  vertical-align: text-top;
  font-weight: 800;
  color: #fde68a;
}

.board-cell.testable {
  cursor: pointer;
  position: relative;
}

.board-cell.testable:hover,
.board-cell.testable:focus-visible {
  transform: translateY(-2px) scale(1.012);
  border-color: rgba(250, 204, 21, 0.9);
  box-shadow: 0 0 0 1px rgba(250, 204, 21, 0.48), 0 20px 42px rgba(147, 51, 234, 0.32);
}

.cell-test-label {
  position: absolute;
  right: 10px;
  bottom: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(250, 204, 21, 0.72);
  background: rgba(250, 204, 21, 0.16);
  color: #fef3c7;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  pointer-events: none;
}

.test-mode-actions {
  border-color: rgba(250, 204, 21, 0.28) !important;
  background: rgba(250, 204, 21, 0.09) !important;
}

.host-volume-row {
  display: grid;
  grid-template-columns: auto minmax(160px, 1fr);
  gap: 12px;
  align-items: center;
  margin: 0;
  color: #dbeafe;
}

.host-volume-row span {
  white-space: nowrap;
  font-size: 0.95rem;
}

@media (max-width: 640px) {
  .host-volume-row {
    grid-template-columns: 1fr;
  }

  .topbar-template-hash {
    font-size: 0.62rem;
  }

  .cell-test-label {
    right: 6px;
    bottom: 6px;
    min-width: 36px;
    padding: 3px 6px;
    font-size: 0.62rem;
  }
}

/* Popup buzzer + disabled host decisions */
.question-headline-tools {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  min-width: 0;
}

.popup-buzz-button {
  appearance: none;
  border: 1px solid rgba(248, 113, 113, 0.52);
  border-radius: 999px;
  padding: 9px 12px;
  min-height: 0;
  color: #fff;
  background: linear-gradient(135deg, #ef4444, #7c3aed 68%, #2563eb);
  font-size: 0.88rem;
  line-height: 1;
  font-weight: 1000;
  letter-spacing: 0.02em;
  box-shadow: 0 12px 34px rgba(124, 58, 237, 0.28), 0 0 28px rgba(239, 68, 68, 0.22);
  cursor: pointer;
  white-space: nowrap;
}

.popup-buzz-button small {
  display: block;
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.62rem;
  letter-spacing: 0;
}

.popup-buzz-button.ready {
  animation: popupBuzzPulse 0.9s infinite alternate ease-in-out;
}

.popup-buzz-button:disabled,
.popup-buzz-button.is-disabled {
  color: rgba(226, 232, 240, 0.72);
  border-color: rgba(148, 163, 184, 0.24);
  background: linear-gradient(135deg, rgba(51, 65, 85, 0.88), rgba(30, 41, 59, 0.88));
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.72;
  filter: grayscale(0.7);
  animation: none;
}

.popup-buzz-button:disabled small,
.popup-buzz-button.is-disabled small {
  color: rgba(203, 213, 225, 0.64);
}

.popup-buzz-status {
  border: 1px solid rgba(147, 197, 253, 0.22);
  border-radius: 999px;
  padding: 8px 11px;
  color: #bfdbfe;
  background: rgba(15, 23, 42, 0.82);
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

@keyframes popupBuzzPulse {
  from { transform: scale(1); box-shadow: 0 12px 34px rgba(124, 58, 237, 0.24); }
  to { transform: scale(1.045); box-shadow: 0 16px 44px rgba(239, 68, 68, 0.35), 0 0 35px rgba(56, 189, 248, 0.22); }
}

.resolve-btn:disabled,
.success-btn:disabled,
.danger-btn:disabled,
.question-action-grid button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.75);
  opacity: 0.42;
  transform: none !important;
  box-shadow: none !important;
}

.resolve-btn:hover:disabled {
  transform: none;
  filter: grayscale(0.75);
}

@media (max-width: 720px) {
  .question-headline-tools {
    align-items: flex-start;
  }

  .popup-buzz-button,
  .popup-buzz-status {
    justify-self: start;
  }
}

/* Recent browser-saved template hashes on start screen */
.recent-templates-box {
  display: grid;
  gap: 12px;
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid rgba(191, 219, 254, 0.14);
}

.recent-templates-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  color: #e0e7ff;
}

.recent-templates-head span {
  color: #94a3b8;
  font-size: 0.82rem;
  font-weight: 750;
}

.recent-template-list {
  display: grid;
  gap: 10px;
}

.recent-template-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 11px;
  border: 1px solid rgba(147, 197, 253, 0.16);
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.58);
}

.recent-template-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, max-content));
  justify-content: end;
  gap: 8px;
  min-width: 0;
}

.recent-template-actions .small-btn {
  min-width: 0;
  max-width: 100%;
  white-space: normal;
  line-height: 1.12;
}

.recent-template-info {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.recent-template-info strong {
  color: #f8fafc;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-template-info code {
  width: max-content;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #bfdbfe;
  font-size: 0.78rem;
  background: rgba(30, 41, 59, 0.86);
  border: 1px solid rgba(147, 197, 253, 0.14);
  border-radius: 999px;
  padding: 4px 8px;
}

.small-btn {
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.86rem;
}

.judgement-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-radius: 18px;
  padding: 13px 15px;
  font-weight: 950;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: rgba(15, 23, 42, 0.72);
}

.judgement-banner.correct {
  color: #dcfce7;
  border-color: rgba(34, 197, 94, 0.48);
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.20), rgba(15, 23, 42, 0.74));
}

.judgement-banner.wrong {
  color: #fee2e2;
  border-color: rgba(248, 113, 113, 0.48);
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.20), rgba(15, 23, 42, 0.74));
}

.judgement-banner.host {
  color: #e0e7ff;
}

.judgement-banner span {
  white-space: nowrap;
}

@media (max-width: 860px) {
  .recent-template-row {
    grid-template-columns: 1fr;
  }

  .recent-template-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    justify-content: stretch;
  }

  .recent-template-row .small-btn {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .recent-template-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .judgement-banner {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* Host reconnect / running instances / save feedback */
.running-instances-box {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid rgba(250, 204, 21, 0.28);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(250, 204, 21, 0.10), rgba(124, 58, 237, 0.10));
}

.running-instance-row {
  border-color: rgba(250, 204, 21, 0.22);
}

.running-instance-actions {
  grid-template-columns: repeat(2, minmax(0, max-content));
}

.button-spinner,
.large-spinner {
  display: inline-block;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.30);
  border-top-color: rgba(255, 255, 255, 0.95);
  animation: kb-spin 760ms linear infinite;
}

.button-spinner {
  width: 1em;
  height: 1em;
  margin-right: 0.45rem;
  vertical-align: -0.15em;
}

.large-spinner {
  width: 44px;
  height: 44px;
  border-width: 3px;
  border-color: rgba(168, 85, 247, 0.22);
  border-top-color: rgba(250, 204, 21, 0.95);
}

@keyframes kb-spin {
  to { transform: rotate(360deg); }
}

button.is-loading {
  cursor: wait;
}

.saving-box {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.85rem 0.95rem;
  width: 100%;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(168, 85, 247, 0.25);
}

.host-disconnected-overlay {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(10px);
}

.host-disconnected-overlay.hidden {
  display: none;
}

.host-disconnected-card {
  width: min(460px, 100%);
  display: grid;
  gap: 14px;
  justify-items: center;
  text-align: center;
  padding: 30px 24px;
  border-radius: 26px;
  color: #f8fafc;
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.96), rgba(49, 46, 129, 0.94));
  box-shadow: 0 24px 80px rgba(2, 6, 23, 0.55);
  border: 1px solid rgba(250, 204, 21, 0.22);
}

.host-disconnected-card h2 {
  margin: 0;
  font-size: clamp(1.4rem, 4vw, 2.15rem);
}

.host-disconnected-card p {
  margin: 0;
  color: rgba(226, 232, 240, 0.82);
  line-height: 1.45;
}

@media (max-width: 680px) {
  .running-instance-actions,
  .recent-template-actions.running-instance-actions {
    grid-template-columns: 1fr;
  }

  .running-instance-actions .small-btn {
    width: 100%;
  }

  .host-disconnected-card {
    padding: 24px 18px;
    border-radius: 22px;
  }
}

/* Spieler-Eingabe: gleichzeitige Antworten + gezielte Punktevergabe */
.text-input-award-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.text-input-award-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(147, 197, 253, 0.16);
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.72);
}

.text-input-award-row > div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.text-input-award-row strong {
  color: #dbeafe;
  font-weight: 950;
}

.text-input-award-row span {
  color: #bfdbfe;
  overflow-wrap: anywhere;
  font-size: 0.92rem;
}

.text-input-award-row .success-btn {
  white-space: nowrap;
}

@media (max-width: 900px) {
  .text-input-award-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .text-input-award-row {
    grid-template-columns: 1fr;
  }

  .text-input-award-row .success-btn {
    width: 100%;
  }
}

.question-buzz-row {
  grid-template-columns: auto minmax(120px, 1fr) auto auto auto;
}

.question-buzz-row.is-current {
  border-color: rgba(34, 211, 238, 0.42);
  background: rgba(14, 32, 72, 0.78);
}

.question-buzz-row.is-waiting {
  opacity: 0.78;
}

.buzz-player-name {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 900;
}

.buzz-time {
  justify-self: start;
  padding: 6px 9px;
  border-radius: 999px;
  border: 1px solid rgba(251, 191, 36, 0.32);
  background: rgba(251, 191, 36, 0.1);
  color: #fde68a;
  font-size: 0.84rem;
  font-weight: 950;
  white-space: nowrap;
}

.buzz-waiting-note {
  justify-self: end;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  color: #b8c7ee;
  background: rgba(15, 23, 42, 0.7);
  font-size: 0.82rem;
  font-weight: 850;
  white-space: nowrap;
}

.public-buzz-list {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid rgba(147, 197, 253, 0.18);
  background: rgba(7, 12, 33, 0.72);
}

.public-buzz-list > strong {
  color: #dbeafe;
  font-size: 0.92rem;
}

.public-buzz-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.58);
  border: 1px solid rgba(147, 197, 253, 0.1);
}

.public-buzz-row.current {
  border-color: rgba(34, 211, 238, 0.34);
  background: rgba(37, 99, 235, 0.16);
}

.public-buzz-row span {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 850;
}

.public-buzz-row b {
  color: #fde68a;
  white-space: nowrap;
}

@media (max-width: 820px) {
  .question-buzz-row {
    grid-template-columns: 1fr;
  }

  .buzz-waiting-note,
  .buzz-time {
    justify-self: start;
  }
}

/* Desktop viewport fit: keep the active game inside 100vh without requiring browser zoom. */
@media (min-width: 1024px) {
  body.game-active {
    height: 100dvh;
    overflow: hidden;
  }

  body.game-active .app-shell {
    width: min(1840px, calc(100% - 28px));
    height: 100dvh;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 12px;
    padding: 14px 0;
  }

  body.game-active .topbar {
    margin: 0;
    padding: 0;
    min-height: 0;
    gap: 14px;
  }

  body.game-active h1 {
    font-size: clamp(2.35rem, 3.35vw, 4rem);
    line-height: 1.02;
    letter-spacing: -0.055em;
    padding-bottom: 0.06em;
  }

  body.game-active .topbar-code-card {
    min-width: 210px;
    padding: 8px 12px;
    border-radius: 16px;
  }

  body.game-active .topbar-code-card strong {
    font-size: clamp(1.15rem, 1.45vw, 1.55rem);
  }

  body.game-active .connection {
    min-width: 98px;
    padding: 10px 14px;
    border-radius: 16px;
  }

  body.game-active main,
  body.game-active #gameView {
    min-height: 0;
    height: 100%;
    overflow: hidden;
  }

  body.game-active #gameView:not(.hidden) {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    gap: 12px;
  }

  body.game-active .game-header.panel {
    min-height: 0;
    padding: 14px 18px;
    border-radius: 22px;
  }

  body.game-active .game-header {
    gap: 12px;
  }

  body.game-active .game-header-main,
  body.game-active .game-header-tools {
    gap: 12px;
  }

  body.game-active .game-title-block h2 {
    margin-bottom: 4px;
    font-size: clamp(1.45rem, 2.05vw, 2.35rem);
  }

  body.game-active .game-title-block p {
    margin-bottom: 0;
  }

  body.game-active .eyebrow {
    margin-bottom: 8px;
    padding: 5px 9px;
  }

  body.game-active .top-game-card {
    padding: 12px;
    border-radius: 17px;
    min-height: 0;
    max-height: min(28dvh, 245px);
    overflow: auto;
  }

  body.game-active .players-card .score-list,
  body.game-active .score-list {
    gap: 8px;
  }

  body.game-active .score-row {
    min-height: 0;
    padding: 9px 10px;
    border-radius: 14px;
  }

  body.game-active .score-subline {
    margin-top: 1px;
  }

  body.game-active #lobbyPanel {
    margin: 0;
    padding: 14px 18px;
    border-radius: 22px;
    min-height: 0;
    max-height: min(18dvh, 150px);
    overflow: auto;
  }

  body.game-active .lobby-card-head {
    padding-bottom: 10px;
  }

  body.game-active .game-layout {
    min-height: 0;
    height: 100%;
    overflow: hidden;
  }

  body.game-active .board-panel {
    min-height: 0;
    height: 100%;
    padding: 10px;
    border-radius: 22px;
    display: flex;
    overflow: visible;
  }

  body.game-active .game-board {
    --board-cell-min: 110px;
    flex: 1 1 auto;
    height: 100%;
    min-height: 0;
    display: grid;
    grid-auto-rows: minmax(0, 1fr);
    gap: 8px;
    padding: 10px;
    overflow: visible;
  }

  body.game-active .category-cell,
  body.game-active .board-cell {
    min-height: 0;
    height: auto;
    border-radius: 15px;
    padding: 8px;
  }

  body.game-active .category-cell {
    font-size: clamp(0.72rem, 0.85vw, 0.98rem);
    line-height: 1.15;
  }

  body.game-active .board-cell {
    font-size: clamp(1.05rem, 1.45vw, 1.8rem);
    line-height: 1.05;
  }

  body.game-active .cell-history {
    font-size: clamp(0.62rem, 0.75vw, 0.82rem);
  }

  body.game-active .cell-history strong {
    font-size: clamp(0.68rem, 0.85vw, 0.9rem);
  }
}

@media (min-width: 1024px) and (max-width: 1450px) {
  body.game-active h1 {
    font-size: clamp(2rem, 3vw, 3.1rem);
  }

  body.game-active .game-board {
    --board-cell-min: 92px;
    gap: 7px;
    padding: 8px;
  }

  body.game-active .category-cell,
  body.game-active .board-cell {
    border-radius: 13px;
    padding: 7px;
  }
}

@media (min-width: 1024px) and (max-height: 850px) {
  body.game-active .app-shell {
    padding: 10px 0;
    gap: 8px;
  }

  body.game-active #gameView:not(.hidden) {
    gap: 8px;
  }

  body.game-active .game-header.panel {
    padding: 10px 14px;
  }

  body.game-active .game-header,
  body.game-active .game-header-main,
  body.game-active .game-header-tools {
    gap: 8px;
  }

  body.game-active .top-game-card {
    padding: 9px;
    max-height: min(25dvh, 200px);
  }

  body.game-active #lobbyPanel {
    padding: 10px 14px;
    max-height: min(16dvh, 120px);
  }

  body.game-active .board-panel {
    padding: 8px;
  }

  body.game-active .game-board {
    gap: 6px;
    padding: 7px;
  }
}

/* Startscreen polish: username first, join action more prominent than hosting */
.home-join-card {
  gap: 18px;
}

.account-box {
  display: grid;
  gap: 10px;
}

.account-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.9fr) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border-radius: 18px;
  background: rgba(30, 41, 59, 0.46);
  border: 1px solid rgba(147, 197, 253, 0.16);
}

.account-panel.logged-in {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  border-color: rgba(250, 204, 21, 0.32);
  background: linear-gradient(135deg, rgba(113, 63, 18, 0.22), rgba(15, 23, 42, 0.52));
}

.account-copy {
  display: grid;
  gap: 3px;
}

.account-copy span {
  color: #94a3b8;
  font-size: 0.86rem;
  line-height: 1.35;
}

.account-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.account-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.username-hero-field {
  display: grid;
  gap: 8px;
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.22), rgba(14, 165, 233, 0.08));
  border: 1px solid rgba(191, 219, 254, 0.2);
}

.username-hero-field label {
  color: #bfdbfe;
  font-size: 0.92rem;
  letter-spacing: 0.02em;
}

.username-hero-field input {
  font-size: 1.12rem;
  min-height: 50px;
}

.join-hero-box {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(230px, 0.82fr);
  gap: 14px;
  align-items: end;
  padding: 16px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.22), rgba(124, 58, 237, 0.16));
  border: 1px solid rgba(96, 165, 250, 0.26);
}

.join-hero-box input {
  min-height: 54px;
  font-size: 1.35rem;
  font-weight: 950;
  letter-spacing: 0.18em;
  text-align: center;
}

.join-primary-btn {
  min-height: 54px;
  font-size: 1.02rem;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  border-color: rgba(191, 219, 254, 0.5);
}

.home-template-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.template-create-btn {
  min-height: 48px;
}

.host-secondary-btn {
  opacity: 0.88;
}

/* Recent hashes and favorites */
.recent-template-row {
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.favorite-star {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid rgba(250, 204, 21, 0.38);
  background: rgba(15, 23, 42, 0.42);
  color: #facc15;
  font-size: 1.1rem;
  cursor: pointer;
}

.favorite-star.active {
  background: rgba(250, 204, 21, 0.18);
  box-shadow: 0 0 0 1px rgba(250, 204, 21, 0.15) inset;
}

.favorites-box {
  border-top-color: rgba(250, 204, 21, 0.22);
}

.button-spinner {
  width: 1em;
  height: 1em;
  display: inline-block;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.36);
  border-top-color: currentColor;
  animation: spin 780ms linear infinite;
  vertical-align: -0.15em;
  margin-right: 0.45em;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Custom hash delete modal */
.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(2, 6, 23, 0.68);
  backdrop-filter: blur(10px);
}

.confirm-overlay.hidden {
  display: none !important;
}

.confirm-card {
  width: min(480px, 100%);
  display: grid;
  gap: 12px;
  padding: 22px;
  border-radius: 22px;
  background: #080d25;
  border: 1px solid rgba(191, 219, 254, 0.18);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
}

.confirm-card > strong {
  font-size: 1.16rem;
  color: #f8fafc;
}

.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* Builder summary: avoid overlap in narrow category columns */
.question-builder-summary {
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "points arrow"
    "status media";
  align-items: center;
  row-gap: 8px;
}

.question-builder-summary .points-pill {
  grid-area: points;
  justify-self: start;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.question-builder-summary .builder-status {
  grid-area: status;
  justify-self: start;
  max-width: 100%;
  overflow: hidden;
}

.question-builder-summary .builder-media-status {
  grid-area: media;
}

.question-builder-summary::after {
  grid-area: arrow;
}

.text-input-award-row.already-awarded {
  border-color: rgba(34, 197, 94, 0.36);
  background: rgba(22, 101, 52, 0.16);
}

.player-leave-btn {
  margin-top: 8px;
  justify-self: start;
}

@media (max-width: 920px) {
  .account-panel {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .account-actions {
    justify-content: stretch;
  }

  .account-actions > button {
    flex: 1 1 160px;
  }

  .join-hero-box {
    grid-template-columns: 1fr;
  }

  .recent-template-row {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .recent-template-actions {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    justify-content: stretch;
  }
}

@media (max-width: 560px) {
  .account-fields,
  .recent-template-actions {
    grid-template-columns: 1fr;
  }

  .confirm-actions {
    flex-direction: column;
  }

  .confirm-actions > button,
  .join-primary-btn,
  .host-secondary-btn {
    width: 100%;
  }
}

/* Fix: headline/logo must never be clipped. */
.topbar,
.topbar-title,
.topbar h1,
.topbar .site-logo,
body.game-active .topbar,
body.game-active .topbar-title,
body.game-active h1,
body.game-active .site-logo {
  overflow: visible !important;
}

.topbar h1,
body.game-active h1 {
  line-height: 1.22 !important;
  padding-top: 0.04em !important;
  padding-bottom: 0.24em !important;
}

.topbar .site-logo,
body.game-active .site-logo {
  margin-top: 0.08rem;
  margin-bottom: 0.12rem;
}

body.game-active .topbar {
  align-items: start !important;
}

/* Home hash/favorites card: keep the main join/host card height stable. */
.home-library-card {
  grid-column: 1 / -1;
  display: none;
  gap: 14px;
  padding: 18px;
  border: 1px solid rgba(191, 219, 254, 0.13);
  border-radius: 22px;
  background: rgba(7, 12, 34, 0.54);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.045);
  min-width: 0;
}

.home-library-card:has(> :not(.hidden)) {
  display: grid;
}

.home-library-card .recent-templates-box,
.home-library-card .running-instances-box {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
  min-width: 0;
}

.home-library-card .running-instances-box {
  padding: 14px;
}

.home-library-card .recent-template-list {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
  align-items: start;
}

@media (max-width: 980px) {
  .home-library-card {
    grid-column: auto;
  }
}

/* Active Spectator mode */
#hostActiveSpectatorTemplateBtn {
  margin-top: 10px;
}

.spectator-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(250, 204, 21, 0.14);
  border: 1px solid rgba(250, 204, 21, 0.38);
  color: #fde68a;
  font-weight: 800;
  white-space: nowrap;
}

.spectator-host-link,
.spectator-control-card,
.spectator-text-input-join,
.host-control-link-box {
  display: grid;
  gap: 10px;
  border-radius: 18px;
  border: 1px solid rgba(139, 92, 246, 0.24);
  background: rgba(18, 18, 42, 0.92);
  padding: 14px;
}

.spectator-host-link code,
.host-control-link-box code,
.qr-card code {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
  color: #c4b5fd;
  font-size: 0.82rem;
}

.host-control-link-box .small-btn.is-copied {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.qr-card {
  display: grid;
  gap: 8px;
  justify-items: start;
  align-items: start;
}

.qr-card img {
  width: min(220px, 100%);
  height: auto;
  border-radius: 16px;
  padding: 10px;
  background: #fff;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.25);
}

.spectator-link-btn {
  width: fit-content;
  text-decoration: none;
}

.spectator-join-details {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 10px;
}

.spectator-join-details summary {
  cursor: pointer;
  font-weight: 800;
  color: #e9d5ff;
}

body.game-active .spectator-control-card {
  min-height: 0;
}

@media (max-width: 720px) {
  .spectator-link-btn,
  .host-control-link-box .small-btn {
    width: 100%;
  }
  .qr-card {
    justify-items: stretch;
  }
  .qr-card img {
    justify-self: center;
    max-width: 180px;
  }
}

/* Active Spectator layout polish: presentation view + no inner scroll traps */
.primary-btn,
.secondary-btn,
.ghost-btn,
.danger-btn,
.success-btn,
.resolve-btn,
.lobby-start-btn,
.spectator-link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.15;
}

body.role-player .board-cell:not(.answered):disabled,
body.role-spectator .board-cell:not(.answered):disabled {
  opacity: 1;
  cursor: default;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 0%, rgba(56, 189, 248, 0.34), transparent 72%),
    linear-gradient(145deg, #1d4ed8, #4338ca 54%, #7e22ce);
  color: #ffffff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 0 0 1px rgba(96, 165, 250, 0.22),
    0 12px 32px rgba(30, 64, 175, 0.22),
    0 0 28px rgba(124, 58, 237, 0.18);
  filter: none;
  transform: none;
}

body.role-player .board-cell.answered:disabled,
body.role-spectator .board-cell.answered:disabled {
  opacity: 0.62;
  cursor: default;
  pointer-events: none;
}

body.role-player .board-cell:not(.answered):disabled:hover,
body.role-spectator .board-cell:not(.answered):disabled:hover {
  outline: none;
  transform: none;
  filter: none;
}

.score-order {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.2em;
  margin-right: 0.45em;
  padding: 0.12em 0.42em;
  border-radius: 999px;
  background: rgba(147, 197, 253, 0.12);
  border: 1px solid rgba(147, 197, 253, 0.16);
  color: #bfdbfe;
  font-size: 0.78em;
  font-weight: 950;
}

.score-row.active-turn-player,
.score-row.current {
  border-color: rgba(250, 204, 21, 0.68);
  background:
    radial-gradient(circle at 0 0, rgba(250, 204, 21, 0.18), transparent 55%),
    linear-gradient(135deg, rgba(30, 41, 59, 0.74), rgba(67, 56, 202, 0.24));
  box-shadow: 0 0 0 1px rgba(250, 204, 21, 0.12), 0 12px 28px rgba(250, 204, 21, 0.1);
}

.score-row.active-turn-player .score-order,
.score-row.current .score-order {
  background: rgba(250, 204, 21, 0.2);
  border-color: rgba(250, 204, 21, 0.38);
  color: #fde68a;
}

.spectator-host-status {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 14px;
  border-radius: 18px;
  background: #0b1230;
  border: 1px solid rgba(147, 197, 253, 0.16);
  min-width: 0;
}

.spectator-host-status.compact {
  padding: 11px 12px;
}

.spectator-host-status p {
  margin: 3px 0 0;
  color: #94a3b8;
  font-size: 0.9rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.spectator-host-status .status-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  box-shadow: 0 0 0 5px rgba(250, 204, 21, 0.09);
  background: #facc15;
}

.spectator-host-status.connected {
  border-color: rgba(34, 197, 94, 0.36);
  background: linear-gradient(135deg, rgba(20, 83, 45, 0.22), #0b1230 70%);
}

.spectator-host-status.connected .status-dot {
  background: #22c55e;
  box-shadow: 0 0 0 5px rgba(34, 197, 94, 0.1), 0 0 22px rgba(34, 197, 94, 0.32);
}

.spectator-host-status.waiting {
  border-color: rgba(250, 204, 21, 0.34);
  background: linear-gradient(135deg, rgba(113, 63, 18, 0.22), #0b1230 72%);
}

.spectator-host-link,
.spectator-control-card,
.spectator-text-input-join,
.host-control-link-box,
.spectator-join-box {
  min-width: 0;
  max-width: 100%;
  overflow: visible;
}

.spectator-control-card,
.spectator-host-link,
.spectator-text-input-join,
.spectator-join-box,
.host-control-link-box {
  justify-items: center;
  text-align: center;
}

.spectator-control-card > *,
.spectator-host-link > *,
.spectator-text-input-join > *,
.spectator-join-box > *,
.host-control-link-box > * {
  min-width: 0;
  max-width: 100%;
}

.qr-card {
  justify-items: center;
  align-items: center;
  text-align: center;
  width: 100%;
  max-width: 100%;
}

.qr-card img {
  width: min(190px, 100%);
  justify-self: center;
}

.spectator-text-input-join .qr-card img,
.spectator-join-box .qr-card img,
.spectator-host-link .qr-card img {
  width: min(170px, 100%);
}

.spectator-link-btn {
  width: min(100%, 320px);
  justify-self: center;
}

body.spectator-lobby .top-game-card,
body.role-spectator .top-game-card,
body.role-spectator #lobbyPanel {
  overflow: visible !important;
  max-height: none !important;
}

body.spectator-game-started .topbar {
  display: none;
}

body.spectator-game-started .app-shell {
  padding-top: 12px;
}

body.spectator-game-started #gameView:not(.hidden) {
  gap: 12px;
}

body.spectator-game-started .game-header.panel {
  padding: 16px 18px;
  overflow: visible;
}

body.spectator-game-started .game-header {
  gap: 14px;
}

body.spectator-game-started .game-header-main {
  grid-template-columns: 1fr !important;
  justify-items: center;
  text-align: center;
  gap: 6px;
}

body.spectator-game-started .game-title-block {
  display: grid;
  justify-items: center;
  gap: 4px;
  width: 100%;
}

body.spectator-game-started #roleLabel {
  margin: 0 auto 2px;
}

body.spectator-game-started #gameTitle {
  margin: 0;
  line-height: 1.05;
}

body.spectator-game-started #turnLabel,
body.spectator-game-started .host-lobby-settings,
body.spectator-game-started .player-controls,
body.spectator-game-started .host-controls {
  display: none !important;
}

body.spectator-game-started .game-header-tools {
  grid-template-columns: minmax(0, 1fr) !important;
  justify-items: center;
  width: 100%;
}

body.spectator-game-started .players-card {
  width: min(100%, 1240px);
  margin: 0 auto;
  padding: 13px;
}

body.spectator-game-started .players-card-header {
  justify-content: center;
  text-align: center;
}

body.spectator-game-started .players-card h3 {
  margin-bottom: 10px;
}

body.spectator-game-started .players-card .score-list {
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: 9px;
}

body.spectator-game-started .score-row {
  padding: 10px 12px;
}

body.spectator-game-started .board-panel {
  flex: 1 1 auto;
}

body.spectator-game-started .game-board {
  overflow: visible !important;
}

body.spectator-game-started .category-cell,
body.spectator-game-started .board-cell {
  min-height: 0;
}

body.role-spectator .lobby-card-head,
body.role-spectator .lobby-list {
  text-align: center;
  justify-content: center;
}

body.role-spectator .lobby-list {
  gap: 10px;
}

@media (min-width: 1024px) {
  body.spectator-game-started main,
  body.spectator-game-started #gameView:not(.hidden) {
    min-height: 0;
  }

  body.spectator-game-started .game-header.panel {
    max-height: none;
  }
}

@media (max-width: 720px) {
  .spectator-host-status {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  body.spectator-game-started .players-card .score-list {
    grid-template-columns: 1fr;
  }
}

/* Patch: host-created player slots + cleaner active spectator presentation */
.precreate-players-box {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: 20px;
  background: rgba(15, 23, 42, 0.74);
  border: 1px solid rgba(147, 197, 253, 0.14);
  min-width: 0;
  overflow: visible;
}

.precreate-copy p {
  margin: 4px 0 0;
}

.precreate-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  min-width: 0;
}

.precreate-actions input {
  min-width: 0;
}

.precreate-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.remove-slot-btn {
  padding: 8px 10px;
  font-size: 0.82rem;
}

.lobby-player.local-slot {
  border-color: rgba(250, 204, 21, 0.32);
  background: rgba(250, 204, 21, 0.08);
}

body.player-local-slot .player-controls {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

body.spectator-game-started #gameView:not(.hidden) {
  position: relative;
}

body.spectator-game-started .game-header.panel {
  position: relative;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 34px 0 10px !important;
  max-width: 100%;
}

body.spectator-game-started .game-title-block {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
}

body.spectator-game-started #roleLabel {
  position: absolute;
  top: 6px;
  left: 10px;
  margin: 0;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.48);
  border: 1px solid rgba(147, 197, 253, 0.18);
  backdrop-filter: blur(8px);
  text-align: left;
  z-index: 2;
}

body.spectator-game-started #gameTitle {
  font-size: clamp(2.1rem, 4.5vw, 4.9rem);
  line-height: 1.02;
  letter-spacing: -0.045em;
  text-align: center;
  text-shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
  max-width: min(92vw, 1300px);
  overflow-wrap: anywhere;
}

body.spectator-game-started .game-header-tools {
  margin-top: 10px;
}

body.spectator-game-started .players-card {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
}

body.spectator-game-started .players-card-header {
  display: none;
}

body.spectator-game-started .players-card .score-list {
  padding: 0;
  overflow: visible;
}

body.spectator-game-started .score-row {
  background: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(8px);
}

body.spectator-game-started .board-panel {
  margin-top: 0;
}

body.spectator-game-started .question-overlay-card {
  max-height: min(90vh, 900px);
}

@media (max-width: 680px) {
  .precreate-actions {
    grid-template-columns: 1fr;
  }

  .precreate-actions .secondary-btn,
  .remove-slot-btn {
    width: 100%;
  }

  body.spectator-game-started #roleLabel {
    position: static;
    justify-self: center;
    margin-bottom: 6px;
  }

  body.spectator-game-started .game-header.panel {
    padding-top: 8px !important;
  }
}

/* Patch: layout fixes for hashes/login/lobby/player controls + private code reveal */
.topbar-code-card {
  position: relative;
  padding-right: 48px !important;
  overflow: visible !important;
}

.code-eye-btn {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid rgba(147, 197, 253, 0.34);
  background: rgba(15, 23, 42, 0.7);
  color: #dbeafe;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  box-shadow: none;
}

.code-eye-btn:hover,
.code-eye-btn:focus-visible {
  border-color: rgba(191, 219, 254, 0.72);
  background: rgba(30, 41, 59, 0.92);
  outline: none;
}

.topbar-code-card.code-obscured .secret-value {
  filter: blur(8px);
  opacity: 0.78;
  user-select: none;
  pointer-events: none;
}

.topbar-code-card:not(.code-obscured) .secret-value {
  filter: none;
}

.topbar-code-card.code-obscured .code-eye-btn {
  background: rgba(55, 65, 81, 0.88);
}

/* Startseite: Login darf nie in die Felder laufen. */
.account-panel {
  grid-template-columns: 1fr !important;
  align-items: stretch !important;
}

.account-copy {
  min-width: 0;
  max-width: 100%;
}

.account-copy span,
.account-copy strong {
  overflow-wrap: anywhere;
}

.account-fields {
  width: 100%;
  min-width: 0;
}

.account-fields input {
  min-width: 0;
  width: 100%;
}

.account-actions {
  justify-content: flex-start;
}

/* Gespeicherte Hashes/Favoriten: keine Button-Überlappung. */
.home-library-card .recent-template-list,
.recent-template-list {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr)) !important;
  gap: 12px !important;
}

.recent-template-row {
  grid-template-columns: auto minmax(0, 1fr) !important;
  grid-template-areas:
    "star info"
    "actions actions";
  align-items: center;
  gap: 10px 12px !important;
  min-width: 0;
  overflow: hidden;
}

.recent-template-row .favorite-star {
  grid-area: star;
}

.recent-template-info {
  grid-area: info;
  min-width: 0;
}

.recent-template-info strong,
.recent-template-info code {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-template-actions {
  grid-area: actions;
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px !important;
  width: 100%;
  min-width: 0;
}

.recent-template-actions .small-btn,
.recent-template-row .small-btn {
  width: 100%;
  min-width: 0 !important;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  padding-left: 8px;
  padding-right: 8px;
  text-align: center;
}

.running-instance-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}

@media (max-width: 560px) {
  .recent-template-actions,
  .running-instance-actions {
    grid-template-columns: 1fr !important;
  }
}

/* Lobbybereich: nicht intern scrollen, sondern ausklappbare Bereiche normal wachsen lassen. */
body.game-active #lobbyPanel,
#lobbyPanel {
  max-height: none !important;
  overflow: visible !important;
}

body.game-phase-lobby main,
body.game-phase-lobby #gameView {
  height: auto !important;
  min-height: 100% !important;
  overflow: visible !important;
}

body.game-phase-lobby #gameView:not(.hidden) {
  grid-template-rows: auto auto auto !important;
}

.precreate-players-details {
  display: block;
  padding: 0;
  overflow: visible;
}

.precreate-players-details > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.42);
  border: 1px solid rgba(147, 197, 253, 0.16);
}

.precreate-players-details > summary::-webkit-details-marker {
  display: none;
}

.precreate-players-details summary span:first-child {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.precreate-players-details summary small {
  color: #94a3b8;
  line-height: 1.25;
}

.precreate-players-details .details-chevron {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  color: #bfdbfe;
  background: rgba(30, 41, 59, 0.62);
  border: 1px solid rgba(147, 197, 253, 0.18);
  transition: transform 180ms ease;
}

.precreate-players-details[open] .details-chevron {
  transform: rotate(180deg);
}

.precreate-details-body {
  display: grid;
  gap: 12px;
  padding: 14px 0 0;
}

.precreate-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.precreate-actions input {
  min-width: 0;
  width: 100%;
}

.precreate-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

@media (max-width: 720px) {
  .precreate-actions {
    grid-template-columns: 1fr;
  }
  .precreate-actions > button {
    width: 100%;
  }
}

/* Spieler-/Spectator-Handy-Modus: kompaktere Spielerbox und kleiner Lobby-verlassen-Button. */
body.role-player .game-header-tools,
body.player-local-slot .game-header-tools {
  grid-template-columns: minmax(0, 1fr) auto !important;
  align-items: stretch;
}

body.role-player .players-card,
body.player-local-slot .players-card {
  min-width: 0;
}

body.role-player .players-card .score-list,
body.player-local-slot .players-card .score-list {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

body.role-player .player-controls,
body.player-local-slot .player-controls {
  align-content: center;
  justify-items: start;
  min-width: 0;
  max-width: min(280px, 100%);
}

.player-leave-btn {
  width: auto !important;
  min-height: 42px;
  padding: 10px 14px !important;
  font-size: 0.92rem;
  margin-top: 0 !important;
}

body.player-local-slot .player-controls .muted,
body.role-player .player-controls .muted {
  margin: 0;
  line-height: 1.35;
}

@media (max-width: 900px) {
  body.role-player .game-header-tools,
  body.player-local-slot .game-header-tools {
    grid-template-columns: 1fr !important;
  }

  body.role-player .player-controls,
  body.player-local-slot .player-controls {
    max-width: 100%;
    justify-items: stretch;
  }

  .player-leave-btn {
    justify-self: start;
  }
}

/* Aktiver Spectator: transparente Headerdaten bleiben außerhalb harter Boxen. */
body.spectator-game-started .players-card {
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
}

body.spectator-game-started .game-header.panel {
  overflow: visible !important;
}

/* Patch: prevent home join/login column from overflowing on awkward mid-width viewports. */
.hero-panel,
.hero-panel > *,
.form-card,
.home-join-card,
.account-panel,
.account-copy,
.account-fields,
.account-actions,
.username-hero-field,
.join-hero-box,
.join-hero-box > * {
  min-width: 0 !important;
  max-width: 100%;
}

/* The right start-card can be narrower than the viewport media query threshold.
   Use container queries so it stacks before the section can spill sideways. */
.home-join-card {
  container-type: inline-size;
  overflow: hidden;
}

.join-hero-box {
  grid-template-columns: minmax(0, 0.72fr) minmax(0, 1fr);
  width: 100%;
  overflow: hidden;
}

.join-hero-box input,
.join-hero-box button,
.account-fields input,
.account-actions button,
.host-secondary-btn {
  min-width: 0 !important;
  max-width: 100%;
}

.join-primary-btn,
.host-secondary-btn,
.account-actions button {
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: center;
  justify-content: center;
  line-height: 1.15;
}

@container (max-width: 500px) {
  .home-join-card .join-hero-box {
    grid-template-columns: 1fr !important;
  }

  .home-join-card .account-fields {
    grid-template-columns: 1fr !important;
  }

  .home-join-card .account-actions {
    justify-content: stretch;
  }

  .home-join-card .account-actions > button,
  .home-join-card .join-primary-btn,
  .home-join-card .host-secondary-btn {
    width: 100%;
  }
}

/* Earlier than the mobile breakpoint, the hero text + form column can become too tight.
   Stack it before the right side starts forcing horizontal overflow. */
@media (max-width: 1160px) {
  .hero-panel {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 18px, 1600px) !important;
  }

  .home-join-card {
    padding: 14px;
  }
}

/* Patch: cleaner transparent player/spectator presentation + absolute leave button */
.question-panel::before {
  background: transparent !important;
  backdrop-filter: none !important;
}

body.role-player .game-header.panel,
body.player-local-slot .game-header.panel,
body.spectator-game-started .game-header.panel {
  position: relative;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

body.role-player .game-header::after,
body.player-local-slot .game-header::after,
body.spectator-game-started .game-header::after {
  display: none !important;
  content: none !important;
}

body.role-player .game-header-tools,
body.player-local-slot .game-header-tools {
  grid-template-columns: minmax(0, 1fr) !important;
  width: 100%;
  align-items: stretch;
  padding-right: clamp(108px, 10vw, 150px);
  position: relative;
}

body.role-player .players-card,
body.player-local-slot .players-card,
body.spectator-game-started .players-card {
  width: 100% !important;
  max-width: none !important;
  min-width: 0;
  padding: 0 !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

body.role-player .players-card-header,
body.player-local-slot .players-card-header,
body.spectator-game-started .players-card-header {
  display: none !important;
}

body.role-player .players-card .score-list,
body.player-local-slot .players-card .score-list,
body.spectator-game-started .players-card .score-list {
  width: 100%;
  max-width: none;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)) !important;
  gap: 10px;
}

body.spectator-game-started .players-card .score-list {
  width: min(100%, 1280px);
  margin-inline: auto;
}

body.role-player .score-row,
body.player-local-slot .score-row,
body.spectator-game-started .score-row {
  min-width: 0;
  background: rgba(7, 12, 34, 0.42) !important;
  backdrop-filter: none !important;
  box-shadow: none;
}

body.role-player .score-row.host-row,
body.player-local-slot .score-row.host-row,
body.spectator-game-started .score-row.host-row {
  background: rgba(250, 204, 21, 0.08) !important;
}

body.role-player .score-row.active-turn-player,
body.role-player .score-row.current,
body.player-local-slot .score-row.active-turn-player,
body.player-local-slot .score-row.current,
body.spectator-game-started .score-row.active-turn-player,
body.spectator-game-started .score-row.current {
  background: rgba(250, 204, 21, 0.11) !important;
  box-shadow: 0 0 0 1px rgba(250, 204, 21, 0.12) inset;
}

body.role-player .player-controls,
body.player-local-slot .player-controls {
  position: absolute !important;
  top: 0;
  right: 0;
  width: auto !important;
  min-width: 0 !important;
  max-width: none !important;
  padding: 0 !important;
  margin: 0 !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  z-index: 5;
  display: flex !important;
  align-items: flex-start;
  justify-content: flex-end;
}

body.role-player .player-controls.hidden,
body.player-local-slot .player-controls.hidden {
  display: none !important;
}

body.role-player .player-controls > :not(.player-leave-btn),
body.player-local-slot .player-controls > :not(.player-leave-btn) {
  display: none !important;
}

body.role-player .player-leave-btn,
body.player-local-slot .player-leave-btn {
  position: relative;
  top: auto;
  right: auto;
  min-height: 38px;
  padding: 9px 12px !important;
  border-radius: 13px;
  font-size: 0.84rem;
  white-space: nowrap;
  background: rgba(15, 23, 42, 0.62) !important;
}

body.role-player .game-title-block,
body.player-local-slot .game-title-block {
  min-width: 0;
  max-width: calc(100% - 120px);
}

body.role-player #turnLabel,
body.player-local-slot #turnLabel {
  display: none !important;
}

body.spectator-game-started #roleLabel {
  background: transparent !important;
  border-color: rgba(147, 197, 253, 0.24) !important;
  backdrop-filter: none !important;
}

@media (max-width: 760px) {
  body.role-player .game-header-tools,
  body.player-local-slot .game-header-tools {
    padding-right: 0;
    padding-top: 46px;
  }

  body.role-player .player-controls,
  body.player-local-slot .player-controls {
    top: 0;
    right: 0;
  }

  body.role-player .game-title-block,
  body.player-local-slot .game-title-block {
    max-width: 100%;
  }

  body.role-player .players-card .score-list,
  body.player-local-slot .players-card .score-list,
  body.spectator-game-started .players-card .score-list {
    grid-template-columns: 1fr !important;
  }
}

/* Patch: player/local-slot presentation must be flat, full width and unclipped. */
body.role-player .game-header.panel,
body.player-local-slot .game-header.panel {
  position: relative !important;
  padding: clamp(14px, 1.4vw, 22px) clamp(18px, 2.6vw, 36px) clamp(18px, 1.8vw, 26px) !important;
  min-height: 0 !important;
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
}

body.role-player .game-header,
body.player-local-slot .game-header {
  gap: clamp(16px, 2vw, 26px) !important;
  min-height: 0 !important;
}

body.role-player .game-header-main,
body.player-local-slot .game-header-main {
  grid-template-columns: minmax(0, 1fr) !important;
  gap: 6px !important;
  min-height: 0 !important;
  padding-right: clamp(116px, 12vw, 170px);
}

body.role-player .game-title-block,
body.player-local-slot .game-title-block {
  max-width: none !important;
  min-height: 0 !important;
}

body.role-player .game-title-block h2,
body.player-local-slot .game-title-block h2 {
  margin: 0 !important;
}

body.role-player .game-header-tools,
body.player-local-slot .game-header-tools {
  position: static !important;
  display: block !important;
  width: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
  min-height: 0 !important;
  overflow: visible !important;
}

body.role-player .players-card,
body.player-local-slot .players-card {
  width: 100% !important;
  max-width: none !important;
  overflow: visible !important;
}

body.role-player .players-card .score-list,
body.player-local-slot .players-card .score-list {
  width: 100% !important;
  max-width: none !important;
  padding: 4px !important;
  margin: -4px !important;
  overflow: visible !important;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)) !important;
}

body.role-player .score-row,
body.player-local-slot .score-row {
  overflow: visible !important;
  background: rgba(7, 12, 34, 0.28) !important;
  backdrop-filter: none !important;
}

body.role-player .score-row.host-row,
body.player-local-slot .score-row.host-row {
  background: rgba(250, 204, 21, 0.07) !important;
}

body.role-player .score-row.active-turn-player,
body.role-player .score-row.current,
body.player-local-slot .score-row.active-turn-player,
body.player-local-slot .score-row.current {
  background: rgba(250, 204, 21, 0.09) !important;
}

body.role-player .player-controls,
body.player-local-slot .player-controls {
  position: absolute !important;
  top: clamp(14px, 1.4vw, 22px) !important;
  right: clamp(18px, 2.6vw, 36px) !important;
  display: flex !important;
  width: auto !important;
  max-width: none !important;
  z-index: 10;
}

body.role-player .player-leave-btn,
body.player-local-slot .player-leave-btn {
  min-height: 34px !important;
  padding: 8px 11px !important;
  border-radius: 999px !important;
  font-size: 0.78rem !important;
  line-height: 1 !important;
  background: rgba(7, 12, 34, 0.45) !important;
}

@media (min-width: 900px) {
  body.role-player .game-header.panel,
  body.player-local-slot .game-header.panel {
    padding-top: 18px !important;
    padding-bottom: 18px !important;
  }
}

@media (max-width: 720px) {
  body.role-player .game-header-main,
  body.player-local-slot .game-header-main {
    padding-right: 0 !important;
    padding-top: 42px;
  }

  body.role-player .player-controls,
  body.player-local-slot .player-controls {
    top: 10px !important;
    right: 12px !important;
  }

  body.role-player .players-card .score-list,
  body.player-local-slot .players-card .score-list {
    grid-template-columns: 1fr !important;
  }
}

/* Patch: compact pre-game player/local-slot card with restored panel background. */
body.role-player.game-phase-lobby #lobbyPanel,
body.player-local-slot.game-phase-lobby #lobbyPanel,
body.role-spectator.game-phase-lobby #lobbyPanel {
  display: none !important;
}

body.role-player.game-phase-lobby .game-layout,
body.player-local-slot.game-phase-lobby .game-layout,
body.role-spectator.game-phase-lobby .game-layout {
  display: none !important;
}

body.role-player.game-phase-lobby main,
body.role-player.game-phase-lobby #gameView,
body.player-local-slot.game-phase-lobby main,
body.player-local-slot.game-phase-lobby #gameView,
body.role-spectator.game-phase-lobby main,
body.role-spectator.game-phase-lobby #gameView {
  height: auto !important;
  min-height: 0 !important;
  overflow: visible !important;
}

body.role-player.game-phase-lobby #gameView:not(.hidden),
body.player-local-slot.game-phase-lobby #gameView:not(.hidden),
body.role-spectator.game-phase-lobby #gameView:not(.hidden) {
  display: block !important;
}

body.role-player .game-header.panel,
body.player-local-slot .game-header.panel {
  display: grid !important;
  grid-template-rows: auto auto !important;
  gap: 14px !important;
  position: relative !important;
  padding: clamp(16px, 1.6vw, 22px) clamp(18px, 2.2vw, 30px) !important;
  min-height: 0 !important;
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
  border: 1px solid rgba(191, 219, 254, 0.14) !important;
  border-radius: 24px !important;
  background: rgba(9, 14, 36, 0.72) !important;
  box-shadow: 0 18px 58px rgba(0, 0, 0, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.055) !important;
  backdrop-filter: none !important;
}

body.role-player .game-header.panel::after,
body.player-local-slot .game-header.panel::after {
  display: block !important;
  content: "" !important;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent, rgba(56, 189, 248, 0.04), rgba(124, 58, 237, 0.08)) !important;
}

body.role-player .game-header-main,
body.player-local-slot .game-header-main {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  gap: 4px !important;
  min-height: 0 !important;
  padding: 0 clamp(118px, 11vw, 165px) 0 0 !important;
  align-items: start !important;
}

body.role-player .game-title-block,
body.player-local-slot .game-title-block {
  display: grid !important;
  gap: 5px !important;
  min-height: 0 !important;
  max-width: none !important;
}

body.role-player .game-title-block h2,
body.player-local-slot .game-title-block h2 {
  margin: 0 !important;
  line-height: 1.08 !important;
  font-size: clamp(1.85rem, 2.6vw, 3rem) !important;
}

body.role-player.game-phase-lobby #turnLabel,
body.player-local-slot.game-phase-lobby #turnLabel {
  display: block !important;
  margin: 0 !important;
  max-width: min(720px, 100%) !important;
  line-height: 1.35 !important;
}

body.role-player:not(.game-phase-lobby) #turnLabel,
body.player-local-slot:not(.game-phase-lobby) #turnLabel {
  display: none !important;
}

body.role-player .game-header-tools,
body.player-local-slot .game-header-tools {
  position: static !important;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  width: 100% !important;
  min-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  overflow: visible !important;
}

body.role-player .players-card,
body.player-local-slot .players-card {
  display: grid !important;
  gap: 10px !important;
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
  padding: 0 !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

body.role-player .players-card-header,
body.player-local-slot .players-card-header {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  padding: 0 !important;
  margin: 0 !important;
  background: transparent !important;
  border: 0 !important;
}

body.role-player .players-card-header h3,
body.player-local-slot .players-card-header h3 {
  margin: 0 !important;
  font-size: 1rem !important;
  color: #e0e7ff !important;
}

body.role-player .players-card .score-list,
body.player-local-slot .players-card .score-list {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)) !important;
  gap: 10px !important;
  width: 100% !important;
  max-width: none !important;
  padding: 3px !important;
  margin: -3px !important;
  overflow: visible !important;
}

body.role-player .score-row,
body.player-local-slot .score-row {
  min-width: 0 !important;
  background: rgba(7, 12, 34, 0.38) !important;
  backdrop-filter: none !important;
  overflow: visible !important;
}

body.role-player .player-controls,
body.player-local-slot .player-controls {
  position: absolute !important;
  top: clamp(14px, 1.6vw, 22px) !important;
  right: clamp(18px, 2.2vw, 30px) !important;
  display: flex !important;
  width: auto !important;
  max-width: none !important;
  min-width: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  z-index: 10 !important;
}

body.role-player .player-controls > :not(.player-leave-btn),
body.player-local-slot .player-controls > :not(.player-leave-btn) {
  display: none !important;
}

body.role-player .player-leave-btn,
body.player-local-slot .player-leave-btn {
  min-height: 34px !important;
  padding: 8px 12px !important;
  border-radius: 999px !important;
  font-size: 0.78rem !important;
  line-height: 1 !important;
  white-space: nowrap !important;
  background: rgba(7, 12, 34, 0.62) !important;
  border-color: rgba(147, 197, 253, 0.32) !important;
}

@media (max-width: 720px) {
  body.role-player .game-header-main,
  body.player-local-slot .game-header-main {
    padding-right: 0 !important;
    padding-top: 40px !important;
  }

  body.role-player .player-controls,
  body.player-local-slot .player-controls {
    top: 12px !important;
    right: 14px !important;
  }

  body.role-player .players-card .score-list,
  body.player-local-slot .players-card .score-list {
    grid-template-columns: 1fr !important;
  }
}

/* Patch: restore board in pre-game player/spectator views and separate active-player color from host gold. */
body.role-player.game-phase-lobby .game-layout,
body.player-local-slot.game-phase-lobby .game-layout,
body.role-spectator.game-phase-lobby .game-layout {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  width: 100% !important;
  margin-top: clamp(14px, 1.6vw, 22px) !important;
  min-height: clamp(340px, 48dvh, 620px) !important;
  height: auto !important;
  overflow: visible !important;
}

body.role-player.game-phase-lobby .board-panel,
body.player-local-slot.game-phase-lobby .board-panel,
body.role-spectator.game-phase-lobby .board-panel {
  display: flex !important;
  width: 100% !important;
  min-height: clamp(340px, 48dvh, 620px) !important;
  height: auto !important;
  padding: clamp(10px, 1.2vw, 18px) !important;
  overflow: visible !important;
}

body.role-player.game-phase-lobby .game-board,
body.player-local-slot.game-phase-lobby .game-board,
body.role-spectator.game-phase-lobby .game-board {
  flex: 1 1 auto !important;
  min-height: 100% !important;
  height: auto !important;
  overflow: visible !important;
}

body.role-player.game-phase-lobby .board-cell:not(.answered):disabled,
body.player-local-slot.game-phase-lobby .board-cell:not(.answered):disabled,
body.role-spectator.game-phase-lobby .board-cell:not(.answered):disabled {
  opacity: 1 !important;
  cursor: default !important;
  pointer-events: none !important;
}

body.role-player .score-row.host-row,
body.player-local-slot .score-row.host-row,
body.spectator-game-started .score-row.host-row {
  border-color: rgba(250, 204, 21, 0.74) !important;
  background:
    radial-gradient(circle at 0 0, rgba(250, 204, 21, 0.14), transparent 56%),
    rgba(7, 12, 34, 0.48) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 0 0 1px rgba(250, 204, 21, 0.08) !important;
}

body.role-player .score-row.active-turn-player:not(.host-row),
body.role-player .score-row.current:not(.host-row),
body.player-local-slot .score-row.active-turn-player:not(.host-row),
body.player-local-slot .score-row.current:not(.host-row),
body.spectator-game-started .score-row.active-turn-player:not(.host-row),
body.spectator-game-started .score-row.current:not(.host-row) {
  border-color: rgba(56, 189, 248, 0.86) !important;
  background:
    radial-gradient(circle at 0 0, rgba(56, 189, 248, 0.18), transparent 58%),
    linear-gradient(135deg, rgba(7, 12, 34, 0.52), rgba(37, 99, 235, 0.16), rgba(124, 58, 237, 0.13)) !important;
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.18) inset, 0 0 24px rgba(56, 189, 248, 0.10) !important;
}

body.role-player .score-row.active-turn-player:not(.host-row) .score-order,
body.role-player .score-row.current:not(.host-row) .score-order,
body.player-local-slot .score-row.active-turn-player:not(.host-row) .score-order,
body.player-local-slot .score-row.current:not(.host-row) .score-order,
body.spectator-game-started .score-row.active-turn-player:not(.host-row) .score-order,
body.spectator-game-started .score-row.current:not(.host-row) .score-order {
  background: rgba(56, 189, 248, 0.22) !important;
  border-color: rgba(56, 189, 248, 0.48) !important;
  color: #bae6fd !important;
}

@media (max-width: 720px) {
  body.role-player.game-phase-lobby .game-layout,
  body.player-local-slot.game-phase-lobby .game-layout,
  body.role-spectator.game-phase-lobby .game-layout,
  body.role-player.game-phase-lobby .board-panel,
  body.player-local-slot.game-phase-lobby .board-panel,
  body.role-spectator.game-phase-lobby .board-panel {
    min-height: 320px !important;
  }
}

/* Patch: Host-Control-Lobby ohne separate Lobby-Box. Spieler vorher anlegen sitzt in der Spielerkarte. */
body.role-host.game-phase-lobby #lobbyPanel {
  display: none !important;
}

body.role-host.game-phase-lobby #gameView:not(.hidden) {
  grid-template-rows: auto minmax(0, 1fr) !important;
}

body.role-host.game-phase-lobby .players-card .score-list {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr));
  align-items: stretch;
}

.precreate-inline-panel {
  grid-column: 1 / -1;
  width: 100%;
  margin-bottom: 2px;
  background: rgba(8, 13, 37, 0.46);
  border-color: rgba(147, 197, 253, 0.18);
}

.precreate-inline-panel > summary {
  min-height: 46px;
  padding: 10px 12px;
  background: rgba(15, 23, 42, 0.34);
}

.precreate-inline-panel .precreate-details-body {
  padding: 12px 2px 2px;
}

.host-lobby-start-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0;
  align-items: center;
  min-width: 0;
}

.host-lobby-start-box p {
  margin: 0;
}

.host-start-btn {
  min-width: 160px;
  justify-content: center;
  text-align: center;
}

@media (max-width: 760px) {
  .host-lobby-start-box {
    grid-template-columns: 1fr;
  }
  .host-start-btn {
    width: 100%;
  }
}

/* Patch: Host lobby accordions grow naturally and use one universal rotating triangle. */
body.role-host.game-phase-lobby main,
body.role-host.game-phase-lobby #gameView {
  height: auto !important;
  min-height: 0 !important;
  overflow: visible !important;
}

body.role-host.game-phase-lobby #gameView:not(.hidden) {
  display: grid !important;
  grid-template-rows: auto auto !important;
  overflow: visible !important;
}

body.role-host.game-phase-lobby .game-header.panel,
body.role-host.game-phase-lobby .game-header,
body.role-host.game-phase-lobby .game-header-main,
body.role-host.game-phase-lobby .game-header-tools,
body.role-host.game-phase-lobby .top-game-card,
body.role-host.game-phase-lobby .players-card,
body.role-host.game-phase-lobby .host-controls,
body.role-host.game-phase-lobby .precreate-players-box,
body.role-host.game-phase-lobby .precreate-players-details,
body.role-host.game-phase-lobby .precreate-details-body {
  max-height: none !important;
  overflow: visible !important;
}

body.role-host.game-phase-lobby .top-game-card {
  height: auto !important;
}

body.role-host.game-phase-lobby .precreate-inline-panel {
  background: rgba(8, 13, 37, 0.48) !important;
  border: 1px solid rgba(147, 197, 253, 0.18) !important;
  border-radius: 16px !important;
  box-shadow: none !important;
}

body.role-host.game-phase-lobby .precreate-inline-panel > summary {
  background: transparent !important;
  border: 0 !important;
}

/* Universal disclosure triangle: same simple glyph everywhere, animated on open. */
.manual-score-menu > summary,
.precreate-players-details > summary,
.question-builder > summary {
  list-style: none !important;
}

.manual-score-menu > summary::-webkit-details-marker,
.precreate-players-details > summary::-webkit-details-marker,
.question-builder > summary::-webkit-details-marker {
  display: none !important;
}

.manual-score-menu > summary::before,
.question-builder > summary::before {
  content: '▶';
  display: inline-grid;
  place-items: center;
  width: 1em;
  margin-right: 0.45rem;
  color: #bfdbfe;
  font-size: 0.88em;
  line-height: 1;
  transform-origin: center;
  transition: transform 180ms ease, color 180ms ease;
}

.manual-score-menu[open] > summary::before,
.question-builder[open] > summary::before {
  transform: rotate(90deg);
  color: #93c5fd;
}

.precreate-players-details > summary {
  justify-content: flex-start !important;
  gap: 10px !important;
}

.precreate-players-details .details-chevron {
  order: -1;
  display: inline-grid !important;
  place-items: center !important;
  flex: 0 0 auto !important;
  width: 1em !important;
  height: 1em !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: #bfdbfe !important;
  font-size: 0 !important;
  line-height: 1 !important;
  transform: none !important;
  transition: none !important;
}

.precreate-players-details .details-chevron::before {
  content: '▶';
  font-size: 0.88rem;
  line-height: 1;
  transform-origin: center;
  transition: transform 180ms ease, color 180ms ease;
}

.precreate-players-details[open] .details-chevron::before {
  transform: rotate(90deg);
  color: #93c5fd;
}

.lobby-settings-toggle {
  display: inline-grid !important;
  place-items: center !important;
}

.lobby-settings-toggle .chevron-icon {
  width: 1em !important;
  height: 1em !important;
  transform: none !important;
}

.lobby-settings-toggle .chevron-icon svg {
  display: none !important;
}

.lobby-settings-toggle .chevron-icon::before {
  content: '▶';
  display: inline-grid;
  place-items: center;
  color: currentColor;
  font-size: 0.9rem;
  line-height: 1;
  transform-origin: center;
  transition: transform 180ms ease;
}

.lobby-settings-menu.open .lobby-settings-toggle .chevron-icon::before {
  transform: rotate(90deg);
}

/* When the host opens settings or precreate controls, let the page/card grow instead of clipping. */
body.role-host.game-phase-lobby .lobby-settings-menu,
body.role-host.game-phase-lobby .lobby-settings-content,
body.role-host.game-phase-lobby .lobby-settings-content-inner {
  max-width: 100% !important;
  overflow: visible !important;
}

/* Patch: unified disclosure styling + smoother animated dropdowns + cyan active player. */
.game-header-tools {
  align-items: start;
}

body.role-host.game-phase-lobby .game-header-tools,
body.role-host.game-phase-lobby .top-game-card,
body.role-host.game-phase-lobby .host-controls {
  align-items: start !important;
  align-self: start !important;
}

/* Active player is cyan/blue everywhere; host keeps gold. */
.score-row.host-row {
  border-color: rgba(250, 204, 21, 0.74) !important;
  background:
    radial-gradient(circle at 0 0, rgba(250, 204, 21, 0.14), transparent 58%),
    linear-gradient(135deg, rgba(7, 12, 34, 0.72), rgba(67, 56, 202, 0.14)) !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 0 0 1px rgba(250, 204, 21, 0.08), 0 0 24px rgba(250, 204, 21, 0.08) !important;
}

.score-row.active-turn-player:not(.host-row),
.score-row.current:not(.host-row),
body.role-player .score-row.active-turn-player:not(.host-row),
body.role-player .score-row.current:not(.host-row),
body.player-local-slot .score-row.active-turn-player:not(.host-row),
body.player-local-slot .score-row.current:not(.host-row),
body.spectator-game-started .score-row.active-turn-player:not(.host-row),
body.spectator-game-started .score-row.current:not(.host-row) {
  border-color: rgba(56, 189, 248, 0.86) !important;
  outline: 0 !important;
  background:
    radial-gradient(circle at 0 0, rgba(56, 189, 248, 0.2), transparent 60%),
    linear-gradient(135deg, rgba(7, 12, 34, 0.66), rgba(37, 99, 235, 0.18), rgba(124, 58, 237, 0.12)) !important;
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.18) inset, 0 0 26px rgba(56, 189, 248, 0.12) !important;
}

.score-row.active-turn-player:not(.host-row) .score-order,
.score-row.current:not(.host-row) .score-order {
  background: rgba(56, 189, 248, 0.22) !important;
  border-color: rgba(56, 189, 248, 0.5) !important;
  color: #bae6fd !important;
}

/* Universal detail rows: triangle left of the title, no boxed toggle icon. */
.manual-score-menu > summary,
.precreate-players-details > summary,
.question-builder > summary,
.lobby-settings-head {
  position: relative;
  min-width: 0;
  display: flex !important;
  align-items: flex-start !important;
  justify-content: flex-start !important;
  gap: 0.48rem !important;
  padding-inline: 0 !important;
}

.manual-score-menu > summary,
.precreate-players-details > summary {
  padding-block: 0 !important;
}

.precreate-players-details > summary {
  padding: 0 !important;
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
}

.precreate-players-details > summary > span:not(.details-chevron),
.lobby-settings-head > span {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.precreate-players-details .details-chevron,
.lobby-settings-toggle {
  order: -1;
  flex: 0 0 1em !important;
  width: 1em !important;
  height: 1em !important;
  min-height: 0 !important;
  margin-top: 0.12em !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: #bfdbfe !important;
  box-shadow: none !important;
}

.precreate-players-details .details-chevron::before,
.lobby-settings-toggle .chevron-icon::before,
.manual-score-menu > summary::before,
.question-builder > summary::before {
  content: '▶' !important;
  display: inline-grid !important;
  place-items: center !important;
  width: 1em !important;
  margin: 0 0.02rem 0 0 !important;
  color: #bfdbfe !important;
  font-size: 0.9rem !important;
  line-height: 1 !important;
  transform-origin: center !important;
  transition: transform 220ms ease, color 180ms ease !important;
}

.manual-score-menu[open] > summary::before,
.question-builder[open] > summary::before,
.precreate-players-details[open] .details-chevron::before,
.lobby-settings-menu.open .lobby-settings-toggle .chevron-icon::before {
  transform: rotate(90deg) !important;
  color: #93c5fd !important;
}

.lobby-settings-menu {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
}

.lobby-settings-head {
  color: #e0e7ff;
  font-weight: 950;
}

.lobby-settings-toggle .chevron-icon,
.lobby-settings-toggle .chevron-icon svg {
  width: 1em !important;
  height: 1em !important;
}

.lobby-settings-toggle .chevron-icon svg {
  display: none !important;
}

/* Smoothly animated details. Native <details> stays compatible if JS is disabled. */
.precreate-details-body,
.manual-score-list,
.question-builder-body {
  overflow: hidden;
  transition: max-height 260ms ease, opacity 190ms ease, transform 190ms ease, padding-top 190ms ease, margin-top 190ms ease;
  will-change: max-height, opacity, transform;
}

.precreate-players-details:not([open]) .precreate-details-body,
.manual-score-menu:not([open]) .manual-score-list,
.question-builder:not([open]) .question-builder-body {
  max-height: 0 !important;
  opacity: 0;
  transform: translateY(-4px);
  margin-top: 0 !important;
  padding-top: 0 !important;
}

.precreate-players-details[open] .precreate-details-body,
.manual-score-menu[open] .manual-score-list,
.question-builder[open] .question-builder-body {
  opacity: 1;
  transform: translateY(0);
}

/* Precreate spacing: no clipped/overlapping arrow, clean padding. */
.precreate-players-box,
.precreate-players-details,
body.role-host.game-phase-lobby .precreate-inline-panel {
  padding: 14px 16px !important;
  background: rgba(8, 13, 37, 0.48) !important;
  border: 1px solid rgba(147, 197, 253, 0.18) !important;
  border-radius: 16px !important;
}

.precreate-details-body {
  gap: 10px !important;
  padding-top: 12px !important;
}

.precreate-copy p,
.precreate-details-body p {
  margin: 0;
}

/* Manual score card: trim unnecessary empty bottom space. */
.manual-score-menu {
  padding: 12px !important;
  min-height: 0 !important;
}

.manual-score-menu[open] {
  padding-bottom: 12px !important;
}

.manual-score-list {
  margin-top: 12px !important;
  margin-bottom: 0 !important;
  padding-bottom: 0 !important;
  align-content: start !important;
}

.manual-score-row:last-child {
  margin-bottom: 0 !important;
}

.host-controls.top-game-card,
.host-controls .manual-score-menu {
  height: auto !important;
  min-height: 0 !important;
}

/* Lobby settings opened content should keep the existing smooth height animation, but use the same disclosure header. */
.lobby-settings-content {
  transition: max-height 260ms ease, opacity 190ms ease, transform 190ms ease, margin-top 190ms ease, visibility 190ms ease !important;
}

.lobby-settings-content-inner {
  margin-top: 10px;
}

/* Patch: fix disclosure alignment, whole-row lobby toggle, and manual score spacing. */
.precreate-players-details > summary {
  position: relative !important;
  display: flex !important;
  align-items: flex-start !important;
  justify-content: flex-start !important;
  gap: 0 !important;
  padding: 10px 12px 10px 34px !important;
  line-height: 1.35 !important;
  cursor: pointer !important;
}

.precreate-players-details > summary::before {
  content: '▶' !important;
  position: absolute !important;
  left: 14px !important;
  top: 18px !important;
  width: 1em !important;
  height: 1em !important;
  display: inline-grid !important;
  place-items: center !important;
  color: #bfdbfe !important;
  font-size: 0.86rem !important;
  line-height: 1 !important;
  transform-origin: 50% 50% !important;
  transition: transform 220ms ease, color 180ms ease !important;
}

.precreate-players-details[open] > summary::before {
  transform: rotate(90deg) !important;
  color: #93c5fd !important;
}

.precreate-players-details .details-chevron {
  display: none !important;
}

.precreate-players-details > summary > span {
  min-width: 0 !important;
  display: grid !important;
  gap: 2px !important;
}

.precreate-players-details summary small {
  line-height: 1.3 !important;
}

.manual-score-menu > summary {
  line-height: 1.6 !important;
  align-items: center !important;
  padding-block: 0 !important;
}

.manual-score-menu > summary::before {
  line-height: 1.6 !important;
}

.manual-score-menu {
  padding: 10px 12px !important;
}

.manual-score-list {
  margin-top: 10px !important;
  padding-bottom: 0 !important;
  gap: 8px !important;
  min-height: 0 !important;
}

.manual-score-row {
  min-height: 0 !important;
}

.manual-score-row:last-child {
  margin-bottom: 0 !important;
}

.lobby-settings-menu {
  background: rgba(8, 13, 37, 0.58) !important;
  border: 1px solid rgba(147, 197, 253, 0.16) !important;
  border-radius: 18px !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.035) !important;
  padding: 0 !important;
  overflow: visible !important;
}

.lobby-settings-head {
  position: relative !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  min-height: 48px !important;
  padding: 12px 16px 12px 38px !important;
  cursor: pointer !important;
  user-select: none !important;
  line-height: 1.35 !important;
}

.lobby-settings-head::before {
  content: '▶' !important;
  position: absolute !important;
  left: 18px !important;
  top: 50% !important;
  display: inline-grid !important;
  place-items: center !important;
  width: 1em !important;
  height: 1em !important;
  color: #bfdbfe !important;
  font-size: 0.9rem !important;
  line-height: 1 !important;
  transform: translateY(-50%) rotate(0deg) !important;
  transform-origin: 50% 50% !important;
  transition: transform 220ms ease, color 180ms ease !important;
}

.lobby-settings-menu.open .lobby-settings-head::before {
  transform: translateY(-50%) rotate(90deg) !important;
  color: #93c5fd !important;
}

.lobby-settings-toggle {
  display: none !important;
}

.lobby-settings-content-inner {
  padding: 0 14px 14px !important;
}

/* Patch: requested final spacing tweaks for precreate summary and lobby-settings inner panel. */
.precreate-players-details > summary {
  padding: 10px 12px 10px 20px !important;
}

.precreate-players-details > summary::before {
  left: 0px !important;
}

.lobby-settings-content-inner {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
}


/* Patch: smooth height animation specifically for "Spieler vorher anlegen".
   This uses real height instead of max-height so the panel no longer jumps while opening/closing. */
.precreate-players-details > .precreate-details-body {
  height: 0;
  max-height: none !important;
  overflow: hidden;
  transition: height 260ms ease, opacity 190ms ease, transform 190ms ease, padding-top 190ms ease, margin-top 190ms ease !important;
  will-change: height, opacity, transform;
}

.precreate-players-details[open] > .precreate-details-body {
  opacity: 1;
  transform: translateY(0);
}

.precreate-players-details:not([open]) > .precreate-details-body {
  height: 0 !important;
  max-height: none !important;
  opacity: 0;
  transform: translateY(-4px);
  margin-top: 0 !important;
  padding-top: 0 !important;
}

.precreate-players-details[open]:not(.is-precreate-height-animating) > .precreate-details-body {
  height: auto;
}

.precreate-players-details.is-precreate-height-animating > .precreate-details-body {
  overflow: hidden;
}

.precreate-players-details > summary {
  padding: 10px 12px 10px 20px !important;
}

.precreate-players-details > summary::before {
  left: 0px !important;
}

@media (prefers-reduced-motion: reduce) {
  .precreate-players-details > .precreate-details-body {
    transition: none !important;
  }
}


/* Patch: einheitliche Board-Ansicht für Host, aktiven Spectator und Spieler.
   Das Board bleibt optisch wie in der Host-Control-Ansicht; die alte aktive
   Spectator-Präsentationsansicht wird nicht mehr separat gestreckt/versteckt. */
body.role-spectator:not(.game-phase-lobby) .topbar,
body.role-player:not(.game-phase-lobby) .topbar,
body.player-local-slot:not(.game-phase-lobby) .topbar {
  display: flex !important;
}

body.role-spectator:not(.game-phase-lobby) #gameView:not(.hidden),
body.role-player:not(.game-phase-lobby) #gameView:not(.hidden),
body.player-local-slot:not(.game-phase-lobby) #gameView:not(.hidden) {
  display: grid !important;
  grid-template-rows: auto auto minmax(0, 1fr) !important;
  gap: 12px !important;
}

body.role-spectator:not(.game-phase-lobby) .game-layout,
body.role-player:not(.game-phase-lobby) .game-layout,
body.player-local-slot:not(.game-phase-lobby) .game-layout {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  width: 100% !important;
  min-height: 0 !important;
  height: 100% !important;
  margin-top: 0 !important;
  overflow: hidden !important;
}

body.role-spectator:not(.game-phase-lobby) .board-panel,
body.role-player:not(.game-phase-lobby) .board-panel,
body.player-local-slot:not(.game-phase-lobby) .board-panel {
  display: flex !important;
  width: 100% !important;
  min-height: 0 !important;
  height: 100% !important;
  padding: 10px !important;
  overflow: visible !important;
  border: 1px solid rgba(191, 219, 254, 0.14) !important;
  border-radius: 22px !important;
  background:
    radial-gradient(circle at 50% -10%, rgba(56, 189, 248, 0.18), transparent 24rem),
    linear-gradient(145deg, rgba(16, 27, 74, 0.86), rgba(9, 13, 38, 0.9)) !important;
  box-shadow: 0 18px 58px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.055) !important;
}

body.role-spectator:not(.game-phase-lobby) .game-board,
body.role-player:not(.game-phase-lobby) .game-board,
body.player-local-slot:not(.game-phase-lobby) .game-board {
  --board-cell-min: 110px;
  flex: 1 1 auto !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  display: grid !important;
  grid-auto-rows: minmax(0, 1fr) !important;
  gap: 8px !important;
  padding: 10px !important;
  overflow: visible !important;
}

body.role-spectator:not(.game-phase-lobby) .category-cell,
body.role-spectator:not(.game-phase-lobby) .board-cell,
body.role-player:not(.game-phase-lobby) .category-cell,
body.role-player:not(.game-phase-lobby) .board-cell,
body.player-local-slot:not(.game-phase-lobby) .category-cell,
body.player-local-slot:not(.game-phase-lobby) .board-cell {
  min-height: 0 !important;
  height: auto !important;
  border-radius: 15px !important;
  padding: 8px !important;
}

body.role-spectator:not(.game-phase-lobby) .category-cell,
body.role-player:not(.game-phase-lobby) .category-cell,
body.player-local-slot:not(.game-phase-lobby) .category-cell {
  font-size: clamp(0.72rem, 0.85vw, 0.98rem) !important;
  line-height: 1.15 !important;
}

body.role-spectator:not(.game-phase-lobby) .board-cell,
body.role-player:not(.game-phase-lobby) .board-cell,
body.player-local-slot:not(.game-phase-lobby) .board-cell {
  font-size: clamp(1.05rem, 1.45vw, 1.8rem) !important;
  line-height: 1.05 !important;
}

body.role-spectator .board-cell:not(.answered):disabled,
body.role-player .board-cell:not(.answered):disabled,
body.player-local-slot .board-cell:not(.answered):disabled {
  opacity: 1 !important;
  cursor: default !important;
  pointer-events: none !important;
  background:
    radial-gradient(circle at 50% 0%, rgba(56, 189, 248, 0.22), transparent 75%),
    linear-gradient(145deg, #1e3a8a, #312e81 56%, #581c87) !important;
  color: #e0f2fe !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.09), 0 16px 35px rgba(0, 0, 0, 0.18) !important;
  filter: none !important;
  transform: none !important;
}

body.role-spectator .board-cell.answered:disabled,
body.role-player .board-cell.answered:disabled,
body.player-local-slot .board-cell.answered:disabled {
  opacity: 1 !important;
}

@media (min-width: 1024px) and (max-width: 1450px) {
  body.role-spectator:not(.game-phase-lobby) .game-board,
  body.role-player:not(.game-phase-lobby) .game-board,
  body.player-local-slot:not(.game-phase-lobby) .game-board {
    --board-cell-min: 92px;
    gap: 7px !important;
    padding: 8px !important;
  }

  body.role-spectator:not(.game-phase-lobby) .category-cell,
  body.role-spectator:not(.game-phase-lobby) .board-cell,
  body.role-player:not(.game-phase-lobby) .category-cell,
  body.role-player:not(.game-phase-lobby) .board-cell,
  body.player-local-slot:not(.game-phase-lobby) .category-cell,
  body.player-local-slot:not(.game-phase-lobby) .board-cell {
    border-radius: 13px !important;
    padding: 7px !important;
  }
}

/* Patch: Board-Ansicht in Lobby für alle Rollen identisch kompakt wie Host-Control.
   Vorher hatten Spieler/Spectator in der Lobby ein eigenes großes Präsentations-Board
   mit min-height: 48dvh; dadurch wurden Kategorie- und Punkte-Zeilen riesig. */
body.game-phase-lobby .game-layout,
body.role-player.game-phase-lobby .game-layout,
body.player-local-slot.game-phase-lobby .game-layout,
body.role-spectator.game-phase-lobby .game-layout,
body.role-host.game-phase-lobby .game-layout {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  width: 100% !important;
  margin-top: 18px !important;
  min-height: 0 !important;
  height: auto !important;
  overflow: visible !important;
}

body.game-phase-lobby #lobbyPanel.hidden + .game-layout,
body.role-player.game-phase-lobby #lobbyPanel.hidden + .game-layout,
body.player-local-slot.game-phase-lobby #lobbyPanel.hidden + .game-layout,
body.role-spectator.game-phase-lobby #lobbyPanel.hidden + .game-layout,
body.role-host.game-phase-lobby #lobbyPanel.hidden + .game-layout {
  margin-top: 18px !important;
}

body.game-phase-lobby .board-panel,
body.role-player.game-phase-lobby .board-panel,
body.player-local-slot.game-phase-lobby .board-panel,
body.role-spectator.game-phase-lobby .board-panel,
body.role-host.game-phase-lobby .board-panel {
  display: flex !important;
  width: 100% !important;
  min-height: 0 !important;
  height: auto !important;
  padding: 10px !important;
  border-radius: 22px !important;
  overflow: visible !important;
}

body.game-phase-lobby .game-board,
body.role-player.game-phase-lobby .game-board,
body.player-local-slot.game-phase-lobby .game-board,
body.role-spectator.game-phase-lobby .game-board,
body.role-host.game-phase-lobby .game-board {
  --board-cell-min: 110px;
  flex: 1 1 auto !important;
  min-height: 0 !important;
  height: auto !important;
  display: grid !important;
  grid-auto-rows: auto !important;
  gap: 6px !important;
  padding: 7px !important;
  overflow: visible !important;
}

body.game-phase-lobby .category-cell,
body.role-player.game-phase-lobby .category-cell,
body.player-local-slot.game-phase-lobby .category-cell,
body.role-spectator.game-phase-lobby .category-cell,
body.role-host.game-phase-lobby .category-cell {
  min-height: 0 !important;
  height: 44px !important;
  padding: 7px 10px !important;
  border-radius: 13px !important;
  font-size: clamp(0.72rem, 0.85vw, 0.98rem) !important;
  line-height: 1.15 !important;
}

body.game-phase-lobby .board-cell,
body.role-player.game-phase-lobby .board-cell,
body.player-local-slot.game-phase-lobby .board-cell,
body.role-spectator.game-phase-lobby .board-cell,
body.role-host.game-phase-lobby .board-cell {
  min-height: 0 !important;
  height: 48px !important;
  padding: 7px 10px !important;
  border-radius: 13px !important;
  font-size: clamp(1.05rem, 1.45vw, 1.8rem) !important;
  line-height: 1.05 !important;
}

body.game-phase-lobby .board-cell:not(.answered):disabled,
body.role-player.game-phase-lobby .board-cell:not(.answered):disabled,
body.player-local-slot.game-phase-lobby .board-cell:not(.answered):disabled,
body.role-spectator.game-phase-lobby .board-cell:not(.answered):disabled {
  opacity: 1 !important;
  cursor: default !important;
  pointer-events: none !important;
}

@media (max-width: 720px) {
  body.game-phase-lobby .game-layout,
  body.role-player.game-phase-lobby .game-layout,
  body.player-local-slot.game-phase-lobby .game-layout,
  body.role-spectator.game-phase-lobby .game-layout,
  body.role-host.game-phase-lobby .game-layout {
    margin-top: 14px !important;
  }

  body.game-phase-lobby .category-cell,
  body.role-player.game-phase-lobby .category-cell,
  body.player-local-slot.game-phase-lobby .category-cell,
  body.role-spectator.game-phase-lobby .category-cell,
  body.role-host.game-phase-lobby .category-cell,
  body.game-phase-lobby .board-cell,
  body.role-player.game-phase-lobby .board-cell,
  body.player-local-slot.game-phase-lobby .board-cell,
  body.role-spectator.game-phase-lobby .board-cell,
  body.role-host.game-phase-lobby .board-cell {
    height: auto !important;
    min-height: 42px !important;
  }
}


/* Patch: active spectator should use the same minimal in-game layout as a player/local-slot. */
body.role-spectator:not(.game-phase-lobby) #lobbyPanel {
  display: none !important;
}

body.role-spectator:not(.game-phase-lobby) .player-controls {
  display: none !important;
}

body.role-spectator:not(.game-phase-lobby) .game-header.panel {
  display: grid !important;
  grid-template-rows: auto auto !important;
  gap: 14px !important;
  position: relative !important;
  padding: clamp(16px, 1.6vw, 22px) clamp(18px, 2.2vw, 30px) !important;
  min-height: 0 !important;
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
  border: 1px solid rgba(191, 219, 254, 0.14) !important;
  border-radius: 24px !important;
  background: rgba(9, 14, 36, 0.72) !important;
  box-shadow: 0 18px 58px rgba(0, 0, 0, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.055) !important;
  backdrop-filter: none !important;
}

body.role-spectator:not(.game-phase-lobby) .game-header.panel::after {
  display: block !important;
  content: "" !important;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent, rgba(56, 189, 248, 0.04), rgba(124, 58, 237, 0.08)) !important;
}

body.role-spectator:not(.game-phase-lobby) .game-header {
  gap: clamp(16px, 2vw, 26px) !important;
  min-height: 0 !important;
}

body.role-spectator:not(.game-phase-lobby) .game-header-main {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  gap: 4px !important;
  min-height: 0 !important;
  padding: 0 !important;
  align-items: start !important;
  justify-items: start !important;
  text-align: left !important;
}

body.role-spectator:not(.game-phase-lobby) .game-title-block {
  display: grid !important;
  gap: 5px !important;
  min-height: 0 !important;
  max-width: none !important;
  justify-items: start !important;
  text-align: left !important;
}

body.role-spectator:not(.game-phase-lobby) .game-title-block h2 {
  margin: 0 !important;
  line-height: 1.08 !important;
  font-size: clamp(1.85rem, 2.6vw, 3rem) !important;
}

body.role-spectator:not(.game-phase-lobby) #turnLabel {
  display: none !important;
}

body.role-spectator:not(.game-phase-lobby) .game-header-tools {
  position: static !important;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  width: 100% !important;
  min-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  overflow: visible !important;
}

body.role-spectator:not(.game-phase-lobby) .players-card {
  display: grid !important;
  gap: 10px !important;
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
  padding: 0 !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

body.role-spectator:not(.game-phase-lobby) .players-card-header {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  padding: 0 !important;
  margin: 0 !important;
  background: transparent !important;
  border: 0 !important;
}

body.role-spectator:not(.game-phase-lobby) .players-card-header h3 {
  margin: 0 !important;
  font-size: 1rem !important;
  color: #e0e7ff !important;
}

body.role-spectator:not(.game-phase-lobby) .players-card .score-list {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)) !important;
  gap: 10px !important;
  width: 100% !important;
  max-width: none !important;
  padding: 3px !important;
  margin: -3px !important;
  overflow: visible !important;
}

body.role-spectator:not(.game-phase-lobby) .score-row {
  min-width: 0 !important;
  background: rgba(7, 12, 34, 0.38) !important;
  backdrop-filter: none !important;
  overflow: visible !important;
}

body.role-spectator:not(.game-phase-lobby) .score-row.host-row {
  border-color: rgba(250, 204, 21, 0.74) !important;
  background:
    radial-gradient(circle at 0 0, rgba(250, 204, 21, 0.14), transparent 56%),
    rgba(7, 12, 34, 0.48) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 0 0 1px rgba(250, 204, 21, 0.08) !important;
}

body.role-spectator:not(.game-phase-lobby) .score-row.active-turn-player:not(.host-row),
body.role-spectator:not(.game-phase-lobby) .score-row.current:not(.host-row) {
  border-color: rgba(56, 189, 248, 0.86) !important;
  background:
    radial-gradient(circle at 0 0, rgba(56, 189, 248, 0.18), transparent 58%),
    linear-gradient(135deg, rgba(7, 12, 34, 0.52), rgba(37, 99, 235, 0.16), rgba(124, 58, 237, 0.13)) !important;
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.18) inset, 0 0 24px rgba(56, 189, 248, 0.10) !important;
}

body.role-spectator:not(.game-phase-lobby) .score-row.active-turn-player:not(.host-row) .score-order,
body.role-spectator:not(.game-phase-lobby) .score-row.current:not(.host-row) .score-order {
  background: rgba(56, 189, 248, 0.22) !important;
  border-color: rgba(56, 189, 248, 0.48) !important;
  color: #bae6fd !important;
}

@media (max-width: 720px) {
  body.role-spectator:not(.game-phase-lobby) .players-card .score-list {
    grid-template-columns: 1fr !important;
  }
}

/* Patch: Lobby-verlassen bei Spielern als echte, klickbare Overlay-Schaltfläche.
   Vorher lag der Button im playerControls-Grid und konnte je nach Spielerlayout
   von Header-/Score-Flächen überdeckt werden. */
body.role-player .game-header.panel,
body.player-local-slot .game-header.panel {
  isolation: isolate !important;
}

body.role-player .game-header.panel::after,
body.player-local-slot .game-header.panel::after {
  z-index: 0 !important;
  pointer-events: none !important;
}

body.role-player .game-header.panel > :not(.player-leave-floating-btn),
body.player-local-slot .game-header.panel > :not(.player-leave-floating-btn) {
  position: relative;
  z-index: 1;
}

.player-leave-floating-btn {
  position: absolute !important;
  top: clamp(14px, 1.6vw, 22px) !important;
  right: clamp(18px, 2.2vw, 30px) !important;
  z-index: 999 !important;
  pointer-events: auto !important;
  cursor: pointer !important;
  user-select: none;
  min-height: 36px !important;
  padding: 9px 13px !important;
  border-radius: 999px !important;
  font-size: 0.82rem !important;
  line-height: 1 !important;
  white-space: nowrap !important;
  background: rgba(7, 12, 34, 0.78) !important;
  border: 1px solid rgba(147, 197, 253, 0.38) !important;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.07) !important;
}

.player-leave-floating-btn:hover:not(:disabled),
.player-leave-floating-btn:focus-visible:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.08);
  border-color: rgba(191, 219, 254, 0.62) !important;
  box-shadow: 0 0 0 3px rgba(147, 197, 253, 0.14), 0 14px 34px rgba(0, 0, 0, 0.28) !important;
}

.player-leave-floating-btn:active:not(:disabled) {
  transform: translateY(0);
}

body.role-player .player-controls .player-leave-btn:not(.player-leave-floating-btn),
body.player-local-slot .player-controls .player-leave-btn:not(.player-leave-floating-btn) {
  display: none !important;
}

@media (max-width: 720px) {
  .player-leave-floating-btn {
    top: 12px !important;
    right: 14px !important;
    min-height: 34px !important;
    padding: 8px 11px !important;
    font-size: 0.78rem !important;
  }
}

/* Patch: Lobby-verlassen sitzt jetzt im Topbar-Bereich links neben dem Lobby-Code. */
.player-topbar-leave-btn {
  flex: 0 0 auto !important;
  position: relative !important;
  z-index: 30 !important;
  pointer-events: auto !important;
  cursor: pointer !important;
  min-height: 42px !important;
  padding: 10px 14px !important;
  border-radius: 999px !important;
  white-space: nowrap !important;
  align-self: center !important;
}

.player-topbar-leave-btn:hover:not(:disabled),
.player-topbar-leave-btn:focus-visible:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

@media (max-width: 900px) {
  .topbar-actions .player-topbar-leave-btn {
    flex: 0 0 auto !important;
  }
}

@media (max-width: 640px) {
  .topbar-actions .player-topbar-leave-btn,
  .topbar-code-card,
  .connection {
    width: 100% !important;
  }
}

/* Patch: Backend dropdown arrows cleaned up.
   Lobby Einstellungen now uses exactly one triangle from .lobby-settings-head::before;
   native markers and old chevron button/SVG are suppressed completely. */
.lobby-settings-toggle,
.lobby-settings-toggle *,
.lobby-settings-toggle .chevron,
.lobby-settings-toggle .chevron-icon,
.lobby-settings-toggle .chevron-icon::before,
.lobby-settings-toggle svg {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.lobby-settings-head,
.manual-score-menu > summary,
.precreate-players-details > summary,
.question-builder > summary {
  list-style: none !important;
}

.lobby-settings-head::marker,
.manual-score-menu > summary::marker,
.precreate-players-details > summary::marker,
.question-builder > summary::marker {
  content: '' !important;
  display: none !important;
}

.lobby-settings-head::-webkit-details-marker,
.manual-score-menu > summary::-webkit-details-marker,
.precreate-players-details > summary::-webkit-details-marker,
.question-builder > summary::-webkit-details-marker {
  display: none !important;
}

.lobby-settings-head {
  position: relative !important;
  min-height: 42px !important;
  padding: 10px 14px 10px 34px !important;
  align-items: center !important;
  line-height: 1.4 !important;
  cursor: pointer !important;
}

.lobby-settings-head::before {
  content: '▶' !important;
  position: absolute !important;
  left: 14px !important;
  top: 50% !important;
  width: 1em !important;
  height: 1em !important;
  display: inline-grid !important;
  place-items: center !important;
  color: #bfdbfe !important;
  font-size: 0.88rem !important;
  line-height: 1 !important;
  transform: translateY(-50%) rotate(0deg) !important;
  transform-origin: 50% 50% !important;
  transition: transform 220ms ease, color 180ms ease !important;
}

.lobby-settings-menu.open .lobby-settings-head::before {
  transform: translateY(-50%) rotate(90deg) !important;
  color: #93c5fd !important;
}

.manual-score-menu > summary::before,
.question-builder > summary::before {
  position: static !important;
  flex: 0 0 1em !important;
  margin: 0 0.42rem 0 0 !important;
  transform: rotate(0deg) !important;
}

.manual-score-menu[open] > summary::before,
.question-builder[open] > summary::before {
  transform: rotate(90deg) !important;
}

/* Patch: Spectator rejoin link copy button in Host-Control. */
.spectator-rejoin-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(56, 189, 248, 0.22);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.10), rgba(124, 58, 237, 0.09));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.045);
}

.spectator-rejoin-box strong {
  color: #e0f2fe;
}

.spectator-rejoin-box p {
  margin: 3px 0 0;
}

.spectator-rejoin-copy-btn.is-copied {
  border-color: rgba(34, 197, 94, 0.52) !important;
  background: linear-gradient(135deg, #16a34a, #2563eb) !important;
}

@media (max-width: 720px) {
  .spectator-rejoin-box {
    align-items: stretch;
    flex-direction: column;
  }
}

/* Reveal-Bild: optionales Bild zur Auflösung */
.optional-label {
  display: inline-flex;
  align-items: center;
  width: max-content;
  margin-left: 6px;
  border-radius: 999px;
  padding: 2px 7px;
  border: 1px solid rgba(147, 197, 253, 0.28);
  background: rgba(14, 165, 233, 0.10);
  color: var(--muted-2);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.reveal-image-builder-block {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 16px;
  border: 1px dashed rgba(147, 197, 253, 0.24);
  background: rgba(14, 165, 233, 0.06);
}

.answer-reveal-image-box {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.answer-reveal-image {
  width: min(100%, 760px);
  max-height: clamp(160px, 34vh, 380px);
  object-fit: contain;
  border-radius: 18px;
  border: 1px solid rgba(74, 222, 128, 0.36);
  background: rgba(0, 0, 0, 0.22);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.24);
}


/* Maintenance/offline mode + question-modal background effects */
body.server-offline .connection.offline {
  border-color: rgba(248, 113, 113, 0.42);
  background: rgba(127, 29, 29, 0.38);
  color: #fecaca;
}

body.question-popup-open {
  overflow: hidden;
  height: 100vh;
}

body.question-popup-open .question-panel {
  overflow: hidden;
}

body.question-popup-open .question-panel::before {
  background: rgba(3, 7, 18, 0.46) !important;
  backdrop-filter: blur(8px) brightness(0.78) saturate(0.92);
  -webkit-backdrop-filter: blur(8px) brightness(0.78) saturate(0.92);
}

body.question-popup-open .question-overlay-card {
  box-shadow:
    0 42px 120px rgba(0, 0, 0, 0.72),
    0 0 72px rgba(124, 58, 237, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}


/* Separate offline-safe template creation action on the start page */
.home-template-actions {
  width: 100%;
}

@media (max-width: 640px) {
  .home-template-actions {
    grid-template-columns: 1fr;
  }
}


/* Patch: Offline-Spielaktionen und Template-only Backend */
.builder-toolbar {
  grid-template-columns: 2fr 0.8fr 0.8fr auto minmax(240px, auto);
}

.builder-save-actions {
  display: grid;
  gap: 8px;
  align-self: stretch;
  min-width: 240px;
}

.builder-save-actions > button {
  min-height: 42px;
}

.save-template-hint {
  margin: 0;
  line-height: 1.35;
}

body.template-builder-only #hostSavedTemplateBtn,
body.template-builder-only #hostActiveSpectatorTemplateBtn {
  display: none !important;
}

.browser-draft-actions {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

body.server-offline #joinBtn:disabled,
body.server-offline #openHostSetupBtn:disabled,
body.server-offline [data-host-recent-hash]:disabled,
body.server-offline [data-reconnect-host-code]:disabled {
  filter: grayscale(0.28);
  box-shadow: none;
}

@media (max-width: 1040px) {
  .builder-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .builder-save-actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .builder-toolbar {
    grid-template-columns: 1fr;
  }
}

/* Patch: Punkteverteilung im Backend */
.builder-point-options {
  display: grid;
  gap: 10px;
  margin: 18px 0 20px;
}

.builder-point-options .second-board-option {
  margin: 0;
}

/* Patch: stable bottom-centered buzzer outside the question card + no-copy question popup */
.question-panel,
.question-overlay-card,
.question-content,
.question-big,
.answer-box,
.released-section {
  -webkit-user-select: none;
  user-select: none;
}

.question-panel input,
.question-panel textarea,
.question-panel select,
.question-panel button {
  -webkit-user-select: auto;
  user-select: auto;
}

.question-buzzer-dock {
  position: fixed;
  left: 50%;
  bottom: clamp(16px, 4vh, 42px);
  transform: translateX(-50%);
  z-index: 985;
  pointer-events: auto;
  display: grid;
  place-items: center;
}

.question-buzzer-dock .popup-buzz-button {
  min-width: clamp(180px, 28vw, 320px);
  min-height: clamp(58px, 7vh, 82px);
  font-size: clamp(1rem, 2.2vw, 1.45rem);
  padding: 14px 24px;
  border-width: 2px;
}

.question-buzzer-dock .popup-buzz-button small {
  font-size: 0.72em;
}

.question-headline-tools .popup-buzz-button {
  display: none !important;
}

@media (max-width: 640px) {
  .question-buzzer-dock {
    bottom: 12px;
    width: calc(100vw - 24px);
  }
  .question-buzzer-dock .popup-buzz-button {
    width: min(100%, 340px);
  }
}

/* Patch: teams + active player controls */
.teams-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.team-summary-card {
  border: 1px solid rgba(147, 197, 253, 0.24);
  border-radius: 14px;
  padding: 8px 9px;
  background: rgba(15, 23, 42, 0.58);
  display: grid;
  gap: 2px;
}

.team-summary-card strong {
  color: #bfdbfe;
  font-size: 0.82rem;
}

.team-summary-card span {
  font-weight: 1000;
}

.team-summary-card small {
  color: rgba(226, 232, 240, 0.62);
}

.team-summary-card.empty {
  opacity: 0.55;
}

.team-badge {
  display: inline-flex;
  align-items: center;
  width: max-content;
  border-radius: 999px;
  border: 1px solid rgba(56, 189, 248, 0.32);
  background: rgba(56, 189, 248, 0.12);
  color: #bfdbfe;
  font-size: 0.68rem;
  font-weight: 900;
  padding: 2px 7px;
}

.team-badge-inline {
  margin-left: 6px;
  vertical-align: middle;
}

.player-team-box,
.host-player-management {
  border: 1px solid rgba(147, 197, 253, 0.18);
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.52);
  padding: 12px;
  margin-bottom: 10px;
}

.player-team-box strong,
.host-player-management strong,
.host-active-player-box label {
  display: block;
  font-weight: 1000;
  margin-bottom: 8px;
  color: #e5edff;
}

.team-join-buttons {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.team-join-btn {
  border: 1px solid rgba(147, 197, 253, 0.22);
  border-radius: 12px;
  padding: 9px 8px;
  color: #dbeafe;
  background: rgba(30, 41, 59, 0.86);
  font-weight: 900;
  cursor: pointer;
}

.team-join-btn:hover,
.team-join-btn.active {
  border-color: rgba(56, 189, 248, 0.58);
  background: rgba(56, 189, 248, 0.2);
  color: #fff;
}

.host-player-management {
  display: grid;
  gap: 12px;
}

.host-team-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border-top: 1px solid rgba(148, 163, 184, 0.16);
  padding-top: 10px;
}

.host-active-player-box .inline-actions {
  grid-template-columns: minmax(0, 1fr) auto;
}

@media (max-width: 760px) {
  .teams-summary,
  .team-join-buttons {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .host-team-tools,
  .host-active-player-box .inline-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}

/* Patch: backend layout cleanup, single dropdown arrow, robust columns */
.builder-toolbar,
.builder-point-options,
.builder-grid-inner,
.category-builder,
.question-builder,
.question-builder-summary,
.question-builder-body,
.question-type-fields,
.question-type-fields label,
.question-type-fields input,
.question-type-fields select,
.question-type-fields textarea,
.category-builder input,
.category-builder select,
.category-builder textarea {
  min-width: 0 !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

.builder-grid-inner {
  align-items: start !important;
  overflow: visible !important;
}

.category-builder {
  overflow: hidden !important;
}

.question-builder > summary,
.manual-score-menu > summary,
.precreate-players-details > summary {
  list-style: none !important;
}

.question-builder > summary::marker,
.question-builder > summary::-webkit-details-marker,
.manual-score-menu > summary::marker,
.manual-score-menu > summary::-webkit-details-marker,
.precreate-players-details > summary::marker,
.precreate-players-details > summary::-webkit-details-marker {
  display: none !important;
  content: '' !important;
}

/* Kategorien/Fragen im Backend: nur ein Pfeil, sauber rechts positioniert */
.question-builder > summary::before,
.manual-score-menu > summary::before {
  display: none !important;
  content: none !important;
}

.question-builder-summary {
  position: relative !important;
  padding-right: 34px !important;
  gap: 6px !important;
  grid-template-columns: minmax(72px, auto) minmax(0, 1fr) auto !important;
}

.question-builder-summary::after {
  content: '▾' !important;
  position: absolute !important;
  right: 12px !important;
  top: 50% !important;
  transform: translateY(-50%) rotate(0deg) !important;
  width: auto !important;
  height: auto !important;
  border: 0 !important;
  line-height: 1 !important;
  pointer-events: none !important;
}

.question-builder[open] .question-builder-summary::after {
  transform: translateY(-50%) rotate(180deg) !important;
}

.question-builder-summary .builder-status,
.question-builder-summary .builder-media-status,
.question-builder-summary .points-pill {
  white-space: nowrap !important;
}

.question-builder-body textarea,
.question-builder-body input,
.question-builder-body select {
  width: 100% !important;
}

.team-management-actions {
  flex-wrap: wrap !important;
}

/* Fragen-Popup: Fragen/Antworten nicht markierbar/kopierbar; Controls bleiben nutzbar */
.question-overlay-card,
.question-overlay-card .question-big,
.question-overlay-card .answer-box,
.question-overlay-card .released-section,
.question-overlay-card .question-headline-row,
.question-overlay-card .question-waiting,
.question-overlay-card .public-buzz-list,
.question-overlay-card .judgement-banner {
  -webkit-user-select: none !important;
  user-select: none !important;
}

.question-overlay-card button,
.question-overlay-card input,
.question-overlay-card textarea,
.question-overlay-card select,
.question-overlay-card label {
  -webkit-user-select: auto !important;
  user-select: auto !important;
}

/* Buzzer bleibt viewport-fixiert unten mittig, unabhängig von Popup-Höhe */
.question-buzzer-dock {
  position: fixed !important;
  left: 50% !important;
  right: auto !important;
  bottom: max(18px, env(safe-area-inset-bottom, 0px) + 18px) !important;
  transform: translateX(-50%) !important;
  z-index: 1400 !important;
  width: min(420px, calc(100vw - 28px)) !important;
  pointer-events: none !important;
}

.question-buzzer-dock .popup-buzz-button {
  width: 100% !important;
  pointer-events: auto !important;
}

/* Patch: Backend Checkbox-Höhen/linien sauber vereinheitlichen */
.audio-filter-options {
  align-items: stretch !important;
}

.audio-filter-options .checkbox-row,
.audio-filter-options .compact-checkbox,
.category-cooldown-row .checkbox-row,
.category-cooldown-row .compact-checkbox {
  min-height: 44px !important;
  height: 44px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 10px !important;
  padding: 0 12px !important;
  line-height: 1.1 !important;
  overflow: hidden !important;
  box-shadow: none !important;
  text-align: left !important;
}

.audio-filter-options .checkbox-row input,
.audio-filter-options .compact-checkbox input,
.category-cooldown-row .checkbox-row input,
.category-cooldown-row .compact-checkbox input {
  flex: 0 0 auto !important;
  width: 16px !important;
  height: 16px !important;
  margin: 0 !important;
  transform: none !important;
  position: static !important;
}

.audio-filter-options .checkbox-row span,
.audio-filter-options .compact-checkbox span,
.category-cooldown-row .checkbox-row span,
.category-cooldown-row .compact-checkbox span {
  flex: 1 1 auto !important;
  min-width: 0 !important;
  text-align: left !important;
  white-space: nowrap !important;
}

/* Patch: Team-Layout mit kleinem Host links und Teams über volle Restbreite */
.score-overview-strip {
  display: grid !important;
  grid-template-columns: minmax(140px, 220px) minmax(0, 1fr) !important;
  gap: 12px !important;
  align-items: start !important;
  margin-bottom: 12px !important;
}

.score-overview-strip .host-row {
  width: 100% !important;
  min-height: 0 !important;
  align-self: start !important;
  padding: 10px 12px !important;
  margin: 0 !important;
}

.score-overview-strip .host-row .score-points {
  font-size: 0.78rem !important;
  padding: 5px 8px !important;
}

.score-overview-strip .teams-summary {
  margin: 0 !important;
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)) !important;
  gap: 10px !important;
  width: 100% !important;
}

.team-summary-card {
  border-color: color-mix(in srgb, var(--team-color, #38bdf8) 72%, rgba(191,219,254,.22)) !important;
  background: linear-gradient(135deg, color-mix(in srgb, var(--team-color, #38bdf8) 14%, rgba(15,23,42,.9)), rgba(15,23,42,.68)) !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 0 0 1px rgba(255,255,255,.02) !important;
}

.team-summary-card.joined {
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 0 0 2px color-mix(in srgb, var(--team-color, #38bdf8) 62%, transparent) !important;
}

.team-card-head {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  gap: 10px !important;
}

.team-summary-card strong {
  color: var(--team-color, #38bdf8) !important;
  text-shadow: 0 0 18px color-mix(in srgb, var(--team-color, #38bdf8) 48%, transparent) !important;
}

.team-summary-card span {
  white-space: nowrap !important;
}

.team-summary-card .team-join-btn {
  margin-top: 8px !important;
  border-color: color-mix(in srgb, var(--team-color, #38bdf8) 58%, rgba(191,219,254,.18)) !important;
  background: color-mix(in srgb, var(--team-color, #38bdf8) 16%, rgba(15,23,42,.88)) !important;
}

.team-summary-card .team-join-btn:hover,
.team-summary-card .team-join-btn.active {
  background: color-mix(in srgb, var(--team-color, #38bdf8) 30%, rgba(15,23,42,.74)) !important;
  color: #fff !important;
}

.team-badge {
  border-color: color-mix(in srgb, var(--team-color, #38bdf8) 58%, rgba(191,219,254,.22)) !important;
  background: color-mix(in srgb, var(--team-color, #38bdf8) 18%, rgba(15,23,42,.76)) !important;
  color: var(--team-color, #38bdf8) !important;
}

@media (max-width: 900px) {
  .score-overview-strip {
    grid-template-columns: 1fr !important;
  }
  .score-overview-strip .host-row {
    max-width: 240px !important;
  }
}

/* Patch: Teams unter dem Host, Team-Mitglieder wirklich in den Team-Containern */
.score-list.team-score-mode,
.players-card .score-list.team-score-mode {
  display: block !important;
  grid-template-columns: none !important;
}

.team-score-layout {
  display: grid !important;
  grid-template-columns: 1fr !important;
  gap: 12px !important;
  align-items: start !important;
  width: 100% !important;
  margin: 0 !important;
}

.team-score-layout > .host-row {
  width: min(240px, 100%) !important;
  max-width: 240px !important;
  min-height: 0 !important;
  align-self: start !important;
  padding: 10px 12px !important;
  margin: 0 !important;
}

.team-score-layout > .teams-summary {
  display: grid !important;
  grid-template-columns: repeat(var(--team-count, 4), minmax(0, 1fr)) !important;
  gap: 10px !important;
  width: 100% !important;
  margin: 0 !important;
}

.team-summary-card {
  position: relative !important;
  min-width: 0 !important;
  min-height: 142px !important;
  align-content: start !important;
  padding: 11px 12px !important;
  gap: 8px !important;
}

.team-delete-btn {
  position: absolute !important;
  top: 7px !important;
  right: 7px !important;
  z-index: 2 !important;
  width: 24px !important;
  height: 24px !important;
  border-radius: 999px !important;
  border: 1px solid color-mix(in srgb, var(--team-color, #38bdf8) 58%, rgba(255,255,255,.22)) !important;
  background: rgba(2, 6, 23, .72) !important;
  color: var(--team-color, #38bdf8) !important;
  font-size: 18px !important;
  font-weight: 1000 !important;
  line-height: 20px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  box-shadow: 0 0 18px color-mix(in srgb, var(--team-color, #38bdf8) 30%, transparent) !important;
}

.team-delete-btn:hover {
  background: color-mix(in srgb, var(--team-color, #38bdf8) 24%, rgba(2,6,23,.9)) !important;
  color: #fff !important;
}

.team-card-head {
  padding-right: 24px !important;
}

.team-card-head strong {
  overflow-wrap: anywhere !important;
}

.team-members-list {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)) !important;
  gap: 6px !important;
  margin-top: 2px !important;
}

.team-member-chip {
  display: grid !important;
  grid-template-columns: auto minmax(0, 1fr) auto !important;
  align-items: center !important;
  gap: 6px !important;
  min-width: 0 !important;
  border-radius: 12px !important;
  border: 1px solid color-mix(in srgb, var(--team-color, #38bdf8) 34%, rgba(191,219,254,.18)) !important;
  background: rgba(2, 6, 23, .34) !important;
  padding: 7px 8px !important;
}

.team-member-chip.current,
.team-member-chip.active-turn-player {
  border-color: color-mix(in srgb, var(--team-color, #38bdf8) 72%, white) !important;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--team-color, #38bdf8) 36%, transparent), 0 0 24px color-mix(in srgb, var(--team-color, #38bdf8) 18%, transparent) !important;
}

.team-member-chip .score-order {
  margin: 0 !important;
  background: color-mix(in srgb, var(--team-color, #38bdf8) 20%, rgba(15,23,42,.9)) !important;
  color: var(--team-color, #38bdf8) !important;
  border-color: color-mix(in srgb, var(--team-color, #38bdf8) 52%, rgba(191,219,254,.16)) !important;
}

.team-member-name {
  min-width: 0 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  color: #f8fafc !important;
  font-weight: 900 !important;
}

.team-member-chip strong {
  color: #e2e8f0 !important;
  font-size: .84rem !important;
  white-space: nowrap !important;
}

.team-empty-note,
.team-no-players-note {
  color: rgba(226, 232, 240, .58) !important;
  font-size: .82rem !important;
}

.team-unassigned-players {
  border: 1px dashed rgba(148, 163, 184, .24) !important;
  border-radius: 16px !important;
  padding: 10px !important;
  background: rgba(15, 23, 42, .42) !important;
}

.team-unassigned-players > strong {
  display: block !important;
  margin-bottom: 8px !important;
  color: rgba(226, 232, 240, .78) !important;
}

.team-unassigned-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)) !important;
  gap: 8px !important;
}

.team-unassigned-grid .team-member-chip {
  --team-color: #94a3b8;
}

@media (max-width: 1100px) {
  .team-score-layout > .teams-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 680px) {
  .team-score-layout > .teams-summary {
    grid-template-columns: 1fr !important;
  }
}

/* Patch: Team view final cleanup - no inner scroll, stable team cards, lobby-only joining */
body.game-active .players-card.top-game-card,
body.game-active .host-controls.top-game-card,
.players-card .score-list.team-score-mode,
.score-list.team-score-mode,
.team-score-layout {
  max-height: none !important;
  height: auto !important;
  overflow: visible !important;
}

body.role-host .players-card.top-game-card,
body.role-player .players-card.top-game-card,
body.player-local-slot .players-card.top-game-card,
body.role-spectator .players-card.top-game-card {
  max-height: none !important;
  overflow: visible !important;
}

/* Team cards stay inside the player container and reflow instead of overflowing. */
.team-score-layout > .teams-summary,
.score-overview-strip .teams-summary {
  display: grid !important;
  grid-template-columns: repeat(var(--team-count, 4), minmax(0, 1fr)) !important;
  gap: 10px !important;
  width: 100% !important;
  min-width: 0 !important;
  overflow: visible !important;
}

.team-summary-card {
  min-width: 0 !important;
  width: 100% !important;
  overflow: visible !important;
}

@media (max-width: 1400px) {
  .team-score-layout > .teams-summary,
  .score-overview-strip .teams-summary {
    grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)) !important;
  }
}

@media (max-width: 760px) {
  .team-score-layout > .teams-summary,
  .score-overview-strip .teams-summary {
    grid-template-columns: 1fr !important;
  }
}

/* Delete X: always white, centered, with a white border. */
.team-delete-btn {
  width: 24px !important;
  height: 24px !important;
  min-width: 24px !important;
  min-height: 24px !important;
  padding: 0 !important;
  border: 1px solid rgba(255,255,255,.86) !important;
  color: #fff !important;
  background: rgba(2, 6, 23, .74) !important;
  line-height: 1 !important;
  display: inline-grid !important;
  place-items: center !important;
  text-align: center !important;
  font-size: 17px !important;
  font-weight: 1000 !important;
}

.team-delete-btn:hover {
  color: #fff !important;
  border-color: #fff !important;
  background: rgba(255,255,255,.16) !important;
}

/* Join buttons are only rendered when they are actionable; make them clearly clickable. */
.team-summary-card .team-join-btn.available {
  opacity: 1 !important;
  cursor: pointer !important;
  color: #fff !important;
  border-width: 2px !important;
  border-color: color-mix(in srgb, var(--team-color, #38bdf8) 78%, white) !important;
  background:
    linear-gradient(135deg,
      color-mix(in srgb, var(--team-color, #38bdf8) 38%, rgba(15,23,42,.72)),
      rgba(15,23,42,.82)) !important;
  box-shadow: 0 0 22px color-mix(in srgb, var(--team-color, #38bdf8) 22%, transparent) !important;
}

.team-summary-card .team-join-btn.available:hover {
  filter: brightness(1.14) !important;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--team-color, #38bdf8) 26%, transparent), 0 0 28px color-mix(in srgb, var(--team-color, #38bdf8) 36%, transparent) !important;
}

.team-summary-card.empty {
  opacity: .9 !important;
}

/* Host controls after game start: prevent cramped controls and preserve select arrows. */
.host-player-management,
.host-active-player-box,
.host-team-tools,
.manual-score-menu {
  min-width: 0 !important;
  max-width: 100% !important;
  overflow: visible !important;
}

.host-active-player-box .inline-actions {
  display: grid !important;
  grid-template-columns: minmax(220px, 1fr) minmax(170px, auto) !important;
  gap: 10px !important;
  align-items: stretch !important;
}

.host-active-player-box select,
.host-active-player-box button {
  min-width: 0 !important;
  width: 100% !important;
  height: auto !important;
  white-space: normal !important;
}

.host-active-player-box select,
#activeTeamSelect,
#activePlayerSelect {
  appearance: auto !important;
  -webkit-appearance: menulist !important;
  padding-right: 36px !important;
}

.host-team-tools {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto !important;
  align-items: end !important;
  gap: 12px !important;
}

.team-management-actions {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 10px !important;
  justify-content: flex-end !important;
  align-items: stretch !important;
  min-width: min(100%, 330px) !important;
}

.team-management-actions button {
  flex: 1 1 150px !important;
  min-width: 145px !important;
  max-width: none !important;
  width: auto !important;
  white-space: normal !important;
  word-break: normal !important;
  overflow-wrap: normal !important;
  line-height: 1.2 !important;
  text-align: center !important;
}

@media (max-width: 900px) {
  .host-active-player-box .inline-actions,
  .host-team-tools {
    grid-template-columns: 1fr !important;
  }

  .team-management-actions {
    justify-content: stretch !important;
    min-width: 0 !important;
  }

  .team-management-actions button {
    flex: 1 1 100% !important;
    width: 100% !important;
  }
}

/* Restore a clean custom arrow for the manual score dropdown. */
.manual-score-menu > summary {
  position: relative !important;
  list-style: none !important;
  padding-right: 32px !important;
  min-height: 22px !important;
  line-height: 1.4 !important;
}

.manual-score-menu > summary::-webkit-details-marker,
.manual-score-menu > summary::marker {
  display: none !important;
  content: '' !important;
}

.manual-score-menu > summary::after {
  content: '▾' !important;
  position: absolute !important;
  right: 12px !important;
  top: 50% !important;
  transform: translateY(-50%) rotate(0deg) !important;
  color: #c7d2fe !important;
  line-height: 1 !important;
  pointer-events: none !important;
}

.manual-score-menu[open] > summary::after {
  transform: translateY(-50%) rotate(180deg) !important;
}

/* Team member chips should stay inside cards in narrow views. */
.team-members-list {
  grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)) !important;
}

.team-member-chip {
  max-width: 100% !important;
}

/* Patch: Team start cleanup + robust media loading acknowledgement */
.media-frame {
  position: relative !important;
  display: grid !important;
  place-items: center !important;
  width: min(100%, 980px) !important;
  margin: 0 auto !important;
  min-height: clamp(180px, 32vh, 420px) !important;
  border-radius: 18px !important;
  overflow: hidden !important;
}

.media-frame .media-loading-spinner {
  position: absolute !important;
  z-index: 1 !important;
  width: 42px !important;
  height: 42px !important;
  border-radius: 999px !important;
  border: 4px solid rgba(191, 219, 254, .24) !important;
  border-top-color: #a78bfa !important;
  animation: mediaSpin .8s linear infinite !important;
}

.media-frame.is-loaded .media-loading-spinner {
  display: none !important;
}

.media-frame.has-error::after {
  content: 'Bild konnte nicht geladen werden';
  position: absolute;
  z-index: 2;
  inset: auto 12px 12px;
  border-radius: 12px;
  padding: 8px 10px;
  background: rgba(127, 29, 29, .86);
  color: #fecaca;
  text-align: center;
  font-weight: 900;
}

.media-frame .question-media {
  position: relative !important;
  z-index: 2 !important;
  opacity: 0 !important;
  transition: opacity .18s ease !important;
}

.media-frame.is-loaded .question-media {
  opacity: 1 !important;
}

.media-sync-status {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 9px !important;
  width: max-content !important;
  max-width: 100% !important;
  margin: 8px auto 0 !important;
  padding: 8px 12px !important;
  border-radius: 999px !important;
  border: 1px solid rgba(167, 139, 250, .42) !important;
  background: rgba(30, 41, 59, .72) !important;
  color: #e9d5ff !important;
  font-size: .86rem !important;
  font-weight: 900 !important;
}

.media-sync-status .media-loading-spinner {
  width: 18px !important;
  height: 18px !important;
  border-radius: 999px !important;
  border: 2px solid rgba(233, 213, 255, .25) !important;
  border-top-color: #f0abfc !important;
  animation: mediaSpin .8s linear infinite !important;
}

@keyframes mediaSpin {
  to { transform: rotate(360deg); }
}

/* Nach Spielstart gibt es keine Team-Verwaltung mehr im Host-Control. */
body:not(.game-phase-lobby) .host-team-tools,
body:not(.game-phase-lobby) .team-management-actions,
body:not(.game-phase-lobby) .team-delete-btn,
body:not(.game-phase-lobby) .team-join-btn {
  display: none !important;
}

.template-permissions-box {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid rgba(147, 197, 253, 0.22);
  border-radius: 18px;
  background: rgba(7, 12, 34, 0.72);
}

.template-permissions-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.template-permissions-box label {
  display: block;
  margin-bottom: 8px;
  color: var(--text, #e5edff);
  font-weight: 800;
}

.template-permissions-box textarea {
  width: 100%;
  min-height: 78px;
  resize: vertical;
}

.template-permissions-box.is-disabled {
  opacity: 0.72;
}

/* Nur-Ansicht für fremde Boards: Fragen bleiben aufklappbar/lesbar, Konfiguration ist gesperrt. */
.template-readonly-mode .builder-toolbar input,
.template-readonly-mode .builder-toolbar select,
.template-readonly-mode .builder-toolbar button:not(#saveTemplateAsNewBtn),
.template-readonly-mode .builder-point-options input,
.template-readonly-mode .builder-grid input,
.template-readonly-mode .builder-grid textarea,
.template-readonly-mode .builder-grid select,
.template-readonly-mode .builder-grid button {
  opacity: 0.62;
  cursor: not-allowed;
}

.template-readonly-mode .builder-grid textarea,
.template-readonly-mode .builder-grid input[readonly] {
  color: rgba(245, 248, 255, 0.86);
  background: rgba(8, 14, 38, 0.72);
  border-color: rgba(153, 180, 255, 0.22);
  user-select: text;
  cursor: default;
}

.template-readonly-mode .question-builder-summary,
.template-readonly-mode .question-builder,
.template-readonly-mode .question-builder *:not(input):not(textarea):not(select):not(button) {
  cursor: default;
}

.template-readonly-mode .question-builder-summary {
  cursor: pointer;
}

.template-readonly-mode .template-permissions-box,
.template-readonly-mode .builder-point-options,
.template-readonly-mode .builder-toolbar {
  position: relative;
}

.template-readonly-mode .template-permissions-box::after {
  content: 'Nur Ansicht';
  position: absolute;
  top: 12px;
  right: 14px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 214, 102, 0.55);
  color: #ffd666;
  background: rgba(255, 214, 102, 0.08);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Patch: Invite-Link + Lobby verlassen für Host, Spectator und Spieler. */
.game-topbar-lobby-actions {
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  justify-content: center !important;
  gap: 6px !important;
  flex: 0 0 auto !important;
  position: relative !important;
  z-index: 40 !important;
  pointer-events: auto !important;
  min-width: 144px !important;
}

.game-topbar-lobby-actions .topbar-invite-btn,
.game-topbar-lobby-actions .player-topbar-leave-btn {
  width: 100% !important;
  min-height: 34px !important;
  padding: 7px 12px !important;
  border-radius: 999px !important;
  white-space: nowrap !important;
  cursor: pointer !important;
  line-height: 1.15 !important;
  justify-content: center !important;
  text-align: center !important;
}

.game-topbar-lobby-actions .topbar-invite-btn {
  font-weight: 900 !important;
  letter-spacing: 0.01em !important;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.18), 0 10px 26px rgba(250, 204, 21, 0.18) !important;
  transform-origin: center !important;
}

.game-topbar-lobby-actions .topbar-invite-btn:hover:not(:disabled),
.game-topbar-lobby-actions .topbar-invite-btn:focus-visible:not(:disabled),
.game-topbar-lobby-actions .player-topbar-leave-btn:hover:not(:disabled),
.game-topbar-lobby-actions .player-topbar-leave-btn:focus-visible:not(:disabled) {
  transform: translateY(-1px) !important;
  filter: brightness(1.08) !important;
}

/* Override earlier single-button topbar patch when the button lives inside the invite group. */
.game-topbar-lobby-actions .player-topbar-leave-btn {
  position: relative !important;
  z-index: 1 !important;
  align-self: stretch !important;
  min-height: 34px !important;
  padding: 7px 12px !important;
}

.invite-join-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(4, 7, 18, 0.72);
  backdrop-filter: blur(10px);
}

.invite-join-card {
  width: min(460px, 100%);
  position: relative;
  padding: 24px;
  border-radius: 24px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(15, 23, 42, 0.96);
  box-shadow: 0 26px 70px rgba(0,0,0,0.45);
}

.invite-join-card h2 {
  margin: 4px 0 8px;
}

.invite-join-card label {
  display: block;
  margin-top: 16px;
  margin-bottom: 8px;
  font-weight: 800;
}

.invite-join-card input {
  width: 100%;
}

.invite-code-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 0;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
}

.invite-code-row span {
  color: var(--muted, #94a3b8);
  font-size: 0.86rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.invite-code-row strong {
  font-size: 1.3rem;
  letter-spacing: 0.16em;
}

.invite-close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  background: rgba(255,255,255,0.08);
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
}

.invite-close-btn:hover,
.invite-close-btn:focus-visible {
  background: rgba(255,255,255,0.16);
}

@media (max-width: 900px) {
  .game-topbar-lobby-actions {
    min-width: 130px !important;
  }
}

@media (max-width: 640px) {
  .game-topbar-lobby-actions,
  .topbar-actions .game-topbar-lobby-actions {
    width: 100% !important;
    min-width: 0 !important;
    flex-direction: row !important;
  }

  .game-topbar-lobby-actions .topbar-invite-btn,
  .game-topbar-lobby-actions .player-topbar-leave-btn {
    flex: 1 1 0 !important;
    width: auto !important;
  }
}

/* Patch: global control consistency, red leave buttons and floating connection status */
.primary-btn,
.secondary-btn,
.ghost-btn,
.danger-btn,
.success-btn,
button[class*="-btn"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border-radius: 12px;
  font-weight: 850;
  line-height: 1.15;
  cursor: pointer;
  transition: transform 150ms ease, filter 150ms ease, box-shadow 150ms ease, border-color 150ms ease, background 150ms ease, opacity 150ms ease;
}

.primary-btn:hover:not(:disabled),
.secondary-btn:hover:not(:disabled),
.ghost-btn:hover:not(:disabled),
.danger-btn:hover:not(:disabled),
.success-btn:hover:not(:disabled),
button[class*="-btn"]:hover:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.08);
}

.primary-btn:focus-visible,
.secondary-btn:focus-visible,
.ghost-btn:focus-visible,
.danger-btn:focus-visible,
.success-btn:focus-visible,
button[class*="-btn"]:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

select {
  min-height: 42px;
  cursor: pointer;
  appearance: auto;
}

.inline-actions,
.settings-actions,
.team-management-actions,
.builder-save-actions,
.template-actions {
  align-items: stretch;
}

/* Spieler/Host/Spectator: Lobby-verlassen immer gleich rot darstellen. */
.game-topbar-lobby-actions .player-topbar-leave-btn,
.topbar-actions .game-topbar-lobby-actions .player-topbar-leave-btn,
body.role-player .game-topbar-lobby-actions .player-topbar-leave-btn,
body.player-local-slot .game-topbar-lobby-actions .player-topbar-leave-btn,
body.role-spectator .game-topbar-lobby-actions .player-topbar-leave-btn,
body.role-host .game-topbar-lobby-actions .player-topbar-leave-btn {
  background: #be123c !important;
  border: 1px solid rgba(251, 113, 133, 0.72) !important;
  color: #fff !important;
  box-shadow: 0 10px 24px rgba(190, 18, 60, 0.22), inset 0 1px 0 rgba(255,255,255,0.12) !important;
}

.game-topbar-lobby-actions .player-topbar-leave-btn:hover:not(:disabled),
.game-topbar-lobby-actions .player-topbar-leave-btn:focus-visible:not(:disabled) {
  background: #e11d48 !important;
  border-color: rgba(253, 164, 175, 0.86) !important;
  box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.16), 0 14px 30px rgba(190, 18, 60, 0.28) !important;
}

.page-connection-status {
  width: max-content;
  margin: 0 0 16px auto;
}

@media (min-width: 1100px) {
  .page-connection-status {
    position: fixed;
    top: 16px;
    right: 18px;
    z-index: 1600;
    margin: 0;
    min-width: 112px;
    backdrop-filter: blur(10px);
  }

  .topbar {
    padding-right: 150px;
  }
}

@media (max-width: 1099px) {
  .page-connection-status {
    display: block;
    margin: -8px 0 14px auto;
  }
}


/* Final patch: lobby settings = same accordion visual as manual score, no extra leave button. */
.host-lobby-settings {
  width: 100% !important;
  min-width: 0 !important;
}

.lobby-settings-menu {
  border: 1px solid rgba(147, 197, 253, 0.26) !important;
  border-radius: 16px !important;
  background: #080d25 !important;
  padding: 10px 12px !important;
  box-shadow: none !important;
  overflow: visible !important;
}

.lobby-settings-menu.open {
  background: #080d25 !important;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.24) !important;
}

.lobby-settings-head {
  position: relative !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  min-height: 0 !important;
  padding: 0 !important;
  color: #dbeafe !important;
  font-weight: 950 !important;
  line-height: 1.6 !important;
  cursor: pointer !important;
  user-select: none !important;
}

.lobby-settings-head::before {
  content: '▶' !important;
  position: static !important;
  flex: 0 0 1em !important;
  display: inline-grid !important;
  place-items: center !important;
  width: 1em !important;
  height: 1em !important;
  margin: 0 0.42rem 0 0 !important;
  color: #bfdbfe !important;
  font-size: 0.9rem !important;
  line-height: 1.6 !important;
  transform: rotate(0deg) !important;
  transform-origin: center !important;
  transition: transform 220ms ease, color 180ms ease !important;
}

.lobby-settings-menu.open .lobby-settings-head::before {
  transform: rotate(90deg) !important;
  color: #93c5fd !important;
}

.lobby-settings-content {
  min-width: 0 !important;
  max-width: 100% !important;
  width: 100% !important;
  transition: max-height 260ms ease, opacity 190ms ease, transform 190ms ease, margin-top 190ms ease, visibility 190ms ease !important;
}

.lobby-settings-menu.open .lobby-settings-content {
  margin-top: 10px !important;
}

.lobby-settings-content-inner {
  margin-top: 0 !important;
  padding: 0 !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  overflow: visible !important;
}

/* Final patch: remove placeholder rows when no players are present. */
.lobby-list:empty,
.score-overview-strip:empty,
.team-unassigned-players:empty {
  display: none !important;
}

/* Final patch: globally custom styled native dropdowns. */
select {
  appearance: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  min-height: 44px !important;
  padding: 11px 42px 11px 14px !important;
  border: 1px solid rgba(147, 197, 253, 0.28) !important;
  border-radius: 14px !important;
  color: #e0f2fe !important;
  background-color: rgba(8, 13, 37, 0.86) !important;
  background-image:
    linear-gradient(45deg, transparent 50%, #93c5fd 50%),
    linear-gradient(135deg, #93c5fd 50%, transparent 50%),
    linear-gradient(135deg, rgba(56, 189, 248, 0.12), rgba(124, 58, 237, 0.08)) !important;
  background-position:
    calc(100% - 22px) 50%,
    calc(100% - 16px) 50%,
    0 0 !important;
  background-size:
    7px 7px,
    7px 7px,
    100% 100% !important;
  background-repeat: no-repeat !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.055), 0 0 0 1px rgba(15, 23, 42, 0.12) !important;
  cursor: pointer !important;
}

select:hover:not(:disabled) {
  border-color: rgba(56, 189, 248, 0.58) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 0 0 4px rgba(56, 189, 248, 0.08) !important;
  filter: brightness(1.05);
}

select:focus,
select:focus-visible {
  border-color: rgba(56, 189, 248, 0.78) !important;
  box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.055) !important;
  outline: none !important;
}

select:disabled {
  opacity: 0.55 !important;
  cursor: not-allowed !important;
  filter: saturate(0.55) !important;
}

select option {
  background: #0b1230 !important;
  color: #e0f2fe !important;
}

.inline-actions select,
.host-transfer-box select,
.host-active-player-box select,
.question-type-fields select,
.builder-toolbar select {
  min-width: min(100%, 220px) !important;
}

@media (max-width: 700px) {
  .inline-actions select,
  .host-transfer-box select,
  .host-active-player-box select,
  .question-type-fields select,
  .builder-toolbar select {
    width: 100% !important;
    min-width: 0 !important;
  }
}

/* Final patch: real custom dropdown menu + accordion visual alignment. */
.custom-select-shell {
  position: relative !important;
  display: inline-block !important;
  width: 100% !important;
  min-width: 0 !important;
  isolation: isolate !important;
}

.inline-actions .custom-select-shell,
.host-transfer-box .custom-select-shell,
.host-active-player-box .custom-select-shell,
.manual-score-row .custom-select-shell,
.settings-row .custom-select-shell,
.form-row .custom-select-shell {
  flex: 1 1 220px !important;
  min-width: 0 !important;
}

.native-select-hidden {
  position: absolute !important;
  left: 0 !important;
  top: 0 !important;
  width: 1px !important;
  height: 1px !important;
  min-height: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
  border: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  background: transparent !important;
}

.custom-select-button {
  width: 100% !important;
  min-height: 46px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 12px !important;
  padding: 11px 14px 11px 16px !important;
  border: 1px solid rgba(56, 189, 248, 0.42) !important;
  border-radius: 14px !important;
  color: #f8fbff !important;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.96), rgba(19, 31, 68, 0.9)) !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 0 0 1px rgba(15, 23, 42, 0.18) !important;
  font: inherit !important;
  font-weight: 700 !important;
  text-align: left !important;
  cursor: pointer !important;
  transition: border-color 160ms ease, box-shadow 160ms ease, filter 160ms ease, transform 160ms ease !important;
}

.custom-select-button:hover:not(:disabled),
.custom-select-shell.open .custom-select-button {
  border-color: rgba(56, 189, 248, 0.86) !important;
  box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.12), inset 0 1px 0 rgba(255,255,255,0.10) !important;
  filter: brightness(1.06) !important;
}

.custom-select-button:focus-visible {
  outline: none !important;
  border-color: rgba(125, 211, 252, 0.95) !important;
  box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.18), inset 0 1px 0 rgba(255,255,255,0.10) !important;
}

.custom-select-current {
  min-width: 0 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

.custom-select-arrow {
  flex: 0 0 auto !important;
  width: 0 !important;
  height: 0 !important;
  border-left: 6px solid transparent !important;
  border-right: 6px solid transparent !important;
  border-top: 7px solid #bfdbfe !important;
  transition: transform 180ms ease, border-top-color 180ms ease !important;
}

.custom-select-shell.open .custom-select-arrow {
  transform: rotate(180deg) !important;
  border-top-color: #67e8f9 !important;
}

.custom-select-menu {
  position: absolute !important;
  z-index: 20000 !important;
  top: calc(100% + 6px) !important;
  left: 0 !important;
  right: 0 !important;
  max-height: min(340px, 48vh) !important;
  overflow-y: auto !important;
  padding: 7px !important;
  border: 1px solid rgba(125, 211, 252, 0.36) !important;
  border-radius: 14px !important;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.98), rgba(8, 13, 37, 0.98)) !important;
  box-shadow: 0 24px 54px rgba(0,0,0,0.42), 0 0 0 1px rgba(147, 197, 253, 0.12) !important;
  opacity: 0 !important;
  transform: translateY(-6px) scale(0.985) !important;
  pointer-events: none !important;
  visibility: hidden !important;
  transition: opacity 160ms ease, transform 160ms ease, visibility 160ms ease !important;
}

.custom-select-shell.open .custom-select-menu {
  opacity: 1 !important;
  transform: translateY(0) scale(1) !important;
  pointer-events: auto !important;
  visibility: visible !important;
}

.custom-select-option {
  width: 100% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 10px !important;
  min-height: 40px !important;
  padding: 9px 10px !important;
  border: 1px solid transparent !important;
  border-radius: 10px !important;
  background: transparent !important;
  color: #dbeafe !important;
  font: inherit !important;
  font-weight: 700 !important;
  text-align: left !important;
  cursor: pointer !important;
  transition: background 130ms ease, border-color 130ms ease, color 130ms ease, transform 130ms ease !important;
}

.custom-select-option:hover:not(:disabled),
.custom-select-option:focus-visible {
  background: rgba(56, 189, 248, 0.12) !important;
  border-color: rgba(56, 189, 248, 0.34) !important;
  color: #ffffff !important;
  outline: none !important;
}

.custom-select-option.selected {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.24), rgba(124, 58, 237, 0.22)) !important;
  border-color: rgba(125, 211, 252, 0.48) !important;
  color: #ffffff !important;
}

.custom-select-check {
  opacity: 0 !important;
  flex: 0 0 auto !important;
  color: #67e8f9 !important;
  font-weight: 950 !important;
}

.custom-select-option.selected .custom-select-check {
  opacity: 1 !important;
}

.custom-select-shell.disabled {
  opacity: 0.55 !important;
  cursor: not-allowed !important;
}

.custom-select-shell.disabled .custom-select-button {
  cursor: not-allowed !important;
  filter: saturate(0.55) !important;
}

/* Native select fallback should not show a second arrow when the custom shell exists. */
.custom-select-shell select {
  background-image: none !important;
}

/* Lobby settings accordion should match the manual score accordion: text left, arrow right. */
.lobby-settings-head {
  padding: 0 32px 0 0 !important;
  min-height: 22px !important;
  line-height: 1.4 !important;
  justify-content: flex-start !important;
}

.lobby-settings-head::before {
  content: none !important;
  display: none !important;
}

.lobby-settings-head::after {
  content: '▾' !important;
  position: absolute !important;
  right: 12px !important;
  top: 50% !important;
  transform: translateY(-50%) rotate(0deg) !important;
  color: #c7d2fe !important;
  font-size: 0.86rem !important;
  line-height: 1 !important;
  pointer-events: none !important;
  transition: transform 180ms ease, color 180ms ease !important;
}

.lobby-settings-menu.open .lobby-settings-head::after {
  transform: translateY(-50%) rotate(180deg) !important;
  color: #93c5fd !important;
}

.lobby-settings-menu,
.manual-score-menu {
  overflow: visible !important;
}

/* Patch: backend actions, advanced board settings, robust question cards */
body.template-builder-only #hostSavedTemplateBtn,
body.template-builder-only #hostActiveSpectatorTemplateBtn {
  display: flex !important;
}

.builder-toolbar {
  align-items: end !important;
}

.builder-toolbar > button,
.builder-save-actions > button,
#resizeBoardBtn,
#saveTemplateBtn,
#saveTemplateAsNewBtn {
  min-height: 44px !important;
  height: 44px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  line-height: 1.1 !important;
  padding-block: 0 !important;
}

.builder-save-actions {
  align-self: end !important;
}

.advanced-board-settings {
  margin: 18px 0 20px !important;
  border: 1px solid rgba(120, 153, 255, 0.28) !important;
  border-radius: 18px !important;
  background: rgba(5, 10, 35, 0.54) !important;
  overflow: hidden !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05) !important;
}

.advanced-board-settings > summary,
.advanced-board-settings-summary {
  list-style: none !important;
  min-height: 48px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 12px !important;
  padding: 12px 46px 12px 18px !important;
  color: #eaf1ff !important;
  font-weight: 950 !important;
  cursor: pointer !important;
  position: relative !important;
  border-radius: 16px !important;
  background: rgba(6, 12, 42, 0.72) !important;
}

.advanced-board-settings > summary::marker,
.advanced-board-settings > summary::-webkit-details-marker {
  display: none !important;
  content: '' !important;
}

.advanced-board-settings > summary::after {
  content: '▾' !important;
  position: absolute !important;
  right: 18px !important;
  top: 50% !important;
  transform: translateY(-50%) rotate(0deg) !important;
  line-height: 1 !important;
  font-size: 14px !important;
  color: #bfdbfe !important;
  transition: transform 160ms ease, color 160ms ease !important;
}

.advanced-board-settings[open] > summary::after {
  transform: translateY(-50%) rotate(180deg) !important;
  color: #67e8f9 !important;
}

.advanced-board-settings .builder-point-options {
  margin: 0 !important;
  padding: 14px !important;
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 12px !important;
}

.advanced-board-settings .second-board-option {
  min-height: 74px !important;
  height: 100% !important;
  align-items: flex-start !important;
  padding: 13px 14px !important;
  border: 1px solid rgba(120, 153, 255, 0.26) !important;
  border-radius: 16px !important;
  background: rgba(10, 18, 52, 0.48) !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05) !important;
}

.advanced-board-settings .second-board-option input[type="checkbox"] {
  flex: 0 0 auto !important;
  margin-top: 2px !important;
}

.advanced-board-settings .second-board-option span {
  min-width: 0 !important;
  line-height: 1.25 !important;
}

.advanced-board-settings .second-board-option small {
  display: block !important;
  margin-top: 3px !important;
  line-height: 1.25 !important;
}

/* Builder grid: wrap categories before cards become too narrow. */
.builder-grid-inner {
  grid-template-columns: repeat(auto-fit, minmax(255px, 1fr)) !important;
  gap: 14px !important;
}

.category-builder,
.question-builder {
  min-width: 0 !important;
  overflow: visible !important;
}

.question-builder-summary {
  display: grid !important;
  grid-template-columns: minmax(92px, max-content) minmax(118px, max-content) 32px 22px !important;
  align-items: center !important;
  gap: 8px !important;
  min-width: 0 !important;
  padding: 10px 34px 10px 10px !important;
  overflow: visible !important;
}

.question-builder-summary .points-pill,
.question-builder-summary .builder-status,
.question-builder-summary .builder-media-status {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-height: 34px !important;
  height: 34px !important;
  line-height: 1 !important;
  padding-block: 0 !important;
  box-sizing: border-box !important;
  white-space: nowrap !important;
  overflow: visible !important;
  text-overflow: clip !important;
}

.question-builder-summary .points-pill {
  min-width: 98px !important;
  justify-self: start !important;
}

.question-builder-summary .builder-status {
  min-width: 122px !important;
  gap: 6px !important;
}

.question-builder-summary .builder-media-status {
  width: 32px !important;
  min-width: 32px !important;
  padding: 0 !important;
  justify-self: center !important;
  border-radius: 999px !important;
}

.question-builder-summary::after {
  right: 11px !important;
  z-index: 1 !important;
}

.question-builder-body {
  overflow: visible !important;
}

.question-builder-body .custom-select-shell,
.question-type-fields .custom-select-shell {
  max-width: 100% !important;
}

.question-builder-body .custom-select-menu,
.question-type-fields .custom-select-menu,
.builder-toolbar .custom-select-menu {
  z-index: 50000 !important;
}

/* Reset button now sits below Host wechseln in lobby settings. */
.reset-game-actions {
  display: flex !important;
  justify-content: flex-start !important;
  margin-top: 12px !important;
  padding-top: 12px !important;
  border-top: 1px solid rgba(120, 153, 255, 0.22) !important;
}

.reset-game-actions .danger-secondary-btn {
  min-height: 42px !important;
  color: #fecaca !important;
  border-color: rgba(248, 113, 113, 0.5) !important;
  background: rgba(127, 29, 29, 0.26) !important;
}

.reset-game-actions .danger-secondary-btn:hover:not(:disabled) {
  color: #fff !important;
  border-color: rgba(248, 113, 113, 0.85) !important;
  background: rgba(185, 28, 28, 0.44) !important;
}

@media (max-width: 980px) {
  .advanced-board-settings .builder-point-options {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 680px) {
  .question-builder-summary {
    grid-template-columns: minmax(92px, max-content) minmax(0, 1fr) 32px 22px !important;
  }

  .question-builder-summary .builder-status {
    min-width: 0 !important;
    padding-inline: 9px !important;
  }
}

/* Final backend custom select + dense question-card fix. */
.question-builder-body > .custom-select-shell,
.question-builder-body > label + .custom-select-shell {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  margin-top: 6px !important;
}

.question-builder-body > select[data-field="fieldType"].native-select-hidden {
  position: absolute !important;
  opacity: 0 !important;
  width: 1px !important;
  height: 1px !important;
  min-height: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  background: none !important;
  color: transparent !important;
}

.question-builder-body .custom-select-button {
  min-height: 48px !important;
  border-radius: 16px !important;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.98), rgba(19, 32, 70, 0.96)) !important;
}

.question-builder-body .custom-select-menu {
  width: 100% !important;
  min-width: 100% !important;
  max-width: min(100%, 420px) !important;
  z-index: 90000 !important;
}

/* Keep category columns wide enough so badges and the details arrow never overlap. */
.builder-grid-inner {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)) !important;
  align-items: start !important;
  overflow: visible !important;
}

.category-builder {
  min-width: 0 !important;
  overflow: visible !important;
}

.question-builder {
  min-width: 0 !important;
  overflow: visible !important;
}

.question-builder-summary {
  position: relative !important;
  display: grid !important;
  grid-template-columns: minmax(86px, max-content) minmax(112px, 1fr) 32px !important;
  gap: 8px !important;
  align-items: center !important;
  min-height: 58px !important;
  padding: 10px 40px 10px 10px !important;
  overflow: hidden !important;
}

.question-builder-summary::after {
  position: absolute !important;
  right: 14px !important;
  top: 50% !important;
  transform: translateY(-50%) rotate(0deg) !important;
  margin: 0 !important;
  z-index: 2 !important;
}

.question-builder[open] .question-builder-summary::after {
  transform: translateY(-50%) rotate(180deg) !important;
}

.question-builder-summary .points-pill,
.question-builder-summary .builder-status,
.question-builder-summary .builder-media-status {
  height: 34px !important;
  min-height: 34px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  line-height: 1 !important;
  box-sizing: border-box !important;
  margin: 0 !important;
}

.question-builder-summary .points-pill {
  min-width: 86px !important;
  max-width: 112px !important;
  padding-inline: 10px !important;
  justify-self: start !important;
  white-space: nowrap !important;
}

.question-builder-summary .builder-status {
  min-width: 112px !important;
  max-width: 100% !important;
  padding-inline: 10px !important;
  gap: 6px !important;
  justify-self: start !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.question-builder-summary .builder-status span:last-child {
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

.question-builder-summary .builder-media-status {
  width: 32px !important;
  min-width: 32px !important;
  padding: 0 !important;
  justify-self: center !important;
  text-align: center !important;
}

@media (max-width: 1460px) {
  .builder-grid-inner {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 310px), 1fr)) !important;
  }
}

@media (max-width: 780px) {
  .question-builder-summary {
    grid-template-columns: minmax(82px, max-content) minmax(0, 1fr) 30px !important;
    padding-right: 38px !important;
  }
  .question-builder-summary .builder-status {
    min-width: 0 !important;
    padding-inline: 8px !important;
  }
}

/* Patch: final backend overflow, smooth accordions and readonly badge cleanup */
.category-builder {
  overflow: visible !important;
  border-radius: 26px !important;
  background-clip: padding-box !important;
}

.category-builder-header {
  border-top-left-radius: 25px !important;
  border-top-right-radius: 25px !important;
  background-clip: padding-box !important;
  overflow: hidden !important;
  margin: 0 !important;
}

/* If a browser still paints header corners outside the border, clip only the top header area visually. */
.category-builder::before {
  border-radius: inherit !important;
}

.builder-grid-inner {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)) !important;
  gap: 14px !important;
  align-items: start !important;
  max-width: 100% !important;
  overflow: visible !important;
}

.question-builder-list {
  padding: 16px !important;
  gap: 14px !important;
  overflow: visible !important;
}

.question-builder {
  min-width: 0 !important;
  max-width: 100% !important;
  overflow: visible !important;
}

.question-builder-summary {
  display: grid !important;
  grid-template-columns: minmax(78px, max-content) minmax(0, 1fr) 32px !important;
  gap: 8px !important;
  align-items: center !important;
  min-width: 0 !important;
  max-width: 100% !important;
  min-height: 58px !important;
  padding: 10px 40px 10px 16px !important;
  overflow: hidden !important;
}

.question-builder-summary .points-pill {
  min-width: 0 !important;
  max-width: 108px !important;
  padding-inline: 10px !important;
  justify-self: start !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

.question-builder-summary .builder-status {
  min-width: 0 !important;
  max-width: 100% !important;
  padding-inline: 10px !important;
  gap: 6px !important;
  justify-self: stretch !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

.question-builder-summary .builder-status span:last-child {
  min-width: 0 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

.question-builder-summary .builder-media-status {
  width: 32px !important;
  min-width: 32px !important;
  height: 32px !important;
  min-height: 32px !important;
  padding: 0 !important;
  justify-self: center !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.question-builder-summary::after {
  right: 12px !important;
  top: 50% !important;
  z-index: 3 !important;
}

@media (min-width: 1500px) {
  .builder-grid-inner {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 275px), 1fr)) !important;
  }
}

@media (max-width: 980px) {
  .builder-grid-inner {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)) !important;
  }
}

/* Einheitliche Height-Animation für alle Accordions/Details, inkl. Erweiterte Board Einstellungen. */
.manual-score-list,
.question-builder-body,
.advanced-board-settings .builder-point-options {
  overflow: hidden !important;
  transition: max-height 260ms ease, opacity 220ms ease, transform 220ms ease !important;
  will-change: max-height, opacity, transform !important;
}

.advanced-board-settings:not([open]) .builder-point-options {
  max-height: 0 !important;
  opacity: 0 !important;
  transform: translateY(-4px) !important;
}

.advanced-board-settings[open] .builder-point-options {
  opacity: 1 !important;
  transform: translateY(0) !important;
}

/* Readonly badge darf nicht mit dem Hilfetext kollidieren. */
.template-permissions-heading {
  position: relative !important;
  align-items: flex-start !important;
}

.template-readonly-mode .template-permissions-heading {
  padding-right: 132px !important;
}

.template-readonly-mode .template-permissions-box::after {
  top: 16px !important;
  right: 16px !important;
  z-index: 2 !important;
  white-space: nowrap !important;
}

@media (max-width: 720px) {
  .template-readonly-mode .template-permissions-heading {
    padding-right: 0 !important;
    padding-top: 34px !important;
  }
  .template-readonly-mode .template-permissions-box::after {
    top: 14px !important;
    left: 16px !important;
    right: auto !important;
  }
}


/* Final patch: backend category overflow, uniform spacing, pills offset, and robust custom selects */
.builder-grid-inner {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)) !important;
  gap: 16px !important;
  align-items: start !important;
  max-width: 100% !important;
  overflow: visible !important;
}

.category-builder {
  position: relative !important;
  min-width: 0 !important;
  max-width: 100% !important;
  overflow: hidden !important;
  border-radius: 26px !important;
  background: rgba(9, 14, 40, 0.58) !important;
  background-clip: padding-box !important;
  isolation: isolate !important;
  box-sizing: border-box !important;
}

.category-builder::before,
.category-builder::after {
  display: none !important;
  content: none !important;
}

.category-builder-header {
  display: grid !important;
  gap: 12px !important;
  padding: 18px !important;
  margin: 0 !important;
  border-radius: 25px 25px 0 0 !important;
  overflow: hidden !important;
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.24), rgba(124, 58, 237, 0.22)) !important;
  background-clip: padding-box !important;
  border-bottom: 1px solid var(--border) !important;
}

.category-builder-header > label,
.question-builder-body > label,
.question-type-fields label {
  margin: 0 0 6px !important;
  line-height: 1.25 !important;
}

.category-builder-header input[data-field="categoryName"] {
  margin: 0 !important;
}

.category-cooldown-row {
  margin-top: 10px !important;
  gap: 10px !important;
  align-items: end !important;
}

.question-builder-list {
  padding: 18px !important;
  gap: 14px !important;
  overflow: visible !important;
}

.question-builder {
  min-width: 0 !important;
  max-width: 100% !important;
  overflow: visible !important;
  border-radius: 20px !important;
  background: rgba(13, 20, 54, 0.74) !important;
  border: 1px solid rgba(191, 219, 254, 0.15) !important;
}

.question-builder > summary,
.question-builder-summary {
  cursor: pointer !important;
  border-radius: 17px !important;
  background: rgba(8, 13, 37, 0.58) !important;
  border: 1px solid rgba(120, 153, 255, 0.24) !important;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease !important;
}

.question-builder > summary:hover,
.question-builder-summary:hover {
  border-color: rgba(125, 211, 252, 0.36) !important;
  background: rgba(13, 24, 64, 0.72) !important;
}

.question-builder[open] > summary,
.question-builder[open] .question-builder-summary {
  border-color: rgba(125, 211, 252, 0.36) !important;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.08) !important;
}

.question-builder-summary {
  display: grid !important;
  grid-template-columns: minmax(94px, max-content) minmax(112px, 1fr) 34px !important;
  gap: 9px !important;
  align-items: center !important;
  min-height: 58px !important;
  padding: 10px 42px 10px 18px !important;
  overflow: hidden !important;
}

.question-builder-summary::after {
  right: 16px !important;
  top: 50% !important;
  z-index: 3 !important;
}

.question-builder-summary .points-pill {
  margin-left: 0 !important;
  justify-self: start !important;
  min-width: 94px !important;
  max-width: 118px !important;
  padding-inline: 12px !important;
}

.question-builder-summary .builder-status {
  justify-self: start !important;
  min-width: 112px !important;
  max-width: 100% !important;
  padding-inline: 11px !important;
}

.question-builder-summary .builder-media-status {
  justify-self: center !important;
  width: 34px !important;
  min-width: 34px !important;
  height: 34px !important;
}

.question-builder-body {
  display: grid !important;
  gap: 14px !important;
  padding-top: 14px !important;
  overflow: visible !important;
}

.question-type-fields {
  display: grid !important;
  gap: 14px !important;
}

.reveal-image-builder-block {
  display: grid !important;
  gap: 8px !important;
}

.reveal-image-builder-block .media-note.hidden:empty {
  display: none !important;
}

/* Backend select menus: force real custom menu instead of native dropdown look. */
.builder-grid .native-select-hidden,
.builder-panel .native-select-hidden,
.question-builder-body select.native-select-hidden,
.question-type-fields select.native-select-hidden {
  position: absolute !important;
  opacity: 0 !important;
  pointer-events: none !important;
  width: 1px !important;
  height: 1px !important;
  min-height: 0 !important;
  max-height: 0 !important;
  border: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  appearance: none !important;
}

.builder-grid .custom-select-shell,
.builder-panel .custom-select-shell,
.question-builder-body .custom-select-shell,
.question-type-fields .custom-select-shell {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  z-index: 20 !important;
}

.builder-grid .custom-select-shell.open,
.builder-panel .custom-select-shell.open,
.question-builder-body .custom-select-shell.open,
.question-type-fields .custom-select-shell.open {
  z-index: 90000 !important;
}

.builder-grid .custom-select-button,
.builder-panel .custom-select-button,
.question-builder-body .custom-select-button,
.question-type-fields .custom-select-button {
  min-height: 48px !important;
  border-radius: 16px !important;
  border-color: rgba(56, 189, 248, 0.42) !important;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.98), rgba(19, 32, 70, 0.96)) !important;
  color: #f8fbff !important;
}

.builder-grid .custom-select-menu,
.builder-panel .custom-select-menu,
.question-builder-body .custom-select-menu,
.question-type-fields .custom-select-menu {
  position: relative !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  width: 100% !important;
  min-width: 100% !important;
  max-width: 100% !important;
  margin-top: 7px !important;
  z-index: 90000 !important;
  display: none !important;
  max-height: 280px !important;
  overflow-y: auto !important;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.99), rgba(7, 12, 34, 0.99)) !important;
  border: 1px solid rgba(125, 211, 252, 0.36) !important;
  box-shadow: 0 18px 42px rgba(0,0,0,0.36), 0 0 0 1px rgba(147,197,253,0.12) !important;
}

.builder-grid .custom-select-shell.open .custom-select-menu,
.builder-panel .custom-select-shell.open .custom-select-menu,
.question-builder-body .custom-select-shell.open .custom-select-menu,
.question-type-fields .custom-select-shell.open .custom-select-menu {
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  transform: none !important;
}

.builder-grid .custom-select-option,
.builder-panel .custom-select-option,
.question-builder-body .custom-select-option,
.question-type-fields .custom-select-option {
  color: #dbeafe !important;
  background: transparent !important;
}

.builder-grid .custom-select-option.selected,
.builder-panel .custom-select-option.selected,
.question-builder-body .custom-select-option.selected,
.question-type-fields .custom-select-option.selected {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.26), rgba(124, 58, 237, 0.24)) !important;
  color: #ffffff !important;
}

@media (max-width: 760px) {
  .builder-grid-inner {
    grid-template-columns: 1fr !important;
  }
  .question-builder-summary {
    grid-template-columns: minmax(90px, max-content) minmax(0, 1fr) 32px !important;
    padding-left: 16px !important;
  }
}

/* Final patch: dropdown clipping, category card background clipping, and universal details animation polish. */
.category-builder {
  overflow: visible !important;
  border-radius: 26px !important;
  background-clip: padding-box !important;
}

.category-builder-header {
  position: relative !important;
  z-index: 0 !important;
  overflow: hidden !important;
  border-radius: 24px 24px 0 0 !important;
  clip-path: inset(0 round 24px 24px 0 0) !important;
  margin: 0 !important;
}

.question-builder-list,
.question-builder,
.question-builder[open],
.question-builder[open] .question-builder-body,
.question-type-fields,
.reveal-image-builder-block,
.builder-grid,
.builder-grid-inner,
.builder-panel {
  overflow: visible !important;
}

.question-builder:not([open]) .question-builder-body,
.question-builder[data-animating-details="1"] .question-builder-body {
  overflow: hidden !important;
}

.question-builder-summary,
.question-builder > summary.question-builder-summary {
  margin-left: 5px !important;
  width: calc(100% - 5px) !important;
  box-sizing: border-box !important;
}

.question-builder-summary .points-pill {
  margin-left: 0 !important;
}

.question-builder-body .custom-select-shell,
.question-type-fields .custom-select-shell,
.builder-grid .custom-select-shell,
.builder-panel .custom-select-shell {
  position: relative !important;
  z-index: 50 !important;
  overflow: visible !important;
}

.question-builder-body .custom-select-shell.open,
.question-type-fields .custom-select-shell.open,
.builder-grid .custom-select-shell.open,
.builder-panel .custom-select-shell.open {
  z-index: 100000 !important;
}

.question-builder-body .custom-select-menu,
.question-type-fields .custom-select-menu,
.builder-grid .custom-select-menu,
.builder-panel .custom-select-menu {
  position: absolute !important;
  top: calc(100% + 6px) !important;
  left: 0 !important;
  right: 0 !important;
  width: auto !important;
  min-width: 100% !important;
  max-width: min(100%, 420px) !important;
  margin-top: 0 !important;
  display: block !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transform: translateY(-6px) scale(0.985) !important;
  transition: opacity 160ms ease, transform 160ms ease, visibility 160ms ease !important;
}

.question-builder-body .custom-select-shell.open .custom-select-menu,
.question-type-fields .custom-select-shell.open .custom-select-menu,
.builder-grid .custom-select-shell.open .custom-select-menu,
.builder-panel .custom-select-shell.open .custom-select-menu {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  transform: translateY(0) scale(1) !important;
}

/* If a select is still native for a split second, hide the platform arrow and keep theme styling. */
.builder-grid select:not(.native-select-hidden),
.builder-panel select:not(.native-select-hidden),
.question-builder-body select:not(.native-select-hidden),
.question-type-fields select:not(.native-select-hidden) {
  appearance: none !important;
  -webkit-appearance: none !important;
  background-color: rgba(8, 13, 37, 0.96) !important;
  color: #e0f2fe !important;
}

/* Apply the same smooth open/close motion to every details body we use. */
details > .manual-score-list,
details > .builder-point-options,
details > .question-builder-body,
details > .precreate-details-body,
details > .spectator-join-body,
details > .accordion-body,
details > .details-body {
  transition: max-height 260ms ease, opacity 190ms ease, transform 190ms ease, margin-top 190ms ease, padding-top 190ms ease !important;
  will-change: max-height, opacity, transform !important;
}

/* Final UI patch: summary pill spacing + portal select menus + modal confirms. */
.question-builder-summary,
.question-builder > summary.question-builder-summary {
  margin-left: 0 !important;
  width: 100% !important;
}

.question-builder-summary .points-pill {
  margin-left: 5px !important;
}

.custom-select-menu.custom-select-menu-portal {
  position: fixed !important;
  z-index: 2147483000 !important;
  display: block !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transform: translateY(-6px) scale(0.985) !important;
  transition: opacity 160ms ease, transform 160ms ease, visibility 160ms ease !important;
  overflow-y: auto !important;
  overscroll-behavior: contain !important;
  border-radius: 0 0 14px 14px !important;
  border: 1px solid rgba(56, 189, 248, 0.38) !important;
  border-top: 0 !important;
  background: rgba(8, 13, 37, 0.99) !important;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(96, 165, 250, 0.08) inset !important;
  color: #eff6ff !important;
}

.custom-select-menu.custom-select-menu-portal.open {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  transform: translateY(0) scale(1) !important;
}

.custom-select-menu.custom-select-menu-portal .custom-select-option {
  width: 100% !important;
  min-height: 42px !important;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto !important;
  align-items: center !important;
  gap: 12px !important;
  padding: 10px 14px !important;
  border: 0 !important;
  border-bottom: 1px solid rgba(148, 163, 184, 0.10) !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: #eff6ff !important;
  text-align: left !important;
  cursor: pointer !important;
}

.custom-select-menu.custom-select-menu-portal .custom-select-option:hover:not(:disabled),
.custom-select-menu.custom-select-menu-portal .custom-select-option:focus-visible {
  background: rgba(56, 189, 248, 0.16) !important;
  color: #ffffff !important;
}

.custom-select-menu.custom-select-menu-portal .custom-select-option.selected {
  background: rgba(125, 92, 255, 0.26) !important;
  color: #ffffff !important;
  font-weight: 900 !important;
}

.custom-select-menu.custom-select-menu-portal .custom-select-check {
  color: #67e8f9 !important;
  opacity: 0 !important;
  font-weight: 1000 !important;
}

.custom-select-menu.custom-select-menu-portal .custom-select-option.selected .custom-select-check {
  opacity: 1 !important;
}

.confirm-card.app-confirm-card {
  border-color: rgba(56, 189, 248, 0.30) !important;
  background: linear-gradient(145deg, rgba(8, 13, 37, 0.98), rgba(31, 22, 75, 0.98)) !important;
}


/* Final hotfix: host start box gap and robust body-portal custom select menus. */
.host-lobby-start-box {
  gap: 0 !important;
}

.custom-select-menu.custom-select-menu-portal,
body > .custom-select-menu.custom-select-menu-portal {
  position: fixed !important;
  z-index: 2147483600 !important;
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  transform: translateY(0) scale(1) !important;
  min-width: 220px !important;
  max-height: min(340px, 55vh) !important;
  overflow-y: auto !important;
  overscroll-behavior: contain !important;
  border: 1px solid rgba(56, 189, 248, 0.42) !important;
  border-radius: 0 0 14px 14px !important;
  background: linear-gradient(180deg, rgba(8, 13, 37, 0.995), rgba(14, 22, 55, 0.995)) !important;
  box-shadow: 0 28px 76px rgba(0, 0, 0, 0.62), 0 0 0 1px rgba(96, 165, 250, 0.12) inset !important;
}

body > .custom-select-menu.custom-select-menu-portal:not(.open) {
  display: none !important;
}

body > .custom-select-menu.custom-select-menu-portal .custom-select-option {
  position: relative !important;
  z-index: 1 !important;
}

/* Final dropdown visibility fix: single body-level portal menu for all custom selects. */
#custom-select-portal-menu.custom-select-menu-portal {
  position: fixed !important;
  z-index: 2147483646 !important;
  display: none !important;
  min-width: 220px !important;
  max-height: min(340px, 55vh) !important;
  overflow-y: auto !important;
  overscroll-behavior: contain !important;
  padding: 7px !important;
  border: 1px solid rgba(56, 189, 248, 0.46) !important;
  border-radius: 0 0 14px 14px !important;
  background: linear-gradient(180deg, rgba(8, 13, 37, 0.995), rgba(14, 22, 55, 0.995)) !important;
  box-shadow: 0 28px 76px rgba(0, 0, 0, 0.62), 0 0 0 1px rgba(96, 165, 250, 0.12) inset !important;
  color: #eff6ff !important;
}

#custom-select-portal-menu.custom-select-menu-portal.open {
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  transform: translateY(0) scale(1) !important;
}

#custom-select-portal-menu .custom-select-option {
  width: 100% !important;
  min-height: 42px !important;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto !important;
  align-items: center !important;
  gap: 12px !important;
  padding: 10px 14px !important;
  border: 1px solid transparent !important;
  border-radius: 10px !important;
  background: transparent !important;
  color: #eff6ff !important;
  text-align: left !important;
  cursor: pointer !important;
}

#custom-select-portal-menu .custom-select-option:hover:not(:disabled),
#custom-select-portal-menu .custom-select-option:focus-visible {
  background: rgba(56, 189, 248, 0.16) !important;
  border-color: rgba(56, 189, 248, 0.34) !important;
  color: #ffffff !important;
}

#custom-select-portal-menu .custom-select-option.selected {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.26), rgba(124, 58, 237, 0.24)) !important;
  border-color: rgba(125, 211, 252, 0.50) !important;
  color: #ffffff !important;
  font-weight: 900 !important;
}

#custom-select-portal-menu .custom-select-check {
  color: #67e8f9 !important;
  opacity: 0 !important;
  font-weight: 1000 !important;
}

#custom-select-portal-menu .custom-select-option.selected .custom-select-check {
  opacity: 1 !important;
}

/* Hotfix: custom select portal options must always render with content, not as an empty line. */
#custom-select-portal-menu.custom-select-menu-portal.open {
  height: auto !important;
  min-height: 44px !important;
  padding: 7px !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

#custom-select-portal-menu.custom-select-menu-portal.open .custom-select-option {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto !important;
  align-items: center !important;
  min-height: 42px !important;
  height: auto !important;
  opacity: 1 !important;
  visibility: visible !important;
}

#custom-select-portal-menu .custom-select-option-label {
  display: block !important;
  min-width: 0 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

#custom-select-portal-menu .custom-select-empty {
  min-height: 42px !important;
  display: flex !important;
  align-items: center !important;
  padding: 10px 14px !important;
  color: rgba(226, 232, 240, 0.72) !important;
  font-weight: 800 !important;
}


/* Final select fix: local empty shell menus must never be visible. All custom select options render in the body portal. */
.custom-select-shell > .custom-select-menu:not(.custom-select-menu-portal),
.custom-select-shell.open > .custom-select-menu:not(.custom-select-menu-portal) {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  height: 0 !important;
  min-height: 0 !important;
  max-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  overflow: hidden !important;
}

#custom-select-portal-menu.custom-select-menu-portal.open {
  display: block !important;
  min-height: 44px !important;
  z-index: 2147483647 !important;
}

#custom-select-portal-menu.custom-select-menu-portal.open:empty::before {
  content: 'Keine Optionen';
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 10px 14px;
  color: rgba(226, 232, 240, 0.72);
  font-weight: 800;
}

/* FINAL FIX: custom selects render local menus again. Portal caused empty/off-screen menus. */
#custom-select-portal-menu,
#custom-select-portal-menu.custom-select-menu-portal,
body > .custom-select-menu.custom-select-menu-portal {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.custom-select-shell {
  position: relative !important;
  overflow: visible !important;
  isolation: auto !important;
}

.custom-select-shell.open {
  z-index: 2147483000 !important;
}

.builder-grid,
.builder-panel,
.category-builder,
.category-builder-body,
.question-builder,
.question-builder-body,
.question-type-fields,
.host-controls-box,
.host-lobby-start-box,
.manual-score-card,
.manual-score-row,
.form-row,
.settings-row {
  overflow: visible !important;
}

.question-builder.select-open-within,
.category-builder.select-open-within,
.builder-panel.select-open-within,
.host-controls-box.select-open-within,
.manual-score-card.select-open-within,
.host-lobby-start-box.select-open-within {
  position: relative !important;
  z-index: 2147482500 !important;
  overflow: visible !important;
}

.custom-select-shell > .custom-select-menu:not(.custom-select-menu-portal),
.custom-select-shell.open > .custom-select-menu:not(.custom-select-menu-portal) {
  position: absolute !important;
  left: 0 !important;
  right: auto !important;
  top: calc(100% + 6px) !important;
  width: 100% !important;
  min-width: 220px !important;
  max-height: min(340px, 55vh) !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  overscroll-behavior: contain !important;
  padding: 7px !important;
  border: 1px solid rgba(56, 189, 248, 0.46) !important;
  border-radius: 0 0 14px 14px !important;
  background: linear-gradient(180deg, rgba(8, 13, 37, 0.995), rgba(14, 22, 55, 0.995)) !important;
  box-shadow: 0 28px 76px rgba(0, 0, 0, 0.62), 0 0 0 1px rgba(96, 165, 250, 0.12) inset !important;
  color: #eff6ff !important;
  z-index: 2147483640 !important;
  transform: translateY(-3px) scale(0.985) !important;
  transform-origin: top center !important;
  transition: opacity 140ms ease, transform 140ms ease, visibility 140ms ease !important;
}

.custom-select-shell > .custom-select-menu:not(.open):not(.custom-select-menu-portal) {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.custom-select-shell.open > .custom-select-menu.open:not(.custom-select-menu-portal) {
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  height: auto !important;
  min-height: 44px !important;
  max-height: min(340px, 55vh) !important;
  transform: translateY(0) scale(1) !important;
}

.custom-select-shell > .custom-select-menu:not(.custom-select-menu-portal) .custom-select-option {
  width: 100% !important;
  min-height: 42px !important;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto !important;
  align-items: center !important;
  gap: 12px !important;
  padding: 10px 14px !important;
  border: 1px solid transparent !important;
  border-radius: 10px !important;
  background: transparent !important;
  color: #eff6ff !important;
  text-align: left !important;
  cursor: pointer !important;
  opacity: 1 !important;
  visibility: visible !important;
}

.custom-select-shell > .custom-select-menu:not(.custom-select-menu-portal) .custom-select-option:hover:not(:disabled),
.custom-select-shell > .custom-select-menu:not(.custom-select-menu-portal) .custom-select-option:focus-visible {
  background: rgba(56, 189, 248, 0.16) !important;
  border-color: rgba(56, 189, 248, 0.34) !important;
  color: #ffffff !important;
}

.custom-select-shell > .custom-select-menu:not(.custom-select-menu-portal) .custom-select-option.selected {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.26), rgba(124, 58, 237, 0.24)) !important;
  border-color: rgba(125, 211, 252, 0.50) !important;
  color: #ffffff !important;
  font-weight: 900 !important;
}

.custom-select-shell > .custom-select-menu:not(.custom-select-menu-portal) .custom-select-option-label {
  display: block !important;
  min-width: 0 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

.custom-select-shell > .custom-select-menu:not(.custom-select-menu-portal) .custom-select-check {
  color: #67e8f9 !important;
  opacity: 0 !important;
  font-weight: 1000 !important;
}

.custom-select-shell > .custom-select-menu:not(.custom-select-menu-portal) .custom-select-option.selected .custom-select-check {
  opacity: 1 !important;
}

.custom-select-shell > .custom-select-menu:not(.custom-select-menu-portal) .custom-select-empty {
  min-height: 42px !important;
  display: flex !important;
  align-items: center !important;
  padding: 10px 14px !important;
  color: rgba(226, 232, 240, 0.72) !important;
  font-weight: 800 !important;
}


/* Host-Testmodus: Board-Wechsel vor dem Spielstart */
.host-test-board-navigation {
  display: flex;
  width: 100%;
  margin-top: 12px;
  pointer-events: auto;
}

.host-test-board-navigation.align-right {
  justify-content: flex-end;
}

.host-test-board-navigation.align-left {
  justify-content: flex-start;
}

.host-test-board-switch-btn {
  min-width: 170px;
  min-height: 44px;
  padding-inline: 18px;
}

@media (max-width: 640px) {
  .host-test-board-switch-btn {
    width: 100%;
  }
}

/* =========================================================
   2026-06 synchronized question / team-play refactor
   ========================================================= */

/* Die linke Spielerbox wächst unabhängig von den Lobby-Einstellungen. */
.game-header-tools,
body.role-host .game-header-tools {
  align-items: start !important;
}

.players-card,
body.role-host .players-card,
body.role-player .players-card,
body.role-spectator .players-card {
  align-self: start !important;
  height: auto !important;
  min-height: 0 !important;
}

/* Aktive Rotation klar und für alle Rollen identisch hervorheben. */
.team-summary-card.active-turn-team {
  border-width: 3px !important;
  border-color: var(--team-color) !important;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--team-color) 32%, transparent),
              0 0 24px color-mix(in srgb, var(--team-color) 24%, transparent) !important;
}

.score-row.host-row.active-host-turn {
  border: 3px solid #ffd84a !important;
  box-shadow: 0 0 0 2px rgba(255, 216, 74, .18), 0 0 22px rgba(255, 216, 74, .2) !important;
}

/* Im Team-Modus existiert bewusst keine persönliche Punkteanzeige. */
.team-score-mode .team-member-chip > strong,
.team-score-mode .team-member-chip .score-points {
  display: none !important;
}

.team-member-chip {
  position: relative;
  padding-right: 34px !important;
}

.team-member-kick {
  position: absolute;
  top: 50%;
  right: 7px;
  width: 24px;
  height: 24px;
  transform: translateY(-50%);
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255,255,255,.75);
  border-radius: 999px;
  background: rgba(220, 38, 38, .24);
  color: #fff;
  font: 800 17px/1 system-ui, sans-serif;
  cursor: pointer;
  z-index: 3;
}

.team-member-kick:hover {
  background: rgba(239, 68, 68, .8);
  transform: translateY(-50%) scale(1.06);
}

/* Gemeinsamer Ladezustand für Bild und Audio. */
.media-sync-status {
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: min(620px, 100%);
  margin: 16px auto;
  padding: 16px 18px;
  border: 1px solid rgba(56, 189, 248, .45);
  border-radius: 16px;
  background: rgba(7, 14, 39, .88);
  text-align: left;
}

.media-sync-status > div {
  display: grid;
  gap: 3px;
}

.media-sync-status small {
  color: var(--muted, #aab4d4);
  overflow-wrap: anywhere;
}

.media-sync-status.has-error {
  border-color: rgba(248, 113, 113, .65);
}

.media-loading-spinner {
  flex: 0 0 auto;
}

/* Mehrere gleichzeitig ausgezeichnete Eingaben. */
.judgement-banner-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

.judgement-banner-list .judgement-banner {
  margin: 0;
}

.team-submission-group {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--team-color, #38bdf8);
  border-radius: 14px;
  background: color-mix(in srgb, var(--team-color, #38bdf8) 8%, rgba(4, 10, 31, .92));
}

.team-submission-group h4 {
  margin: 0;
  color: var(--team-color, #38bdf8);
}

.text-answer-monitor.is-locked,
.player-text-input-box.is-locked {
  border-color: rgba(148, 163, 184, .45);
  opacity: .94;
}

/* Team-Chat */
.team-chat-panel {
  display: grid;
  gap: 10px;
  width: 100%;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--team-color, #38bdf8);
  border-radius: 16px;
  background: color-mix(in srgb, var(--team-color, #38bdf8) 7%, rgba(4, 10, 31, .94));
}

.team-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.team-chat-head strong { color: var(--team-color, #38bdf8); }
.team-chat-head span { color: var(--muted, #aab4d4); font-size: .8rem; }

.team-chat-messages {
  display: grid;
  gap: 6px;
  max-height: 190px;
  overflow-y: auto;
  padding: 8px;
  border-radius: 12px;
  background: rgba(1, 5, 20, .48);
}

.team-chat-message {
  width: fit-content;
  max-width: 88%;
  padding: 7px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,.07);
  overflow-wrap: anywhere;
}

.team-chat-message.mine {
  justify-self: end;
  background: color-mix(in srgb, var(--team-color, #38bdf8) 20%, rgba(255,255,255,.05));
}

.team-chat-compose,
.private-message-compose {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.host-private-message-panel .private-message-compose {
  grid-template-columns: minmax(130px, .7fr) minmax(0, 1fr) auto;
}

/* Private Host-Nachrichten im Popup */
.private-message-panel {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding: 13px;
  border: 1px solid rgba(129, 140, 248, .42);
  border-radius: 15px;
  background: rgba(12, 18, 50, .74);
}

.private-message-history {
  display: grid;
  gap: 6px;
  max-height: 150px;
  overflow-y: auto;
}

.private-message {
  padding: 7px 9px;
  border-radius: 9px;
  background: rgba(255,255,255,.06);
  overflow-wrap: anywhere;
}
.private-message.from-host { border-left: 3px solid #60a5fa; }
.private-message.from-player { border-left: 3px solid #a78bfa; }

.team-award-row {
  border-color: var(--team-color, #38bdf8) !important;
}

/* Popup bleibt stabil, auch wenn Medienstatus/Chat wächst. */
.question-overlay-card .question-content {
  min-width: 0;
}

@media (max-width: 820px) {
  .host-private-message-panel .private-message-compose,
  .team-chat-compose,
  .private-message-compose {
    grid-template-columns: 1fr;
  }
}

.score-row { position: relative; }


/* Mehrfachwertung eines Spieler-Eingabe-Feldes auch auf dem Board lesbar. */
.cell-multi-awards {
  display: grid;
  gap: 2px;
  justify-items: center;
  min-width: 0;
}
.cell-multi-awards strong {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* =========================================================
   2026-06 follow-up: active turn, direct chat, audio controls,
   stable header layout, late team join and emoji reactions
   ========================================================= */

/* Nur der tatsächlich aktive Spieler/das aktive Team wird hervorgehoben. */
.team-summary-card.joined {
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 0 0 1px rgba(255,255,255,.02) !important;
}

.score-row.active-turn-player:not(.host-row),
.score-row.current:not(.host-row) {
  border: 3px solid #60a5fa !important;
  box-shadow: 0 0 0 2px rgba(96,165,250,.18), 0 0 24px rgba(96,165,250,.24) !important;
}

.team-summary-card.active-turn-team {
  border-width: 4px !important;
  border-color: var(--team-color, #38bdf8) !important;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--team-color, #38bdf8) 34%, transparent),
              0 0 28px color-mix(in srgb, var(--team-color, #38bdf8) 28%, transparent) !important;
}

/* Spielerbox bleibt unter dem Boardnamen in einem stabilen Grid und wird
   durch das Öffnen der Lobby-Einstellungen nicht aus dem Container gedrückt. */
body.game-active .game-header.panel {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  align-items: start !important;
  align-content: start !important;
  overflow: visible !important;
}

body.game-active .game-header-main {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px) !important;
  align-items: start !important;
  gap: 14px !important;
  width: 100% !important;
  min-width: 0 !important;
}

body.game-active .game-header-tools {
  position: static !important;
  inset: auto !important;
  transform: none !important;
  display: grid !important;
  grid-template-columns: minmax(260px, .85fr) minmax(360px, 1.15fr) !important;
  align-items: start !important;
  gap: 14px !important;
  width: 100% !important;
  min-width: 0 !important;
}

body.game-active .players-card,
body.game-active .host-controls,
body.game-active .player-controls {
  position: static !important;
  inset: auto !important;
  transform: none !important;
  width: 100% !important;
  min-width: 0 !important;
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
  align-self: start !important;
}

body.role-player .game-header-tools,
body.player-local-slot .game-header-tools,
body.role-spectator .game-header-tools {
  grid-template-columns: minmax(0, 1fr) !important;
}

@media (max-width: 980px) {
  body.game-active .game-header-main,
  body.game-active .game-header-tools {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

/* Kick-X sauber zentriert, Hover ohne transform/translateY-Sprung. */
.team-member-kick {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  top: 50% !important;
  translate: 0 -50% !important;
  transform: none !important;
  padding: 0 0 2px !important;
  line-height: 1 !important;
  text-align: center !important;
}

.team-member-kick:hover,
.team-member-kick:focus-visible {
  translate: 0 -50% !important;
  transform: none !important;
  background: rgba(239, 68, 68, .86) !important;
}

/* Ein während des Spiels neu beigetretener Spieler bekommt genau einmal die
   Team-Auswahl. Der Button wird nur gerendert, wenn der Server sie erlaubt. */
body:not(.game-phase-lobby) .team-summary-card .team-join-btn.available {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}

/* Browserübergreifend identische MP3-Controls und Range-Slider. */
.custom-audio-controls,
.host-volume-row,
.player-audio-box {
  min-width: 0 !important;
}

.audio-seek,
.volume-slider {
  appearance: none !important;
  -webkit-appearance: none !important;
  width: 100% !important;
  min-width: 0 !important;
  height: 28px !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 999px !important;
  background: transparent !important;
  box-shadow: none !important;
  cursor: pointer !important;
  accent-color: transparent !important;
}

.audio-seek::-webkit-slider-runnable-track,
.volume-slider::-webkit-slider-runnable-track {
  width: 100%;
  height: 7px;
  border: 1px solid rgba(148,163,184,.32);
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(96,165,250,.82), rgba(139,92,246,.82));
  box-shadow: inset 0 1px 3px rgba(0,0,0,.45);
}

.audio-seek::-moz-range-track,
.volume-slider::-moz-range-track {
  width: 100%;
  height: 7px;
  border: 1px solid rgba(148,163,184,.32);
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(96,165,250,.82), rgba(139,92,246,.82));
  box-shadow: inset 0 1px 3px rgba(0,0,0,.45);
}

.audio-seek::-webkit-slider-thumb,
.volume-slider::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 19px;
  height: 19px;
  margin-top: -7px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #7c3aed;
  box-shadow: 0 3px 12px rgba(0,0,0,.48), 0 0 0 3px rgba(124,58,237,.22);
}

.audio-seek::-moz-range-thumb,
.volume-slider::-moz-range-thumb {
  width: 17px;
  height: 17px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #7c3aed;
  box-shadow: 0 3px 12px rgba(0,0,0,.48), 0 0 0 3px rgba(124,58,237,.22);
}

.audio-seek:focus-visible,
.volume-slider:focus-visible {
  outline: 2px solid #67e8f9 !important;
  outline-offset: 3px !important;
}

.compact-audio-btn {
  min-height: 42px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  line-height: 1 !important;
}

/* Online-Badge: feste Höhe oben rechts, bei drohender Überlappung ausblenden. */
.page-connection-status {
  position: fixed !important;
  top: 14px !important;
  right: 18px !important;
  z-index: 1200 !important;
  height: 32px !important;
  min-height: 32px !important;
  max-height: 32px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 13px !important;
  line-height: 1 !important;
  white-space: nowrap !important;
}

@media (max-width: 1180px) {
  .page-connection-status {
    display: none !important;
  }
}

/* Emoji-Reaktion für die aktuelle Frage. */
.question-emoji-picker {
  display: grid;
  grid-template-columns: auto minmax(120px, 190px);
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: fit-content;
  max-width: 100%;
  margin: 10px auto;
  padding: 9px 12px;
  border: 1px solid rgba(148,163,184,.3);
  border-radius: 14px;
  background: rgba(8,15,40,.76);
}

.question-emoji-picker label {
  font-weight: 850;
  color: #dbeafe;
}

/* Separater, pro Popup zurückgesetzter Privat-Chat wie ein Twitch-PN-Dock. */
.direct-chat-dock {
  position: fixed;
  right: max(16px, env(safe-area-inset-right, 0px) + 12px);
  bottom: max(16px, env(safe-area-inset-bottom, 0px) + 12px);
  z-index: 1900;
  width: min(390px, calc(100vw - 28px));
  border: 1px solid rgba(129,140,248,.56);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(10,16,45,.985), rgba(5,10,29,.985));
  box-shadow: 0 24px 70px rgba(0,0,0,.58), 0 0 0 1px rgba(255,255,255,.04) inset;
  overflow: hidden;
}

.direct-chat-dock.hidden {
  display: none !important;
}

.direct-chat-toggle {
  width: 100%;
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border: 0;
  border-radius: 0;
  background: linear-gradient(135deg, rgba(79,70,229,.42), rgba(14,165,233,.26));
  color: #fff;
  font-weight: 900;
  cursor: pointer;
}

.direct-chat-toggle:hover {
  transform: none !important;
  background: linear-gradient(135deg, rgba(99,102,241,.58), rgba(14,165,233,.36));
}

.direct-chat-body {
  display: none;
  gap: 10px;
  padding: 12px;
}

.direct-chat-dock.open .direct-chat-body {
  display: grid;
}

.direct-chat-target {
  display: grid;
  grid-template-columns: auto minmax(0,1fr);
  align-items: center;
  gap: 9px;
}

.direct-chat-messages {
  display: grid;
  gap: 7px;
  max-height: 240px;
  overflow-y: auto;
  padding: 9px;
  border-radius: 12px;
  background: rgba(1,5,20,.58);
  overscroll-behavior: contain;
}

.direct-chat-message {
  width: fit-content;
  max-width: 88%;
  padding: 8px 10px;
  border-radius: 11px;
  background: rgba(255,255,255,.075);
  overflow-wrap: anywhere;
}

.direct-chat-message.mine {
  justify-self: end;
  background: rgba(79,70,229,.28);
}

.direct-chat-message.from-host {
  border-left: 3px solid #60a5fa;
}

.direct-chat-message.from-player {
  border-left: 3px solid #a78bfa;
}

.direct-chat-compose {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 8px;
}

@media (max-width: 560px) {
  .direct-chat-dock {
    right: 10px;
    bottom: 10px;
    width: calc(100vw - 20px);
  }
  .direct-chat-compose,
  .direct-chat-target,
  .question-emoji-picker {
    grid-template-columns: 1fr;
  }
}

body.role-player .game-header-main,
body.player-local-slot .game-header-main,
body.role-spectator .game-header-main {
  grid-template-columns: minmax(0, 1fr) !important;
}

/* =========================================================
   2026-06 fixed join emoji, host header placement and chat colors
   ========================================================= */

/* Kein Sprung/Zoom beim Löschen eines Teams. */
.team-delete-btn:hover,
.team-delete-btn:focus-visible {
  transform: none !important;
  translate: none !important;
}

/* Das feste Spiel-Emoji wird einmal auf dem Startbildschirm gewählt. */
.username-hero-field {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) minmax(108px, 132px) !important;
  align-items: end !important;
  gap: 12px !important;
}

.username-name-field,
.username-emoji-field,
.invite-player-identity > div {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.username-emoji-field select,
.username-emoji-field .custom-select-shell,
.invite-player-identity select,
.invite-player-identity .custom-select-shell {
  width: 100% !important;
  min-width: 0 !important;
}

.username-emoji-field select,
.username-emoji-field .custom-select-trigger {
  min-height: 48px !important;
  font-size: 1.32rem !important;
  text-align: center !important;
}

.invite-player-identity {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(105px, 125px);
  align-items: end;
  gap: 12px;
}

@media (max-width: 560px) {
  .username-hero-field,
  .invite-player-identity {
    grid-template-columns: 1fr !important;
  }
}

/* Die frühere Emoji-Reaktion im Fragen-Popup ist vollständig deaktiviert. */
.question-emoji-picker {
  display: none !important;
}

/* Host: Spielerbox direkt unter dem Boardnamen. Lobby-Einstellungen behalten
   daneben wieder die volle, uncapped Breite. */
body.role-host.game-active .game-header-main {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) minmax(420px, 1fr) !important;
  grid-template-areas:
    "title settings"
    "players settings" !important;
  column-gap: 18px !important;
  row-gap: 14px !important;
  align-items: start !important;
  width: 100% !important;
  min-width: 0 !important;
}

body.role-host.game-active .game-title-block {
  grid-area: title !important;
  min-width: 0 !important;
}

body.role-host.game-active .players-card.host-header-players {
  grid-area: players !important;
  position: static !important;
  inset: auto !important;
  transform: none !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: none !important;
  align-self: start !important;
  overflow: visible !important;
}

body.role-host.game-active #hostLobbySettings {
  grid-area: settings !important;
  justify-self: stretch !important;
  align-self: start !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: none !important;
}

body.role-host.game-active #hostLobbySettings .lobby-settings-menu,
body.role-host.game-active #hostLobbySettings .lobby-settings-content,
body.role-host.game-active #hostLobbySettings .lobby-settings-content-inner {
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
}

body.role-host.game-active .game-header-tools {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  width: 100% !important;
  min-width: 0 !important;
  align-items: start !important;
}

@media (max-width: 1120px) {
  body.role-host.game-active .game-header-main {
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-areas:
      "title"
      "players"
      "settings" !important;
  }
}

/* Privat-Chat: Host wie die goldene Host-Karte, Spieler in Teamfarbe bzw. Blau. */
.direct-chat-message.from-host {
  border: 2px solid rgba(250, 204, 21, .82) !important;
  border-left-width: 4px !important;
  background:
    radial-gradient(circle at 0 0, rgba(250, 204, 21, .19), transparent 62%),
    linear-gradient(135deg, rgba(245, 215, 110, .17), rgba(124, 58, 237, .11)) !important;
  color: #fff7cc !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.07), 0 0 18px rgba(250,204,21,.10) !important;
}

.direct-chat-message.from-host b {
  color: #fde68a !important;
}

.direct-chat-message.from-player {
  border: 2px solid color-mix(in srgb, var(--chat-player-color, #38bdf8) 78%, white) !important;
  border-left-width: 4px !important;
  background:
    radial-gradient(circle at 0 0, color-mix(in srgb, var(--chat-player-color, #38bdf8) 22%, transparent), transparent 64%),
    color-mix(in srgb, var(--chat-player-color, #38bdf8) 12%, rgba(4,10,31,.94)) !important;
  color: #f8fafc !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 0 18px color-mix(in srgb, var(--chat-player-color, #38bdf8) 13%, transparent) !important;
}

.direct-chat-message.from-player b {
  color: color-mix(in srgb, var(--chat-player-color, #38bdf8) 72%, white) !important;
}

.direct-chat-message .player-round-emoji {
  margin-left: .32rem !important;
}


/* =========================================================
   2026-06 board navigation, start emoji menu and favorites
   ========================================================= */

/* Der Board-Wechsel gehört unter das Panel und darf nicht als zweite Flex-Spalte
   innerhalb der Board-Fläche erscheinen. */
.host-test-board-navigation {
  grid-column: 1 / -1 !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 2px !important;
  align-items: center !important;
}

body.role-host.game-phase-lobby .game-layout {
  row-gap: 12px !important;
}

.host-test-board-navigation.align-right {
  justify-content: flex-end !important;
}

.host-test-board-navigation.align-left {
  justify-content: flex-start !important;
}

.host-test-board-switch-btn {
  width: auto !important;
  min-width: 170px !important;
  min-height: 44px !important;
  height: auto !important;
  align-self: auto !important;
}

/* Das feste Emoji-Menü darf die Startkarten überlagern und wird nicht mehr an
   der Kante der Join-Karte oder des Hero-Panels abgeschnitten. */
#homeView.hero-panel,
#homeView .home-join-card,
#homeView .username-hero-field,
#homeView .username-emoji-field {
  overflow: visible !important;
}

#homeView .home-join-card {
  position: relative !important;
  z-index: 20 !important;
}

#homeView .username-hero-field {
  position: relative !important;
  z-index: 30 !important;
}

#homeView .username-emoji-field {
  position: relative !important;
  z-index: 40 !important;
}

#homeView .username-emoji-field .custom-select-shell.open {
  z-index: 100000 !important;
  isolation: auto !important;
}

#homeView .username-emoji-field .custom-select-menu {
  z-index: 100001 !important;
  max-height: min(360px, 60vh) !important;
}

#homeView .join-hero-box,
#homeView .home-template-actions,
#homeView .account-box {
  position: relative !important;
  z-index: 1 !important;
}

/* Favoriten stehen optisch über den übrigen lokal gespeicherten Hashes. */
.home-library-card #favoriteTemplatesBox {
  order: 1 !important;
}

.home-library-card #recentTemplatesBox {
  order: 2 !important;
}

.home-library-card #runningInstancesBox {
  order: 0 !important;
}

.favorite-star[aria-busy="true"] {
  cursor: wait !important;
}

@media (max-width: 640px) {
  .host-test-board-switch-btn {
    width: 100% !important;
  }
}

/* =========================================================
   2026-06 compact host lobby, exact emoji menu width and score actions
   ========================================================= */

/* Das Emoji-Menü übernimmt exakt die Breite seines sichtbaren Select-Buttons.
   Der globale Mindestwert von 220px gilt hier bewusst nicht. */
#homeView .username-emoji-field .custom-select-menu,
.invite-join-card .invite-player-identity > div:last-child .custom-select-menu {
  left: 0 !important;
  right: auto !important;
  width: 100% !important;
  min-width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

#homeView .username-emoji-field .custom-select-shell,
.invite-join-card .invite-player-identity > div:last-child .custom-select-shell {
  min-width: 0 !important;
  max-width: 100% !important;
}

/* Das Team-Löschen-X wird über ein eigenes, exakt zentriertes Glyph gerendert.
   Dadurch hängt es nicht mehr von der Schrift-Baseline des Buttons ab. */
.team-delete-btn {
  font-size: 0 !important;
  line-height: 0 !important;
  padding: 0 !important;
  display: grid !important;
  place-items: center !important;
}

.team-delete-btn::before {
  content: "\00d7";
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  padding: 0 0 1px 0;
  box-sizing: border-box;
  color: currentColor;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
}

.team-delete-btn:hover,
.team-delete-btn:focus-visible {
  transform: none !important;
  translate: none !important;
}

/* Im Einladungsdialog klebt der Join-Button nicht mehr direkt am Namensfeld. */
.invite-join-card #inviteJoinBtn {
  margin-top: 18px !important;
}

/* Vor Spielstart werden Team-Rotation und Team-Werkzeuge nebeneinander gezeigt.
   Das spart deutlich Höhe im Host-Control. */
body.role-host.game-phase-lobby .host-player-management.team-lobby-management {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  align-items: stretch !important;
  gap: 10px !important;
  padding: 10px !important;
  margin-bottom: 8px !important;
}

body.role-host.game-phase-lobby .host-player-management.team-lobby-management > .host-active-player-box,
body.role-host.game-phase-lobby .host-player-management.team-lobby-management > .host-team-tools {
  min-width: 0 !important;
  height: 100% !important;
  margin: 0 !important;
  padding: 10px !important;
  border: 1px solid rgba(147, 197, 253, 0.16) !important;
  border-radius: 14px !important;
  background: rgba(8, 13, 37, 0.34) !important;
}

body.role-host.game-phase-lobby .host-player-management.team-lobby-management > .host-team-tools {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  align-content: space-between !important;
  align-items: start !important;
  gap: 8px !important;
  border-top: 1px solid rgba(147, 197, 253, 0.16) !important;
}

body.role-host.game-phase-lobby .host-player-management.team-lobby-management .host-active-player-box .inline-actions {
  grid-template-columns: minmax(0, 1fr) minmax(130px, auto) !important;
  gap: 8px !important;
}

body.role-host.game-phase-lobby .host-player-management.team-lobby-management .team-management-actions {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 8px !important;
  min-width: 0 !important;
  width: 100% !important;
  justify-content: stretch !important;
}

body.role-host.game-phase-lobby .host-player-management.team-lobby-management .team-management-actions button {
  min-width: 0 !important;
  width: 100% !important;
  padding: 9px 10px !important;
}

body.role-host.game-phase-lobby .host-controls.top-game-card {
  gap: 8px !important;
  padding: 10px !important;
}

body.role-host.game-phase-lobby .host-controls .manual-score-menu,
body.role-host.game-phase-lobby .host-controls .host-lobby-start-box {
  margin: 0 !important;
}

/* Im Nicht-Team-Modus stehen die Punkte links vom Kick-X; der Button ist Teil
   des Grids und liegt nicht mehr absolut über dem Punktestand. */
.score-list:not(.team-score-mode) > .score-row:not(.host-row) {
  grid-template-columns: minmax(0, 1fr) auto 26px !important;
  gap: 10px !important;
  padding-right: 10px !important;
}

.score-list:not(.team-score-mode) > .score-row:not(.host-row) > .score-points {
  grid-column: 2 !important;
  justify-self: end !important;
  min-width: 48px !important;
}

.score-list:not(.team-score-mode) > .score-row:not(.host-row) > .team-member-kick {
  position: static !important;
  inset: auto !important;
  grid-column: 3 !important;
  justify-self: end !important;
  align-self: center !important;
  translate: none !important;
  transform: none !important;
  margin: 0 !important;
}

.score-list:not(.team-score-mode) > .score-row:not(.host-row) > .team-member-kick:hover,
.score-list:not(.team-score-mode) > .score-row:not(.host-row) > .team-member-kick:focus-visible {
  translate: none !important;
  transform: none !important;
}

/* Das Board bleibt kompakt, aber der Navigationsbutton erhält eine eigene
   Grid-Zeile. Auf sehr niedrigen Viewports darf die Hostseite notfalls scrollen,
   statt den Board-2-Button am unteren Rand abzuschneiden. */
body.role-host.game-phase-lobby .game-layout {
  grid-template-rows: minmax(0, 1fr) auto !important;
  align-content: start !important;
  padding-bottom: 10px !important;
  overflow: visible !important;
}

body.role-host.game-phase-lobby .host-test-board-navigation {
  min-height: 44px !important;
  padding-bottom: 2px !important;
}

@media (min-width: 1024px) {
  body.role-host.game-phase-lobby .app-shell {
    height: auto !important;
    min-height: 100dvh !important;
  }

  body.role-host.game-phase-lobby main,
  body.role-host.game-phase-lobby #gameView {
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
  }

  body.role-host.game-phase-lobby #gameView:not(.hidden) {
    grid-template-rows: auto auto auto !important;
  }

  body.role-host.game-phase-lobby .game-layout,
  body.role-host.game-phase-lobby .board-panel {
    height: auto !important;
    min-height: 0 !important;
  }
}

@media (max-width: 1180px) {
  body.role-host.game-phase-lobby .host-player-management.team-lobby-management {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

@media (max-width: 680px) {
  #homeView .username-emoji-field .custom-select-menu,
  .invite-join-card .invite-player-identity > div:last-child .custom-select-menu {
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
  }
}

@media (min-width: 1024px) {
  body.role-host.game-phase-lobby {
    height: auto !important;
    min-height: 100dvh !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }
}

/* Final alignment correction for the team delete button. */
.team-delete-btn {
  padding: 2px 0 0 1px !important;
}

/* Final logo placement: compact and aligned with the left edge of the page wrapper. */
.topbar-title {
  display: flex !important;
  align-items: flex-start !important;
  justify-content: flex-start !important;
  justify-self: start !important;
  width: auto !important;
  padding: 0 !important;
}

.site-logo,
.topbar .site-logo,
body.game-active .site-logo {
  display: block !important;
  width: clamp(210px, 15vw, 300px) !important;
  max-width: 100% !important;
  max-height: none !important;
  height: auto !important;
  margin: 0 !important;
  object-fit: contain !important;
  object-position: left top !important;
}

body.game-active .site-logo {
  width: clamp(165px, 11vw, 220px) !important;
}

@media (max-width: 980px) {
  .site-logo,
  .topbar .site-logo,
  body.game-active .site-logo {
    width: clamp(190px, 34vw, 250px) !important;
  }
}

@media (max-width: 600px) {
  .site-logo,
  .topbar .site-logo,
  body.game-active .site-logo {
    width: clamp(165px, 52vw, 220px) !important;
  }
}
