/* Tamagoblin — interface portrait pour smartphone (référence : iPhone 13 Pro Max, 428 × 926 points CSS).
   Zones de sécurité iOS respectées (encoche, barre d'accueil). Aucun défilement horizontal. */
:root {
  --fond: #1f2b1c;
  --panneau: #f6efe0;
  --encre: #2b2418;
  --encre-douce: #6d604b;
  --vert: #5f9b3f;
  --vert-fonce: #2f4a2a;
  --accent: #e9a23b;
  --bas: #d9534f;
  --moyen: #e9a23b;
  --bon: #5fae4a;
  --rayon: 16px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: var(--fond); color: var(--encre);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

#app {
  position: fixed; inset: 0; height: 100dvh; display: grid; grid-template-rows: auto 1fr auto;
  padding: var(--sat) var(--sar) 0 var(--sal); max-width: 640px; margin: 0 auto;
}

/* ---------------------------------------------------------------- haut : nom, saison, jauges */
.haut { background: var(--vert-fonce); color: #f4f0e2; padding: 6px 10px 8px; }
.titre { display: flex; align-items: center; gap: 8px; }
.nom-bloc { flex: 1; min-width: 0; text-align: center; }
.nom-bloc h1 { margin: 0; font-size: 1.15rem; letter-spacing: .02em; }
.pastille { display: inline-block; margin-top: 2px; font-size: .72rem; padding: 1px 8px; border-radius: 99px;
  background: rgba(255,255,255,.14); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.rond { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: rgba(255,255,255,.12); }
.rond:active { transform: scale(.94); }
.jauges { list-style: none; margin: 8px 0 0; padding: 0; display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.jauges li { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; }
.jauges svg { width: 20px; height: 20px; }
.jauges .barre { width: 100%; height: 7px; border-radius: 99px; background: rgba(255,255,255,.18); overflow: hidden; }
.jauges .barre i { display: block; height: 100%; width: 50%; border-radius: inherit; background: var(--bon); transition: width .6s, background-color .6s; }
.jauges .valeur { font-size: .7rem; line-height: 1; opacity: .9; display: none; }
.jauges[data-mode="chiffres"] .barre { display: none; }
.jauges[data-mode="chiffres"] .valeur { display: block; }
.jauges[data-mode="masquees"] { display: none; }
.jauges li.bas svg { color: #ffb3a8; animation: pouls 1.6s ease-in-out infinite; }
@keyframes pouls { 50% { transform: scale(1.15); } }

/* ---------------------------------------------------------------- scène */
.scene { position: relative; overflow: hidden; background: #6b7a5a; min-height: 200px; }
.scene .decor { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 100%;
  opacity: 0; transition: opacity 700ms ease-in-out; pointer-events: none; }
.scene .decor.visible { opacity: 1; }
.scene .voile, .scene .noemie, .scene .bulle, .scene .zzz, .scene .badge-provisoire { z-index: 3; }
.scene .voile { position: absolute; inset: 0; pointer-events: none; transition: background-color 2s; }
.scene .noemie { position: absolute; display: block; max-width: none; transition: opacity .25s; touch-action: manipulation; }
.badge-provisoire { position: absolute; top: 8px; left: 8px; font-size: .7rem; font-weight: 700; color: #c22;
  background: rgba(255,255,255,.9); border: 2px dashed #d33; border-radius: 8px; padding: 2px 8px; pointer-events: none; }
.bulle { position: absolute; max-width: min(78%, 330px); background: #fff; color: var(--encre); padding: 10px 14px;
  border-radius: 18px; font-size: .95rem; line-height: 1.3; box-shadow: 0 4px 14px rgba(0,0,0,.25); pointer-events: none;
  animation: apparition .25s ease-out; }
.bulle::after { content: ""; position: absolute; left: 50%; bottom: -9px; margin-left: -9px; border: 9px solid transparent;
  border-bottom: 0; border-top-color: #fff; }
@keyframes apparition { from { opacity: 0; transform: translateY(6px) scale(.96); } }
.zzz { position: absolute; right: 18%; top: 24%; color: #fff; font-weight: 700; font-size: 1.6rem; pointer-events: none;
  text-shadow: 0 2px 6px rgba(0,0,0,.5); animation: flotte 3s ease-in-out infinite; }
.zzz span { font-size: .75em; margin-left: 2px; }
@keyframes flotte { 50% { transform: translateY(-10px); opacity: .7; } }
.coeur { position: absolute; font-size: 1.6rem; pointer-events: none; animation: monte 1.2s ease-out forwards; }
@keyframes monte { to { transform: translateY(-70px) scale(1.3); opacity: 0; } }

/* ---------------------------------------------------------------- actions (bas) : UNE ligne compacte */
.actions { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 2px; padding: 4px 4px calc(4px + var(--sab));
  background: var(--panneau); border-top: 1px solid rgba(0,0,0,.08); }
.actions button { position: relative; min-height: 50px; min-width: 0; border-radius: 12px; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-start; gap: 1px; padding: 3px 0 2px; }
.actions button img { width: 100%; max-width: 46px; height: 34px; object-fit: contain; object-position: 50% 100%; pointer-events: none; }
.actions button span { font-size: .6rem; font-weight: 700; line-height: 1.1; color: var(--vert-fonce); white-space: nowrap;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.actions button:active { transform: scale(.94); background: #ebe2cc; }
.actions button.actif { background: #e7f1dc; outline: 2px solid var(--vert); }
.rond.icone-image { background: transparent; padding: 0; }
.rond.icone-image img { width: 40px; height: 40px; object-fit: contain; }
@media (min-width: 420px) { .actions button span { font-size: .64rem; } .actions button img { height: 38px; } }
@media (max-width: 390px) { .actions button span { font-size: .55rem; letter-spacing: -.02em; font-weight: 600; } }
@media (max-width: 340px) { .actions button span { font-size: .5rem; } }

/* avatar saisonnier (vraie Noémie) */
.avatar { width: 40px; height: 40px; border-radius: 12px; flex: none; object-fit: cover; box-shadow: 0 1px 4px rgba(0,0,0,.3); }

/* accès rapide chambre ↔ parc (sur la scène, en haut à droite) */
.bouton-lieu { position: absolute; z-index: 5; top: 8px; right: 8px; min-height: 44px; padding: 4px 12px 4px 8px; border-radius: 99px;
  display: flex; align-items: center; gap: 6px; background: rgba(255,255,255,.88); color: var(--vert-fonce); font-weight: 700;
  font-size: .82rem; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.bouton-lieu .emoji { font-size: 1.3rem; line-height: 1; }
.bouton-lieu:active { transform: scale(.95); }
.bouton-lieu[hidden] { display: none; }

/* balle rebondissante */
.scene .balle { position: absolute; left: 0; top: 0; z-index: 4; touch-action: none; cursor: grab; will-change: transform;
  filter: drop-shadow(0 3px 3px rgba(0,0,0,.35)); }
.scene .balle.tenue { cursor: grabbing; filter: drop-shadow(0 8px 6px rgba(0,0,0,.3)); }

/* glisser-déposer : l'objet suit le doigt, le menu s'efface */
[data-objet] { touch-action: none; }
.fantome { position: fixed; left: 0; top: 0; z-index: 30; width: 64px; height: 64px; display: grid; place-items: center;
  pointer-events: none; filter: drop-shadow(0 6px 8px rgba(0,0,0,.35)); transition: scale .12s; }
.fantome img { width: 64px; height: 64px; object-fit: contain; }
.fantome .emoji { font-size: 2.6rem; }
.fantome.cible { scale: 1.2; }
.feuille.glisse .feuille-contenu, .feuille.glisse .feuille-fond { opacity: .08; transition: opacity .15s; }

/* ---------------------------------------------------------------- feuille (panneau du bas) */
.feuille { position: fixed; inset: 0; z-index: 10; }
.feuille-fond { position: absolute; inset: 0; background: rgba(0,0,0,.35); animation: fondu .2s; }
@keyframes fondu { from { opacity: 0; } }
.feuille-contenu { position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 640px; max-height: 72dvh;
  display: flex; flex-direction: column; background: var(--panneau); border-radius: 22px 22px 0 0;
  padding: 6px 14px calc(14px + var(--sab)); box-shadow: 0 -6px 24px rgba(0,0,0,.25); animation: glisse .22s ease-out; }
@keyframes glisse { from { transform: translateY(40%); opacity: .4; } }
.feuille-contenu > header { display: flex; align-items: center; justify-content: space-between; padding: 6px 0 8px; }
.feuille-contenu h2 { margin: 0; font-size: 1.1rem; color: var(--vert-fonce); }
.feuille-contenu .rond { background: rgba(0,0,0,.06); }
.feuille-corps { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding-bottom: 4px; }
.grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.choix { min-height: 84px; padding: 8px 6px; border-radius: var(--rayon); background: #fff; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px; text-align: center; font-size: .82rem; font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.choix:active { transform: scale(.96); }
.choix .emoji { font-size: 1.9rem; line-height: 1; }
.choix img { width: 40px; height: 40px; object-fit: contain; }
.choix small { font-weight: 400; color: var(--encre-douce); font-size: .7rem; }
.choix[disabled] { opacity: .45; }
.choix.actif { outline: 2px solid var(--vert); background: #eef6e6; }
.choix .apercu-tenue { width: 64px; height: 64px; object-fit: cover; object-position: 50% 0; border-radius: 10px; }
.note { color: var(--encre-douce); font-size: .82rem; margin: 10px 2px 2px; line-height: 1.35; }

/* paramètres */
.reglages { display: flex; flex-direction: column; gap: 4px; }
.reglages h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--encre-douce); margin: 14px 2px 4px; }
.ligne { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #fff; border-radius: 12px;
  padding: 10px 12px; min-height: 48px; font-size: .9rem; }
.ligne.indispo { opacity: .55; }
.ligne input[type=range] { width: 46%; accent-color: var(--vert); }
.ligne select { font: inherit; padding: 6px 8px; border-radius: 8px; border: 1px solid #ccc; background: #fff; max-width: 55%; }
.ligne input[type=checkbox] { width: 24px; height: 24px; accent-color: var(--vert); }
.bouton { background: var(--vert); color: #fff; font-weight: 600; padding: 10px 14px; border-radius: 10px; min-height: 44px; }
.bouton.danger { background: var(--bas); }
.bouton.discret { background: rgba(0,0,0,.08); color: var(--encre); }
.etiquette { font-size: .72rem; font-weight: 700; color: #fff; background: #9b8f78; border-radius: 6px; padding: 2px 6px; }

/* journal */
.journal { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.journal li { background: #fff; border-radius: 12px; padding: 8px 12px; font-size: .88rem; line-height: 1.3; }
.journal time { display: block; font-size: .72rem; color: var(--encre-douce); }

.toast { position: fixed; left: 50%; bottom: calc(90px + var(--sab)); transform: translateX(-50%); z-index: 20;
  background: rgba(30,30,30,.92); color: #fff; padding: 10px 16px; border-radius: 99px; font-size: .88rem;
  max-width: 90vw; text-align: center; animation: apparition .2s; }

@media (min-height: 860px) { .jauges svg { width: 22px; height: 22px; } }
@media (max-width: 350px) { .jauges { gap: 3px; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
