:root {
  --bg: transparent; /* hors zone (letterbox) - transparent pour integration iframe WordPress */
  --ui: #ffcd75; /* texte UI principal */
  --ui2: #a7f070; /* accents */
  --danger: #b13e53;
  --ok: #38b764;
  --ink: #1a1c2c;
  --stage-fallback: transparent; /* Fond transparent pour laisser voir le background WordPress */
}


* { box-sizing: border-box; }
html,
body {
  height: 100%;
  margin: 0;
  background-color: var(--stage-fallback, transparent);
  background: var(--bg, var(--stage-fallback, transparent));
  color: var(--ui);
  font-family: monospace;
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  /* Empêcher le scroll quand le clavier s'ouvre */
  overflow: hidden;
  position: fixed;
  width: 100%;
}

body * {
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}


/* Wrapper pour centrer le canvas et gérer le letterboxing */
.wrap {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center; /* centre horizontal + vertical */
  width: 100vw; /* explicite */
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
  background-color: var(--stage-fallback, transparent);
}

/* Référence de position */
#gameWrapper {
  position: relative;
  width: fit-content;
  margin: 0 auto;
  display: grid;
  background-color: var(--stage-fallback, transparent);
}

/* Calques de base */
#bgLayer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background-color: var(--stage-fallback, transparent);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
  z-index: 0;
}

#bgLayer.no-transition {
  transition: none;
}

#legendBgOverlay {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0;
  transition: none;
  pointer-events: none;
  z-index: 1;
}

body.is-legend-level #legendBgOverlay {
  background-image: url("./fondniveau61.webp");
}

body.is-title #gameCanvas,
body.is-title #hud {
  visibility: hidden;
}

body.is-inter-level #gameWrapper > :not(#bgLayer):not(#interLevelScreen):not(#legendResultScreen):not(#overlay) {
  opacity: 0;
  pointer-events: none;
}

body.is-inter-level #gameCanvas,
body.is-inter-level #hud {
  visibility: hidden;
}

#gameCanvas {
  position: relative;
  z-index: 1;
  background: transparent;
  display: block;
  width: 100%;
  height: auto;
  touch-action: manipulation;
}

#hud {
  position: absolute;
  left: 0;
  right: 0;
  top: var(--hud-top, 14vh);
  margin: 0 auto;
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto 1fr; /* gauche | centre | droite */
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(4px);
  border-radius: 12px;
  color: #fff;
  z-index: 5;
  pointer-events: none; /* HUD non interactif */
}

/* Overlays (titre, pause, fin, inter-niveau) */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.8);
  transition: opacity 0.2s;
  opacity: 0;
  pointer-events: none;
  /* Prendre toute la taille du gameWrapper (qui s'adapte au canvas scalé) */
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.overlay.no-transition {
  transition: none;
}

.overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.overlay.show.inter-level-screen {
  background-color: rgba(0, 0, 0, 0);
}

.overlay.overlay-rules,
#overlay.overlay-rules {
  background: #000;
}

.overlay.overlay-title {
  background: transparent;
  align-items: stretch;
  justify-content: center;
  /* Padding fixe condensé pour rester dans le canvas */
  --title-overlay-pad-y: 20px;
  --title-overlay-pad-x: 10px;
  padding: var(--title-overlay-pad-y) var(--title-overlay-pad-x);
}

#overlay {
  z-index: 1001;
}

