/* ---------- Boutons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 60px;
  padding: 12px 26px;
  border-radius: 999px;
  border: 1.5px solid rgba(var(--accent-rgb), .65);
  background: linear-gradient(180deg, var(--btn-a, rgba(58, 30, 78, .88)), var(--btn-b, rgba(24, 12, 36, .9)));
  color: var(--gold-light);
  font: 600 22px/1.15 var(--font-title);
  letter-spacing: .02em;
  text-align: center;
  box-shadow: 0 6px 22px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .12);
  transition: transform .15s ease, box-shadow .25s ease, filter .25s ease, opacity .25s ease;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; pointer-events: none; }

.btn-primary {
  border-color: #f6e3a8;
  background: linear-gradient(180deg, #f3d687 0%, #d9a94a 55%, #a8741f 100%);
  color: #2a1606;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .45);
  box-shadow: 0 0 26px rgba(255, 196, 100, .45), 0 8px 24px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .6);
  position: relative;
}
/* Halo qui respire : opacité d'un pseudo-élément (animé par la carte graphique) */
.btn-primary::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: inherit;
  box-shadow: 0 0 34px rgba(255, 206, 120, .8);
  opacity: 0;
  animation: btn-glow 2.6s ease-in-out infinite;
  pointer-events: none;
}
@keyframes btn-glow { 50% { opacity: 1; } }

.btn-ghost {
  background: transparent;
  border-color: rgba(var(--accent-rgb), .3);
  box-shadow: none;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 1.5px solid rgba(var(--accent-rgb), .55);
  background: rgba(20, 10, 30, .72);
  color: var(--gold-light);
  font-size: 26px;
  line-height: 1;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .45);
}
.icon-btn.small { width: 50px; height: 50px; font-size: 20px; flex: none; }

/* Bouton de menu (grande carte tactile) */
.btn-menu {
  width: 100%;
  justify-content: flex-start;
  gap: 16px;
  min-height: 78px;
  padding: 12px 22px;
  border-radius: 22px;
  text-align: left;
}
.btn-menu strong { display: block; font-weight: 600; font-size: 24px; }
.btn-menu small {
  display: block;
  margin-top: 2px;
  font: italic 500 19px/1.2 var(--font-text);
  color: rgba(var(--accent-light-rgb), .75);
  letter-spacing: 0;
}
.btn-menu > span:not(.btn-icon):not(.switch) { flex: 1; }
.btn-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255, 230, 160, .35), rgba(120, 70, 20, .2));
  border: 1px solid rgba(var(--accent-rgb), .4);
  font-size: 24px;
}

