/* Style HUD Terraria : décor de forêt du jeu, panneaux bleus translucides, boutons et onglets
   découpés dans les sprites d'interface (assets/ui), texte blanc détouré de noir.
   Mobile d'abord : tout est pensé pour 375 px, puis centré sur grand écran. */

/* Police : assets/fonts/ui.ttf (Andy Bold), Comic Neue si le fichier manque */
@font-face {
  font-family: "CratariaUI";
  src: url("../assets/fonts/ui.ttf") format("truetype");
  font-display: swap;
}

:root {
  --panel: rgba(63, 82, 151, .78);   /* couleur des panneaux du jeu */
  --panel-edge: #000;
  --panel-light: rgba(140, 160, 240, .3);
  --slot: #4955ba;                    /* fond d'un onglet, si l'image manque */
  --field: rgba(24, 32, 90, .85);
  --text: #ffffff;
  --muted: #c9cdf0;
  --menu: #a7a7a7;
  --gold: #ffe745;
  --font: "CratariaUI", "Comic Neue", "Comic Sans MS", system-ui, sans-serif;
  /* Détourage noir du texte, comme dans le jeu */
  --outline: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000, 0 2px 0 #000;
  /* Onglet du jeu (CategoryPanel), et sa version dorée fabriquée par js/app.js */
  --tab: url("../assets/ui/CategoryPanel.png");
  --tab-on: var(--tab);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  /* Décor de forêt du jeu, du plus proche au plus lointain, puis le dégradé du ciel */
  background:
    url("../assets/bg/Background_11.png") repeat-x left bottom -200px,
    url("../assets/bg/Background_9.png") repeat-x left bottom -90px,
    url("../assets/bg/Background_8.png") repeat-x left bottom -20px,
    url("../assets/bg/Background_7.png") repeat-x left bottom 40px,
    url("../assets/bg/Background_0.png") repeat-x left top / auto 100%,
    linear-gradient(#1d47c9, #7fb6f5);
  background-attachment: fixed;
  image-rendering: pixelated;
  color: var(--text);
  font: 700 17px/1.35 var(--font);
  text-shadow: var(--outline);
  touch-action: manipulation; /* pas de zoom au double tap */
}
/* Sol en bas de l'écran : blocs d'herbe et de terre du jeu (ui/ground.png, assemblé depuis Tiles_2 et Tiles_0), à l'échelle x2 */
body::after {
  content: "";
  position: fixed;
  inset: auto 0 0;
  z-index: -1;
  height: 96px;
  background: url("../assets/ui/ground.png") repeat-x 0 0 / 96px 96px;
}

/* Soleil et nuages qui dérivent */
#sky { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
#sky i { position: absolute; left: 0; animation: drift linear infinite; }
#sky .sun { left: auto; right: 24px; top: 40px; width: 114px; height: 114px; background: url("../assets/ui/Sun.png"); animation: none; }
#sky .c1 { top: 70px;  width: 256px; height: 104px; background: url("../assets/bg/Cloud_0.png");  animation-duration: 140s; animation-delay: -40s; }
#sky .c2 { top: 190px; width: 192px; height: 64px;  background: url("../assets/bg/Cloud_1.png");  animation-duration: 190s; animation-delay: -120s; }
#sky .c3 { top: 20px;  width: 302px; height: 132px; background: url("../assets/bg/Cloud_4.png");  animation-duration: 240s; animation-delay: -10s; }
@keyframes drift { from { transform: translateX(-320px); } to { transform: translateX(110vw); } }

button, input { font: inherit; color: inherit; text-shadow: inherit; }
h2 { margin: 0 0 12px; font-size: 1.5rem; text-align: center; }
h3 { margin: 18px 0 8px; font-size: 1.1rem; }
.muted { color: var(--muted); }
.center { text-align: center; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
canvas, img { image-rendering: pixelated; }
/* Portrait : canevas 104×68 (corps 40×56 centré, place pour les ailes et l'arme), agrandi x2,5 (js/avatar.js, center) */
.avatar { width: 260px; height: 170px; }

#view {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: calc(110px + env(safe-area-inset-bottom));
}

/* Panneau : bleu translucide à bord noir, comme les fenêtres du jeu */
.card, #menu, #toast {
  background: var(--panel);
  border: 2px solid var(--panel-edge);
  border-radius: 10px;
  box-shadow: inset 0 0 0 2px var(--panel-light), 0 4px 0 #0005;
}
.card { padding: 16px; }
.card + .card { margin-top: 12px; }

/* Logo (assets/ui/logo.webp) : image lissée, pas en pixels nets */
.logo, .logo img { image-rendering: auto; }
.logo.big { margin: 0 0 16px; }
.logo.big img { display: block; width: 100%; height: auto; }
.tagline { margin: -8px 0 16px; text-align: center; color: var(--muted); }

form { display: grid; gap: 12px; margin-bottom: 12px; }
label { display: grid; gap: 4px; font-size: 1rem; }
input {
  min-height: 46px;
  padding: 0 12px;
  border: 2px solid #000;
  border-radius: 8px;
  background: var(--field);
  font-size: 17px; /* 16 px minimum : iOS ne zoome pas sur le champ */
}
input:focus { outline: none; border-color: var(--gold); }
/* Texte saisi lisible : pas de détourage noir, et pas de fond clair quand le navigateur pré-remplit */
input { text-shadow: none; color: #fff; caret-color: var(--gold); letter-spacing: .02em; }
input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus {
  -webkit-text-fill-color: #fff;
  box-shadow: inset 0 0 0 100px #1b2560;
  transition: background-color 9999s;
}

/* Boutons et cases : l'onglet du jeu étiré en 9 tranches (coins à l'échelle x2),
   doré quand il est survolé ou choisi */
.btn, .seg button, .stepper button, .tabs button, .icon {
  border: 2px solid transparent;
  border-radius: 8px;
  border-image: var(--tab) 8 fill / 16px;
  background: var(--slot) padding-box;
  cursor: pointer;
}
.btn:hover, .btn:focus-visible, .seg button.on, .tabs button.on, .stepper button:hover, .icon:hover {
  border-image-source: var(--tab-on);
  color: var(--gold);
  outline: none;
}
.btn { width: 100%; min-height: 52px; font-size: 1.3rem; }
.btn:active { transform: translateY(1px); }
.btn.primary { color: var(--gold); }
.btn:disabled { opacity: .6; }
.btn img { height: 22px; width: auto; vertical-align: -4px; margin-right: 6px; }
.icon { width: 44px; height: 44px; font-size: 1.3rem; }

/* Liens et entrées de menu : gris, jaunes au survol, comme le menu principal */
.link, #menu button {
  width: 100%;
  min-height: 44px;
  border: 0;
  background: none;
  color: var(--menu);
  font-size: 1.15rem;
  cursor: pointer;
}
.link:hover, #menu button:hover, #menu button:focus-visible { color: var(--gold); outline: none; }

.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 16px; }
.seg button { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; }
/* Classement : 3 boutons sur une ligne, plus compacts */
#r-kind { grid-template-columns: repeat(3, 1fr); gap: 4px; }
#r-kind button { min-height: 40px; padding: 0 4px; font-size: .85rem; }

#topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  padding-top: calc(8px + env(safe-area-inset-top));
  background: rgba(18, 24, 56, .6);
  backdrop-filter: blur(4px);
}
/* Icône du jeu, puis pièces / niveau / bonus et barre d'XP (js/hud.js) */
#topbar { gap: 10px; padding: 6px 12px; padding-top: calc(6px + env(safe-area-inset-top)); }
/* Tête du personnage : 24 × 24 px de son avatar, ×1,5 */
.top-head { width: 36px; height: 36px; flex: none; image-rendering: pixelated; }
.top-hud { flex: 1; min-width: 0; max-width: 520px; }
.top-hud[hidden] { visibility: hidden; display: block; }
.top-hud .hud-row { gap: 8px; font-size: 1rem; }
.top-hud .coins img { height: 18px; }
.top-hud .level { min-width: 0; }
.top-hud .buffs { min-width: 0; overflow-x: auto; scrollbar-width: none; }
.top-hud .buffs::-webkit-scrollbar { display: none; }
.top-hud .buffs button { flex: none; width: 24px; height: 24px; }
.top-hud .buffs img { width: 20px; height: 20px; }
.top-hud .xpbar { height: 12px; margin-top: 3px; }
.top-hud .xpbar span { font-size: .6rem; line-height: 12px; }