.panel {
  pointer-events: auto;
  background: linear-gradient(180deg, rgba(14, 16, 28, 0.9) 0%, rgba(8, 10, 22, 0.85) 100%);
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  padding: 18px 20px;
  min-width: 260px;
  /* S'adapter à la taille du canvas (90% pour laisser des marges) */
  width: 90%;
  max-height: 94%;
  text-align: left;
  border-radius: 16px;
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  /* Permettre scroll interne si contenu trop grand */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.inter-level-panel, element.style {
	margin-top: 200px;
}

.panel-shell,
.legend-leaderboard-panel {
  /* S'adapter à la taille du canvas (90% de largeur) */
  width: 90%;
  /* Hauteur adaptative pour éviter le resize quand le clavier s'ouvre */
  height: auto;
  max-height: 90%;
  /* Empêcher le flex de rétrécir le panel */
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  /* Permettre le scroll interne si le contenu est trop grand */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.panel-header,
.legend-leaderboard-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.panel-header h1,
.legend-leaderboard-header h1 {
  margin: 0;
  letter-spacing: 0.04em;
  text-align: left;
}
.panel-subtitle,
.legend-leaderboard-subtitle {
  margin: 0;
  font-size: 0.95rem;
  color: var(--ui2);
  opacity: 0.9;
}
.panel-grid,
.legend-leaderboard-grid {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 12px;
}
.panel h1 {
  margin: 0 0 12px;
  font-size: clamp(1.15rem, 3vw, 1.35rem);
  letter-spacing: 1px;
  text-align: center;
}
.panel p { margin: 6px 0; }
.panel-section {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.panel-card {
  padding: 14px 16px;
  gap: 10px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
}
.panel-section + .panel-section {
  margin-top: 10px;
}
.panel-title {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel-subline {
  margin: 2px 0 0;
  font-size: 0.95rem;
}

.panel-footer {
  margin-top: 8px;
}
.panel-actions {
  margin-top: 6px;
  justify-content: flex-start;
}
.panel-stat-list {
  list-style: none;
  padding: 0;
  margin: 6px 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}
.panel-stat-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.98rem;
}
.panel-stat-list span {
  color: var(--ui2);
}
.panel-stat-list strong {
  font-size: 1.05rem;
}
.panel-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.panel .control-mode-setting {
  margin: 6px 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  text-align: left;
}
.panel .control-mode-label {
  font-size: 14px;
  letter-spacing: 0.5px;
}
.panel .control-mode-toggle {
  display: flex;
  border: 2px solid var(--ui);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.35);
}
.panel .control-mode-option {
  flex: 1 1 50%;
  margin: 0;
  border: none;
  border-radius: 0;
  padding: 10px 12px;
  background: transparent;
  color: var(--ui);
  font-size: 14px;
  letter-spacing: 0.5px;
  line-height: 1.2;
}
.panel .control-mode-option + .control-mode-option {
  border-left: 2px solid rgba(255, 255, 255, 0.2);
}
.panel .control-mode-option.is-active {
  background: var(--ui);
  color: var(--ink);
}
.panel .control-mode-option:focus-visible {
  outline: 2px solid var(--ui2);
  outline-offset: 2px;
}
.btnrow { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
  button {
    font-family: inherit;
    font-size: 14px;
    letter-spacing: 0.5px;
    padding: 10px 14px;
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.32);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.02) 100%);
    color: var(--ui);
    cursor: pointer;
    transition: transform 0.12s ease, filter 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.25);
  }
  button:hover { filter: brightness(1.15); transform: translateY(-1px); }
  button:active { transform: translateY(0); filter: brightness(1); }
  button:focus-visible { outline: 2px solid var(--ui2); outline-offset: 2px; }

.btn {
  font-family: inherit;
  font-size: inherit;
}

.btn.btn-secondary {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0.04) 100%);
  border-color: rgba(255, 255, 255, 0.36);
  color: var(--ui);
}

.btn.btn-secondary:hover {
  filter: brightness(1.08);
}

.title-screen {
  flex: 1 1 100%;
  width: 100%;
  height: 100%;
  max-width: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  position: relative;
  padding: clamp(10px, 2vw, 18px);
  pointer-events: none;
}

.title-account-anchor {
  display: none;
}

.title-screen-spacer {
  flex: 1 1 clamp(160px, 42vh, 420px);
  width: 100%;
  pointer-events: none;
}

