/* =========================================================
   NINTENDAWN — menu HOME
   ========================================================= */

/* ---------- Thèmes (Blanc basique / Noir basique) ---------- */
:root {
  --bg: #ebebeb;
  --surface: #ffffff;
  --text: #2d2d2d;
  --muted: #828282;
  --line: #c9c9c9;
  --accent: #00a6dd;
  --sel-a: #00c3f0;
  --sel-b: #3ef0e6;
  --tile-empty: #f3f3f3;
  --stripe: rgba(0, 0, 0, 0.045);
  --shadow: 0 2px 6px rgba(0, 0, 0, 0.13);
  --splash-bg: #e60012;
  --setup-bg: #ffffff;
  --head-line: #4a4a4a;
  --btn-line: #3c3c3c;
  --dot: #c9c9c9;
  --dot-on: #3255d6;
  --empty-line: #d9d9d9;

  --gutter: clamp(16px, 6.5vw, 104px);
  --tile: clamp(132px, min(21vw, 36vh), 268px);
  --gap: clamp(10px, 1.2vw, 16px);
  --round: clamp(52px, 5.4vw, 78px);

  color-scheme: light;
}

/* Le thème blanc est celui par défaut, quel que soit le réglage de l'appareil.
   Le noir s'active avec le bouton Thème (gardé dans le navigateur, et sur le compte d'un membre). */
:root[data-theme="dark"] {
  --bg: #2d2d2d;
  --surface: #3c3c3c;
  --text: #ffffff;
  --muted: #a8a8a8;
  --line: #5a5a5a;
  --accent: #2fd9f5;
  --tile-empty: #333333;
  --stripe: rgba(255, 255, 255, 0.04);
  --shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  --setup-bg: #2d2d2d;
  --head-line: #8a8a8a;
  --btn-line: #8a8a8a;
  --dot: #5a5a5a;
  --dot-on: #5f86ff;
  --empty-line: #444444;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Nunito Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color 0.3s;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus { outline: none; }

/* Cadre de sélection animé, partagé par tout ce qui se navigue */
.is-sel::after {
  content: "";
  position: absolute;
  inset: -8px;
  border: 4px solid var(--sel-a);
  border-radius: inherit;
  pointer-events: none;
  animation: sel-pulse 0.9s ease-in-out infinite alternate;
}

@keyframes sel-pulse {
  from { border-color: var(--sel-a); box-shadow: 0 0 0 0 rgba(0, 195, 240, 0); }
  to   { border-color: var(--sel-b); box-shadow: 0 0 10px 0 rgba(62, 240, 230, 0.35); }
}

kbd {
  display: inline-grid;
  place-items: center;
  width: 1.55em;
  height: 1.55em;
  border-radius: 50%;
  background: var(--text);
  color: var(--bg);
  font: 800 0.78em/1 inherit;
  font-family: inherit;
}

/* =========================================================
   1. Splash
   ========================================================= */
.splash {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: clamp(18px, 4vh, 34px);
  background: var(--splash-bg);
  color: #fff;
  transition: opacity 0.55s;
}

.splash.is-out { opacity: 0; pointer-events: none; }

.splash-logo {
  display: flex;
  gap: 3px;
  height: clamp(110px, 22vmin, 190px);
}

.half {
  height: 100%;
  width: auto;
  aspect-ratio: 1 / 2;
  opacity: 0;
}

.splash.is-play .half-left  { animation: snap-left 0.5s cubic-bezier(0.5, 0, 0.75, 0) forwards, settle-left 0.22s 0.5s ease-out; }
.splash.is-play .half-right { animation: snap-right 0.5s cubic-bezier(0.5, 0, 0.75, 0) forwards, settle-right 0.22s 0.5s ease-out; }

@keyframes snap-left  { from { opacity: 0; transform: translateY(-70%); } 30% { opacity: 1; } to { opacity: 1; transform: none; } }
@keyframes snap-right { from { opacity: 0; transform: translateY(70%); }  30% { opacity: 1; } to { opacity: 1; transform: none; } }
@keyframes settle-left  { 40% { transform: translateY(-4%); } }
@keyframes settle-right { 40% { transform: translateY(4%); } }

.splash-name {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  opacity: 0;
}

/* Comme le logo d'origine : petite ligne espacée, puis SWITCH en gros */
.sn-top {
  font-size: clamp(0.95rem, 2.6vmin, 1.4rem);
  font-weight: 800;
  letter-spacing: 0.32em;
  margin-right: -0.32em;
}

.sn-bottom {
  margin-top: 0.12em;
  font-size: clamp(2.4rem, 7.6vmin, 4.2rem);
  font-weight: 900;
  letter-spacing: 0.02em;
}

.splash.is-play .splash-name { animation: name-in 0.5s 0.8s ease-out forwards; }

@keyframes name-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* =========================================================
   2. Première utilisation
   ========================================================= */
.setup {
  position: fixed;
  inset: 0;
  z-index: 65;
  display: flex;
  flex-direction: column;
  background: var(--setup-bg);
  transition: opacity 0.4s;
}

.setup.is-out { opacity: 0; pointer-events: none; }

.setup-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: clamp(64px, 11vh, 96px);
  margin: 0 calc(var(--gutter) * 0.45);
  padding: clamp(14px, 3vh, 26px) calc(var(--gutter) * 0.55) 12px;
  border-bottom: 1px solid var(--head-line);
}

