:root {
  --bg: #080817;
  --card: rgba(17, 18, 40, .82);
  --card-strong: rgba(25, 27, 60, .96);
  --line: rgba(255,255,255,.12);
  --text: #f6f7ff;
  --muted: #b9bdd8;
  --accent: #8f5cff;
  --accent-2: #00e5ff;
  --danger: #ff3b6a;
  --success: #39f29a;
  --shadow: 0 30px 90px rgba(0,0,0,.5);
  --radius: 26px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 20% 10%, rgba(143,92,255,.32), transparent 34%),
    radial-gradient(circle at 90% 0%, rgba(0,229,255,.22), transparent 30%),
    linear-gradient(140deg, #05050d, #0c0b21 50%, #05050d);
  overflow-x: hidden;
}

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

a {
  color: inherit;
  text-decoration: none;
}

.bg-orb {
  position: fixed;
  width: 420px;
  height: 420px;
  border-radius: 999px;
  filter: blur(48px);
  opacity: .38;
  z-index: -1;
  pointer-events: none;
}

.bg-orb-1 {
  left: -120px;
  bottom: -110px;
  background: #8f5cff;
}

.bg-orb-2 {
  right: -140px;
  top: 35%;
  background: #00e5ff;
}

.hidden {
  display: none !important;
}

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  min-height: 100vh;
  padding: 30px 0;
  display: grid;
  place-items: center;
}

.single-page {
  width: min(760px, calc(100% - 28px));
}

.hero-card,
.chat-layout,
.modal-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(255,255,255,.11), rgba(255,255,255,.045));
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.hero-card {
  width: min(720px, 100%);
  padding: clamp(22px, 4vw, 46px);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 26px;
}

.brand-mark {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  border-radius: 24px;
  background:
    linear-gradient(145deg, rgba(143,92,255,.9), rgba(0,229,255,.75));
  box-shadow: 0 18px 42px rgba(143,92,255,.35);
  font-weight: 900;
  font-size: 34px;
}

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

h1 {
  font-size: clamp(34px, 7vw, 64px);
  letter-spacing: -.06em;
  line-height: .95;
}

h2 {
  font-size: clamp(22px, 3vw, 34px);
  letter-spacing: -.04em;
}

h3 {
  font-size: 25px;
  letter-spacing: -.04em;
  margin-bottom: 20px;
}

.brand-row p,
.topbar p,
.rules-box p {
  color: var(--muted);
  margin-top: 8px;
  line-height: 1.55;
}

.rules-box {
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.2);
  border-radius: 22px;
  padding: 18px;
  margin: 24px 0;
}

.join-form {
  display: grid;
  gap: 12px;
}

.join-form label,
.modal-card label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  color: var(--text);
  background: rgba(0,0,0,.28);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 16px;
  padding: 14px 15px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(143,92,255,.8);
  box-shadow: 0 0 0 4px rgba(143,92,255,.15);
}

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

.check-line {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.4;
  margin: 7px 0;
}

.check-line input {
  width: auto;
  margin-top: 3px;
  accent-color: var(--accent);
}

.primary-btn,
.ghost-btn,
.danger-btn,
.message-form button,
.link-btn {
  border: 0;
  border-radius: 16px;
  min-height: 48px;
  padding: 0 18px;
  font-weight: 900;
  cursor: pointer;
  transition: transform .18s, filter .18s, border-color .18s;
}

.primary-btn,
.message-form button,
.link-btn {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 18px 44px rgba(143,92,255,.28);
}

.ghost-btn {
  color: var(--text);
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15);
}

.danger-btn {
  color: #fff;
  background: linear-gradient(135deg, #ff3b6a, #ff7a3d);
  box-shadow: 0 18px 44px rgba(255,59,106,.25);
}

.primary-btn:hover,
.ghost-btn:hover,
.danger-btn:hover,
.message-form button:hover,
.link-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
}

.link-btn {
  display: inline-grid;
  place-items: center;
  margin-top: 25px;
}

.mini-links {
  margin-top: 22px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}

.mini-links a {
  color: var(--accent-2);
  font-weight: 800;
}

.chat-layout {
  width: 100%;
  padding: clamp(14px, 2vw, 24px);
  display: grid;
  gap: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 8px 4px 12px;
}

.pill {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  color: var(--muted);
  font-weight: 900;
  white-space: nowrap;
}

.pill[data-mode="connecté"] {
  color: #082013;
  background: var(--success);
}

.pill[data-mode="recherche"],
.pill[data-mode="connexion"] {
  color: #0b1720;
  background: var(--accent-2);
}

.pill[data-mode="bloqué"] {
  color: #fff;
  background: var(--danger);
}

.video-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.video-card {
  position: relative;
  min-height: clamp(240px, 32vw, 480px);
  overflow: hidden;
  border-radius: 24px;
  background: rgba(0,0,0,.45);
  border: 1px solid rgba(255,255,255,.12);
}

video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #05050d;
}