.title-account-bar {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  right: calc(env(safe-area-inset-right, 0px) + 12px);
  justify-content: flex-end;
  align-items: flex-start;
  width: auto;
  max-width: calc(100% - 24px);
  padding: 0;
  margin: 0;
  pointer-events: auto;
  z-index: 1100;
}

.title-account-anchor.is-visible {
  display: flex;
}

.account-status-wrapper {
  width: auto;
}

.title-account-card {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  pointer-events: auto;
  text-align: right;
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  max-width: min(62vw, 220px);
  cursor: pointer;
}

.title-account-card:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.85);
  outline-offset: 2px;
}

.title-account-status {
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  opacity: 0.85;
  text-align: right;
  align-self: stretch;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 540px) and (orientation: portrait) {
  .title-account-bar {

    top: calc(env(safe-area-inset-top, 0px) + 8px);
    right: calc(env(safe-area-inset-right, 0px) + 12px);
    max-width: calc(100% - 24px);

  }

  .title-account-card {
    padding: 5px 7px;
    border-radius: 7px;
    max-width: min(68vw, 200px);
  }

  .title-account-status {
    font-size: 0.74rem;
  }
}

.title-buttons {
  pointer-events: auto;
  /* S'adapter à la taille du canvas */
  width: 85%;
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  gap: 14px;
  text-align: center;
}

.title-buttons button {
  width: 100%;
  padding: 12px 16px;
  font-size: clamp(1rem, 2.4vw, 1.15rem);
  letter-spacing: 0.08em;
  background: rgba(0, 0, 0, 0.55);
  border-color: rgba(255, 255, 255, 0.85);
  color: #fff;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.title-buttons button.is-disabled,
.title-buttons button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  filter: saturate(0.6);
}

.title-buttons button:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.85);
  outline-offset: 2px;
}

.pending-badge-dot {
  display: none;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  margin-left: 8px;
  border-radius: 999px;
  background: linear-gradient(135deg, #f8e77c 0%, #f5c24a 100%);
  color: #0c0c0c;
  font-weight: 800;
  font-size: 0.72rem;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
}

[data-pending-badge="legend"][data-has-pending="yes"] .pending-badge-dot {
  display: inline-flex;
}

.global-notice {
  position: absolute;
  left: 50%;
  bottom: clamp(12px, 2vh, 20px);
  transform: translate(-50%, 10px);
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(10, 10, 14, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 1200;
}

.global-notice.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.global-notice[data-variant="info"] {
  border-color: rgba(245, 194, 74, 0.4);
}

.global-notice[data-variant="error"] {
  border-color: rgba(244, 102, 102, 0.5);
}

.progress-busy-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.progress-busy-overlay[data-busy="true"] {
  display: flex;
}

.overlay.overlay-title .progress-busy-overlay {
  inset: calc(-1 * var(--title-overlay-pad-y, 0px))
    calc(-1 * var(--title-overlay-pad-x, 0px));
}

.progress-busy-card {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 14px;
  color: #fff;
  font-size: 1rem;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35);
}

.progress-spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  animation: progress-spin 0.9s linear infinite;
}

.progress-busy-text {
  font-weight: 600;
  letter-spacing: 0.02em;
}

@keyframes progress-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.account-panel {
  /* DIMENSIONS FIXES pour éviter le shrinking quand le clavier s'ouvre */
  width: 88%;
  max-width: 350px;         /* Largeur fixe max pour mobile */
  height: 600px;            /* Hauteur FIXE (ne change pas avec clavier) */
  max-height: 600px;        /* Hauteur FIXE max */
  /* Position absolue pour éviter le recentrage flex quand le clavier s'ouvre */
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  /* Garantir que le panel reste à cette position fixe */
  margin: 0;
  /* Empêcher le flex de rétrécir le panel */
  flex-shrink: 0;
  /* Scroll interne si nécessaire (ex: clavier mobile) */
  overflow: hidden;
}