.setup.is-final .setup-head { border-color: transparent; }

.setup-head h2 { margin: 0; font-size: clamp(1.15rem, 2vw, 1.6rem); font-weight: 600; }

.dots { display: flex; gap: clamp(7px, 1vw, 12px); }

/* Étapes passées pleines, étape en cours bleue, étapes à venir en simple cercle */
.dots i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--dot);
}

.dots i.done { background: var(--text); border-color: var(--text); }
.dots i.on { background: var(--dot-on); border-color: var(--dot-on); }

.setup-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(18px, 3.5vh, 34px);
  padding: 24px var(--gutter);
}

.setup-body.is-in > * { animation: step-in 0.3s ease-out both; }

@keyframes step-in { from { opacity: 0; transform: translateX(16px); } }

.setup-lead {
  margin: 0;
  width: min(100%, 880px);
  font-size: clamp(1.1rem, 2.4vw, 1.85rem);
  line-height: 1.4;
}

.setup-note { margin: 0; width: min(100%, 640px); font-size: 0.82rem; color: var(--muted); }

/* Bloc aligné : la phrase, la liste et la note partagent le même bord gauche */
.stack {
  display: flex;
  flex-direction: column;
  gap: clamp(18px, 3.5vh, 34px);
  width: min(100%, 640px);
}

.stack > * { width: 100%; }

/* Listes (langues, régions, réseaux) */
.opts { width: min(100%, 640px); display: grid; }
.opts.two { width: min(100%, 940px); grid-template-columns: 1fr 1fr; column-gap: clamp(20px, 4vw, 48px); grid-auto-flow: column; grid-template-rows: repeat(5, auto); }

.opt {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: clamp(48px, 7vh, 58px);
  padding: 0 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  text-align: left;
  font-size: clamp(1rem, 1.5vw, 1.2rem);
  cursor: pointer;
}

.opts > .opt:first-child,
.opts.two > .opt:nth-child(6) { border-top: 1px solid var(--line); }

.opt-ic { display: inline-flex; width: 1.3em; color: var(--text); }
.opt-ic svg { width: 100%; }

/* Boutons rectangulaires */
.btns { display: flex; flex-direction: column; align-items: center; gap: clamp(12px, 2.4vh, 22px); width: 100%; }

.btn {
  position: relative;
  width: min(100%, 420px);
  min-height: clamp(46px, 7vh, 58px);
  padding: 8px 20px;
  border: 1px solid var(--btn-line);
  border-radius: 4px;
  background: var(--setup-bg);
  font-size: clamp(1rem, 1.4vw, 1.15rem);
  cursor: pointer;
}

/* Écran « Informations importantes » : bouton secondaire compact sous le texte,
   bouton principal plus haut et nettement plus bas dans l'écran */
.infos {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(100%, 880px);
}

.infos .setup-lead { margin-bottom: clamp(28px, 9vh, 80px); text-align: center; }

.btn-sm,
.btn-main {
  width: clamp(240px, 40vw, 520px);
}

.btn-sm {
  min-height: clamp(36px, 5.2vh, 50px);
  font-size: clamp(0.9rem, 1.2vw, 1.05rem);
}

.btn-main {
  min-height: clamp(46px, 7vh, 66px);
  margin-top: clamp(48px, 15vh, 150px);
  font-size: clamp(1.05rem, 1.6vw, 1.35rem);
}

