:root {
  --primary: #ff3d7f;
  --secondary: #7c4dff;
  --bg: #12101f;
  --text: #ffffff;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --bg-image: none;
  --glass: color-mix(in srgb, var(--bg) 70%, transparent);
  --surface: color-mix(in srgb, var(--text) 7%, transparent);
  --surface-2: color-mix(in srgb, var(--text) 12%, transparent);
  --line: color-mix(in srgb, var(--text) 14%, transparent);
  --muted: color-mix(in srgb, var(--text) 62%, transparent);
  --radius: 22px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: var(--bg); color: var(--text); font-family: var(--font);
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
.ico { flex-shrink: 0; display: block; }

/* ---------- fond ---------- */
#video {
  position: fixed; inset: 0; width: 100%; height: 100%;
  object-fit: cover; transform: scaleX(-1) scale(1.12);
  filter: blur(22px) saturate(1.15) brightness(.5);
}
.backdrop {
  position: fixed; inset: 0;
  background:
    radial-gradient(1100px 700px at 0% 0%, color-mix(in srgb, var(--primary) 26%, transparent), transparent 65%),
    radial-gradient(900px 700px at 100% 100%, color-mix(in srgb, var(--secondary) 26%, transparent), transparent 65%),
    color-mix(in srgb, var(--bg) 62%, transparent);
}
body.has-bg-image .backdrop {
  background: linear-gradient(color-mix(in srgb, var(--bg) 20%, transparent), color-mix(in srgb, var(--bg) 45%, transparent)), var(--bg-image) center / cover no-repeat;
}