.account-panel-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  gap: 14px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 12px; /* Espace en bas pour que le scroll montre tout le contenu */
}

.account-panel-footer {
  flex: 0 0 auto;
  margin-top: auto;
}

.account-panel-footer .panel-actions {
  margin-bottom: 8px;
}
.account-auth-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.settings-grid {
  gap: 14px;
}

.settings-toggle-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.settings-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
}

.settings-volume-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.settings-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) 1.2fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  font-size: 0.9rem;
}

.settings-row input[type='range'] {
  width: 100%;
}

.settings-sensitivity-card input[type='range'] {
  width: 100%;
}

.pause-panel .panel-actions,
.gameover-panel .panel-actions,
.account-panel .panel-actions {
  justify-content: center;
  flex-wrap: wrap;
}

.account-referral-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.account-referral-link {
  word-break: break-all;
  font-size: 0.9rem;
}

.account-panel .account-referral-redeem .btnrow.account-referral-actions {
  justify-content: center;
  margin-top: 12px;
}

.account-panel .account-referral-redeem .btnrow.account-referral-actions button {
  width: auto;
}

.account-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

.account-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.account-form input {
  border: 1px solid var(--ui);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.55);
  color: var(--ui);
  padding: 8px 10px;
  font-size: 1rem;
}

.account-field-note {
  font-size: 0.8rem;
  line-height: 1.2;
  opacity: 0.9;
}

.account-field-error {
  color: var(--danger);
  min-height: 0.9rem;
  margin: -2px 0 0;
}

.account-field-error[hidden] {
  display: none;
}

.account-message {
  min-height: 20px;
  font-size: 0.85rem;
  margin: 4px 0 0;
  text-align: left;
}

.account-message.is-error {
  color: var(--danger);
}

.account-message.is-success {
  color: var(--ok);
}

.account-switch,
.account-forgot {
  background: none;
  border: none;
  color: var(--ui2);
  text-decoration: underline;
  padding: 0;
  font-size: 0.9rem;
  align-self: flex-start;
}

.account-forgot {
  margin-top: 8px;
  margin-bottom: 4px;
}

.account-status-line {
  font-size: 0.95rem;
  margin: 4px 0 8px;
}

.account-panel .btnrow {
  margin-top: 10px;
}

.account-panel button[data-account-close] {
  min-width: 120px;
}

/* Colonnes */
.hud-left  { display:flex; flex-direction:column; justify-content:center; }
.hud-center{ display:flex; flex-direction:column; align-items:center; }
.hud-right {
  display:flex;
  flex-direction:row;
  align-items:center;
  justify-content:flex-end;
  gap:10px;
}

.hud-right-stats {
  display:flex;
  flex-direction:column;
  align-items:flex-end;
}

.hud-legend-boost{
  display:none;
  align-items:flex-end;
  text-align:right;
  padding:0;
  border-radius:0;
  background:none;
  line-height:1.05;
  gap:2px;
  font-variant-numeric: tabular-nums;
}
.hud-legend-boost-badge{
  width:28px;
  height:28px;
  object-fit:contain;
  display:block;
}

/* Score 2 lignes */
.hud-score-label{ font-size: .9rem; opacity:.9; line-height:1; }
.hud-score-value{
  font-size: 1.25rem; font-weight: 800;
  font-variant-numeric: tabular-nums; line-height:1.05;
}

/* Combo */
.combo-chip{
  display:flex; align-items:center; gap:6px;
  padding: 6px 10px; border-radius: 10px;
  background: rgba(255,255,255,0.12);
  transform-origin: center;
}
.combo-icon{ opacity:.9; }
.combo-mult{ font-weight: 800; }
.combo-streak{ opacity:.85; }

.combo-bar{
  width: 100%; height: 3px; margin-top: 6px;
  background: rgba(255,255,255,.18); border-radius:3px; overflow:hidden;
}
.combo-bar-fill{
  height:100%; width:0%; background:#ff44cc;
  transition:width .15s linear;
}