.local-card video {
  transform: scaleX(-1);
}

.video-label {
  position: absolute;
  left: 14px;
  bottom: 14px;
  padding: 9px 12px;
  border-radius: 999px;
  background: rgba(0,0,0,.56);
  border: 1px solid rgba(255,255,255,.12);
  font-weight: 900;
}

.small-floating {
  position: absolute;
  right: 14px;
  bottom: 14px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: rgba(0,0,0,.56);
  border: 1px solid rgba(255,255,255,.18);
  padding: 9px 12px;
  font-weight: 900;
  cursor: pointer;
}

.small-floating.second {
  bottom: 58px;
}

.small-floating.muted {
  background: rgba(255,59,106,.82);
}

.waiting-layer {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  text-align: center;
  padding: 26px;
  background: rgba(8,8,23,.82);
}

.waiting-layer span {
  color: var(--muted);
}

.spinner {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 5px solid rgba(255,255,255,.16);
  border-top-color: var(--accent-2);
  animation: spin 1s linear infinite;
}

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

.controls-card {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr;
  gap: 12px;
}

.text-chat {
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 22px;
  background: rgba(0,0,0,.18);
}

.messages {
  height: 170px;
  overflow: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message {
  width: fit-content;
  max-width: min(720px, 88%);
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(255,255,255,.08);
  color: var(--text);
  word-break: break-word;
}

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

.message.local {
  margin-left: auto;
  background: rgba(143,92,255,.34);
}

.message.remote {
  background: rgba(0,229,255,.18);
}

.message-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.1);
}

.message-form input {
  min-height: 48px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0,0,0,.65);
}

.modal-card {
  width: min(520px, 100%);
  padding: 24px;
  position: relative;
  display: grid;
  gap: 12px;
  background: var(--card-strong);
}

.modal-close {
  position: absolute;
  right: 14px;
  top: 14px;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: rgba(255,255,255,.08);
  cursor: pointer;
  font-size: 24px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  opacity: 0;
  z-index: 80;
  max-width: min(680px, calc(100% - 28px));
  padding: 13px 16px;
  border-radius: 16px;
  color: var(--text);
  background: rgba(16,17,40,.94);
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: var(--shadow);
  pointer-events: none;
  transition: opacity .18s, transform .18s;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100%, calc(100% - 18px));
    padding: 12px 0;
  }

  .brand-row,
  .topbar {
    align-items: flex-start;
  }

  .video-grid,
  .controls-card {
    grid-template-columns: 1fr;
  }

  .video-card {
    min-height: 260px;
  }

  .message-form {
    grid-template-columns: 1fr;
  }

  .mini-links,
  .topbar {
    flex-direction: column;
  }

  .pill {
    align-self: flex-start;
  }
}

/* Ajustement compact uniquement pour l'écran de roulette, sans changer le design général */
@media (min-width: 960px) {
  body:has(.chat-layout:not(.hidden)) {
    overflow: hidden;
  }

  .app-shell:has(.chat-layout:not(.hidden)) {
    width: min(1180px, calc(100% - 14px));
    min-height: 100vh;
    padding: 8px 0;
    display: grid;
    place-items: center;
  }

  .chat-layout {
    height: calc(100vh - 16px);
    max-height: 720px;
    padding: 10px;
    gap: 10px;
    grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr);
    align-content: stretch;
  }

  .chat-layout .topbar {
    grid-column: 1 / -1;
    grid-row: 1;
    padding: 2px 4px 6px;
  }

  .chat-layout .topbar h2 {
    font-size: 24px;
  }

  .chat-layout .topbar p {
    margin-top: 3px;
  }

  .chat-layout .pill {
    padding: 7px 11px;
  }

  .chat-layout .video-grid {
    grid-column: 1;
    grid-row: 2 / 4;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
    min-height: 0;
  }

  .chat-layout .video-card {
    min-height: 0;
    border-radius: 18px;
  }

  .chat-layout .video-label {
    left: 10px;
    bottom: 10px;
    padding: 7px 10px;
  }

  .chat-layout .small-floating {
    right: 10px;
    bottom: 10px;
    padding: 7px 10px;
  }

  .chat-layout .small-floating.second {
    bottom: 48px;
  }

  .chat-layout .controls-card {
    grid-column: 2;
    grid-row: 2;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
  }

  .chat-layout .primary-btn,
  .chat-layout .ghost-btn,
  .chat-layout .danger-btn,
  .chat-layout .message-form button {
    min-height: 40px;
    border-radius: 12px;
  }

  .chat-layout .text-chat {
    grid-column: 2;
    grid-row: 3;
    min-height: 0;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    border-radius: 18px;
  }

  .chat-layout .messages {
    height: auto;
    min-height: 0;
  }

  .chat-layout .message-form {
    padding: 9px;
  }

  .chat-layout .message-form input {
    min-height: 40px;
    padding: 10px 12px;
    border-radius: 12px;
  }
}