.switch {
  flex: none;
  position: relative;
  width: 64px;
  height: 36px;
  border-radius: 99px;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(var(--accent-rgb), .45);
  transition: background .25s ease;
}
.switch::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 4px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #cfc3a6;
  transition: transform .25s ease, background .25s ease;
}
.btn-toggle[aria-pressed='true'] .switch { background: rgba(232, 180, 80, .55); }
.btn-toggle[aria-pressed='true'] .switch::after { transform: translateX(28px); background: #fff4cf; box-shadow: 0 0 12px rgba(255, 220, 140, .9); }

/* Petit sur-titre doré (écran de départ du jeu) */
.home-kicker {
  margin: 0;
  font: 500 20px/1 var(--font-title);
  letter-spacing: .3em;
  color: var(--gold);
}

a.icon-btn, a.btn { text-decoration: none; }

/* ---------- Écran de veille : seulement les messages ---------- */

.screensaver {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  background:
    radial-gradient(ellipse at 50% 50%, var(--panel-a), transparent 70%),
    radial-gradient(circle at 18% 22%, rgba(255, 220, 150, .12), transparent 30%),
    rgb(var(--veil-deep-rgb));
  cursor: pointer;
  animation: fade-in .6s ease;
}
.ss-band {
  width: 100%;
  overflow: hidden;
  padding: 3vh 0;
  border-style: solid;
  border-width: 2px 0;
  border-image: linear-gradient(90deg, transparent, var(--gold) 20%, var(--gold-light) 50%, var(--gold) 80%, transparent) 1;
}
.ss-band { --ticker-font: clamp(64px, 17vh, 220px); }
.screensaver .ticker-item { padding: 0 .6em; font-size: calc(var(--ticker-font) * min(1, var(--fs-ticker, 1))); }
.ss-hint {
  position: absolute;
  bottom: max(20px, env(safe-area-inset-bottom));
  left: 0;
  right: 0;
  margin: 0;
  text-align: center;
  font-style: italic;
  font-size: 20px;
  color: rgba(var(--accent-light-rgb), .55);
  animation: hint 5s ease forwards;
  pointer-events: none;
}
@keyframes hint { 10%, 70% { opacity: 1; } 100% { opacity: 0; } }
body.saver .ticker { visibility: hidden; }

.steps { margin: 6px 0 0; padding-left: 1.3em; font-size: 21px; line-height: 1.45; }
.steps strong { color: var(--gold-light); }

/* ---------- Menu du jeu ---------- */

.game-menu-btn {
  position: fixed;
  z-index: 55;
  left: max(16px, env(safe-area-inset-left));
  top: calc(var(--ticker-space, 0px) + 14px);
  transition: opacity .5s ease, top .5s ease;
}
body.at-home .game-menu-btn { opacity: 0; pointer-events: none; }

.live-status {
  position: fixed;
  z-index: 55;
  right: max(16px, env(safe-area-inset-right));
  top: calc(var(--ticker-space, 0px) + 14px);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 44vw;
  min-height: 50px;
  padding: 8px 18px;
  border-radius: 99px;
  border: 1.5px solid rgba(var(--accent-rgb), .5);
  background: rgba(20, 10, 30, .78);
  color: var(--ink);
  font: 600 18px/1.2 var(--font-title);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .45);
  transition: opacity .5s ease, top .5s ease;
}
.live-status .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-status .dot { flex: none; width: 12px; height: 12px; border-radius: 50%; background: #8c8c8c; }
.live-status[data-state='live'] .dot { background: #4be07a; box-shadow: 0 0 10px #4be07a; }
.live-status[data-state='connecting'] .dot,
.live-status[data-state='waiting'] .dot { background: #f2c14e; animation: blink 1s ease-in-out infinite; }
.live-status[data-state='error'] .dot { background: #ef5b5b; }
@keyframes blink { 50% { opacity: .3; } }

.drawer {
  position: fixed;
  z-index: 60;
  left: max(12px, env(safe-area-inset-left));
  top: calc(var(--ticker-space, 0px) + 82px);
  width: min(400px, calc(100vw - 24px));
  max-height: calc(100vh - var(--ticker-space, 0px) - 100px);
  overflow-y: auto;
  display: grid;
  gap: 10px;
  padding: 18px;
  border-radius: 24px;
  background: linear-gradient(160deg, var(--panel-a), var(--panel-b));
  border: 1px solid rgba(var(--accent-rgb), .5);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
  animation: drawer-in .3s ease;
}
.drawer h2 {
  margin: 0 0 4px;
  font: 600 22px/1.2 var(--font-title);
  color: var(--gold);
  text-align: center;
  letter-spacing: .1em;
}
@keyframes drawer-in { from { opacity: 0; transform: translateY(-10px) scale(.98); } }
body:not(.mode-live) .live-only { display: none; }

/* ---------- Bandeau des messages ---------- */

.ticker {
  position: fixed;
  z-index: 50;
  left: 0;
  right: 0;
  top: 0;
  height: calc(var(--ticker-h, 58px) * max(1, var(--fs-ticker, 1)));
  display: flex;
  align-items: center;
  overflow: hidden;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(var(--veil-rgb), 0), rgba(var(--veil-rgb), .8) 10%, rgba(var(--veil-rgb), .8) 90%, rgba(var(--veil-rgb), 0));
  border-style: solid;
  border-width: 1.5px 0;
  border-image: linear-gradient(90deg, transparent, var(--gold) 20%, var(--gold-light) 50%, var(--gold) 80%, transparent) 1;
  transition: opacity .7s ease;
}
/* Fondus sur les bords (au lieu d'un masque, coûteux sur iPad) */
.ticker::before,
.ticker::after {
  content: '';
  position: absolute;
  z-index: 1;
  top: 0;
  bottom: 0;
  width: 9%;
}
.ticker::before { left: 0; background: linear-gradient(90deg, rgb(var(--veil-rgb)), transparent); }
.ticker::after { right: 0; background: linear-gradient(-90deg, rgb(var(--veil-rgb)), transparent); }
.ticker.off { opacity: 0; }

.ticker-track {
  display: flex;
  width: max-content;
  animation: ticker var(--ticker-dur, 40s) linear infinite;
  will-change: transform;
}
.ticker-group { display: flex; align-items: center; flex: none; }
.ticker-item {
  padding: 0 .9em;
  font: italic 600 calc(var(--ticker-font, 30px) * var(--fs-ticker, 1))/1 var(--font-ticker);
  color: var(--c-ticker, var(--gold-light));
  white-space: nowrap;
  text-shadow: 0 0 14px rgba(255, 200, 110, .55), 0 1px 2px rgba(0, 0, 0, .9);
}
.ticker-sep { color: var(--gold); font-size: calc(var(--ticker-font, 30px) * .7); text-shadow: 0 0 10px rgba(255, 210, 120, .9); }
@keyframes ticker { to { transform: translateX(-50%); } }

/* Sur le tableau de bord, le ruban est juste au-dessus des boutons du bas */
body.at-home .ticker {
  --ticker-h: 56px;
  --ticker-font: 28px;
  top: auto;
  bottom: var(--dash-bottom-h);
}

/* ---------- Réglages ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(4, 2, 8, .7);
  animation: fade-in .25s ease;
}
@keyframes fade-in { from { opacity: 0; } }
.modal-card {
  position: relative;
  width: min(640px, 100%);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 26px 28px 30px;
  border-radius: 28px;
  background: linear-gradient(165deg, var(--panel-solid-a), var(--panel-solid-b) 70%);
  border: 1px solid rgba(var(--accent-rgb), .55);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .7), inset 0 0 40px rgba(var(--accent-rgb), .06);
}
.modal-card h2 {
  margin: 0 0 8px;
  font: 700 34px/1.1 var(--font-title);
  color: var(--gold-light);
  text-align: center;
}
.modal-card h3 {
  margin: 24px 0 6px;
  font: 600 22px/1.2 var(--font-title);
  color: var(--gold);
  letter-spacing: .04em;
}
.modal-close { position: absolute; right: 16px; top: 16px; }
.hint { margin: 0 0 12px; font-size: 20px; color: rgba(243, 233, 210, .8); }
.hint strong { color: var(--gold-light); }

.field { display: grid; gap: 6px; margin: 12px 0; }
.field > span:first-child { font: 600 17px/1.2 var(--font-title); color: rgba(var(--accent-light-rgb), .85); }
.field-row { display: flex; gap: 10px; align-items: center; }
.field input {
  width: 100%;
  min-height: 56px;
  padding: 10px 18px;
  border-radius: 16px;
  border: 1.5px solid rgba(var(--accent-rgb), .45);
  background: rgba(0, 0, 0, .35);
  color: var(--ink);
  font-size: 22px;
  outline: none;
}
.field input:focus { border-color: var(--gold-light); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .25); }

.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.form-actions .btn { font-size: 18px; min-height: 54px; padding: 10px 20px; }
.form-status { min-height: 1.3em; margin: 12px 0 0; font-size: 20px; font-style: italic; }
.form-status[data-state='live'] { color: #8ff0ae; }
.form-status[data-state='error'] { color: #f5a0a0; }
.form-status[data-state='connecting'],
.form-status[data-state='waiting'] { color: #f5d98a; }

.settings-toggles { display: grid; gap: 10px; }
.settings-toggles .btn-menu { min-height: 66px; }

/* ---------- Résultat ---------- */

.result {
  position: absolute;
  right: max(4vw, 24px);
  top: 50%;
  width: min(46vw, 640px);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  padding: 30px 32px;
  border-radius: 30px;
  background: linear-gradient(165deg, var(--panel-a), var(--panel-b));
  border: 1px solid rgba(var(--accent-rgb), .6);
  box-shadow: 0 0 60px rgba(255, 200, 120, .25), 0 30px 80px rgba(0, 0, 0, .6);
  transform: translateY(-50%);
  animation: result-in .9s cubic-bezier(.2, .9, .3, 1) both;
}
@keyframes result-in { from { opacity: 0; transform: translate(40px, -50%) scale(.96); } }

.result-inner { overflow-y: auto; scrollbar-width: thin; text-align: center; }
.result-kicker { margin: 0; font: 500 20px/1.2 var(--font-title); letter-spacing: .25em; color: var(--gold); }
.result-number {
  margin: 6px 0 0;
  font: 700 110px/1 var(--font-title);
  color: #fff3c4;
  text-shadow: 0 0 26px rgba(255, 200, 100, .9), 0 0 60px rgba(255, 150, 60, .5);
}
.result-title { margin: 8px 0 0; font: 600 36px/1.15 var(--font-title); color: var(--gold-light); }
.result-text { margin: 14px 0 0; font: italic 500 26px/1.3 var(--font-text); }
.result-stats { margin: 10px 0 0; font-size: 20px; color: rgba(243, 233, 210, .7); }

.winners {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}
.winners li {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 6px 16px 6px 6px;
  border-radius: 99px;
  background: linear-gradient(180deg, rgba(255, 220, 140, .2), rgba(255, 200, 100, .08));
  border: 1px solid rgba(var(--accent-rgb), .55);
  font-size: 24px;
  animation: winner-in .6s cubic-bezier(.2, 1.4, .4, 1) both;
  animation-delay: calc(var(--i, 0) * 90ms + .3s);
}
.winners img,
.winners .avatar {
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  background: radial-gradient(circle at 35% 30%, #f6e3a8, #a8741f);
  display: grid;
  place-items: center;
  color: #2a1606;
  font: 700 20px/1 var(--font-title);
}
.winners .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.winners .handle { color: rgba(var(--accent-light-rgb), .6); font-size: .8em; margin-left: 4px; }
@keyframes winner-in { from { opacity: 0; transform: scale(.6); } }

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

/* ---------- Message temporaire ---------- */

.toast {
  position: fixed;
  z-index: 80;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  max-width: calc(100vw - 32px);
  padding: 14px 26px;
  border-radius: 99px;
  background: rgba(20, 10, 30, .92);
  border: 1px solid rgba(var(--accent-rgb), .6);
  color: var(--gold-light);
  font-size: 22px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  transform: translateX(-50%);
  animation: toast-in .35s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } }

/* ---------- Petits écrans ---------- */

@media (max-height: 720px) {
  .btn-menu { min-height: 64px; padding: 8px 18px; }
  .btn-menu strong { font-size: 21px; }
  .btn-menu small { font-size: 17px; }
}

@media (orientation: portrait) {
  .result {
    left: 16px;
    right: 16px;
    top: auto;
    bottom: 16px;
    width: auto;
    max-height: 48vh;
    transform: none;
    animation-name: result-in-portrait;
  }
  @keyframes result-in-portrait { from { opacity: 0; transform: translateY(30px); } }
  .focus-door.split { transform: translateY(-22vh) scale(.62); }
}