/* ---------- écrans ---------- */
#app { position: fixed; inset: 0; }
.screen {
  position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  opacity: 0; visibility: hidden; transform: translateY(12px);
  transition: opacity .4s var(--ease), transform .4s var(--ease), visibility 0s .4s;
  padding: 32px;
}
.screen.active { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
.center-col { display: flex; flex-direction: column; align-items: center; gap: 26px; text-align: center; }
.eyebrow { margin: 0; text-transform: uppercase; letter-spacing: .22em; font-size: 14px; font-weight: 700; color: var(--muted); }

/* ---------- boutons ---------- */
.cta {
  border: 0; border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff; font-weight: 700; letter-spacing: .01em;
  box-shadow: 0 14px 40px -12px color-mix(in srgb, var(--primary) 70%, transparent);
  display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  transition: transform .15s var(--ease), filter .15s;
}
.cta:active { transform: scale(.97); }
.cta:disabled { filter: grayscale(.8) brightness(.7); cursor: not-allowed; }
.cta-lg { font-size: 24px; padding: 22px 30px; width: 100%; }
.cta-sm { font-size: 19px; padding: 15px 28px; }
.btn-ghost {
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 13px 24px; font-size: 18px; font-weight: 600; text-decoration: none; color: var(--text);
  display: inline-flex; align-items: center; gap: 10px; transition: background .15s;
}
.btn-ghost.small { padding: 8px 16px 8px 12px; font-size: 15px; }
.btn-ghost:active { background: var(--surface-2); }

/* ---------- accueil ---------- */
.welcome-inner { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; max-width: 1100px; }
.brand-logo { max-height: 20vh; max-width: 55vw; object-fit: contain; margin-bottom: 10px; filter: drop-shadow(0 8px 30px rgba(0,0,0,.3)); }
#welcome-title { font-size: clamp(48px, 7.5vw, 120px); font-weight: 800; letter-spacing: -.035em; margin: 0; line-height: .95; }
#welcome-subtitle { font-size: clamp(18px, 2vw, 28px); margin: 6px 0 36px; color: var(--muted); font-weight: 400; }
.shutter { position: relative; width: 168px; height: 168px; border-radius: 50%; border: 0; background: none; padding: 0; }
.shutter-ring { position: absolute; inset: 0; border-radius: 50%; border: 3px solid color-mix(in srgb, var(--text) 75%, transparent); animation: ring 2.4s var(--ease) infinite; }
.shutter-core {
  position: absolute; inset: 14px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center; color: #fff;
  box-shadow: 0 20px 60px -10px color-mix(in srgb, var(--primary) 70%, transparent);
  transition: transform .2s var(--ease);
}
.shutter:active .shutter-core { transform: scale(.92); }
@keyframes ring { 0% { transform: scale(1); opacity: .9; } 70% { transform: scale(1.22); opacity: 0; } 100% { opacity: 0; } }
.start-text { font-size: clamp(18px, 1.8vw, 24px); font-weight: 600; margin: 18px 0 0; letter-spacing: .02em; }
.camera-error { position: absolute; bottom: 40px; background: #b3261e; color: #fff; padding: 14px 22px; border-radius: 14px; max-width: 80vw; text-align: center; }

/* ---------- formats ---------- */

/* ---------- live ---------- */
#screen-live { flex-direction: row; align-items: stretch; gap: 24px; padding: 24px; }
.stage-wrap { flex: 1; display: flex; align-items: center; justify-content: center; min-width: 0; }
.stage { position: relative; max-width: 100%; max-height: 100%; border-radius: var(--radius); overflow: hidden; box-shadow: 0 30px 90px -20px rgba(0,0,0,.7); background: #000; }
#live-canvas { display: block; max-width: 100%; max-height: calc(100vh - 48px); }
.stage.mirror #live-canvas { transform: scaleX(-1); }
.stage-hud { position: absolute; top: 18px; left: 18px; right: 18px; display: flex; justify-content: space-between; pointer-events: none; }
.hud-pill { background: rgba(10,10,14,.6); backdrop-filter: blur(10px); padding: 10px 18px; border-radius: 999px; font-weight: 700; font-size: 20px; display: inline-flex; align-items: center; gap: 10px; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: #ff3b30; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .3; } }
.countdown { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.count-num { position: relative; width: min(42vh, 340px); height: min(42vh, 340px); display: flex; align-items: center; justify-content: center; font-size: min(26vh, 220px); font-weight: 800; color: #fff; text-shadow: 0 10px 50px rgba(0,0,0,.5); animation: count 1s var(--ease) forwards; font-variant-numeric: tabular-nums; }
.count-num svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.count-num circle { fill: none; stroke: #fff; stroke-width: 4; stroke-dasharray: 302; stroke-dashoffset: 0; animation: sweep 1s linear forwards; opacity: .9; }
.count-smile { font-size: min(10vh, 90px); font-weight: 800; color: #fff; text-shadow: 0 10px 50px rgba(0,0,0,.5); animation: count .6s var(--ease) forwards; }
@keyframes count { 0% { transform: scale(1.4); opacity: 0; } 18% { transform: scale(1); opacity: 1; } 85% { opacity: 1; } 100% { transform: scale(.92); opacity: 0; } }
@keyframes sweep { to { stroke-dashoffset: 302; } }
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.flash.on { animation: flash .45s ease-out; }
@keyframes flash { 0% { opacity: 1; } 100% { opacity: 0; } }
.thumbs { position: absolute; bottom: 18px; left: 18px; display: flex; gap: 10px; }
.thumbs img { height: 78px; border-radius: 10px; border: 3px solid #fff; box-shadow: 0 6px 20px rgba(0,0,0,.4); animation: pop .3s var(--ease); }
@keyframes pop { from { transform: scale(.5); opacity: 0; } }
.fx-loading { position: absolute; bottom: 18px; right: 18px; font-size: 15px; font-weight: 600; }

.panel {
  width: 400px; flex-shrink: 0;
  background: var(--glass); backdrop-filter: blur(20px);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; display: flex; flex-direction: column; gap: 16px;
}
.panel-head { display: flex; justify-content: space-between; align-items: center; }
.format-label { font-weight: 700; font-size: 20px; }
.tabs { display: flex; gap: 4px; background: var(--surface); padding: 4px; border-radius: 999px; }
.tabs button { flex: 1; border: 0; background: transparent; border-radius: 999px; padding: 11px 6px; font-weight: 700; font-size: 15px; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: background .2s, color .2s; }
.tabs button.active { background: var(--text); color: var(--bg); }
.tab-body { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; align-content: start; padding: 2px; }
.chip { border: 0; background: none; padding: 0; display: flex; flex-direction: column; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; color: var(--muted); }
.chip .sw {
  width: 100%; aspect-ratio: 1; border-radius: 16px; overflow: hidden; display: flex; align-items: center; justify-content: center;
  background: var(--surface) center / cover; color: var(--muted);
  outline: 3px solid transparent; outline-offset: 2px; transition: outline-color .15s;
}
.chip .sw.contain { background-size: contain; background-repeat: no-repeat; background-origin: content-box; padding: 6px; }
.chip .sw canvas, .chip .sw img { width: 100%; height: 100%; display: block; object-fit: cover; }
.panel.mirror .chip .sw canvas.live { transform: scaleX(-1); }
.chip.active { color: var(--text); }
.chip.active .sw { outline-color: var(--primary); }
.toggle-row { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-radius: 16px; background: var(--surface); font-weight: 600; font-size: 17px; }
.toggle-row .lbl { display: inline-flex; align-items: center; gap: 10px; }
.switch { width: 58px; height: 32px; border-radius: 999px; background: var(--surface-2); position: relative; border: 0; transition: background .2s; }
.switch::after { content: ''; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s var(--ease); }
.switch.on { background: var(--primary); }
.switch.on::after { transform: translateX(26px); }
.section-label { grid-column: 1 / -1; margin: 6px 0 0; font-size: 13px; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); font-weight: 700; }
#screen-live.capturing .panel { opacity: .35; pointer-events: none; }

/* ---------- traitement ---------- */
.spinner { width: 84px; height: 84px; border-radius: 50%; border: 6px solid var(--surface-2); border-top-color: var(--primary); animation: spin 1s linear infinite; }
.spinner.small { width: 16px; height: 16px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }
#processing-text { margin: 0; font-weight: 600; }
.progress { width: 360px; height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
#progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--primary), var(--secondary)); transition: width .2s; }

/* ---------- résultat ---------- */
#screen-result { flex-direction: row; gap: 32px; padding: 32px; align-items: stretch; }
.result-media { flex: 1; display: flex; align-items: center; justify-content: center; min-width: 0; }
.result-media img { max-width: 100%; max-height: calc(100vh - 64px); border-radius: 14px; box-shadow: 0 30px 90px -20px rgba(0,0,0,.75); animation: pop .5s var(--ease); }
.result-side { width: 420px; flex-shrink: 0; display: flex; flex-direction: column; gap: 18px; background: var(--glass); backdrop-filter: blur(20px); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; overflow-y: auto; }
.result-title { margin: 6px 0 0; font-size: 34px; font-weight: 800; letter-spacing: -.02em; }
.qr-box { background: #fff; color: #111; border-radius: 18px; padding: 14px; display: flex; gap: 16px; align-items: center; }
.qr-box img { width: 150px; height: 150px; display: block; flex-shrink: 0; }
.qr-text { display: flex; flex-direction: column; gap: 6px; font-size: 16px; }
.qr-text strong { font-size: 18px; }
.qr-text span { color: #555; }
.share-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.share-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 16px; padding: 16px 16px; display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: 18px; transition: background .15s; }
.share-btn .ico { color: var(--primary); }
.share-btn:active { background: var(--surface-2); }
.share-btn:disabled { opacity: .4; }
.upload-state { margin: 0; text-align: center; color: var(--muted); min-height: 1.2em; }
.result-footer { margin-top: auto; display: flex; justify-content: space-between; gap: 12px; }

/* ---------- merci ---------- */
.done-mark { width: 150px; height: 150px; }
.done-mark circle { fill: none; stroke: var(--primary); stroke-width: 5; stroke-dasharray: 327; stroke-dashoffset: 327; }
.done-mark path { fill: none; stroke: var(--text); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 80; stroke-dashoffset: 80; }
#screen-thanks.active .done-mark circle { animation: draw .7s var(--ease) forwards; }
#screen-thanks.active .done-mark path { animation: draw .45s .45s var(--ease) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
#thanks-text { font-size: clamp(40px, 6vw, 88px); font-weight: 800; letter-spacing: -.03em; margin: 0; }

/* ---------- modales ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(8px); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 20px; z-index: 20; }
body.vk-open .modal { padding-top: 2vh; }
.modal-card { width: min(720px, 100%); max-height: 90vh; overflow-y: auto; background: color-mix(in srgb, var(--bg) 92%, #fff 8%); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; box-shadow: 0 30px 90px rgba(0,0,0,.6); }
body.vk-open .modal-card { max-height: calc(100vh - 430px); }
.modal-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.modal-icon { width: 48px; height: 48px; border-radius: 14px; background: color-mix(in srgb, var(--primary) 18%, transparent); color: var(--primary); display: flex; align-items: center; justify-content: center; }
.modal-card h2 { margin: 0; font-size: 28px; font-weight: 700; }
#terms h2 { margin-bottom: 16px; }
.fields { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 16px; color: var(--muted); }
.field input, .field select {
  font: inherit; font-size: 24px; font-weight: 500; padding: 14px 18px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); outline: none; user-select: text;
}
.field select option { color: #111; }
.field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 30%, transparent); }
.phone-row { display: flex; gap: 10px; }
.phone-row select { width: 130px; }
.phone-row input { flex: 1; min-width: 0; }
.check { display: flex; gap: 14px; align-items: flex-start; font-size: 17px; font-weight: 400; line-height: 1.45; padding: 4px 0; }
.check input { width: 28px; height: 28px; flex-shrink: 0; accent-color: var(--primary); margin: 0; }
.check a { color: var(--primary); font-weight: 600; }
.form-error { color: #ff6b81; font-weight: 600; min-height: 1.2em; margin: 12px 0 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 18px; }
.terms-text { white-space: pre-wrap; line-height: 1.6; font-size: 17px; color: var(--muted); }
.tech-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

/* ---------- clavier virtuel ---------- */
.vk { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: #17171c; padding: 12px; transform: translateY(105%); transition: transform .25s var(--ease); display: flex; flex-direction: column; gap: 8px; box-shadow: 0 -10px 40px rgba(0,0,0,.5); }
.vk.open { transform: none; }
.vk-row { display: flex; gap: 8px; justify-content: center; }
.vk-key { flex: 1; max-width: 96px; height: 70px; border: 0; border-radius: 12px; background: #34343c; color: #fff; font-size: 27px; font-weight: 500; display: flex; align-items: center; justify-content: center; }
.vk-key:active { background: var(--primary); }
.vk-space { max-width: 420px; flex: 5; font-size: 19px; }
.vk-ok { background: var(--primary); max-width: 160px; flex: 2; font-size: 22px; font-weight: 700; }
.vk-back, .vk-shift, .vk-mode, .vk-abc { background: #4a4a55; max-width: 130px; flex: 1.5; font-size: 21px; }
.vk-shift.active { background: #fff; color: #111; }
.vk-domain { max-width: 210px; font-size: 17px; background: #26262e; }

/* ---------- divers ---------- */
.toast { position: fixed; left: 50%; top: 28px; transform: translate(-50%, -160%); background: #fff; color: #111; padding: 16px 26px; border-radius: 999px; font-weight: 700; font-size: 19px; z-index: 40; transition: transform .35s var(--ease); box-shadow: 0 10px 40px rgba(0,0,0,.35); max-width: 90vw; text-align: center; }
.toast.show { transform: translate(-50%, 0); }
.toast.error { background: #ff4d6d; color: #fff; }
.net-status { position: fixed; right: 14px; bottom: 10px; font-size: 13px; font-weight: 600; color: var(--muted); z-index: 5; display: flex; align-items: center; gap: 6px; }
.net-status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #34c759; }
.net-status.offline::before { background: #ff9f0a; }
.hotspot { position: fixed; top: 0; left: 0; width: 90px; height: 90px; z-index: 50; }

/* ---------- écran vertical (borne portrait / tablette) ---------- */
@media (orientation: portrait) {
  #screen-live, #screen-result { flex-direction: column; padding: 16px; gap: 16px; }
  .panel, .result-side { width: 100%; }
  .tab-body { grid-template-columns: repeat(4, 1fr); max-height: 26vh; }
  #live-canvas { max-height: 55vh; }
  .result-media img { max-height: 50vh; }
}

/* ---------- téléphone : interface type appareil photo ---------- */
@media (max-width: 760px) {
  .screen { padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)); }
  .brand-logo { max-height: 14vh; max-width: 70vw; }
  #welcome-subtitle { margin-bottom: 24px; }
  .shutter { width: 136px; height: 136px; }


  #screen-live { flex-direction: column; padding: 0; gap: 0; overflow: hidden; }
  .stage-wrap { flex: 1; min-height: 0; padding: calc(10px + env(safe-area-inset-top)) 10px 10px; }
  .stage { border-radius: 18px; }
  #live-canvas { max-width: calc(100vw - 20px); max-height: calc(100vh - 300px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); max-height: calc(100dvh - 300px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
  .hud-pill { font-size: 15px; padding: 7px 12px; }
  .thumbs img { height: 52px; border-width: 2px; }
  .panel {
    width: 100%; border-radius: 22px 22px 0 0; border-bottom: 0; gap: 10px;
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  }
  .panel-head .btn-ghost { padding: 6px 12px 6px 8px; font-size: 14px; }
  .format-label { font-size: 16px; }
  .tabs button { padding: 9px 4px; font-size: 14px; }
  .tab-body {
    display: flex; overflow-x: auto; overflow-y: hidden; max-height: none; gap: 10px;
    scroll-snap-type: x proximity; padding: 4px 2px 2px; scrollbar-width: none;
  }
  .tab-body::-webkit-scrollbar { display: none; }
  .chip { flex: 0 0 70px; scroll-snap-align: start; font-size: 12px; }
  .chip .sw { border-radius: 14px; }
  .toggle-row { flex: 0 0 auto; flex-direction: column; justify-content: center; gap: 8px; padding: 10px 12px; font-size: 13px; border-radius: 14px; }
  .toggle-row .lbl { gap: 6px; }
  .section-label { display: none; }
  /* Déclencheur rond façon appareil photo */
  #btn-shoot { width: 76px; height: 76px; padding: 0; border-radius: 50%; align-self: center; box-shadow: 0 0 0 4px var(--bg), 0 0 0 7px rgba(255,255,255,.85); }
  #btn-shoot span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

  #screen-result { flex-direction: column; justify-content: flex-start; gap: 14px; padding: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom)); }
  .result-media { flex: none; }
  .result-media img { max-height: 44vh; max-height: 44dvh; border-radius: 12px; }
  .result-side { width: 100%; padding: 16px; gap: 14px; overflow: visible; }
  .result-title { font-size: 26px; }
  .qr-box { padding: 10px; gap: 12px; }
  .qr-box img { width: 110px; height: 110px; }
  .qr-text { font-size: 14px; }
  .qr-text strong { font-size: 16px; }
  .share-btn { padding: 13px 12px; font-size: 16px; }
  .result-footer .btn-ghost, .result-footer .cta { padding: 12px 18px; font-size: 16px; }

  .count-num { width: 62vw; height: 62vw; font-size: 38vw; }
  .done-mark { width: 110px; height: 110px; }

  .modal { align-items: flex-end; padding: 0; }
  .modal-card { width: 100%; max-height: 92vh; max-height: 92dvh; border-radius: 22px 22px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
  .modal-card h2 { font-size: 22px; }
  .modal-icon { width: 40px; height: 40px; }
  .field input, .field select { font-size: 18px; padding: 12px 14px; }
  .phone-row select { width: 112px; }
  .check { font-size: 15px; }
  .check input { width: 24px; height: 24px; }
  .modal-actions { position: sticky; bottom: calc(-20px - env(safe-area-inset-bottom)); background: inherit; padding: 12px 0 0; }
  .toast { font-size: 16px; padding: 12px 18px; top: calc(14px + env(safe-area-inset-top)); }
  .net-status { bottom: calc(6px + env(safe-area-inset-bottom)); }
}

/* ---------- choix du format : grille de 4, tient toujours dans l'écran ---------- */
#screen-format {
  display: grid; grid-template-rows: auto 1fr; justify-content: stretch; align-items: stretch;
  gap: clamp(14px, 2.5vh, 32px);
  padding: calc(clamp(14px, 3vh, 36px) + env(safe-area-inset-top)) clamp(14px, 4vw, 48px) calc(clamp(26px, 4vh, 44px) + env(safe-area-inset-bottom));
  overflow: hidden;
}
.screen-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; width: 100%; max-width: 1240px; margin: 0 auto; }
.screen-head .btn-ghost { justify-self: start; padding: clamp(8px, 1.2vh, 13px) clamp(12px, 2vw, 24px); font-size: clamp(14px, 1.6vh, 18px); }
.screen-title { margin: 0; text-align: center; font-weight: 800; letter-spacing: -.02em; font-size: clamp(20px, min(4.2vh, 5.4vw), 46px); line-height: 1.1; }
.format-grid {
  display: grid; width: 100%; max-width: 1240px; margin: 0 auto; min-height: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr);
  gap: clamp(10px, 2vw, 24px); align-content: center;
}
/* Écran horizontal : les 4 formats sur une ligne */
@media (orientation: landscape) {
  .format-grid { grid-template-columns: repeat(var(--format-count, 4), minmax(0, 1fr)); grid-auto-rows: minmax(0, min(100%, 420px)); }
}
/* Nombre impair de formats en vertical : la dernière carte prend toute la largeur */
@media (orientation: portrait) {
  .format-grid[data-count="3"] .format-card:last-child, .format-grid[data-count="1"] .format-card { grid-column: 1 / -1; }
}
.format-card {
  position: relative; min-width: 0; min-height: 0; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(4px, 1vh, 10px);
  padding: clamp(12px, 2.2vh, 30px) clamp(8px, 1.5vw, 20px);
  background: linear-gradient(160deg, color-mix(in srgb, var(--text) 10%, transparent), color-mix(in srgb, var(--text) 3%, transparent));
  backdrop-filter: blur(18px);
  border: 1px solid var(--line); border-radius: clamp(16px, 2.4vh, 26px);
  transition: transform .2s var(--ease), border-color .2s, box-shadow .2s;
}
.format-card::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(120% 80% at 50% 0%, color-mix(in srgb, var(--primary) 16%, transparent), transparent 60%);
}
.format-card:active { transform: scale(.97); border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 35%, transparent); }
.fmt-illu { width: min(62%, 24vh, 160px); height: auto; aspect-ratio: 1; flex-shrink: 1; min-height: 0; color: var(--text); }
.format-card h3 { margin: clamp(2px, .8vh, 10px) 0 0; font-size: clamp(16px, min(2.8vh, 4.6vw), 26px); font-weight: 750; line-height: 1.15; text-align: center; }
.format-card p { margin: 0; color: var(--muted); font-size: clamp(12px, min(1.8vh, 3.4vw), 16px); line-height: 1.3; text-align: center; }
/* Très petits écrans : on garde l'essentiel */
@media (max-height: 560px) { .format-card p { display: none; } }
@media (max-width: 420px) and (orientation: portrait) {
  .screen-head { grid-template-columns: auto 1fr; }
  .screen-head .head-spacer { display: none; }
  .screen-title { text-align: right; }
}

.app-version { margin: 14px 0 0; font-size: 13px; color: var(--muted); }

/* Navigateurs mobiles plus anciens sans color-mix() (Chrome < 111, Safari < 16.2, Samsung Internet ancien) */
@supports not (color: color-mix(in srgb, red 50%, blue)) {
  :root { --glass: rgba(18, 16, 31, .72); --surface: rgba(255, 255, 255, .07); --surface-2: rgba(255, 255, 255, .12); --line: rgba(255, 255, 255, .14); --muted: rgba(255, 255, 255, .62); }
  .backdrop { background: rgba(18, 16, 31, .55); }
  .format-card { background: rgba(255, 255, 255, .06); }
  .format-card::after { display: none; }
  .modal-card { background: #1d1b2b; }
}

/* Résultat vidéo (boomerang long) */
#result-video { max-width: 100%; max-height: calc(100vh - 64px); border-radius: 14px; box-shadow: 0 30px 90px -20px rgba(0,0,0,.75); background: #000; }
@media (max-width: 760px) { #result-video { max-height: 44vh; max-height: 44dvh; border-radius: 12px; } }
