* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  background: #07080d;
  color: #fff;
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

/* ---------- Écran idle ---------- */

#idle {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
}

.idle-bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(130deg, #0b1026, #1b1040 45%, #09203f 75%, #0b1026);
  background-size: 300% 300%;
  animation: pan-bg 18s ease-in-out infinite;
}

body.demo-mode .idle-bg {
  background: linear-gradient(130deg, #26100b, #401b10 45%, #0b2033 75%, #26100b);
  background-size: 300% 300%;
}

.idle-inner {
  position: relative;
  text-align: center;
  z-index: 1;
}

.idle-logo {
  font-size: clamp(56px, 9vw, 130px);
  font-weight: 900;
  letter-spacing: 0.04em;
}

.idle-logo span {
  background: linear-gradient(90deg, #7c6cff, #4cc9f0);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.idle-msg {
  margin-top: 14px;
  font-size: clamp(20px, 2.6vw, 34px);
  font-weight: 600;
  opacity: 0.9;
  animation: pulse-soft 2.4s ease-in-out infinite;
}

.idle-sub {
  margin-top: 10px;
  font-size: 15px;
  opacity: 0.65;
  min-height: 20px;
}

.idle-status {
  margin-top: 26px;
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 13px;
}

.idle-status span {
  padding: 6px 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
}

.idle-actions {
  margin-top: 30px;
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

button,
.btn {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  padding: 11px 22px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  transition: background 0.2s, transform 0.1s;
}

button:hover,
.btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

button:active,
.btn:active {
  transform: scale(0.97);
}

body.demo-mode #btnDemo {
  background: #ffb703;
  border-color: #ffb703;
  color: #211a00;
}

.camwrap {
  position: fixed;
  right: 26px;
  bottom: 26px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  background: #000;
}

.camwrap video,
.camwrap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

#hud {
  position: fixed;
  left: 84px;
  bottom: 26px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 14px;
  color: #7cffb2;
  background: rgba(0, 0, 0, 0.45);
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid rgba(124, 255, 178, 0.3);
}

#btnExit {
  position: fixed;
  left: 26px;
  bottom: 26px;
  z-index: 50;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 17px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.25);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}

#btnExit:hover {
  background: rgba(255, 80, 80, 0.55);
  color: #fff;
}

#hud.hud-err {
  color: #ff9c9c;
  border-color: rgba(255, 120, 120, 0.45);
}

#camSelect {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  padding: 11px 22px;
  cursor: pointer;
  max-width: 280px;
}

#camSelect option {
  background: #14162b;
  color: #fff;
}

body.ad-playing #idle {
  display: none;
}

/* ---------- Publicité ---------- */

#adLayer {
  position: fixed;
  inset: 0;
  z-index: 10;
}

.ad-loading {
  height: 100%;
  display: grid;
  place-items: center;
  font-size: 24px;
  opacity: 0.8;
  background: #101223;
}

.ad {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--c1), var(--c2));
  background-size: 300% 300%;
  animation: pan-bg 14s ease-in-out infinite;
  overflow: hidden;
}

.ad-blob {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  filter: blur(70px);
}

.ad-blob.b1 {
  width: 45vw;
  height: 45vw;
  top: -12vw;
  left: -10vw;
  animation: drift 11s ease-in-out infinite alternate;
}

.ad-blob.b2 {
  width: 34vw;
  height: 34vw;
  bottom: -8vw;
  right: -6vw;
  animation: drift 13s ease-in-out infinite alternate-reverse;
}

.ad-blob.b3 {
  width: 18vw;
  height: 18vw;
  top: 40%;
  left: 55%;
  background: rgba(0, 0, 0, 0.18);
  animation: drift 9s ease-in-out infinite alternate;
}

.ad-content {
  position: relative;
  z-index: 1;
  max-width: 1000px;
  padding: 0 6vw;
  text-align: center;
  display: grid;
  justify-items: center;
  gap: 22px;
}

.ad-content > * {
  animation: rise 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.ad-content > :nth-child(2) {
  animation-delay: 0.12s;
}

.ad-content > :nth-child(3) {
  animation-delay: 0.22s;
}

.ad-content > :nth-child(4) {
  animation-delay: 0.34s;
}

.ad-content > :nth-child(5) {
  animation-delay: 0.46s;
}

.ad-chip {
  font-size: clamp(14px, 1.6vw, 20px);
  font-weight: 800;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  padding: 10px 26px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(6px);
}

.ad-emoji {
  font-size: clamp(90px, 16vw, 190px);
  line-height: 1;
  filter: drop-shadow(0 18px 35px rgba(0, 0, 0, 0.35));
  animation: rise 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) both, float 3.6s ease-in-out 1s infinite !important;
}

.ad-headline {
  font-size: clamp(40px, 7vw, 96px);
  font-weight: 900;
  line-height: 1.05;
  text-wrap: balance;
  text-shadow: 0 6px 30px rgba(0, 0, 0, 0.25);
}

.ad-subline {
  font-size: clamp(18px, 2.2vw, 30px);
  font-weight: 500;
  opacity: 0.94;
  max-width: 30ch;
}

.ad-cta {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  color: #111;
  font-size: clamp(18px, 2vw, 26px);
  font-weight: 800;
  padding: 18px 44px;
  border-radius: 999px;
  animation: rise 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) both, pulse-cta 1.6s ease-in-out 1s infinite !important;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.3);
}

