.multiplayer-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: linear-gradient(115deg, #5b2d7f, #dd5f58);
  color: #fff9f0;
  padding: 13px 14px;
  margin: 0 0 14px;
  border: 2px solid #f6c85f;
  border-radius: 15px;
  box-shadow: 0 5px 0 #2c1c37;
}
.multiplayer-banner[hidden] {
  display: none;
}
.multiplayer-banner small {
  display: block;
  color: var(--lime);
  font: 10px monospace;
  letter-spacing: 1px;
}
.multiplayer-banner strong {
  display: block;
  font-size: 13px;
  margin-top: 4px;
}
.multiplayer-banner button {
  color: var(--paper);
  font-size: 34px;
  line-height: 1;
  padding: 0 4px;
}
.multiplayer-banner button:hover {
  color: var(--coral);
}
.multiplayer-banner-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.multiplayer-banner #multiplayerShare,
.multiplayer-banner #resumeMultiplayer {
  padding: 8px 10px;
  border: 2px solid #2c1c37;
  border-radius: 10px;
  background: #f6c85f;
  color: #2c1c37;
  font: 900 12px system-ui;
  box-shadow: 0 3px 0 #2c1c37;
  white-space: nowrap;
}
.multiplayer-banner #resumeMultiplayer[hidden] { display: none; }
.multiplayer-banner #multiplayerShare span { margin-right: 3px; font-size: 16px; }
.cast-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 20px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 3px;
}
.cast-control[hidden] {
  display: none;
}
.cast-control small,
.cast-control strong {
  display: block;
}
.cast-control small {
  color: var(--muted);
  font: 10px monospace;
  letter-spacing: 1px;
}
.cast-control strong {
  max-width: 156px;
  margin-top: 4px;
  font-size: 12px;
}
.cast-control button {
  flex: 0 0 auto;
  padding: 9px 10px;
}
.game-cast-button {
  padding: 5px 8px;
  border: 1px solid #5b2d7f;
  border-radius: 999px;
  background: #efe2ff;
  color: #5b2d7f !important;
  font-weight: 900;
}
.game-cast-button[hidden] { display: none; }
#multiplayerDialog {
  width: min(640px, calc(100% - 24px));
  max-width: 640px;
  max-height: min(760px, calc(100dvh - 24px));
  overflow-y: auto;
  border: 3px solid #2c1c37;
  border-radius: 26px;
  background:
    radial-gradient(circle at 92% 5%, #f6c85f 0 5rem, transparent 5.1rem),
    linear-gradient(145deg, #fff9f0 0 58%, #e8dcff 100%);
  box-shadow: 0 14px 0 #2c1c37, 0 28px 90px #0008;
}
#multiplayerDialog .dialog-head { padding: 22px 28px 10px; }
#multiplayerDialog .dialog-head h2 {
  margin-top: 4px;
  color: #2c1c37;
  font-size: clamp(2rem, 7vw, 3.2rem);
  letter-spacing: -0.07em;
}
#sessionChoices { padding: 4px 28px 28px; }
.multiplayer-welcome { padding: 8px 0 18px; text-align: center; }
.multiplayer-burst {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin: 2px 0 16px;
}
.multiplayer-burst span,
.multiplayer-burst b {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border: 2px solid #2c1c37;
  border-radius: 12px;
  background: #b7f5ff;
  color: #2c1c37;
  font: 900 25px monospace;
  box-shadow: 0 5px 0 #2c1c37;
  transform: rotate(-6deg);
  animation: multiplayer-choice-bob 1.7s ease-in-out infinite alternate;
}
.multiplayer-burst b {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #f7b2a8;
  font-size: 20px;
  transform: rotate(5deg);
  animation-delay: -0.7s;
}
.multiplayer-burst span:last-child {
  background: #eaf9d2;
  transform: rotate(6deg);
  animation-delay: -1.1s;
}
@keyframes multiplayer-choice-bob { to { translate: 0 -5px; } }
.multiplayer-welcome h3 {
  margin: 8px 0;
  color: #2c1c37;
  font-size: clamp(1.8rem, 7vw, 3rem);
  line-height: 0.95;
  letter-spacing: -0.07em;
}
.multiplayer-welcome h3 em { color: #dd5f58; }
.multiplayer-welcome > p:last-child {
  max-width: 40ch;
  margin: 12px auto 0;
  color: #5e5266;
  line-height: 1.4;
  font-weight: 700;
}
.multiplayer-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.multiplayer-choice {
  display: grid;
  min-height: 154px;
  padding: 18px;
  border: 3px solid #2c1c37;
  border-radius: 18px;
  color: #2c1c37;
  text-align: left;
  box-shadow: 0 7px 0 #2c1c37;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.multiplayer-choice:hover,
.multiplayer-choice:focus-visible {
  transform: translateY(-4px) rotate(-1deg);
  box-shadow: 0 11px 0 #2c1c37;
}
.multiplayer-choice:active { transform: translateY(3px); box-shadow: 0 4px 0 #2c1c37; }
.multiplayer-choice-create { background: #b7f5ff; }
.multiplayer-choice-scan { background: #f6c85f; }
.multiplayer-choice > span { font-size: 31px; }
.multiplayer-choice > strong { align-self: end; margin-top: 16px; font-size: 20px; }
.multiplayer-choice > small { margin-top: 4px; color: #5e5266; font-weight: 700; line-height: 1.25; }
.multiplayer-choice > b { justify-self: end; margin-top: -23px; font-size: 28px; }
.multiplayer-code-button {
  width: 100%;
  justify-content: center;
  margin-top: 20px;
  border: 2px solid #2c1c37;
  color: #2c1c37;
  font-size: 13px;
}
.multiplayer-privacy-note {
  display: block;
  margin: 12px auto 0;
  color: #6e6374;
  font-size: 10px;
  text-align: center;
}
.session-scanner { padding: 6px 28px 28px; text-align: center; }
.session-scanner[hidden] { display: none; }
.scanner-heading {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 8px 0 14px;
  color: #2c1c37;
  text-align: left;
}
.scanner-heading > span { font-size: 34px; }
.scanner-heading strong,
.scanner-heading small { display: block; }
.scanner-heading strong { font-size: 18px; }
.scanner-heading small { margin-top: 4px; color: #6e6374; }
#sessionScannerVideo {
  display: block;
  width: min(100%, 410px);
  aspect-ratio: 1;
  margin: 0 auto;
  border: 4px solid #2c1c37;
  border-radius: 18px;
  background: #17121f;
  object-fit: cover;
}
#sessionScannerStatus { min-height: 20px; margin: 12px 0; color: #6e6374; font: 11px monospace; }
.session-scanner .dialog-action { width: 100%; justify-content: center; }
#multiplayerDialog:has(.waiting-lobby:not([hidden])) {
  width: min(420px, calc(100% - 24px));
  max-width: 420px;
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  border: 2px solid #5b2d7f;
  border-radius: 20px;
}
.waiting-lobby {
  position: relative;
  overflow: hidden;
  padding: 4px 20px 20px;
  text-align: center;
}
.waiting-lobby::before {
  position: absolute;
  z-index: -1;
  inset: 0 -30px auto;
  height: 180px;
  background:
    radial-gradient(circle at 18% 25%, #f6c85f 0 4px, transparent 5px),
    radial-gradient(circle at 82% 14%, #dd5f58 0 5px, transparent 6px),
    linear-gradient(145deg, rgba(91, 45, 127, 0.2), transparent 72%);
  content: "";
  pointer-events: none;
}
.lobby-sparkles {
  margin-top: -4px;
  color: #5b2d7f;
  font-size: 20px;
  letter-spacing: 0.25em;
}
.session-code-label {
  margin: 8px 0 0;
  color: var(--muted);
  font: 800 11px monospace;
  letter-spacing: 0.14em;
}
.waiting-lobby .session-code {
  display: block;
  margin: 4px 0 0;
  color: #5b2d7f;
  font: 900 clamp(36px, 13vw, 54px) monospace;
  letter-spacing: 0.12em;
  line-height: 1;
  text-shadow: 2px 2px 0 #f6c85f;
}
.lobby-share-hint,
#sessionPlayersText {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
}
.session-invite {
  display: grid;
  justify-items: center;
  gap: 8px;
  margin: 12px 0;
}
.session-invite img {
  width: min(180px, 52vw);
  height: auto;
  padding: 6px;
  border: 2px solid #5b2d7f;
  border-radius: 12px;
  background: #fff;
}
.session-invite button {
  padding: 8px 12px;
  font-size: 12px;
}
.lobby-status {
  max-width: 31ch;
  margin: 14px auto;
  padding: 10px 12px;
  border: 2px solid #f6c85f;
  border-radius: 12px;
  background: rgba(246, 200, 95, 0.22);
  color: var(--ink);
  font-weight: 900;
  line-height: 1.35;
}
.lobby-players {
  display: grid;
  gap: 7px;
  max-height: min(260px, 29vh);
  margin: 14px 0;
  padding: 8px;
  overflow-y: auto;
  border: 2px dashed rgba(91, 45, 127, 0.55);
  border-radius: 14px;
  background: rgba(91, 45, 127, 0.08);
  text-align: left;
}
.lobby-players .live-player {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 9px;
  min-height: 46px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  outline: none;
  background: var(--paper);
  font-size: 14px;
}
.lobby-players .live-player.is-host {
  border-color: #f6c85f;
}
.lobby-players .player-avatar {
  font-size: 24px;
}
.lobby-players .player-name {
  max-width: none;
  font-weight: 800;
}
.lobby-player-badges {
  display: flex;
  gap: 4px;
  align-items: center;
}
.lobby-player-you,
.lobby-player-role {
  padding: 3px 6px;
  border-radius: 999px;
  font: 800 10px monospace;
  white-space: nowrap;
}
.lobby-player-you {
  background: #5b2d7f;
  color: #fff;
}
.lobby-player-role {
  background: #f6c85f;
  color: #2c1c37;
}
.lobby-host-controls {
  display: grid;
  gap: 8px;
  margin: 14px 0;
  padding: 12px;
  border-radius: 14px;
  background: linear-gradient(145deg, #5b2d7f, #704093);
  color: #fff;
  text-align: left;
}
.lobby-host-controls[hidden] {
  display: none;
}
.lobby-host-controls label {
  font-size: 12px;
  font-weight: 900;
}
.lobby-host-controls select {
  width: 100%;
  padding: 11px;
  border: 2px solid #f6c85f;
  border-radius: 8px;
  background: #fff;
  color: #2c1c37;
  font: inherit;
}
.lobby-host-controls .dialog-action,
.waiting-lobby > .dialog-action {
  width: 100%;
  justify-content: center;
  margin: 0;
}
.waiting-lobby > .dialog-action {
  margin-top: 10px;
}
.waiting-lobby .cast-control {
  margin: 14px 0 0;
  border-radius: 12px;
  text-align: left;
}
html[data-theme="dark"] .lobby-players .live-player {
  background: #242823;
}
html[data-theme="dark"] .waiting-lobby .session-code,
html[data-theme="dark"] .lobby-sparkles {
  color: #cda7ec;
}
html[data-theme="dark"] #multiplayerDialog {
  border-color: #f6c85f;
  background:
    radial-gradient(circle at 92% 5%, #8b6c20 0 5rem, transparent 5.1rem),
    linear-gradient(145deg, #211b28 0 58%, #342541 100%);
  box-shadow: 0 14px 0 #f6c85f, 0 28px 90px #000b;
}
html[data-theme="dark"] #multiplayerDialog .dialog-head h2,
html[data-theme="dark"] .multiplayer-welcome h3,
html[data-theme="dark"] .scanner-heading {
  color: #fff9f0;
}
html[data-theme="dark"] .multiplayer-welcome > p:last-child,
html[data-theme="dark"] .multiplayer-choice > small,
html[data-theme="dark"] .scanner-heading small,
html[data-theme="dark"] #sessionScannerStatus,
html[data-theme="dark"] .multiplayer-privacy-note {
  color: #d5cbdc;
}
html[data-theme="dark"] .multiplayer-choice,
html[data-theme="dark"] .multiplayer-burst span,
html[data-theme="dark"] .multiplayer-burst b,
html[data-theme="dark"] #sessionScannerVideo {
  border-color: #fff9f0;
  box-shadow: 0 7px 0 #fff9f0;
}
html[data-theme="dark"] .multiplayer-choice,
html[data-theme="dark"] .multiplayer-burst span,
html[data-theme="dark"] .multiplayer-burst b {
  color: #2c1c37;
}
html[data-theme="dark"] .multiplayer-code-button {
  border-color: #fff9f0;
  color: #fff9f0;
}
@media (max-width: 560px) {
  #multiplayerDialog .dialog-head { padding-inline: 20px; }
  #sessionChoices,
  .session-scanner { padding-inline: 20px; }
  .multiplayer-choice-grid { grid-template-columns: 1fr; }
  .multiplayer-choice { min-height: 126px; }
}
@media (max-width: 380px) {
  .waiting-lobby {
    padding-inline: 14px;
  }
  .lobby-player-you {
    display: none;
  }
  .waiting-lobby .cast-control {
    align-items: stretch;
    flex-direction: column;
  }
  .waiting-lobby .cast-control strong {
    max-width: none;
  }
}