/* Le cadre de sélection colle aux listes et boutons, comme sur la console */
.opt.is-sel::after,
.btn.is-sel::after,
.net-btn.is-sel::after,
.field.is-sel + .field-ring { inset: -2px; border-radius: 4px; }

/* Texte des informations importantes */
.legal {
  position: relative;
  width: min(100%, 860px);
  max-height: 52vh;
  overflow-y: auto;
  padding: 4px 18px;
  line-height: 1.6;
}

.legal.is-sel::after { inset: 0; border-radius: 4px; }
.legal h3 { margin: 6px 0 10px; font-size: 1.15rem; font-weight: 700; }
.legal h4 { margin: 18px 0 4px; font-size: 1rem; font-weight: 700; }
.legal p { margin: 0; }

.setup-sub {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: clamp(0.85rem, 1.25vw, 1.05rem);
  line-height: 1.5;
}

/* Introduction : trois cartes de profil en éventail, texte à droite */
.intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(28px, 7vh, 64px);
  width: min(100%, 900px);
}

.intro-row {
  display: flex;
  align-items: center;
  gap: clamp(24px, 5vw, 64px);
  width: 100%;
}

.intro-cards {
  position: relative;
  flex: none;
  width: clamp(230px, 34vw, 340px);
  aspect-ratio: 1.75;
}

.card {
  position: absolute;
  top: 10%;
  width: 37%;
  margin: 0;
  background: #fff;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18);
  color: #2d2d2d;
  text-align: center;
  font-size: clamp(0.72rem, 1vw, 0.9rem);
}

.card img { display: block; width: 100%; aspect-ratio: 1 / 1.05; object-fit: cover; }
.card figcaption { padding: 6px 4px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card:nth-child(1) { left: 0; transform: rotate(-9deg); }
.card:nth-child(2) { left: 31.5%; top: 0; z-index: 1; }
.card:nth-child(3) { left: 63%; transform: rotate(8deg); }

.intro .btn-main { margin-top: 0; }

/* Choix de l'icône : grille 6 × 2 de carrés presque jointifs */
.icon-pick { width: min(100%, 760px); }

.icons {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: clamp(4px, 0.8vw, 8px);
  margin-top: clamp(12px, 2.5vh, 20px);
}

.icon-choice {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  background: var(--tile-empty);
  cursor: pointer;
}

.icon-choice img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* Comme « Créer mon icône » : large bouton centré sous la grille */
.btn-import {
  display: block;
  width: min(100%, 72%);
  min-height: clamp(38px, 5.4vh, 50px);
  margin: clamp(16px, 3.5vh, 28px) auto 0;
  font-size: clamp(0.92rem, 1.25vw, 1.08rem);
}

.btn-import.shake { animation: shake 0.32s; }

.import-note {
  margin: 10px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}
.icon-choice.is-sel::after { inset: -4px; border-radius: 0; }

.avatar.is-emoji { font-size: clamp(1.4rem, 2.2vw, 1.9rem); font-weight: 400; }

/* Pseudo */
.pseudo {
  display: flex;
  align-items: center;
  gap: clamp(24px, 6vw, 80px);
  width: min(100%, 860px);
}

.pseudo .avatar.xl { width: clamp(110px, 16vw, 180px); font-size: clamp(3rem, 7vw, 5rem) !important; cursor: default; }

.pseudo-form { flex: 1; display: flex; flex-direction: column; gap: 22px; align-items: flex-start; }
.pseudo-form .btn { width: min(100%, 280px); }

.field {
  position: relative;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--btn-line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: clamp(1.1rem, 1.8vw, 1.4rem);
  font-weight: 700;
}

.field:focus { border-color: var(--sel-a); box-shadow: 0 0 0 3px var(--sel-a); }
.field.shake, .tile.shake { animation: shake 0.32s; }

.form-error {
  margin: -6px 0 0;
  color: #e8463c;
  font-size: 0.92rem;
  font-weight: 600;
}

/* Formulaire de connexion : champs serrés, bouton un peu détaché */
.stack.login { width: min(100%, 460px); gap: 10px; }
.stack.login .setup-lead { margin-bottom: 10px; }
.stack.login .btn { margin-top: 14px; width: 100%; }

/* Lien discret sous le bouton de connexion */
.link-btn {
  position: relative;
  align-self: center;
  margin-top: 6px;
  padding: 6px 10px;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.stack.login .link-btn { width: auto; }

/* Tuile « Se connecter » de « Qui joue ? » */
.avatar.is-add {
  background: transparent;
  border: 3px dashed var(--line);
  box-shadow: none;
  color: var(--muted);
}

.avatar.is-add svg { width: 34%; }

/* Préparatifs terminés */
.done {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(28px, 6vw, 90px);
  width: min(100%, 980px);
}

.done h2 { margin: 0 0 18px; font-size: clamp(1.7rem, 3.4vw, 2.6rem); font-weight: 600; }
.done p { margin: 0; max-width: 26em; font-size: clamp(1rem, 1.5vw, 1.2rem); line-height: 1.5; }

.home-btn {
  position: relative;
  flex: none;
  width: clamp(110px, 14vw, 160px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 0;
  background: var(--text);
  color: var(--setup-bg);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 0 0 10px var(--setup-bg), 0 0 0 12px var(--text);
  animation: home-pulse 1.6s ease-in-out infinite;
}

.home-btn svg { width: 46%; }
.home-btn.is-sel::after { inset: -22px; border-radius: 50%; }

@keyframes home-pulse { 50% { transform: scale(1.05); } }

/* Connexion à Internet */
.net {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.45);
  animation: panel-in 0.2s ease-out;
}

.net-card {
  width: min(100%, 640px);
  padding: clamp(24px, 4vh, 40px) 0 0;
  background: var(--setup-bg);
  border-radius: 6px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  text-align: center;
  overflow: visible;
}

.net-steps {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: clamp(8px, 2vw, 18px);
  padding: 0 16px;
}

.net-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 96px;
  color: var(--muted);
  transition: color 0.3s;
}

.net-step svg { height: 34px; width: auto; }
.net-step small { font-size: 0.82rem; }
.net-step.is-on { color: var(--dot-on); }

.net-dots { display: flex; gap: 6px; padding-top: 15px; }

.net-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--dot-on);
  animation: net-blink 1s infinite;
}