#menu {
  inset: unset;
  top: calc(64px + env(safe-area-inset-top));
  right: 12px;
  margin: 0;
  padding: 8px 12px;
  min-width: 200px;
  color: var(--text);
}
#menu button { display: block; text-align: left; }

#toast {
  background: #2c3a75; /* opaque : lisible sur la scène et les modales */
  z-index: 20;
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  width: max-content;
  max-width: min(420px, calc(100% - 32px));
  padding: 12px 18px;
  line-height: 1.45;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 20px);
  transition: opacity .25s, transform .25s;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; cursor: pointer; }
/* Explication : icône et titre au-dessus du texte */
#toast.info { display: grid; justify-items: center; gap: 4px; padding: 14px 20px; }
#toast .toast-icon { width: 36px; height: 36px; object-fit: contain; image-rendering: pixelated; }
#toast .toast-title { font-size: 1.1rem; color: var(--gold); }

/* Création du personnage : l'aperçu reste visible pendant qu'on fait défiler les réglages */
.creator .preview {
  position: sticky;
  top: calc(64px + env(safe-area-inset-top));
  z-index: 2;
  display: grid;
  place-items: center;
  padding: 8px;
  background: #3b4b8c; /* opaque : les réglages défilent dessous */
}
.creator .preview canvas { width: 260px; height: 170px; }
.creator .card:last-child { display: grid; gap: 12px; }
.creator .seg { margin: 0; }

.stepper { display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; gap: 8px; text-align: center; }
.stepper button { height: 48px; }
.stepper img { width: 32px; height: 32px; }

/* Onglets de couleur : icônes du jeu, teintées avec la couleur choisie (masque + multiply) */
.tabs { display: flex; justify-content: space-between; gap: 4px; }
.tabs button { position: relative; width: 48px; height: 48px; padding: 0; }
.tabs img, .tabs i { position: absolute; inset: 0; margin: auto; width: 30px; height: 30px; }
.tabs i {
  -webkit-mask: center / contain no-repeat; /* image posée par js/creator.js */
  mask: center / contain no-repeat;
  mix-blend-mode: multiply;
}
.target-label { margin: 0; text-align: center; }

/* Curseurs du jeu : barre bordée de noir (teinte = Hue.png), poignée ColorSlider.png.
   --h, --s, --l sont posés par js/creator.js pour colorer les barres saturation et luminosité. */
input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 44px;
  padding: 0;
  border: 0;
  background: none;
}
/* Hue.png a déjà son cadre (noir puis blanc) : les barres dégradées reprennent le même cadre en ombres internes */
input[type=range]::-webkit-slider-runnable-track { height: 16px; border-radius: 3px; background: var(--track); box-shadow: var(--frame, none); }
input[type=range]::-moz-range-track { height: 16px; border-radius: 3px; background: var(--track); box-shadow: var(--frame, none); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 11px; height: 25px; margin-top: -4.5px; border: 0; background: url("../assets/ui/ColorSlider.png"); }
input[type=range]::-moz-range-thumb { width: 11px; height: 25px; border: 0; border-radius: 0; background: url("../assets/ui/ColorSlider.png"); }
#c-h { --track: url("../assets/ui/Hue.png") 0 0 / 100% 100%; }
#c-s, #c-l { --frame: inset 0 0 0 2px #000, inset 0 0 0 4px #fff; }
#c-s { --track: linear-gradient(90deg, hsl(var(--h) 0% var(--l)), hsl(var(--h) 100% var(--l))); }
#c-l { --track: linear-gradient(90deg, #000, hsl(var(--h) var(--s) 50%), #fff); }

/* --- Barre d'onglets du bas : posée sur sa propre bande d'herbe et de terre, opaque,
   pour que le contenu qui défile dessous ne se voie jamais à travers --- */
#tabs {
  position: fixed;
  inset: auto 0 0;
  z-index: 6;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  /* Pleine largeur pour le fond ; boutons centrés sur 480 px max */
  padding: 30px max(8px, calc((100% - 464px) / 2)) calc(6px + env(safe-area-inset-bottom));
  /* Couleur terre seulement sous l'herbe (au-delà des 96 px de l'image, ex. encoche iPhone) :
     les brins d'herbe gardent le ciel en fond */
  background: url("../assets/ui/ground.png") repeat-x 0 0 / 96px 96px,
              linear-gradient(transparent 40px, #8b5a3c 40px);
}
#tabs button {
  display: grid;
  justify-items: center;
  gap: 2px;
  min-height: 60px;
  padding: 6px 0 4px;
  border: 2px solid transparent;
  border-image: var(--tab) 8 fill / 16px;
  background: var(--slot) padding-box;
  border-radius: 8px;
  font-size: .75rem;
  cursor: pointer;
}
#tabs button.on { border-image-source: var(--tab-on); color: var(--gold); }
#tabs img { height: 28px; width: auto; }
/* Marchand : sa tête (1re image de la planche NPC_17, 40×56, réduite de moitié) */
.tab-npc { display: block; width: 20px; height: 28px; background: url("../assets/ui/npc/NPC_17.png") 0 0 / 20px auto no-repeat; image-rendering: pixelated; }