.ad-cta-arrow {
  transition: transform 0.2s;
}

.ad-cta:hover .ad-cta-arrow {
  transform: translateX(6px);
}

.ad-target {
  position: absolute;
  left: 84px;
  bottom: 26px;
  z-index: 1;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(0, 0, 0, 0.3);
  padding: 8px 14px;
  border-radius: 10px;
}

.ad-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 6px;
  background: rgba(255, 255, 255, 0.2);
  z-index: 1;
}

.ad-progress i {
  display: block;
  height: 100%;
  width: 100%;
  background: #fff;
  animation: progress var(--dur) linear forwards;
}

/* ---------- Médias dans les pubs ---------- */

.ad-media {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.ad-media img,
.ad-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ad-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.55));
}

/* ---------- Admin ---------- */

.dash.admin {
  max-width: 1100px;
  margin: 0 auto;
}

.admin-head {
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
  margin-bottom: 26px;
}

.admin-head h1 {
  margin: 0;
  font-size: 24px;
}

.tabs {
  display: flex;
  gap: 6px;
  flex: 1;
  flex-wrap: wrap;
}

.tabs button {
  border-radius: 10px;
  padding: 9px 18px;
  background: transparent;
  border-color: transparent;
  opacity: 0.65;
}

.tabs button.active {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
  opacity: 1;
}

.tab {
  display: grid;
  gap: 16px;
}

.panel.narrow {
  max-width: 640px;
}

.admin label {
  display: block;
  font-size: 13px;
  opacity: 0.85;
  margin: 10px 0 4px;
  grid-column: 1 / -1;
}

.admin input {
  width: 100%;
  margin-top: 5px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
}

.admin input[type='color'] {
  padding: 2px;
  width: 52px;
  height: 36px;
  cursor: pointer;
}

.admin input[type='color']::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.admin input[type='color']::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
}

.admin fieldset {
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 10px 0 0;
}

.admin legend {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.6;
  padding: 0 6px;
}

.admin .check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 4px 14px 4px 0;
  opacity: 0.9;
  cursor: pointer;
}

.admin .check input {
  width: auto;
  margin: 0;
}

.admin .ages {
  display: flex;
  flex-wrap: wrap;
}

.admin .colors span {
  display: inline-flex;
  gap: 8px;
  margin-top: 5px;
}

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

.row-btns {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.primary {
  background: linear-gradient(90deg, #7c6cff, #4cc9f0);
  border: none;
  color: #0b1026;
  font-weight: 800;
}

.danger:hover {
  background: rgba(255, 80, 80, 0.35);
}

.feedback {
  min-height: 22px;
  margin-top: 12px;
  font-size: 14px;
  opacity: 0.95;
}

.hint {
  font-size: 12.5px;
  opacity: 0.55;
  margin-top: 14px;
}

.hint code {
  background: rgba(255, 255, 255, 0.1);
  padding: 1px 6px;
  border-radius: 5px;
}

.adrow {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.adrow:last-child {
  border-bottom: none;
}

.adrow-emoji {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 22px;
  flex-shrink: 0;
}

.adrow-main {
  flex: 1;
  min-width: 0;
}

.adrow-main small {
  display: block;
  opacity: 0.6;
  font-size: 12.5px;
  margin-top: 2px;
}

.adrow button {
  padding: 8px 14px;
  font-size: 13px;
}

.media-info {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  font-size: 13px;
  opacity: 0.85;
}

.media-info.hidden {
  display: none !important;
}

.filebtn {
  display: block;
  margin-top: 16px;
  cursor: pointer;
}

.filebtn input {
  margin-top: 6px;
}

/* ---------- Animations ---------- */

@keyframes pan-bg {
  0% { background-position: 0% 40%; }
  50% { background-position: 100% 60%; }
  100% { background-position: 0% 40%; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(34px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-18px); }
}

@keyframes pulse-soft {
  0%, 100% { opacity: 0.9; }
  50% { opacity: 0.45; }
}

@keyframes pulse-cta {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.045); }
}

@keyframes drift {
  from { transform: translate(0, 0); }
  to { transform: translate(6vw, 4vh); }
}

@keyframes progress {
  from { width: 100%; }
  to { width: 0; }
}

/* ---------- Dashboard ---------- */

.dash {
  height: 100%;
  overflow: auto;
  padding: 34px clamp(20px, 4vw, 60px);
}

.dash h1 {
  font-size: 30px;
  margin-bottom: 6px;
}

.dash h1 span {
  background: linear-gradient(90deg, #7c6cff, #4cc9f0);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.dash .updated {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  opacity: 0.55;
  margin-bottom: 28px;
}

.dash .updated a {
  color: #8fa8ff;
  text-decoration: none;
}

.dash .updated a:hover {
  text-decoration: underline;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 20px;
}

.card .k {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  opacity: 0.6;
}

.card .v {
  font-size: 32px;
  font-weight: 800;
  margin-top: 8px;
}

.card .s {
  font-size: 13px;
  opacity: 0.7;
  margin-top: 4px;
}

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

.panel {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 20px;
}

.panel h2 {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  opacity: 0.7;
  margin-bottom: 16px;
}

.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  font-size: 14px;
  padding: 7px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.row:last-child {
  border-bottom: none;
}

.row .bar {
  grid-column: 1 / -1;
  height: 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.row .bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #7c6cff, #4cc9f0);
  border-radius: 4px;
}

.muted {
  opacity: 0.5;
  font-size: 14px;
}