.net-dots i:nth-child(2) { animation-delay: 0.2s; }
.net-dots i:nth-child(3) { animation-delay: 0.4s; }
.net.is-ok .net-dots i { animation: none; }

@keyframes net-blink { 0%, 100% { opacity: 0.2; } 50% { opacity: 1; } }

.net-status { margin: clamp(18px, 3vh, 28px) 0; font-size: clamp(1.05rem, 1.6vw, 1.25rem); }

.net-btn {
  position: relative;
  width: 100%;
  padding: 18px;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0 0 6px 6px;
  background: none;
  color: var(--dot-on);
  font-size: 1.1rem;
  cursor: pointer;
}

/* =========================================================
   3. Qui joue ?
   ========================================================= */
.who {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  transition: opacity 0.35s;
}

.who.is-out { opacity: 0; pointer-events: none; }

.who-title {
  margin: 0;
  padding: clamp(28px, 9vh, 96px) var(--gutter) 0;
  text-align: center;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  font-weight: 700;
}

.who-users {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  align-content: center;
  gap: clamp(28px, 4.5vw, 64px);
  padding: 24px var(--gutter);
}

.who-user {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.who-user.is-sel::after { display: none; }

.who-user .avatar {
  width: clamp(104px, 13vw, 168px);
  font-size: clamp(2.6rem, 4.6vw, 4.2rem);
  border-width: 4px;
  cursor: inherit;
}

.who-user.is-sel .avatar::after {
  content: "";
  position: absolute;
  inset: -12px;
  border: 4px solid var(--sel-a);
  border-radius: 50%;
  animation: sel-pulse 0.9s ease-in-out infinite alternate;
}

.who-name {
  font-size: clamp(1.05rem, 1.5vw, 1.3rem);
  font-weight: 700;
}

.who-user.is-sel .who-name { color: var(--accent); }

.who.is-in .who-user { animation: who-pop 0.45s calc(var(--i) * 70ms) both cubic-bezier(0.2, 1.4, 0.4, 1); }

@keyframes who-pop { from { opacity: 0; transform: scale(0.6); } }

/* =========================================================
   4. Sortie de veille — comme sur la console : fond du thème,
   touche appuyée au centre, consigne et trois points en bas
   ========================================================= */
.lock {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  background: var(--bg);
  color: var(--text);
  transition: opacity 0.35s;
}

.lock.is-open { opacity: 0; pointer-events: none; }

.lock-icon {
  width: clamp(92px, 13vmin, 132px);
  aspect-ratio: 1;
  border: 4px solid currentColor;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: clamp(2.4rem, 6vmin, 3.6rem);
  font-weight: 700;
  line-height: 1;
}

.lock-icon svg { width: 46%; }
.lock-icon.bump { animation: lock-bump 0.18s ease-out; }

@keyframes lock-bump { 50% { transform: scale(0.92); } }

.lock-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: clamp(36px, 9vh, 80px);
  text-align: center;
  font-size: clamp(1rem, 1.7vw, 1.35rem);
}