/* --- Écran des caisses --- */
.hud-row { display: flex; justify-content: space-between; align-items: center; font-size: 1.2rem; }
.coins { display: flex; align-items: center; gap: 8px; color: var(--gold); }
.coins img { height: 22px; }
.xpbar { position: relative; height: 20px; margin-top: 8px; border-radius: 4px; background: #111a40; box-shadow: inset 0 0 0 2px #000; overflow: hidden; }
.xpbar i { position: absolute; inset: 2px auto 2px 2px; max-width: calc(100% - 4px); background: linear-gradient(#7cf35a, #2f9e2f); transition: width .7s ease-out; }
.xpbar span { position: relative; display: block; font-size: .8rem; line-height: 20px; text-align: center; }

.crate-card { display: grid; grid-template-columns: 64px 1fr auto; align-items: center; gap: 12px; }
.crate-card h3 { margin: 0; }
.crate-card p { margin: 2px 0 0; font-size: .9rem; }
.crate-card .btn { width: auto; min-width: 104px; padding: 0 12px; font-size: 1.1rem; }
.crate-img { width: 64px; height: 64px; object-fit: contain; }
.stock { color: var(--gold); white-space: nowrap; }
.coins small { font-size: .75rem; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 4px 10px; margin: 4px 0 0; font-size: .85rem; }
.chips span { color: var(--c); white-space: nowrap; }
.chips span::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 4px; border: 2px solid #000; border-radius: 2px; background: var(--c); vertical-align: -1px; }

/* --- Collection : une section par pool, cases d'inventaire du jeu --- */
.dex-pool { margin-top: 12px; scroll-margin-top: 76px; /* sous la barre du haut */ }
.dex-pool.complete { box-shadow: inset 0 0 0 2px var(--gold), 0 4px 0 #0005; }
.dex-head { display: flex; align-items: center; gap: 8px; }
.dex-head h3 { flex: 1; margin: 0; }
.dex-crates img { width: 32px; height: 32px; object-fit: contain; }
.dex-count { color: var(--gold); }
.dex-pool .xpbar { height: 10px; margin: 8px 0 10px; }
.dex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); grid-auto-rows: 56px; gap: 4px; }
.dex-slot {
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 6px;
  border: 0;
  border-radius: 6px;
  /* Rareté : halo léger derrière l'objet */
  background:
    radial-gradient(circle closest-side, color-mix(in srgb, var(--rarity, transparent) 55%, transparent), transparent),
    url("../assets/ui/Inventory_Back.png") 0 0 / 100% 100%;
  cursor: pointer;
}
.dex-slot img { max-width: 40px; max-height: 40px; }
.dex-slot.missing img { filter: brightness(0); opacity: .45; }
.dex-slot { position: relative; }
.dex-slot .pts { position: absolute; left: 4px; bottom: 1px; font-size: .7rem; color: var(--gold); }
.equip-grid .dex-slot .pts { top: 2px; bottom: auto; }
.dex-slot.sel { box-shadow: inset 0 0 0 2px #fff; }
.pick-info { margin: 0 0 10px; text-align: center; }
.pick-info .up { color: #7cf35a; }
.pick-info .down { color: #ff7070; }
.dex-slot .qty { position: absolute; right: 4px; bottom: 0; font-size: .85rem; }
.dex-slot .stat-tag { position: absolute; left: 3px; top: 1px; font-size: .6rem; color: var(--muted); }
#k-bag-card .hud-row { margin-bottom: 8px; }
#k-sell { width: auto; min-height: 44px; padding: 0 12px; font-size: 1rem; }

/* --- Personnage : avatar habillé, 6 emplacements, sélecteur en <dialog> --- */
.power { margin: 0 0 12px; color: var(--muted); }
.power b { color: var(--gold); }
/* Cellules carrées, comme l'inventaire du jeu ; le nom de l'emplacement est écrit en dessous */
.equip-grid { display: grid; grid-template-columns: repeat(3, 72px); justify-content: center; gap: 26px 12px; margin-bottom: 24px; }
.equip-grid .dex-slot { width: 72px; height: 72px; padding: 8px; overflow: visible; }
.equip-grid .dex-slot img { max-width: 44px; max-height: 44px; }
.equip-grid .dex-slot .slot-name { position: absolute; top: 100%; left: -6px; right: -6px; margin-top: 2px; font-size: .7rem; color: var(--muted); text-align: center; }
.equip-grid .dex-slot small { font-size: .7rem; color: var(--muted); }
.equip-grid .dex-slot.empty { opacity: .7; }
.dex-slot.on { box-shadow: inset 0 0 0 2px var(--gold); }
#h-picker { width: min(420px, calc(100% - 32px)); max-height: 80vh; margin: auto; overflow: auto; color: var(--text); }
#h-picker::backdrop { background: rgba(5, 8, 25, .8); }
#h-picker h3 { margin-top: 0; }
#h-picker .dex-grid { margin-bottom: 12px; }

/* --- Bonus actifs : icônes de buff à côté du niveau, détail au toucher --- */
.level { display: flex; align-items: center; gap: 6px; }
.buffs { display: flex; gap: 2px; }
.buffs button { display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; background: none; cursor: pointer; }
.buffs img { width: 24px; height: 24px; }

/* --- Écran Pêche : canne (bouton pour en changer), appâts, tuiles de poissons 3 par ligne --- */
/* Canne : dans une cellule d'inventaire du jeu, comme un objet qu'on peut remplacer */
.rod-btn { display: grid; place-items: center; width: 64px; height: 64px; padding: 0; border: 0; border-radius: 6px; background: url("../assets/ui/Inventory_Back.png") 0 0 / 100% 100%; cursor: pointer; }
.rod-btn img { max-width: 44px; max-height: 44px; }
#p-bait-card .hud-row { margin-bottom: 8px; font-size: 1rem; }
#p-bait-card .muted { margin: 0; font-size: .85rem; }
#p-rods { width: min(420px, calc(100% - 32px)); margin: auto; color: var(--text); }
#p-rods::backdrop { background: rgba(5, 8, 25, .8); }
#p-rods h3 { margin-top: 0; }
#p-rods .dex-grid { margin-bottom: 12px; }
.buffs .left { position: absolute; right: 0; bottom: -2px; font-size: .65rem; }
.buffs button { position: relative; }
#p-sell-card { padding: 8px 12px; }
.bag-count small { display: block; font-size: .75rem; }
#p-sell-all { width: auto; min-height: 44px; padding: 0 12px; font-size: 1rem; }
/* Marchand : deux PNJ du jeu côte à côte (1re image 40×56 de leur planche, ×2), le Pêcheur tourné vers la droite,
   le Marchand vers la gauche ; celui qu'on a choisi est doré, son stock en dessous */
.npcs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.npcs button {
  display: grid; justify-items: center; gap: 4px; padding: 8px 4px;
  border: 2px solid transparent; border-radius: 8px; border-image: var(--tab) 8 fill / 16px; background: var(--slot) padding-box;
  color: var(--text); font: inherit; cursor: pointer;
}
.npcs button.on { border-image-source: var(--tab-on); color: var(--gold); }
.npcs button:not(.on) .npc { filter: grayscale(.6) brightness(.8); }
.npc { display: block; width: 80px; height: 112px; background: url("../assets/ui/npc/NPC_369.png") 0 0 / 80px auto no-repeat; image-rendering: pixelated; transform: scaleX(-1); }
.npc.merchant-npc { background-image: url("../assets/ui/npc/NPC_17.png"); transform: none; }
.merchant .bubble { margin-bottom: 10px; }
.bubble { padding: 10px 12px; border-radius: 8px; background: #0005; box-shadow: inset 0 0 0 2px #0008; }
.bubble b { color: var(--gold); }
.bubble p { margin: 4px 0 0; font-size: .95rem; line-height: 1.3; }
.merchant .hud-row { margin-bottom: 8px; font-size: 1rem; }
.merchant .hud-row .muted { font-size: .85rem; }
.offer .sub { font-size: .7rem; color: var(--muted); }
.offer.sold > img { opacity: .4; }

/* Poissons : une carte par biome, poissons 3 par ligne ; biome verrouillé grisé */
#p-list { display: grid; gap: 12px; margin-top: 12px; }
#p-list .card { margin: 0; padding: 12px; }
.biome-dex .dex-head { margin-bottom: 10px; }
.biome-dex .dex-head img { width: 32px; height: 32px; object-fit: contain; }
.biome-dex .dex-head b { font-size: .85rem; }
.biome-dex.locked .dex-head img { filter: grayscale(1) brightness(.6); }
.biome-bonus { margin: -4px 0 10px; font-size: .8rem; color: var(--muted); } /* gris tant que le biome n'est pas complet */
.biome-dex.done .biome-bonus { color: var(--gold); }
.biome-dex.done .biome-bonus::before { content: "✓ "; }
.fish-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.fish-tile { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px 8px; border-radius: 8px; background: #0003; box-shadow: inset 0 0 0 2px #0006; text-align: center; }
.fish-tile img { width: 44px; height: 44px; object-fit: contain; }
.fish-tile h3 { margin: 0; height: 2.6em; display: grid; place-items: center; overflow: hidden; font-size: .8rem; line-height: 1.3; color: var(--rarity); }
.fish-tile .qty { position: absolute; top: 4px; right: 6px; font-size: .85rem; color: var(--gold); }
.fish-tile .btn { min-height: 44px; margin-top: auto; padding: 0 4px; font-size: .9rem; gap: 2px; }
.fish-tile .btn img { width: 16px; height: 16px; }
.fish-tile.missing img { filter: brightness(0); opacity: .45; }
.fish-tile.missing h3 { color: var(--muted); }

/* --- Aquarium (js/aquarium.js) : bac en verre du jeu (bord en tuile de verre), eau, sable et décor, poissons et bulles en position absolue --- */
.tank-card .hud-row { margin-bottom: 10px; }
.aq-actions { display: flex; gap: 6px; }
#a-add, #a-feed-all { width: auto; min-height: 44px; padding: 0 12px; font-size: 1rem; }
.tank {
  position: relative; height: 260px; overflow: hidden; image-rendering: pixelated;
  border: 8px solid #8fd3e6; border-image: var(--glass, none) 4 / 8px repeat; border-radius: 4px;
  /* Surface de l'eau (tuile du jeu) sur sa couleur qui fonce vers le fond, et des rayons de lumière qui glissent */
  background: var(--water, none) 0 0 / 32px 32px repeat-x,
              repeating-linear-gradient(100deg, transparent 0 60px, rgb(255 255 255 / .05) 60px 90px),
              linear-gradient(var(--water-color, rgb(40 90 210)), rgb(5 15 60));
  animation: flow 4s linear infinite;
}
.tank-sand {
  position: absolute; inset: auto 0 0; height: 40px;
  background: var(--sand-top, none) 0 0 / 32px 32px repeat-x;
}
.tank .decor { position: absolute; bottom: 28px; }
.tank-empty { position: absolute; inset: 40% 16px auto; margin: 0; text-align: center; text-shadow: 0 2px 0 #000; }
/* Reflets sur la vitre, par-dessus tout ; ne capte pas les clics */
.tank-glass {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(115deg, transparent 18%, rgb(255 255 255 / .13) 19% 23%, transparent 24% 30%, rgb(255 255 255 / .07) 31% 33%, transparent 34%);
}
.swimmer { position: absolute; left: 0; top: 0; cursor: pointer; filter: drop-shadow(0 1px 0 #0006); }
.air-bubble { position: absolute; background: url("../assets/tiles/Bubble.png") 0 0 / 100% 100%; opacity: .8; pointer-events: none; animation: bubble-rise linear forwards; }
@keyframes bubble-rise { 50% { margin-left: 6px; } to { transform: translateY(var(--rise)); margin-left: -4px; opacity: 0; } }

/* Fiches : une par poisson (2 par ligne), puis les places libres */
.aq-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 12px 0 16px; }
.aq-list .card { margin: 0; }
.aq-add { place-content: center; justify-items: center; min-height: 160px; border-style: dashed; opacity: .75; cursor: pointer; }
.hall-card { cursor: default; }
.retired { color: var(--gold); font-weight: normal; }
#a-release-warn { margin: 0 0 8px; }
.aq-add b { font-size: 2.4rem; line-height: 1; color: var(--gold); }
.aq-add:hover, .aq-add:focus-visible { opacity: 1; }
.aq-card { display: grid; justify-items: center; align-content: start; gap: 3px; padding: 8px 6px; color: var(--text); font: inherit; text-align: center; cursor: pointer; min-width: 0; }
.aq-card > img { width: 36px; height: 36px; object-fit: contain; }
.aq-card .aq-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .85rem; }
.aq-card small { font-size: .65rem; }
.aq-card .hearts.small img { width: 8px; height: 8px; }
.aq-card .stats { width: 100%; gap: 3px; }
.aq-card .stat { grid-template-columns: 2.4em 1fr; gap: 4px; font-size: .6rem; }
.aq-card .stat i { height: 6px; }
.aq-card .stat em { display: none; }
/* Places libres : cases d'inventaire vides de 72 px, comme les emplacements vides de l'équipement (nom en dessous) */
/* Barres de stats : nom, barre dorée, valeur */
.stats { display: grid; gap: 4px; }
.stat { display: grid; grid-template-columns: 5.5em 1fr 2em; align-items: center; gap: 6px; font-size: .75rem; text-align: left; }
.stat i { height: 8px; border-radius: 3px; background: #111a40; box-shadow: inset 0 0 0 1px #000; overflow: hidden; }
.stat b { display: block; height: 100%; background: linear-gradient(var(--gold), #c9a514); }
.stat em { font-style: normal; text-align: right; }
#a-fish-dlg, #a-pick-dlg, #a-feed-dlg { width: min(360px, calc(100% - 32px)); margin: auto; color: var(--text); }
#a-fish-dlg::backdrop, #a-pick-dlg::backdrop, #a-feed-dlg::backdrop { background: rgba(5, 8, 25, .8); }
#a-fish-dlg > img { width: 48px; height: 48px; object-fit: contain; margin-top: 8px; }
#a-fish-dlg .stats { margin: 0 0 12px; }
#a-fish-dlg .stat { font-size: .95rem; }
#a-fish-dlg .stat, #a-ghost-dlg .stat { grid-template-columns: 5.5em 1fr auto; } /* « 10 / 15 » : stat / potentiel */
#a-fish-dlg .stat em, #a-ghost-dlg .stat em { white-space: nowrap; }
#a-fish-dlg p { margin: 0 0 12px; }
.rename { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin: 8px 0; }
.rename .btn { width: auto; min-height: 44px; padding: 0 12px; font-size: 1rem; }
#a-pick-dlg h3 { margin-top: 0; }
/* Cœurs du jeu (Heart.png) : pleins jusqu'aux PV, gris au-delà ; petits sur les fiches */
.hearts { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; margin: 4px 0 8px; }
.hearts img { width: 22px; height: 22px; }
.hearts.small { margin: 0; gap: 1px; }
.hearts.small img { width: 12px; height: 12px; }
.hearts img.lost { filter: grayscale(1) brightness(.5); opacity: .5; }
.hungry { color: var(--gold); }
#a-hunger { margin: 0 0 10px; }
#a-feed { margin-bottom: 12px; }
.aq-title small { display: block; font-size: .7rem; }
#a-bait-dlg { width: min(340px, calc(100% - 32px)); margin: auto; }
#a-bait-dlg .dex-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
#a-bait-dlg .dex-slot { width: 72px; height: 72px; }
#a-bait-dlg .dex-slot img { max-width: 44px; max-height: 44px; }
#a-bait-dlg .dex-slot .qty { font-size: 1rem; }
#a-bait-dlg .dex-slot .pts { font-size: .8rem; }
#a-feed-dlg .btn + .btn { margin-top: 8px; }
#a-stock .dex-slot .pts, #a-baits .dex-slot .pts { left: 2px; bottom: 1px; font-size: .65rem; }
/* Tombe (--tomb : assemblée par js/aquarium.js) ×2, dans le bac sur le sable, sur la fiche et dans la fenêtre */
.tomb { display: block; width: 64px; height: 64px; background: var(--tomb, none) 0 0 / 100% 100%; image-rendering: pixelated; }
.tank .tomb { position: absolute; bottom: 30px; z-index: 1; cursor: pointer; } /* devant le décor */
.aq-card.dead { align-content: center; opacity: .85; }
#a-ghosts p { margin: 4px 0 10px; font-size: .85rem; }
.dex-slot.ghost img { opacity: .55; filter: grayscale(1) sepia(1) hue-rotate(170deg) saturate(3) brightness(1.3) drop-shadow(0 0 4px #9cf); animation: haunt 3s ease-in-out infinite; }
@keyframes haunt { 50% { transform: translateY(-3px); opacity: .35; } }
#a-tomb-img { margin: 8px auto 0; }
/* Œuf (js/fishart.js > eggUrl) : sur la fiche, dans la fenêtre et sur le sable du bac, qui se dandine */
.egg-img { width: 36px; height: 48px; image-rendering: pixelated; animation: wobble 2.4s ease-in-out infinite; }
#a-egg-img { margin: 8px auto 0; }
.tank .tomb.egg { width: 36px; height: 48px; background-size: 100% 100%; animation: wobble 2.4s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes wobble { 0%, 70%, 100% { transform: rotate(0); } 78% { transform: rotate(-8deg); } 86% { transform: rotate(7deg); } 94% { transform: rotate(-3deg); } }
/* Reproduction (choix du partenaire), fantôme et mini-jeu de résurrection, visite d'un aquarium */
#a-mate-dlg, #a-ghost-dlg, #r-aq-dlg { width: min(360px, calc(100% - 32px)); margin: auto; }
#r-aq-dlg { width: min(560px, calc(100% - 32px)); }
#a-mate-dlg::backdrop, #a-ghost-dlg::backdrop, #a-revive::backdrop, #r-aq-dlg::backdrop { background: rgba(5, 8, 25, .8); }
#a-mates { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
#a-mates .dex-slot { width: 72px; height: 80px; }
#a-mates .slot-name { max-width: 68px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#a-breed-info { font-size: .85rem; }
#a-breed { margin-bottom: 8px; }
.ghost-img { width: 48px; height: 48px; object-fit: contain; margin-top: 8px; opacity: .6; filter: grayscale(1) sepia(1) hue-rotate(170deg) saturate(3) brightness(1.3) drop-shadow(0 0 4px #9cf); }
#a-ghost-dlg .stats { margin: 0 0 12px; text-align: left; }
.revive { width: min(400px, calc(100% - 16px)); margin: auto; padding: 8px; }
.revive canvas { display: block; box-sizing: border-box; width: 100%; aspect-ratio: 3 / 4; image-rendering: pixelated; touch-action: none; cursor: pointer;
  border: 8px solid #8fd3e6; border-image: var(--glass, none) 4 / 8px repeat; border-radius: 4px; } /* vitre de l'aquarium */
.revive-msg { position: absolute; inset: 30% 28px auto; margin: 0; padding: 14px 16px; border-radius: 8px; background: rgb(10 18 50 / .8); text-align: center; line-height: 1.45; text-shadow: 0 2px 0 #000; pointer-events: none; }
.revive-msg b { display: block; margin-bottom: 6px; font-size: 1.3rem; color: var(--gold); }
.revive-msg i { display: block; margin-top: 10px; font-style: normal; color: var(--gold); animation: pulse .8s infinite alternate; }
.revive-win { position: absolute; inset: 8px; display: grid; place-items: center; overflow: hidden; border-radius: 4px; background: radial-gradient(circle, rgb(255 250 210 / .55), rgb(10 18 50 / .85) 65%); pointer-events: none; animation: flash .7s ease-out reverse; }
.revive-win > * { grid-area: 1 / 1; }
.revive-win .rays { width: 440px; height: 440px; border-radius: 50%; background: repeating-conic-gradient(var(--gold) 0 7deg, transparent 7deg 22deg); -webkit-mask: radial-gradient(circle, #000 15%, transparent 68%); mask: radial-gradient(circle, #000 15%, transparent 68%); opacity: .5; animation: spin 6s linear infinite; }
.revive-win .fx { position: relative; width: 0; height: 0; }
.revive-win .fx i { position: absolute; width: 6px; height: 6px; margin: -3px; background: var(--gold); box-shadow: 0 0 8px var(--gold); animation: fly 1.1s ease-out forwards; }
.revive-win img { width: 96px; height: 96px; object-fit: contain; image-rendering: pixelated; filter: drop-shadow(0 0 12px var(--gold)); animation: revive-in .9s ease-out; }
.revive-win p { align-self: end; margin: 0 0 22%; font-size: 1.6rem; color: var(--gold); text-shadow: 0 2px 0 #000; }
@keyframes revive-in { from { transform: scale(.3); opacity: 0; filter: grayscale(1) brightness(2); } }
#r-visit { margin-top: 12px; }

/* --- Courses : prochaine course, volets Participer / Parier, historique ; plein écran : couloirs d'eau, podium --- */
.race-head { display: flex; align-items: center; gap: 12px; }
.race-head img { width: 40px; height: 40px; image-rendering: pixelated; animation: tick-tock 1s steps(2) infinite; }
@keyframes tick-tock { 50% { transform: rotate(-8deg); } }
.race-head h2 { margin: 0; color: var(--gold); font-size: 1.4rem; }
.race-head p { margin: 2px 0 0; font-size: .85rem; }
.race-clock { margin: 10px 0; text-align: center; font-size: 2rem; color: var(--text); text-shadow: 0 2px 0 #000; }
.race-clock small { display: block; font-size: .8rem; color: var(--muted); text-shadow: none; }
.race-pots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; text-align: center; }
.race-pots span { display: grid; padding: 6px 2px; border-radius: 6px; background: #0003; }
.race-pots b { font-size: 1.1rem; color: var(--gold); }
.race-pots small { font-size: .65rem; color: var(--muted); }
.race-mode { margin: 12px 0; }
#rc-last h3 { margin: 0 0 10px; }
.race-mode img { width: 22px; height: 22px; object-fit: contain; }
.race-hint { margin: 0 0 10px; font-size: .85rem; color: var(--muted); }
/* Participer : une ligne par poisson vivant, bouton d'inscription ou « Inscrit » */
.race-mine { display: grid; gap: 6px; }
.race-mine.closed { opacity: .5; }
.race-fish, .race-entry, .race-row {
  display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 8px; padding: 6px 8px;
  border: 2px solid #000; border-radius: 6px; background: #1b2457; color: var(--text); font: inherit; text-align: left;
}
.race-fish > img, .race-entry > img, .race-row > img { width: 32px; height: 32px; object-fit: contain; }
.race-fish .who, .race-entry .who, .race-row .who { display: grid; min-width: 0; }
.race-fish .who b { color: var(--rarity); }
.race-fish small, .race-entry .who small, .race-row small { font-size: .68rem; }
.race-fish .btn { width: auto; min-height: 40px; padding: 0 10px; font-size: .95rem; }
.race-fish.joined { box-shadow: inset 0 0 0 2px var(--gold); }
.race-ok { color: var(--gold); font-size: .9rem; }
/* Parier : partants, cote du moment */
.race-entries { display: grid; gap: 6px; }
.race-entry { cursor: pointer; }
.race-entry.mine { box-shadow: inset 0 0 0 2px #5a7cff; }
.race-entry.bet { box-shadow: inset 0 0 0 2px var(--gold); }
.race-entry .odds { display: grid; justify-items: end; font-size: 1.1rem; color: var(--gold); }
.race-entry .odds small { font-size: .65rem; color: var(--text); }
/* Historique */
.race-history { display: grid; gap: 6px; }
.race-row { cursor: pointer; width: 100%; }
.race-place { font-size: 1.1rem; color: var(--gold); }

/* Plein écran */
.race-show {
  width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 16px 12px calc(16px + env(safe-area-inset-bottom));
  border: 0; overflow-y: auto; color: var(--text);
  background: radial-gradient(circle at 50% 0, #34479a, #0d1336 70%);
}
.race-show::backdrop { background: #0d1336; }
.race-show h2 { margin: 4px 40px 12px; text-align: center; color: var(--gold); font-size: 1.2rem; }
.race-show .dlg-x { position: absolute; top: 12px; right: 12px; }
.race-show.done .dlg-x { display: none; }
.race-stage { position: relative; max-width: 720px; margin: 0 auto; }
/* Mini-carte : la course entière sur une barre, un point par poisson affiché (doré : le sien) */
.race-map { position: relative; height: 14px; margin: 0 6px 8px; border-radius: 7px; background: #0006; box-shadow: inset 0 0 0 2px #000; }
.race-map::after { content: ""; position: absolute; top: 2px; bottom: 2px; right: 2px; width: 6px; background: repeating-linear-gradient(#fff 0 2px, #000 2px 4px); }
.race-map i { position: absolute; top: 3px; width: 8px; height: 8px; margin-left: -4px; border-radius: 50%; background: #9fc3ff; box-shadow: 0 0 0 1px #000; transition: left .1s linear; }
.race-map i.focus { z-index: 1; background: var(--gold); width: 10px; height: 10px; top: 2px; }
/* Scène sous l'eau : le monde fait trois écrans de long, la caméra le fait glisser (js/races.js) */
.race-scene { position: relative; overflow: hidden; border: 2px solid #000; border-radius: 8px;
  background: linear-gradient(color-mix(in srgb, var(--sea, #1d5fc0) 75%, #fff), var(--sea, #1d5fc0) 35%, #06173d); }
.race-world { position: absolute; inset: 0 auto 0 0; will-change: transform; }
.race-surface { position: absolute; inset: 0 0 auto; height: 16px; background: var(--surface) var(--cam, 0) 0 / 32px 32px repeat-x; image-rendering: pixelated; opacity: .9; }
.race-rays { position: absolute; inset: 0; pointer-events: none; mix-blend-mode: screen; animation: shimmer 4s ease-in-out infinite;
  background: repeating-linear-gradient(105deg, transparent 0 60px, #fff1 60px 90px, transparent 90px 180px) var(--cam, 0) 0; }
@keyframes shimmer { 50% { opacity: .5; } }
.race-sand { position: absolute; inset: auto 0 0; height: 44px; background: var(--sand-top) 0 0 / 32px 32px repeat-x; image-rendering: pixelated; }
.race-sand::after, .tank-sand::after { content: ""; position: absolute; inset: 32px 0 0; background: #c9a764 var(--sand, none) 0 0 / 32px 32px; image-rendering: pixelated; }
.race-decor { position: absolute; bottom: 28px; image-rendering: pixelated; }
.race-mark { position: absolute; top: 18px; bottom: 44px; border-left: 2px dashed #fff5; padding-left: 4px; font-size: .6rem; color: #fffa; }
.race-start { position: absolute; top: 16px; bottom: 44px; width: 4px; background: #fff8; }
.race-finish { position: absolute; top: 16px; bottom: 44px; width: 16px; border: 2px solid #000; background: repeating-conic-gradient(#fff 0 25%, #000 0 50%) 0 0 / 12px 12px; }
.race-finish::before { content: "ARRIVÉE"; position: absolute; top: 4px; left: 50%; writing-mode: vertical-rl; transform: translateX(-50%) rotate(180deg);
  padding: 4px 1px; background: #c0392b; color: #fff; font-size: .55rem; border: 1px solid #000; }
/* Couloir : une ligne de flotteurs, le poisson et son étiquette (place, nom) qui le suivent */
.lane { position: absolute; left: 0; right: 0; height: 38px; border-bottom: 2px dotted #ffffff30; }
.lane.focus { background: linear-gradient(90deg, #ffd34d00, #ffd34d22, #ffd34d00); }
.runner { position: absolute; left: 0; bottom: 3px; z-index: 1; width: 30px; height: 30px; object-fit: contain; filter: drop-shadow(0 2px 0 #0008); }
.lane.focus .runner { filter: drop-shadow(0 0 4px var(--gold)); }
.runner-tag { position: absolute; left: 0; top: -3px; z-index: 2; font-size: .58rem; color: #fff; text-shadow: 1px 1px 0 #000; white-space: nowrap; pointer-events: none; }
.runner-tag b { color: var(--gold); }
.lane.focus .runner-tag { color: var(--gold); }
.wake { position: absolute; bottom: 14px; width: 10px; height: 10px; background: url("../assets/tiles/Bubble.png") 0 0 / 100% 100%; image-rendering: pixelated; animation: wake 1s ease-out forwards; pointer-events: none; }
@keyframes wake { to { transform: translate(-26px, -14px) scale(.5); opacity: 0; } }
/* Incidents : « Crampe ! » en rouge, « Élan ! » en vert, qui montent et s'effacent */
.race-event { position: absolute; top: -6px; z-index: 3; padding: 1px 5px; border: 1px solid #000; border-radius: 6px; background: #c0392b; color: #fff;
  font-size: .6rem; white-space: nowrap; pointer-events: none; animation: event 1.4s ease-out forwards; }
.race-event.boost { background: #2f9e2f; }
@keyframes event { 0% { transform: translateY(6px) scale(.6); opacity: 0; } 20% { transform: none; opacity: 1; } 100% { transform: translateY(-14px); opacity: 0; } }
/* Décompte 3, 2, 1, Partez ! */
.race-go { position: absolute; inset: 0; display: grid; place-items: center; z-index: 3; pointer-events: none; opacity: 0;
  font-size: 4rem; color: var(--gold); text-shadow: 0 4px 0 #000, 0 0 16px #000; }
.race-go.on { animation: pop .7s ease-out; }
@keyframes pop { 0% { opacity: 0; transform: scale(2.4); } 30% { opacity: 1; transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: scale(.8); } }
#rs-ahead { margin: 10px 0; font-size: .95rem; }
/* Podium : 2e, 1er, 3e ; les marches montent, le vainqueur brille */
.podium { display: grid; grid-template-columns: repeat(3, 1fr); align-items: end; gap: 8px; max-width: 420px; margin: 8px auto 12px; text-align: center; }
.podium-step { display: grid; justify-items: center; gap: 2px; animation: drop .6s ease-out backwards; }
.podium-step.p1 { animation-delay: .5s; }
.podium-step.p2 { animation-delay: .25s; }
.podium-step > img { width: 44px; height: 44px; object-fit: contain; transform: rotate(45deg); }
.podium-step.p1 > img { width: 56px; height: 56px; filter: drop-shadow(0 0 8px #ffd34d); animation: podium-bob 1.4s ease-in-out infinite; }
@keyframes podium-bob { 50% { transform: translateY(-4px); } } /* même rendu qu'avant : le nom en double faisait déjà gagner celui du bouchon */
.podium-step b { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .85rem; }
.podium-step small { font-size: .65rem; color: var(--muted); }
.podium-block { display: grid; align-content: start; justify-items: center; gap: 4px; width: 100%; padding-top: 6px; border: 2px solid #000; border-radius: 6px 6px 0 0;
  box-shadow: inset 0 3px 0 #fff6; animation: podium-rise .6s ease-out backwards; transform-origin: bottom; }
.podium-block span { font-size: 1.6rem; color: #000a; text-shadow: 0 1px 0 #fff8; }
.podium-block em { display: flex; align-items: center; gap: 3px; font-style: normal; font-size: .85rem; color: #fff;
  text-shadow: 1px 0 #000, -1px 0 #000, 0 1px #000, 0 -1px #000, 1px 1px #000; }
.podium-block em img { width: 14px; height: 14px; }
.p1 .podium-block { height: 108px; background: linear-gradient(#ffe680, #d9a400); }
.p2 .podium-block { height: 88px; background: linear-gradient(#f0f0f0, #9aa3b5); }
.p3 .podium-block { height: 76px; background: linear-gradient(#f0b27a, #a8642b); }
@keyframes podium-rise { from { transform: scaleY(0); } }
@keyframes drop { from { opacity: 0; transform: translateY(-40px); } }
.race-results { list-style: none; max-width: 420px; margin: 0 auto 10px; padding: 0; display: grid; gap: 4px; }
.race-results li { display: grid; grid-template-columns: 36px 28px 1fr; align-items: center; gap: 8px; color: var(--gold); }
.race-results li > img { width: 28px; height: 28px; object-fit: contain; }
#rs-gains { margin: 0 0 12px; }
.race-show-actions { display: flex; justify-content: center; gap: 8px; }
.race-show-actions .btn { width: auto; min-width: 140px; }
/* Confettis à l'arrivée */
.confetti { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
.confetti i { position: absolute; top: -12px; width: 8px; height: 12px; background: var(--c); animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); } }
#rc-bet-dlg { width: min(360px, calc(100% - 32px)); margin: auto; color: var(--text); }
#rc-bet-dlg::backdrop { background: rgba(5, 8, 25, .8); }
#rc-bet-dlg > img { width: 48px; height: 48px; object-fit: contain; margin-top: 8px; }
#rc-bet-dlg .stepper { margin: 8px 0; font-size: 1.2rem; }
#rc-bet-range { width: 100%; --frame: inset 0 0 0 2px #000; }

/* --- Bandeau d'installation (mobile) et tutoriel --- */
#install-bar {
  position: fixed; inset: auto 8px calc(110px + env(safe-area-inset-bottom)); z-index: 7;
  display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 14px;
  border: 2px solid #000; border-radius: 8px; background: var(--panel); box-shadow: 0 4px 0 #0005; font-size: .95rem;
}
#install-bar[hidden] { display: none; }
#install-bar span { flex: 1; }
#install-bar .btn { width: auto; min-height: 44px; padding: 0 12px; font-size: 1rem; }
#install-bar .icon { min-width: 44px; min-height: 44px; border: 0; background: none; color: var(--text); font-size: 1.1rem; cursor: pointer; }
#tuto { width: min(440px, calc(100% - 32px)); max-height: calc(100% - 32px); margin: auto; overflow-y: auto; color: var(--text); }
#tuto::backdrop { background: rgba(5, 8, 25, .85); }
#tuto h2 { margin-top: 0; text-align: center; color: var(--gold); }
.tuto-steps { display: grid; gap: 10px; margin: 0 0 12px; padding: 0; list-style: none; counter-reset: s; }
.tuto-steps li { display: grid; grid-template-columns: 36px 1fr; align-items: center; gap: 10px; }
.tuto-steps img { width: 32px; height: 32px; object-fit: contain; }
.tuto-steps b { color: var(--gold); }
.tuto-steps li > span:last-child { font-size: .9rem; line-height: 1.35; }
.tuto-npc { margin: 0 auto; }

/* --- Choix d'un bonus de niveau --- */
#k-bonus { width: min(420px, calc(100% - 32px)); margin: auto; color: var(--text); }
#k-bonus::backdrop { background: rgba(5, 8, 25, .85); }
#k-bonus h3 { margin: 0; color: var(--gold); font-size: 1.6rem; text-align: center; }
#k-bonus p { text-align: center; }
#k-bonus-list { display: grid; gap: 8px; }
.btn.bonus { display: grid; grid-template-columns: 40px 1fr; gap: 10px; min-height: 64px; padding: 8px 12px; text-align: left; }
.btn.bonus img { width: 36px; height: 36px; object-fit: contain; }
.btn.bonus b { display: block; color: var(--gold); }
.btn.bonus small { display: block; font-size: .8rem; color: var(--text); }

/* --- Classement --- */
.rank-list { list-style: none; margin: 8px 0 0; padding: 0; }
.rank-row { display: grid; grid-template-columns: 32px 66px 1fr auto; align-items: center; gap: 10px; padding: 4px 6px; border-radius: 6px; }
.rank-row:nth-child(odd) { background: rgba(0, 0, 0, .15); }
.rank-row { cursor: pointer; }
.rank-row.me { box-shadow: inset 0 0 0 2px var(--gold); }
.rank-row .rank { text-align: center; }
.rank-row:nth-child(1) .rank { color: var(--gold); }
.rank-row canvas { width: 66px; height: 51px; image-rendering: pixelated; }
.rank-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-row .score { color: var(--gold); }

/* --- Ouverture : plein écran, caisse au centre --- */
#opening {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-rows: 1fr auto;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
  background: rgba(5, 8, 25, .94);
}
#opening .stage { position: relative; display: grid; place-items: center; }
#opening .glow {
  position: absolute;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--glow) 0%, transparent 60%);
  opacity: .4;
  transition: background .15s, transform .2s, opacity .2s;
}
#opening .crate { width: 128px; height: 128px; object-fit: contain; }
#opening .reveal { position: relative; text-align: center; }
#opening .loot { width: 96px; height: 96px; object-fit: contain; }
#opening .loot-name { margin: 12px 0 4px; font-size: 1.8rem; }
#opening .loot-sub { margin: 0; color: var(--muted); }
#opening .actions { max-width: 448px; width: 100%; margin: 0 auto; }

/* Effets qui montent en puissance avec la rareté (data-tier : 1 commun → 4 légendaire) */
#opening .fx, #opening .rays, #opening .flash { position: absolute; pointer-events: none; }
#opening .fx { inset: 50% auto auto 50%; }
#opening .fx i {
  position: absolute;
  width: 6px;
  height: 6px;
  margin: -3px;
  background: var(--glow);
  box-shadow: 0 0 8px var(--glow);
  animation: fly .9s ease-out forwards;
}
#opening .rays {
  width: 440px;
  height: 440px;
  border-radius: 50%;
  background: repeating-conic-gradient(var(--glow) 0 7deg, transparent 7deg 22deg);
  -webkit-mask: radial-gradient(circle, #000 15%, transparent 68%);
  mask: radial-gradient(circle, #000 15%, transparent 68%);
  opacity: 0;
  transition: opacity .4s;
}
#opening .flash { inset: 0; background: #fff; opacity: 0; }
#opening.flash-on .flash { animation: flash .7s ease-out; }
#opening.quake .stage { animation: quake .5s; }
#opening[data-tier="2"].revealed .rays { opacity: .2; animation: spin 14s linear infinite; }
#opening[data-tier="3"].revealed .rays { opacity: .4; animation: spin 8s linear infinite; }
#opening[data-tier="4"].revealed .rays { opacity: .6; animation: spin 5s linear infinite, rainbow 2s linear infinite; }
#opening[data-tier="3"] .glow, #opening[data-tier="4"] .glow { width: 320px; height: 320px; }
#opening[data-tier="3"].revealed .loot, #opening[data-tier="4"].revealed .loot { width: 128px; height: 128px; filter: drop-shadow(0 0 10px var(--glow)); }
#opening[data-tier="4"].revealed .loot-name { animation: rainbow 2s linear infinite; }
@keyframes fly { from { transform: translate(0, 0) scale(1.4); opacity: 1; } to { transform: translate(var(--dx), var(--dy)) scale(.3); opacity: 0; } }
@keyframes flash { from { opacity: .9; } to { opacity: 0; } }
@keyframes quake { 20%, 60% { transform: translate(-6px, 3px); } 40%, 80% { transform: translate(6px, -3px); } }
@keyframes rainbow { to { filter: hue-rotate(360deg); } }

#opening.shaking .crate { animation: shake .12s infinite; }
#opening.shaking .glow { animation: pulse .5s infinite alternate; }
#opening.tease .glow { transform: scale(1.35); opacity: .9; }
#opening.burst .crate { transform: scale(1.6); opacity: 0; transition: transform .25s, opacity .25s; }
#opening.burst .glow { transform: scale(1.6); opacity: .9; }
#opening.silhouette .loot { filter: brightness(0) drop-shadow(0 0 6px var(--glow)); }
#opening.silhouette .loot-name, #opening.silhouette .loot-sub { visibility: hidden; }
#opening.revealed .reveal { animation: pop-in .35s ease-out; }
#opening.revealed .glow { opacity: .55; animation: spin 6s linear infinite; }
@keyframes shake { 25% { transform: translate(calc(var(--amp) * -1), 1px) rotate(-3deg); } 75% { transform: translate(var(--amp), -1px) rotate(3deg); } }
@keyframes pulse { to { transform: scale(1.15); opacity: .8; } }
@keyframes pop-in { from { transform: scale(.4); } 70% { transform: scale(1.15); } }
@keyframes spin { to { transform: rotate(360deg) scale(1.1); } }

/* --- Pêche : scène du biome (js/fishing.js). Coordonnées fixes en px depuis le coin haut-gauche :
   le personnage (canevas ×2) se tient sur le sol à gauche, le fil va de la pointe de sa canne au bouchon (250, 154) --- */
.scene-card { padding: 10px; }
/* Bande de biomes : défile sans barre (flèches du jeu de part et d'autre, js/fishing.js) */
.biomes { display: grid; grid-template-columns: 28px 1fr 28px; align-items: center; gap: 4px; margin-bottom: 10px; }
.biome-nav { display: grid; place-items: center; height: 48px; padding: 0; border: 0; background: none; cursor: pointer; }
.biome-nav img { width: 24px; height: 24px; }
.biome-nav:disabled { opacity: .3; cursor: default; }
.biome-list { position: relative; display: flex; gap: 6px; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; }
.biome-list::-webkit-scrollbar { display: none; }
.biome-list button {
  scroll-snap-align: start;
  display: grid; justify-items: center; gap: 2px; flex: 0 0 64px; min-height: 48px; padding: 3px 2px;
  /* Même onglet du jeu que les autres boutons (doré quand c'est le biome choisi) */
  border: 2px solid transparent; border-radius: 8px; border-image: var(--tab) 8 fill / 16px; background: var(--slot) padding-box;
  color: var(--text); font-size: .7rem; cursor: pointer;
}
.biome-list button img { width: 22px; height: 22px; object-fit: contain; }
.biome-list button.on, .biome-list button:hover { border-image-source: var(--tab-on); color: var(--gold); }
.biome-list button.locked { opacity: .55; }
.biome-list button.locked img { filter: grayscale(1); }
#fishing { margin-top: 12px; }
.pond, .fish-actions { text-align: center; }
.fish-head { position: absolute; inset: 8px 8px auto; z-index: 3; text-shadow: 0 2px 0 #000, 0 0 4px #000; pointer-events: none; }
.fish-msg { margin: 0; font-size: 1.4rem; }
.fish-sub { margin: 2px 0 0; font-size: 1rem; }
#fishing.bite .fish-msg { color: var(--gold); }
.pond { position: relative; height: 240px; overflow: hidden; border: 2px solid #000; border-radius: 6px; image-rendering: pixelated; }
.pond .angler { position: absolute; left: -40px; top: 30px; z-index: 2; width: 176px; height: 136px; }
.pond .line { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.pond .ground {
  position: absolute; left: 0; top: 150px; bottom: 0; z-index: 1; width: 128px;
  /* --ground-top : rangée du haut du sol du biome (x2). Rien derrière : ses brins et creux transparents laissent voir le décor */
  background: var(--ground-top, none) 0 0 / 32px 32px repeat-x;
}
/* --ground : terre en dessous, sur son propre calque (un motif répété remonterait aussi derrière la rangée du haut) */
.pond .ground::after { content: ""; position: absolute; inset: 32px 0 0; background: var(--ground, none) 0 0 / 32px 32px, #5b3a26; }
.pond .bobber, .pond .alert, .pond .fish-crate { position: absolute; z-index: 2; }
/* Bouchon de la canne en bois (Projectile_360), à l'échelle x2 ; le fil arrive sur son sommet (+30, +20) */
.pond .bobber {
  left: 220px;
  top: 134px;
  width: 60px;
  height: 60px;
  animation: bob 1.6s ease-in-out infinite;
}
.pond .alert { left: 256px; top: 96px; font-size: 2.6rem; color: var(--gold); opacity: 0; text-shadow: 0 2px 0 #000; }
.pond .fish-crate { left: 216px; top: 150px; width: 68px; height: 68px; object-fit: contain; opacity: 0; }
.pond .water {
  position: absolute;
  inset: 168px 0 0;
  /* --water : tuile de surface du liquide du biome (js/fishing.js), x2, sur sa couleur qui fonce avec la profondeur */
  background: var(--water, none) 0 0 / 32px 32px repeat-x, linear-gradient(var(--water-color, rgb(40, 90, 210)), rgba(5, 10, 40, .95));
  opacity: .9;
  animation: flow 4s linear infinite;
}
@keyframes flow { to { background-position: 32px 0, 0 0; } }
#fishing.bite .bobber { animation: dip .25s ease-in-out infinite alternate; }
#fishing.bite .alert { opacity: 1; animation: pop-in .25s; }
#fishing.caught .bobber { opacity: 0; }
#fishing.caught .fish-crate { opacity: 1; animation: reel .7s ease-out forwards; }
/* Ferrer / Annuler remplacent la carte Pêcher pendant la partie, au même endroit (en bas, sous le pouce) */
.fish-actions { display: none; gap: 4px; }
#fishing.playing .fish-actions { display: grid; }
#fishing.playing #p-cast { display: none; }
#f-reel { min-height: 64px; font-size: 1.6rem; }
/* Prise : halo de la couleur de rareté, rayons à partir de « rare », flash et tremblement pour le légendaire */
.pond .catch-rays {
  position: absolute; left: 250px; top: 120px; z-index: 1; width: 260px; height: 260px; margin: -130px 0 0 -130px;
  border-radius: 50%; pointer-events: none; opacity: 0;
  background: repeating-conic-gradient(var(--glow) 0 8deg, transparent 8deg 24deg);
  -webkit-mask: radial-gradient(circle, #000 10%, transparent 65%);
  mask: radial-gradient(circle, #000 10%, transparent 65%);
}
#fishing.caught .fish-crate { filter: drop-shadow(0 0 6px var(--glow)); }
#fishing.caught[data-tier="1"] .fish-crate { filter: drop-shadow(0 0 10px var(--glow)); }
#fishing.caught[data-tier="2"] .catch-rays { opacity: .35; animation: spin 8s linear infinite; }
#fishing.caught[data-tier="3"] .catch-rays { opacity: .55; animation: spin 5s linear infinite; }
#fishing.caught[data-tier="4"] .catch-rays { opacity: .75; animation: spin 3s linear infinite, rainbow 2s linear infinite; }
#fishing.caught[data-tier="3"] .fish-crate, #fishing.caught[data-tier="4"] .fish-crate { animation: reel-big .9s ease-out forwards; filter: drop-shadow(0 0 14px var(--glow)); }
#fishing.caught[data-tier="4"] .pond { animation: quake .5s; }
#fishing.caught .fish-head { animation: pop-in .4s ease-out; }
@keyframes reel-big { to { transform: translateY(-80px) scale(2.2); } }
@keyframes bob { 50% { transform: translateY(-4px); } }
@keyframes dip { to { transform: translateY(12px); } }
@keyframes reel { to { transform: translateY(-90px) scale(1.4); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* --- Croix de fermeture des modales (assets/ui/SearchCancel.png, remplacée par ✕ si elle manque : js/app.js) --- */
.dlg-x { position: absolute; top: 10px; right: 10px; display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; background: none; color: var(--text); font-size: 1.2rem; cursor: pointer; }
.dlg-x img { width: 22px; height: 22px; }
.dlg-x:hover, .dlg-x:focus-visible { filter: brightness(1.5); outline: none; }
/* Modales : fond opaque (le panneau du jeu est translucide) et page assombrie derrière */
dialog.card { color: var(--text); background: #2c3a75; }
dialog.card::backdrop { background: rgba(5, 8, 25, .8); }
dialog.card h3 { margin-right: 36px; }

/* --- Fiche d'un appât avant de l'utiliser --- */
#p-bait-dlg, #p-sell-dlg { width: min(360px, calc(100% - 32px)); margin: auto; color: var(--text); }
#p-bait-dlg::backdrop, #p-sell-dlg::backdrop { background: rgba(5, 8, 25, .8); }
#p-bait-dlg > img, #p-sell-dlg > img { width: 48px; height: 48px; object-fit: contain; margin-top: 8px; }
#p-bait-dlg h3, #p-sell-dlg h3 { margin: 8px 36px 4px; }
#p-bait-dlg p, #p-sell-dlg p { margin: 0 0 12px; }
/* Quantité à vendre : flèches du jeu autour du nombre, curseur doré rempli jusqu'à la valeur */
#s-qty .stepper { margin-top: 8px; font-size: 1.2rem; }
#s-range { --frame: inset 0 0 0 2px #000; }

/* Classement Pêche : sous-onglets Découvert / Frigo */
