/* Thème Ribin (D-41) : la direction artistique pixel art du prototype playground.
   Servi par le moteur sous /ribin/design.css ; une vue l'adopte par
   <link rel="stylesheet" href="/ribin/design.css">. Tout est local : polices et icônes
   viennent du moteur (CSP font-src 'self'), aucune ressource externe.
   Toutes les couleurs sont des variables : changer de direction artistique = changer ce bloc. */

@font-face {
  font-family: "Press Start 2P";
  src: url("/ribin/fonts/pressstart2p/PressStart2P-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "VT323";
  src: url("/ribin/fonts/vt323/VT323-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #1b1430;
  --bg-2: #241a3d;
  --panel: #2e2350;
  --panel-2: #3a2d63;
  --ink: #fff7e8;
  --ink-dim: #b9add6;
  --line: #0d0919;
  --primary: #ffc531;
  --primary-dark: #c98a12;
  --secondary: #3fa7ff;
  --secondary-dark: #1d6fbf;
  --pink: #ff5fa2;
  --green: #4ddb7a;
  /* Rouge de texte : 4,5:1 au moins sur --bg, --panel et --panel-2 (WCAG AA). */
  --red: #ff7088;
  --font-title: "Press Start 2P", monospace;
  --font-body: "VT323", monospace;
  --px: 4px;
  --grid: 32px;
  --focus: #ffffff;
  /* Zones de l'encoche et de la barre d'accueil des téléphones */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

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

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
}

/* Fond quadrillé à 32 px ; la classe .grid le donne à un autre élément. */
body,
.grid {
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--bg-2) 2px, transparent 2px),
    linear-gradient(90deg, var(--bg-2) 2px, transparent 2px);
  background-size: var(--grid) var(--grid);
}

body {
  min-height: 100dvh;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 22px;
  line-height: 1.15;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* Texte pour les lecteurs d'écran seulement : présent dans l'arbre d'accessibilité, invisible. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Pixels nets : images, canevas, avatars et icônes ne sont jamais lissés. */
img,
canvas,
.avatar,
.px-icon {
  image-rendering: pixelated;
}

.avatar {
  display: block;
  border: var(--px) solid var(--line);
}

.px-icon {
  display: block;
  flex: none;
  width: 1em;
  height: 1em;
  fill: currentColor;
  shape-rendering: crispEdges;
}

/* Titres : police pixel, jamais de titre sans elle. */
h1,
h2,
h3,
.title {
  font-family: var(--font-title);
  font-weight: 400;
  margin: 0;
  line-height: 1.35;
}

h1,
.title {
  font-size: 20px;
  color: var(--primary);
  text-shadow: 3px 3px 0 var(--pink), 6px 6px 0 var(--line);
  text-align: center;
}

h2,
.section-title {
  font-size: 12px;
  color: var(--primary);
}

h3 {
  font-size: 11px;
  color: var(--ink);
}

.section-title {
  font-family: var(--font-title);
  margin: 0 0 12px;
}

.section-title.big {
  font-size: 20px;
  text-align: center;
  margin: 12px 0;
}

/* ---------- Primitives ---------- */

.panel {
  background: var(--panel);
  border: var(--px) solid var(--line);
  box-shadow: inset 0 var(--px) 0 var(--panel-2), 0 var(--px) 0 var(--line);
  padding: 14px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 16px;
  text-align: center;
  line-height: 1.2;
  border: var(--px) solid var(--line);
  background: var(--panel-2);
  font-family: var(--font-title);
  font-size: 12px;
  box-shadow: inset 0 calc(var(--px) * -1) 0 rgba(0, 0, 0, 0.3), 0 var(--px) 0 var(--line);
  transition: transform 0.05s;
}

.btn:active:not(:disabled):not([aria-disabled="true"]) {
  transform: translateY(var(--px));
  box-shadow: inset 0 calc(var(--px) * -1) 0 rgba(0, 0, 0, 0.3);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
}

.btn-primary {
  background: var(--primary);
  color: var(--line);
}

.btn-secondary {
  background: var(--secondary);
  color: var(--line);
}

.btn-danger {
  background: var(--red);
  color: var(--line);
}

.btn-ghost {
  background: transparent;
  box-shadow: none;
  border-color: var(--panel-2);
  color: var(--ink-dim);
}

.btn-big {
  font-size: 15px;
  min-height: 56px;
  padding: 16px 20px;
}

.btn-small {
  /* Cible tactile de 44 px au moins, même pour le petit bouton. */
  min-height: 44px;
  padding: 6px 10px;
  font-size: 10px;
}

.btn-block {
  width: 100%;
}

/* Bouton réduit à une icône 8×8 : centrage exact. */
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  min-height: 44px;
  padding: 0;
  font-size: 18px;
  line-height: 0;
}

.input {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 8px 12px;
  background: var(--bg);
  border: var(--px) solid var(--line);
  border-radius: 0;
  font-family: var(--font-body);
  font-size: 24px;
  color: var(--ink);
  outline: none;
}

.input:focus {
  border-color: var(--primary);
}

.input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* Texte pour les lecteurs d'écran seulement : présent dans l'arbre d'accessibilité, invisible. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.input::placeholder {
  color: var(--ink-dim);
  opacity: 1;
}

.input-big {
  font-size: 28px;
  text-align: center;
}

.input-code {
  font-family: var(--font-title);
  font-size: 18px;
  text-align: center;
  letter-spacing: 6px;
  text-transform: uppercase;
}

.input-code::placeholder {
  letter-spacing: 0;
  font-size: 12px;
}

.label {
  display: block;
  margin: 10px 0 6px;
  color: var(--ink-dim);
  font-size: 18px;
}