.lock-hint p { margin: 0; }

.lock-dots { display: flex; justify-content: center; gap: 12px; margin-top: 12px; }

.lock-dots i {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  transition: background-color 0.1s;
}

.lock-dots i.on { background: currentColor; }

/* =========================================================
   5. Menu HOME
   ========================================================= */
.home {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------- Barre du haut ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: clamp(14px, 3.6vh, 36px) var(--gutter) 0;
}

.users { display: flex; gap: clamp(8px, 1vw, 14px); }

.avatar {
  position: relative;
  width: clamp(44px, 4.2vw, 60px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 3px solid var(--surface);
  box-shadow: var(--shadow);
  padding: 0;
  cursor: pointer;
  background: linear-gradient(140deg, var(--uc, #ff7a45), color-mix(in srgb, var(--uc, #ff7a45) 55%, #6b2b8f));
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: clamp(1.1rem, 1.7vw, 1.5rem);
}

.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

/* Compte invité : silhouette grise */
.avatar.is-guest { background: #b9b9b9; color: #f4f4f4; }

/* Le rognage se fait dans un calque à part : l'avatar lui-même ne coupe pas son cadre de sélection */
.guest-crop {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  overflow: hidden;
}

.guest-crop svg { display: block; width: 100%; height: 100%; }

.status {
  display: flex;
  align-items: center;
  gap: clamp(10px, 1.2vw, 16px);
  font-size: clamp(1rem, 1.5vw, 1.3rem);
  font-weight: 600;
}

.wifi { width: 1.25em; }

.battery { display: inline-flex; align-items: center; gap: 6px; }

.batt {
  position: relative;
  width: 1.7em;
  height: 0.85em;
  border: 2px solid currentColor;
  border-radius: 3px;
  padding: 1px;
}

.batt::after {
  content: "";
  position: absolute;
  right: -5px;
  top: 50%;
  width: 3px;
  height: 40%;
  background: currentColor;
  border-radius: 0 2px 2px 0;
  transform: translateY(-50%);
}

.batt i {
  display: block;
  height: 100%;
  width: calc(var(--batt, 1) * 100%);
  background: currentColor;
  border-radius: 1px;
}

/* ---------- Rangée de tuiles ---------- */
.library {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: calc(var(--tile) + 96px);
}

.tiles {
  display: flex;
  gap: var(--gap);
  overflow-x: auto;
  padding: 50px var(--gutter) 22px;
  scroll-padding-inline: var(--gutter);
  scrollbar-width: none;
}

.tiles::-webkit-scrollbar { display: none; }

.tile {
  position: relative;
  flex: 0 0 var(--tile);
  height: var(--tile);
  display: block;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: var(--tile-empty);
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s;
}

.tile .art {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
}

.tile .art img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Projet sans image : jaquette générée */
.art.is-gen {
  display: flex;
  align-items: flex-end;
  padding: 10%;
  background:
    radial-gradient(circle at 80% 15%, rgba(255, 255, 255, 0.28), transparent 45%),
    linear-gradient(140deg, var(--c), color-mix(in srgb, var(--c) 55%, #1a1030));
  color: #fff;
  font-weight: 900;
  font-size: calc(var(--tile) * 0.13);
  line-height: 1.05;
  text-align: left;
}

/* Emplacement vide : une case claire à peine dessinée, comme une console neuve */
.tile.is-empty {
  background: var(--tile-empty);
  box-shadow: inset 0 0 0 1px var(--empty-line);
}


/* Titre au-dessus de la tuile sélectionnée (position et largeur calculées par placeLabel) */
.tiles { position: relative; }

.tile .name {
  position: absolute;
  left: 0;
  bottom: calc(100% + 14px);
  overflow: hidden;
  white-space: nowrap;
  color: var(--accent);
  font-size: clamp(1rem, 1.55vw, 1.45rem);
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
}

.name-text { display: inline-block; }

/* Titre trop long : il défile, marque une pause au bout, puis repart du début */
.tile .name.is-scroll .name-text { animation: marquee var(--dur, 6s) linear infinite; }

@keyframes marquee {
  0%, 18% { transform: translateX(0); }
  82%, 100% { transform: translateX(var(--shift, 0)); }
}

.tiles .tile.is-sel .name { opacity: 1; }

.tile.is-pressed { transform: scale(0.95); }
.tile.shake { animation: shake 0.32s; }

@keyframes shake {
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.home.is-in .tiles .tile { animation: tile-in 0.5s calc(var(--i) * 35ms) both cubic-bezier(0.2, 0.8, 0.2, 1); }
.home.is-in .dock .round { animation: tile-in 0.5s calc(200ms + var(--i) * 35ms) both cubic-bezier(0.2, 0.8, 0.2, 1); }

@keyframes tile-in { from { opacity: 0; transform: translateX(40px); } }

/* ---------- Boutons ronds ---------- */
.dock {
  display: flex;
  justify-content: center;
  gap: clamp(14px, 2vw, 30px);
  padding: 46px var(--gutter) clamp(18px, 4.5vh, 44px);
}

.round {
  position: relative;
  width: var(--round);
  height: var(--round);
  flex: none;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--ic);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background-color 0.3s;
}

.round svg { width: 46%; height: 46%; }

.round .label {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 16px);
  transform: translateX(-50%);
  white-space: nowrap;
  color: var(--accent);
  font-size: clamp(0.95rem, 1.3vw, 1.2rem);
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
}

.round.is-sel .label { opacity: 1; }

.ic-off, .is-muted .ic-on { display: none; }
.is-muted .ic-off { display: block; }

/* ---------- Barre du bas ---------- */
.bottombar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 calc(var(--gutter) * 0.45);
  padding: 14px calc(var(--gutter) * 0.55) max(16px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  font-weight: 600;
}

.joycons { width: 44px; color: var(--muted); }

.hints { display: flex; gap: 26px; }

.hint {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: 0;
  padding: 0;
  font-size: clamp(0.95rem, 1.2vw, 1.1rem);
  font-weight: 600;
}

button.hint { cursor: pointer; position: relative; border-radius: 99px; }

/* =========================================================
   Panneaux (bibliothèque, profil)
   ========================================================= */
.panel {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--bg);
  color: var(--text);
  flex-direction: column;
}

.panel[open] { display: flex; animation: panel-in 0.25s ease-out; }
.panel::backdrop { background: var(--bg); }

@keyframes panel-in { from { opacity: 0; transform: scale(1.02); } }

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin: 0 calc(var(--gutter) * 0.45);
  padding: clamp(18px, 4vh, 38px) calc(var(--gutter) * 0.55) 16px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 { margin: 0; font-size: clamp(1.3rem, 2.2vw, 1.9rem); font-weight: 700; }

.panel-sel {
  color: var(--accent);
  font-weight: 700;
  font-size: clamp(0.95rem, 1.4vw, 1.25rem);
  text-align: right;
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 30px var(--gutter);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(104px, 13vw, 176px), 1fr));
  gap: clamp(14px, 1.6vw, 22px);
  --tile: clamp(104px, 13vw, 176px);
}

.grid .tile { height: auto; aspect-ratio: 1; }
.grid .tile .name { display: none; }

/* ---------- Page utilisateur (comme sur la console) ---------- */
.avatar.xl { width: 128px; font-size: 3.2rem; cursor: default; border-width: 4px; }

.upage-head { justify-content: flex-start; align-items: center; gap: 14px; }
.upage-head .avatar { width: 44px; border-width: 2px; font-size: 1.1rem; cursor: default; box-shadow: none; }

.upage-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(210px, 30%) 1fr;
  margin: 0 calc(var(--gutter) * 0.45);
}

/* Menu de gauche, sur le fond gris du panneau */
.upage-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 26px 18px 26px calc(var(--gutter) * 0.3);
}