/* Vies / Temps à droite (2 lignes) */
.hud-lives{ font-size: 1rem; line-height:1; }
.hud-time { font-size: .95rem; opacity:.9; line-height:1.05; }

/* Responsive léger */
@media (max-width: 360px){
  #hud{ gap:8px; padding:6px 8px; }
  .hud-score-value{ font-size: 1.1rem; }
}

.inter-level-screen,
.legend-result-screen {
  align-items: center;
  justify-content: center;
  /* Padding fixe condensé pour rester dans le canvas */
  padding: 30px 10px;
}

.inter-level-screen.gameover-mode {
  background-image: url("./fondgameover.webp");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.inter-level-screen.legend-mode {
  background-image: url("./interlevel5.webp");
  background-size: cover;
  background-position: center;
}

.inter-level-panel,
.legend-result-panel {
  /* S'adapter à la taille du canvas */
  width: 88%;
  max-height: 90%;
  gap: 12px;
}

.inter-level-panel .panel-header,
.legend-result-panel .panel-header {
  align-items: center;
  text-align: center;
}

.inter-level-summary,
.legend-result-message {
  text-align: center;
}

.inter-level-summary .panel-subline,
.legend-result-message .panel-subline {
  font-size: 1.05rem;
}

.inter-level-buttons,
.legend-buttons {
  width: 100%;
  justify-content: center;
}

.rules-screen {
  width: 100%;
  height: 100%;
  display: block;
  align-self: stretch;
}

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

.legend-leaderboard-panel {
  /* Dimensions déjà définies dans .panel-shell, .legend-leaderboard-panel ci-dessus */
  /* Réappliquer ici pour spécificité */
  width: 90%;
  max-height: 90%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.legend-leaderboard-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.legend-leaderboard-header h1 {
  margin: 0;
  letter-spacing: 0.04em;
}

.legend-leaderboard-grid {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 12px;
}

.legend-leaderboard-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px 14px;
  min-height: 0;
  --legend-leaderboard-row-height: clamp(52px, 8vw, 64px);
  --legend-leaderboard-visible-rows: 5;
  --legend-leaderboard-row-gap: 10px;
  --legend-leaderboard-scroll-height: calc(
    var(--legend-leaderboard-row-height) * var(--legend-leaderboard-visible-rows) +
    (var(--legend-leaderboard-visible-rows) - 1) * var(--legend-leaderboard-row-gap)
  );
}

.legend-leaderboard-body {
  position: relative;
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  gap: 8px;
  min-height: var(--legend-leaderboard-scroll-height);
  overflow: hidden;
}

.legend-leaderboard-scroll {
  flex: 0 0 var(--legend-leaderboard-scroll-height);
  height: var(--legend-leaderboard-scroll-height);
  min-height: var(--legend-leaderboard-scroll-height);
  max-height: var(--legend-leaderboard-scroll-height);
  position: relative;
  overflow-y: auto;
  padding-right: 0;
  padding-bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-gutter: stable both-edges;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.legend-leaderboard-scroll.has-sticky-overlay {
  padding-bottom: 0;
}

.legend-leaderboard-scroll::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.legend-leaderboard-card-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.legend-leaderboard-card .panel-title {
  margin: 0;
}

.leaderboard-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.leaderboard-status-row .btn {
  flex: 0 0 auto;
}

.leaderboard-status {
  font-size: 0.92rem;
  color: var(--ui2);
  opacity: 0.95;
}

.leaderboard-status[data-variant="error"] {
  color: #f3b8b8;
}

.leaderboard-status[data-variant="offline"] {
  color: #f5d274;
}

.leaderboard-status[data-variant="loading"] {
  opacity: 0.8;
}

.leaderboard-row,
.leaderboard-entry {
  display: flex;
  align-items: center;
  gap: 10px;
}

.leaderboard-skeleton {
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(255, 255, 255, 0.08);
}

.skeleton-block {
  display: inline-block;
  height: 16px;
  background: linear-gradient(90deg, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0.16) 50%, rgba(255,255,255,0.06) 100%);
  background-size: 200% 100%;
  border-radius: 10px;
  animation: skeletonPulse 1.2s ease-in-out infinite;
}

.skeleton-rank {
  width: 54px;
}

.skeleton-name {
  flex: 1;
  width: 100%;
  height: 18px;
  margin: 0 10px;
}

.skeleton-score {
  width: 82px;
  height: 18px;
  margin-left: auto;
}

.leaderboard-list {
  list-style: none;
  padding: 0;
  margin: 2px 0 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.leaderboard-empty {
  margin: 4px 0 0;
  font-size: 0.95rem;
  color: var(--ui2);
  opacity: 0.9;
}

@keyframes skeletonPulse {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.leaderboard-sticky {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0;
  background: none;
  border: none;
  box-shadow: none;
  z-index: 2;
  pointer-events: none;
}
.leaderboard-sticky.floating .legend-leaderboard-row {
  background: #ffffff;
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.36);
}

.leaderboard-sticky .legend-leaderboard-row {
  pointer-events: auto;
}

.legend-leaderboard-row {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
  gap: 12px;
  line-height: 1.4;
}

.legend-leaderboard-row.is-player-row {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.09) 0%, rgba(255, 255, 255, 0.05) 100%);
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.38);
}