.hint {
  margin: 6px 0;
  color: var(--ink-dim);
  text-align: center;
}

.error {
  margin: 8px 0 0;
  color: var(--red);
  text-align: center;
}

.blink {
  animation: blink 1.2s steps(2) infinite;
}

@keyframes blink {
  50% {
    opacity: 0.35;
  }
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 3px solid var(--line);
  background: var(--panel-2);
  font-size: 19px;
}

button.chip:active {
  background: var(--pink);
  color: var(--line);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 1px 8px;
  background: var(--line);
  border: 2px solid var(--panel-2);
  color: var(--primary);
  font-size: 18px;
  line-height: 1.1;
}

.segmented {
  display: flex;
  border: var(--px) solid var(--line);
}

.segmented > button {
  flex: 1;
  min-height: 44px;
  padding: 8px 6px;
  border: 0;
  border-right: 3px solid var(--line);
  background: var(--bg);
  font-size: 20px;
}

.segmented > button:last-child {
  border-right: 0;
}

.segmented > button.active,
.segmented > button[aria-pressed="true"],
.segmented > button[aria-selected="true"] {
  background: var(--secondary);
  color: var(--line);
}

/* Bandeau de joueurs : avatar, nom, score ; .me, .offline. */
.strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 6px 2px 4px;
}

.strip-player {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 54px;
}

.strip-player.offline {
  opacity: 0.45;
}

.strip-player.me .strip-name {
  color: var(--primary);
}

.strip-name {
  max-width: 64px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 18px;
}

.score,
.strip-score {
  font-family: var(--font-title);
  font-size: 10px;
  color: var(--primary);
}

.score-big {
  font-family: var(--font-title);
  font-size: 40px;
  color: var(--primary);
  text-shadow: 4px 4px 0 var(--line);
  text-align: center;
}

/* Jauge de temps ou de progression : .bar > .bar-fill (largeur posée par la vue). */
.bar {
  position: relative;
  height: 26px;
  border: var(--px) solid var(--line);
  background: var(--bg);
}

.bar-fill {
  height: 100%;
  background: var(--green);
  transition: width 0.1s linear;
}

.bar.urgent .bar-fill {
  background: var(--red);
}

.bar-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-title);
  font-size: 11px;
  text-shadow: 2px 2px 0 var(--line);
}

/* Compte à rebours : chiffres géants qui clignotent quand ça presse. */
.countdown {
  margin: 0;
  font-family: var(--font-title);
  font-size: 48px;
  line-height: 1;
  text-align: center;
  color: var(--primary);
  text-shadow: 4px 4px 0 var(--pink), 8px 8px 0 var(--line);
  font-variant-numeric: tabular-nums;
}

.countdown.urgent {
  color: var(--red);
  animation: blink 0.6s steps(2) infinite;
}

.toast {
  position: fixed;
  top: calc(12px + var(--safe-t));
  left: 50%;
  z-index: 40;
  max-width: calc(100vw - 24px);
  transform: translateX(-50%);
  padding: 6px 14px;
  border: var(--px) solid var(--line);
  background: var(--red);
  color: var(--line);
  box-shadow: 0 var(--px) 0 var(--line);
}

.toast-ok {
  background: var(--green);
}

/* Bulle de dialogue : posée au-dessus de son auteur (position: relative). */
.bubble {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  z-index: 5;
  max-width: 200px;
  padding: 4px 8px;
  overflow: hidden;
  border: 3px solid var(--line);
  background: #ffffff;
  color: var(--line);
  font-size: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
  animation: bubble-in 0.15s steps(3) both;
}

@keyframes bubble-in {
  from {
    transform: translateX(-50%) scale(0.3);
  }
}

/* Podium : rangs de métal. .podium est la liste des lignes, .podium-stage les trois marches. */
.rank-1 {
  --metal: #ffc531;
  --metal-light: #ffe58a;
  --metal-dark: #b07a0c;
}

.rank-2 {
  --metal: #b9c2d8;
  --metal-light: #e6ebf5;
  --metal-dark: #6f7891;
}

.rank-3 {
  --metal: #d9874a;
  --metal-light: #f2b483;
  --metal-dark: #8e4f22;
}

.podium {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.podium-stage {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
  padding: 24px 4px 0;
}

.podium-spot {
  flex: 1;
  max-width: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.podium-name {
  max-width: 100%;
  padding: 0 6px;
  overflow: hidden;
  background: var(--line);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.podium-block {
  width: 100%;
  transform-origin: bottom;
  animation: grow 0.5s steps(5) both;
}

.podium-top {
  height: 12px;
  border: var(--px) solid var(--line);
  border-bottom: 0;
  background: var(--metal-light);
}

.podium-front {
  position: relative;
  display: grid;
  place-items: center;
  border: var(--px) solid var(--line);
  background: var(--metal);
  box-shadow:
    inset var(--px) var(--px) 0 var(--metal-light),
    inset calc(var(--px) * -1) calc(var(--px) * -1) 0 var(--metal-dark);
}

.rank-1 .podium-front {
  height: 150px;
}

.rank-2 .podium-front {
  height: 105px;
}

.rank-3 .podium-front {
  height: 70px;
}

.podium-rank {
  font-family: var(--font-title);
  color: var(--metal-light);
  text-shadow: 3px 3px 0 var(--metal-dark);
}

@keyframes grow {
  from {
    transform: scaleY(0);
  }
}

@keyframes pop {
  from {
    transform: scale(0.2);
  }

  70% {
    transform: scale(1.2);
  }
}

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

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.pop {
  animation: pop 0.4s steps(4);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