.upage-tab {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 11px 14px 11px 20px;
  border: 0;
  border-radius: 3px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: clamp(1rem, 1.4vw, 1.15rem);
  text-align: left;
  cursor: pointer;
}

.upage-tab small { font-size: 0.75rem; color: var(--muted); }

/* Onglet affiché : texte bleu et barre verticale, même quand la sélection est à droite */
.upage-tab.is-current { color: var(--dot-on); }
.upage-tab.is-current::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 2px;
  background: var(--dot-on);
}

.upage-tab.is-sel::after,
.up-row.is-sel::after { inset: -2px; border-radius: 4px; }

/* Contenu de droite, sur fond clair */
.upage-main {
  overflow-y: auto;
  padding: 26px clamp(18px, 3vw, 44px);
  background: var(--surface);
}

.up-card {
  display: flex;
  align-items: flex-start;
  gap: clamp(16px, 2.5vw, 30px);
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

/* Grande icône carrée */
.avatar.up-icon {
  flex: none;
  width: clamp(96px, 12vw, 150px);
  border: 0;
  border-radius: 4px;
  box-shadow: none;
  font-size: clamp(2.4rem, 4vw, 3.6rem);
  cursor: default;
}

.avatar.up-icon img,
.up-icon .guest-crop { border-radius: 4px; }

.up-id { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; }

.up-name {
  position: relative;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 3px;
  font-size: clamp(1.1rem, 1.8vw, 1.45rem);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.up-name.is-sel { overflow: visible; }
.up-name.is-sel::after { inset: -3px; border-radius: 4px; }

.up-status { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--muted); }
.up-status i { width: 9px; height: 9px; border-radius: 50%; background: #9a9a9a; }
.up-status i.on { background: #2ecc71; }

.up-code { margin: 0; color: var(--muted); font-size: 0.85rem; }

/* Titre de section avec sa petite barre, comme « Activité » sur la console */
.up-sec {
  margin: 24px 0 8px;
  padding-left: 10px;
  border-left: 3px solid var(--muted);
  font-size: 1rem;
  font-weight: 600;
}

.up-list { list-style: none; margin: 0; padding: 0; }

.up-game {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--line);
}

.up-game b { display: block; font-weight: 600; }
.up-game small { display: block; color: var(--muted); font-size: 0.82rem; }

.up-game .mini {
  flex: none;
  width: 56px;
  height: 56px;
  overflow: hidden;
  display: grid;
  place-items: center;
  border-radius: 2px;
  background: linear-gradient(140deg, var(--c, #888), color-mix(in srgb, var(--c, #888) 55%, #1a1030));
  color: #fff;
  font-weight: 900;
}

.up-game .mini img { width: 100%; height: 100%; object-fit: cover; }

.up-empty {
  display: grid;
  place-items: center;
  gap: 14px;
  padding: 70px 0;
  color: var(--muted);
  text-align: center;
}

.up-empty svg { width: 64px; }

/* Lignes des paramètres utilisateur */
.up-row {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: clamp(1rem, 1.4vw, 1.1rem);
  text-align: left;
  cursor: pointer;
}

.up-row b { font-weight: 600; color: var(--muted); }
.up-row.is-static { cursor: default; }
.up-row.danger { color: #e8463c; }
.up-gap { height: 22px; }

/* Statuts : en ligne (vert), en jeu (vert, plus marqué), hors ligne (gris) */
.up-status i.play,
.up-person .dot.play { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25); }
.up-person .dot { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: #9a9a9a; vertical-align: 1px; }
.up-person .dot.on { background: #2ecc71; }

/* Personne (ami, demande) : avatar rond, pseudo, statut ou boutons */
.up-person {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 6px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
}

button.up-person { cursor: pointer; }
.up-person .avatar { width: 48px; border-width: 2px; font-size: 1.2rem; box-shadow: none; cursor: inherit; }
.up-person b { display: block; font-weight: 600; }
.up-person small { color: var(--muted); font-size: 0.82rem; }
.up-person.is-sel::after { inset: -2px; border-radius: 4px; }

.up-acts { margin-left: auto; display: flex; gap: 8px; }

.mini-btn {
  position: relative;
  padding: 7px 14px;
  border: 1px solid var(--btn-line);
  border-radius: 4px;
  background: var(--setup-bg);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.mini-btn.is-sel::after { inset: -3px; border-radius: 5px; }

.up-back { margin-bottom: 18px; padding-top: 6px; color: var(--muted); }

/* Recherche par code ami */
.up-search { display: flex; flex-direction: column; gap: 12px; padding-top: 18px; max-width: 460px; }
.up-search .btn { width: 100%; }
.up-msg { margin: 0; font-weight: 600; font-size: 0.92rem; }
.up-msg.is-error { color: #e8463c; }
.up-msg.is-ok { color: #16a34a; }

/* Compteur de demandes et pastille de notification */
.pill {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: #e8463c;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
}

.upage-tab .pill { align-self: flex-start; margin-top: 2px; color: #fff; }

.avatar .notif {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  border: 2px solid var(--bg);
  border-radius: 50%;
  background: #e8463c;
}

.console-ic { width: 40px; color: var(--muted); }

.row-empty {
  padding: 16px 18px;
  border: 2px dashed var(--line);
  border-radius: 4px;
  color: var(--muted);
  font-weight: 600;
}

/* =========================================================
   Veille / lancement
   ========================================================= */
.sleep,
.launch {
  position: fixed;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s;
}

.sleep { z-index: 75; }
.launch { z-index: 95; transition-duration: 0.55s; }

.sleep.is-on,
.launch.is-on { opacity: 1; pointer-events: auto; }

/* ---------- Lancement : la jaquette grandit jusqu'au plein écran ---------- */
.zoom {
  position: fixed;
  z-index: 96;
  overflow: hidden;
  background: #111;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  container-type: size;
  pointer-events: none;
  transition: opacity 0.35s;
}

/* Fond : la jaquette floutée, qui apparaît pendant le zoom */
.zoom-bg {
  position: absolute;
  inset: -10%;
  width: 120%;
  height: 120%;
  object-fit: cover;
  filter: blur(30px) brightness(0.7) saturate(1.25);
  opacity: 0;
  transition: opacity 0.5s;
}

.zoom.is-on .zoom-bg { opacity: 1; }

/* Devant : la jaquette entière, toujours visible en entier */
.zoom-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Projet sans image : le nom généré grandit avec le cadre */
.zoom .art.is-gen {
  align-items: center;
  justify-content: center;
  padding: 10cqmin;
  font-size: 13cqmin;
  text-align: center;
}

/* Écran-titre : la jaquette « respire » un instant avant le fondu */
.zoom.is-full .zoom-art { animation: zoom-breathe 0.85s ease-in-out; }
.zoom.is-out { opacity: 0; }

@keyframes zoom-breathe { 50% { transform: scale(1.035); } }

/* Le menu recule derrière la jaquette */
.home { transition: transform 0.5s cubic-bezier(0.65, 0, 0.25, 1), opacity 0.5s; }
.home.is-launching { transform: scale(0.96); opacity: 0.55; }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 720px) {
  :root {
    --tile: clamp(128px, 44vw, 210px);
    --round: 50px;
  }

  .tiles { padding-top: 44px; scroll-snap-type: x mandatory; }
  .tile { scroll-snap-align: start; }

  /* Quatre indications en bas de la configuration : elles passent sur deux lignes */
  .setup .hints { flex-wrap: wrap; justify-content: flex-end; gap: 8px 16px; }

  .dock { gap: 12px; padding-top: 42px; }
  .round .label { font-size: 0.9rem; }

  .upage-body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .upage-nav { flex-direction: row; overflow-x: auto; padding: 10px 0; gap: 2px; }
  .upage-tab { flex: none; padding: 10px 14px; }
  .upage-tab small { display: none; }
  .upage-tab.is-current::before { left: 14px; right: 14px; top: auto; bottom: 2px; width: auto; height: 3px; }
  .up-card { flex-direction: column; align-items: center; text-align: center; }
  .up-id { width: 100%; align-items: center; }
  .up-name { width: 100%; }
  .avatar.xl { width: 104px; font-size: 2.6rem; }

  .opts.two { grid-template-columns: 1fr; grid-auto-flow: row; grid-template-rows: none; }
  .opts.two > .opt:nth-child(6) { border-top: 0; }
  .setup-body { justify-content: flex-start; padding-top: 28px; }
  .pseudo, .done, .intro-row { flex-direction: column; text-align: center; }
  .pseudo-form { align-items: stretch; width: 100%; }
  .pseudo-form .btn { width: 100%; }
  .net-steps { gap: 2px; padding: 0 8px; }
  .net-step { width: 74px; }
  .net-dots { gap: 4px; }
  .hints { gap: 16px; }
}

@media (hover: none) {
  .home .hints { display: none; }
}

@media (max-height: 520px) and (orientation: landscape) {
  :root { --tile: clamp(110px, 30vh, 170px); }
  .dock { padding-top: 34px; padding-bottom: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