.legend-leaderboard-row.is-player-row-active {
  outline: 1px solid rgba(255, 255, 255, 0.2);
}

.legend-leaderboard-row.is-player-row-hidden {
  visibility: hidden;
}

.legend-leaderboard-row.is-sticky-row {
  position: relative;
}

.legend-leaderboard-rank {
  font-weight: 700;
  min-width: 44px;
  text-align: center;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.legend-leaderboard-name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
}

.legend-leaderboard-score {
  margin-left: auto;
  font-weight: 700;
  text-align: right;
}

.lb-badge {
  width: 32px;
  height: 32px;
  object-fit: contain;
  vertical-align: middle;
  filter: drop-shadow(0 0 6px rgba(0, 0, 0, 0.35));
}

.legend-leaderboard-actions {
  margin-top: 6px;
  justify-content: center;
}

/* PR#1 — Hide scrollbar in Account overlay while keeping scroll */
.account-panel .panel-grid.account-panel-body {
  overflow-y: auto;               /* keep scroll */
  scrollbar-width: none;          /* Firefox */
  -ms-overflow-style: none;       /* IE/old Edge */
}
.account-panel .panel-grid.account-panel-body::-webkit-scrollbar {
  width: 0;
  height: 0;
}

/* ========================================
   LANDSCAPE ORIENTATION LOCK
   ======================================== */

/* Overlay qui apparaît quand l'appareil est en mode paysage */
#landscape-warning {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(10px);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  color: var(--ui, #ffcd75);
  font-family: monospace;
}

#landscape-warning .rotate-icon {
  font-size: 4rem;
  margin-bottom: 1.5rem;
  animation: rotate-pulse 2s ease-in-out infinite;
}

#landscape-warning h2 {
  font-size: 1.5rem;
  margin: 0 0 1rem;
  color: var(--ui, #ffcd75);
}

#landscape-warning p {
  font-size: 1rem;
  margin: 0;
  opacity: 0.8;
}

@keyframes rotate-pulse {
  0%, 100% {
    transform: rotate(0deg) scale(1);
  }
  50% {
    transform: rotate(-90deg) scale(1.1);
  }
}

/* Afficher l'overlay seulement en mode paysage */
@media (orientation: landscape) {
  #landscape-warning {
    display: flex !important;
  }
}

/* Sur desktop/tablette large, ne pas afficher l'avertissement */
@media (orientation: landscape) and (min-width: 1024px) {
  #landscape-warning {
    display: none !important;
  }
}
