/* ==========================================================
   Grindvie — interface RPG rétro
   Bois sombre, parchemin, filigrane d'or, pixel-art.
   ========================================================== */
:root {
  --wood-950: #140c06;
  --wood-900: #1c120a;
  --wood-800: #2a1b0e;
  --wood-700: #3d2814;
  --wood-600: #573a1e;
  --wood-500: #7a5530;
  --gold-700: #8a5a12;
  --gold-600: #b37a22;
  --gold-500: #d9a441;
  --gold-300: #f0cc7a;
  --gold-100: #fbecc2;
  --parch-50: #fdf7e6;
  --parch-100: #f7ecd0;
  --parch-200: #eedcb0;
  --parch-300: #ddc48c;
  --ink: #2b1c0d;
  --ink-soft: #6a5032;
  --ink-faint: #9a7f5a;
  --sante: #3f7a22;   --sante-bg: #dcebc2;
  --prod: #245d92;    --prod-bg: #d3e2f0;
  --esprit: #6e3d99;  --esprit-bg: #e7d9f2;
  --maison: #a5521c;  --maison-bg: #f5dcc2;
  --danger: #a33a24;
  --ok: #4a8a26;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --corner-tl: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' shape-rendering='crispEdges'%3E%3Cpath fill='%231c120a' d='M0 0h10v3H3v7H0z'/%3E%3Cpath fill='%23e2ad4a' d='M1 1h8v1H2v7H1z'/%3E%3Cpath fill='%23fff0b8' d='M1 1h2v1H1z'/%3E%3Cpath fill='%231c120a' d='M4 4h3v3H4z'/%3E%3Cpath fill='%23e2ad4a' d='M5 5h1v1H5z'/%3E%3C/svg%3E");
  --corner-tr: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' shape-rendering='crispEdges'%3E%3Cg transform='matrix(-1 0 0 1 12 0)'%3E%3Cpath fill='%231c120a' d='M0 0h10v3H3v7H0z'/%3E%3Cpath fill='%23e2ad4a' d='M1 1h8v1H2v7H1z'/%3E%3Cpath fill='%23fff0b8' d='M1 1h2v1H1z'/%3E%3Cpath fill='%231c120a' d='M4 4h3v3H4z'/%3E%3Cpath fill='%23e2ad4a' d='M5 5h1v1H5z'/%3E%3C/g%3E%3C/svg%3E");
  --corner-bl: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' shape-rendering='crispEdges'%3E%3Cg transform='matrix(1 0 0 -1 0 12)'%3E%3Cpath fill='%231c120a' d='M0 0h10v3H3v7H0z'/%3E%3Cpath fill='%23e2ad4a' d='M1 1h8v1H2v7H1z'/%3E%3Cpath fill='%23fff0b8' d='M1 1h2v1H1z'/%3E%3Cpath fill='%231c120a' d='M4 4h3v3H4z'/%3E%3Cpath fill='%23e2ad4a' d='M5 5h1v1H5z'/%3E%3C/g%3E%3C/svg%3E");
  --corner-br: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' shape-rendering='crispEdges'%3E%3Cg transform='matrix(-1 0 0 -1 12 12)'%3E%3Cpath fill='%231c120a' d='M0 0h10v3H3v7H0z'/%3E%3Cpath fill='%23e2ad4a' d='M1 1h8v1H2v7H1z'/%3E%3Cpath fill='%23fff0b8' d='M1 1h2v1H1z'/%3E%3Cpath fill='%231c120a' d='M4 4h3v3H4z'/%3E%3Cpath fill='%23e2ad4a' d='M5 5h1v1H5z'/%3E%3C/g%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Alegreya Sans", "Segoe UI", sans-serif;
  font-size: 16px;
  color: var(--ink);
  background-color: var(--wood-900);
  /* planches de bois de la taverne */
  background-image:
    radial-gradient(120% 60% at 50% 0%, rgba(255, 190, 110, .10), transparent 60%),
    linear-gradient(90deg, rgba(0,0,0,.35) 0 2px, transparent 2px 100%),
    linear-gradient(180deg, #2a1b0e 0%, #21150b 100%);
  background-size: 100% 100%, 92px 100%, 100% 100%;
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
  caret-color: var(--gold-600);
}
::selection { background: var(--gold-300); color: var(--wood-900); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--gold-300); outline-offset: 2px; border-radius: 6px; }
* { scrollbar-width: thin; scrollbar-color: var(--wood-500) var(--wood-900); }
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--wood-900); }
::-webkit-scrollbar-thumb { background: var(--wood-500); border-radius: 8px; border: 2px solid var(--wood-900); }

.ico { width: 1em; height: 1em; display: inline-block; vertical-align: -0.12em; flex-shrink: 0; }

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(86px + var(--safe-b));
}

/* ---------- HUD ---------- */
.hud {
  position: sticky; top: 0; z-index: 8;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  padding: 10px 14px 12px;
  background:
    linear-gradient(180deg, rgba(255,220,150,.08), transparent 40%),
    linear-gradient(180deg, var(--wood-700), var(--wood-800));
  border-bottom: 2px solid var(--gold-600);
  box-shadow: 0 1px 0 var(--wood-950), 0 8px 18px rgba(10, 5, 0, .55);
  color: var(--parch-100);
}
.hud-portrait { position: relative; width: 56px; height: 64px; flex-shrink: 0; }
#hudAvatar {
  width: 56px; height: 64px; object-fit: cover; object-position: 50% 10%;
  image-rendering: pixelated;
  background: radial-gradient(circle at 50% 75%, rgba(240,204,122,.35), transparent 70%), var(--wood-950);
  border: 2px solid var(--gold-500);
  border-radius: 10px;
  box-shadow: 0 0 0 2px var(--wood-950), inset 0 0 10px rgba(0,0,0,.6);
}
.hud-lvl {
  position: absolute; right: -8px; bottom: -6px;
  min-width: 30px; height: 30px; padding: 0 5px;
  display: grid; place-items: center;
  font-family: "Pixelify Sans", monospace; font-weight: 700; font-size: .82rem; line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--wood-900);
  background: linear-gradient(180deg, var(--gold-100), var(--gold-500) 60%, var(--gold-600));
  clip-path: polygon(50% 0, 100% 18%, 100% 62%, 50% 100%, 0 62%, 0 18%);
  filter: drop-shadow(0 2px 0 var(--wood-950));
}
.hud-info { min-width: 0; }
.hud-name {
  display: flex; align-items: center; gap: 6px;
  font-family: "Pixelify Sans", monospace; font-weight: 600; font-size: 1.12rem; line-height: 1.1;
  color: var(--gold-100); text-shadow: 0 2px 0 var(--wood-950);
}
.hud-name > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud-prestige {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 1px 6px; border-radius: 999px; font-size: .7rem;
  background: var(--wood-950); border: 1px solid currentColor;
}
.hud-title { font-size: .82rem; color: var(--parch-300); margin: 1px 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.gauge {
  position: relative; height: 14px; border-radius: 4px;
  background: var(--wood-950);
  border: 1px solid #000a;
  box-shadow: inset 0 2px 3px rgba(0,0,0,.7), 0 1px 0 rgba(255,220,150,.12);
  overflow: hidden;
}
.gauge::after { /* graduations : une par niveau de la tranche */
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), rgba(20,12,6,.55) calc(10% - 1px) 10%);
  pointer-events: none;
}
.gauge-fill {
  height: 100%; width: 0%;
  background: linear-gradient(180deg, #ffe39a, var(--gold-500) 55%, var(--gold-700));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.5);
  transition: width .8s var(--ease-out);
}
.gauge-label {
  position: absolute; inset: 0; z-index: 1; display: grid; place-items: center;
  font-family: "Pixelify Sans", monospace; font-size: .66rem; color: var(--parch-50);
  text-shadow: 0 1px 0 #000, 0 0 3px #000;
}
.gauge.sante .gauge-fill { background: linear-gradient(180deg, #a8dc6c, var(--sante)); }
.gauge.prod .gauge-fill { background: linear-gradient(180deg, #86c2f0, var(--prod)); }
.gauge.esprit .gauge-fill { background: linear-gradient(180deg, #cfa4f0, var(--esprit)); }
.gauge.maison .gauge-fill { background: linear-gradient(180deg, #f2b27a, var(--maison)); }
.gauge.tall { height: 18px; }
.gauge.tall .gauge-label { font-size: .72rem; }

.hud-stats { display: flex; flex-direction: column; gap: 5px; }
.counter {
  display: flex; align-items: center; gap: 5px; justify-content: flex-end;
  padding: 3px 9px 3px 7px; border-radius: 999px;
  background: rgba(10, 5, 0, .45); border: 1px solid rgba(240,204,122,.28);
  font-family: "Pixelify Sans", monospace; font-size: .86rem; font-variant-numeric: tabular-nums;
  color: var(--gold-100);
}
.counter .ico { width: 14px; height: 14px; }
#hudStreakIco { color: #ff9a3a; display: inline-flex; }
#hudTotalIco { color: var(--gold-300); display: inline-flex; }

/* ---------- Vue ---------- */
#view { flex: 1; padding: 16px 12px 10px; display: flex; flex-direction: column; gap: 18px; }

/* Cadre parchemin à coins dorés */
.frame {
  position: relative;
  background:
    radial-gradient(130% 90% at 50% 0%, var(--parch-50) 0%, var(--parch-100) 45%, var(--parch-200) 100%);
  border: 3px solid var(--wood-700);
  border-radius: 8px;
  box-shadow:
    inset 0 0 0 1px var(--gold-600),
    inset 0 0 26px rgba(140, 90, 30, .22),
    0 3px 0 var(--wood-950),
    0 12px 24px rgba(8, 4, 0, .5);
}
.frame::before {
  content: ""; position: absolute; inset: -7px; pointer-events: none; z-index: 2;
  background: var(--corner-tl) top left / 15px no-repeat, var(--corner-tr) top right / 15px no-repeat,
              var(--corner-bl) bottom left / 15px no-repeat, var(--corner-br) bottom right / 15px no-repeat;
  image-rendering: pixelated;
}
.panel { padding: 14px; }
.plank {
  display: flex; align-items: center; gap: 9px;
  margin: -14px -14px 14px; padding: 10px 16px;
  background:
    radial-gradient(circle at 8px 50%, var(--gold-500) 0 2px, var(--wood-950) 2.5px 3px, transparent 3.5px),
    radial-gradient(circle at calc(100% - 8px) 50%, var(--gold-500) 0 2px, var(--wood-950) 2.5px 3px, transparent 3.5px),
    linear-gradient(180deg, var(--wood-600), var(--wood-700) 60%, var(--wood-800));
  border-radius: 5px 5px 0 0;
  border-bottom: 2px solid var(--wood-950);
  box-shadow: inset 0 1px 0 rgba(255,220,150,.2);
  color: var(--gold-100);
  font-family: "Pixelify Sans", monospace; font-weight: 600; font-size: 1rem; letter-spacing: .01em;
  text-shadow: 0 2px 0 var(--wood-950);
}
.plank .ico { width: 18px; height: 18px; color: var(--gold-300); }
.plank .aside { margin-left: auto; font-family: "Alegreya Sans", sans-serif; font-weight: 500; font-size: .8rem; color: var(--parch-300); text-shadow: none; }
.plank .icon-btn { color: var(--gold-300); margin-left: auto; }

.muted { color: var(--ink-soft); }
.help { font-size: .86rem; color: var(--ink-soft); line-height: 1.45; margin: 8px 0 0; }
.help ol { padding-left: 18px; margin: 6px 0; }
.center { text-align: center; }
h2 { font-family: "Pixelify Sans", monospace; font-weight: 600; font-size: 1.3rem; margin: 0 0 12px; color: var(--ink); text-wrap: balance; }

/* ---------- Panorama de la journée ---------- */
.vista {
  position: relative;
  margin: -16px -12px 0;
  border-bottom: 3px solid var(--wood-950);
  box-shadow: inset 0 -2px 0 var(--gold-600);
  overflow: hidden;
  line-height: 0;
}
.vista canvas.scene { width: 100%; height: auto; aspect-ratio: 2 / 1; image-rendering: pixelated; display: block; }
.vista .hero-sprite {
  position: absolute; left: 50%; bottom: 12%;
  width: 34%; height: auto; aspect-ratio: 4 / 5;
  filter: drop-shadow(0 0 1px rgba(20,10,0,.6));
  transform: translateX(-50%);
  image-rendering: pixelated;
  animation: idle 2.4s ease-in-out infinite;
}
@keyframes idle { 50% { transform: translateX(-50%) translateY(-1.5%); } }
.vista-tag {
  position: absolute; left: 12px; top: 12px; line-height: 1.2;
  padding: 5px 10px; border-radius: 6px;
  background: rgba(20, 12, 6, .62); backdrop-filter: blur(3px);
  border: 1px solid rgba(240,204,122,.35);
  color: var(--gold-100); font-family: "Pixelify Sans", monospace; font-size: .8rem;
}

.day-card { margin-top: -34px; z-index: 3; }
.day-date { font-family: "Pixelify Sans", monospace; font-weight: 700; font-size: 1.35rem; text-transform: capitalize; line-height: 1.1; }
.day-msg { margin: 4px 0 12px; color: var(--ink-soft); }
.pips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pip {
  width: 16px; height: 16px;
  background: var(--parch-300);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  box-shadow: inset 0 0 0 2px rgba(90,60,20,.35);
  transition: background .4s var(--ease-out), transform .4s var(--ease-out);
}
.pip.on { background: linear-gradient(135deg, var(--gold-100), var(--gold-500) 50%, var(--gold-700)); transform: scale(1.12); }
.pips-count { margin-left: 4px; font-family: "Pixelify Sans", monospace; font-size: .95rem; font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.ribbon {
  position: relative; margin: 14px -22px -4px; padding: 9px 16px; text-align: center;
  font-family: "Pixelify Sans", monospace; font-weight: 600; color: #4a2c04;
  background: linear-gradient(180deg, #ffe9a6, var(--gold-500));
  border-top: 2px solid var(--gold-700); border-bottom: 2px solid var(--gold-700);
  box-shadow: 0 3px 0 rgba(60,30,0,.25);
}
.ribbon::before, .ribbon::after {
  content: ""; position: absolute; bottom: -10px; width: 12px; height: 10px; background: var(--gold-700);
}
.ribbon::before { left: 0; clip-path: polygon(0 0, 100% 0, 100% 100%); }
.ribbon::after { right: 0; clip-path: polygon(0 0, 100% 0, 0 100%); }
.ribbon .ico { color: #7a4a06; }

/* ---------- Quêtes ---------- */
.quest-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.quest {
  display: grid; grid-template-columns: 46px 1fr auto; align-items: center; gap: 10px;
  padding: 9px 10px 9px 8px;
  background: rgba(255, 251, 238, .62);
  border: 1px solid rgba(122, 85, 48, .32);
  border-radius: 10px;
  box-shadow: 0 1px 0 rgba(255,255,255,.7) inset, 0 1px 2px rgba(90,60,20,.12);
  transition: background .25s, opacity .25s, box-shadow .25s;
}
.quest.now { box-shadow: 0 0 0 2px var(--gold-500), 0 4px 14px rgba(217,164,65,.35); background: rgba(255, 246, 214, .9); }
.quest.done { background: rgba(255, 251, 238, .3); }
.quest.done .q-title { text-decoration: line-through; text-decoration-color: rgba(106,80,50,.55); color: var(--ink-faint); }
.quest.done .q-lead, .quest.done .q-meta { opacity: .6; }
.quest.event { background: rgba(255, 240, 220, .5); border-style: dashed; }

.q-lead { display: grid; place-items: center; gap: 3px; }
.q-time { font-family: "Pixelify Sans", monospace; font-size: .92rem; font-variant-numeric: tabular-nums; color: var(--ink); }
.sigil {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  border: 2px solid currentColor;
  background: var(--parch-50);
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.08);
}
.sigil .ico { width: 15px; height: 15px; }
.sigil.sm { width: 20px; height: 20px; border-width: 1.5px; }
.sigil.sm .ico { width: 10px; height: 10px; }
.c-sante { color: var(--sante); } .c-prod { color: var(--prod); } .c-esprit { color: var(--esprit); } .c-maison { color: var(--maison); }

.q-body { min-width: 0; }
.q-title { font-weight: 700; font-size: 1.02rem; line-height: 1.25; overflow-wrap: anywhere; }
.q-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 8px; margin-top: 4px; font-size: .8rem; color: var(--ink-soft); }
.q-meta .ico { width: 11px; height: 11px; }
.q-meta > span { display: inline-flex; align-items: center; gap: 4px; }
.tag { padding: 1px 8px 1px 6px; border-radius: 999px; font-weight: 700; font-size: .74rem; }
.tag.sante { background: var(--sante-bg); color: #2d5a16; }
.tag.prod { background: var(--prod-bg); color: #18466f; }
.tag.esprit { background: var(--esprit-bg); color: #522a75; }
.tag.maison { background: var(--maison-bg); color: #7a3a10; }
.tag.recur { background: #fbe9b8; color: #6e4a06; box-shadow: inset 0 0 0 1px rgba(179,122,34,.45); }
.tag.gcal { background: #f3e1cf; color: #6e3e14; }

.check {
  width: 42px; height: 42px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 10px; cursor: pointer;
  border: 2px solid var(--wood-500);
  background: linear-gradient(180deg, var(--parch-50), var(--parch-200));
  box-shadow: inset 0 -3px 0 rgba(90,60,20,.18), inset 0 2px 0 #fff, 0 1px 0 rgba(255,255,255,.6);
  color: transparent;
  transition: transform .12s var(--ease-out), background .3s, border-color .3s;
}
.check .ico { width: 20px; height: 20px; }
.check:hover { border-color: var(--gold-600); }
.check:active { transform: scale(.92); }
.quest.done .check {
  border-color: var(--gold-700);
  background: radial-gradient(circle at 35% 30%, #fff3c2, var(--gold-500) 55%, var(--gold-700));
  box-shadow: inset 0 -2px 0 rgba(60,30,0,.35), 0 2px 6px rgba(179,122,34,.45);
  color: #3d2304;
}
.quest.stamp .check { animation: stamp .42s var(--ease-out); }
@keyframes stamp { 0% { transform: scale(1.45) rotate(-14deg); } 100% { transform: scale(1) rotate(0); } }

.section-label {
  display: flex; align-items: center; gap: 10px;
  margin: 16px 0 8px;
  font-family: "Pixelify Sans", monospace; font-size: .82rem; letter-spacing: .03em;
  color: var(--ink-soft);
}
.section-label::before, .section-label::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, rgba(122,85,48,.5), transparent); }
.section-label:first-child { margin-top: 0; }

.empty { text-align: center; padding: 18px 8px 8px; color: var(--ink-soft); }
.empty .ico.big { width: 40px; height: 40px; color: var(--wood-500); margin-bottom: 8px; }
.empty p { margin: 0 0 14px; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 42px; padding: 9px 16px; border-radius: 9px; cursor: pointer;
  font-family: "Pixelify Sans", monospace; font-weight: 600; font-size: .92rem; letter-spacing: .01em;
  border: 2px solid var(--gold-700);
  background: linear-gradient(180deg, #ffe7a8, var(--gold-500) 55%, var(--gold-600));
  color: #3a2004;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.6), inset 0 -2px 0 rgba(90,50,0,.25), 0 3px 0 var(--wood-950);
  transition: transform .1s var(--ease-out), box-shadow .1s, filter .15s;
  text-decoration: none;
}
.btn .ico { width: 15px; height: 15px; }
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(2px); box-shadow: inset 0 1px 0 rgba(255,255,255,.6), 0 1px 0 var(--wood-950); }
.btn.secondary { background: linear-gradient(180deg, var(--parch-50), var(--parch-200)); border-color: var(--wood-500); color: var(--ink); }
.btn.green { background: linear-gradient(180deg, #bfe68a, #5f9a2f 60%, #3f7a1c); border-color: #2a520f; color: #f4ffe4; text-shadow: 0 1px 0 #1d3a08; }
.btn.danger { background: linear-gradient(180deg, #f2a28c, var(--danger) 60%, #7a2414); border-color: #5a170b; color: #fff2ec; text-shadow: 0 1px 0 #4a1006; }
.btn.small { min-height: 34px; padding: 5px 11px; font-size: .82rem; }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px;
  background: none; border: none; border-radius: 8px; cursor: pointer; color: var(--ink-soft);
}
.icon-btn .ico { width: 16px; height: 16px; }
.icon-btn:hover { background: rgba(122,85,48,.12); color: var(--ink); }

.fab {
  position: fixed; right: max(16px, calc(50% - 264px)); bottom: calc(96px + var(--safe-b)); z-index: 9;
  width: 60px; height: 60px; border-radius: 50%; padding: 0;
  display: grid; place-items: center; cursor: pointer;
  border: 3px solid var(--wood-950);
  background: radial-gradient(circle at 35% 30%, #fff1b8, var(--gold-500) 55%, var(--gold-700));
  box-shadow: 0 0 0 2px var(--gold-500), 0 6px 16px rgba(0,0,0,.5);
  color: var(--wood-900);
  transition: transform .15s var(--ease-out);
}
.fab .ico { width: 24px; height: 24px; }
.fab:active { transform: scale(.92); }

/* ---------- Filtres ---------- */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 34px; padding: 4px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid rgba(122,85,48,.45); background: rgba(255,251,238,.7);
  font-weight: 700; font-size: .84rem;
}
.chip .ico { width: 12px; height: 12px; }
.chip.active { background: var(--wood-700); color: var(--gold-100); border-color: var(--wood-950); box-shadow: inset 0 1px 0 rgba(255,220,150,.2); }

/* ---------- Formulaires ---------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 13px; }
.field label, .field .lbl { display: flex; align-items: center; gap: 5px; font-weight: 800; font-size: .84rem; color: var(--ink-soft); }
.field input[type=text], .field input[type=time], .field input[type=number], .field input[type=date], .field select, .field textarea {
  width: 100%; min-height: 42px; padding: 9px 11px; border-radius: 8px;
  border: 1px solid rgba(122,85,48,.55); background: var(--parch-50);
  box-shadow: inset 0 2px 4px rgba(90,60,20,.12);
}
.field input::placeholder, .field textarea::placeholder { color: var(--ink-faint); }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--gold-600); box-shadow: 0 0 0 3px rgba(217,164,65,.35); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 10px; background: rgba(122,85,48,.14); }
.seg.seg-grid { grid-auto-flow: row; grid-template-columns: 1fr 1fr; }
.seg button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 6px 6px; border: none; border-radius: 7px; cursor: pointer;
  background: transparent; font-weight: 700; font-size: .86rem; color: var(--ink-soft);
}
.seg button .ico { width: 13px; height: 13px; }
.seg button.active { background: var(--parch-50); color: var(--ink); box-shadow: 0 1px 0 rgba(255,255,255,.8) inset, 0 1px 3px rgba(90,60,20,.25); }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.days button { min-height: 38px; border-radius: 8px; border: 1px solid rgba(122,85,48,.45); background: var(--parch-50); cursor: pointer; font-family: "Pixelify Sans", monospace; font-size: .86rem; }
.days button.active { background: var(--gold-500); border-color: var(--gold-700); color: #3a2004; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0 10px; }

/* ---------- Héros ---------- */
.hero-id { text-align: center; padding-top: 6px; }
.hero-name { font-family: "Pixelify Sans", monospace; font-size: 1.55rem; font-weight: 700; line-height: 1.1; }
.hero-sub { color: var(--ink-soft); margin-top: 3px; }
.badges { display: flex; justify-content: center; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  font-family: "Pixelify Sans", monospace; font-size: .84rem;
  background: var(--wood-700); color: var(--gold-100); border: 1px solid var(--wood-950);
}
.badge .ico { width: 12px; height: 12px; }
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.stat { text-align: center; padding: 10px 4px; border-radius: 10px; background: rgba(255,251,238,.6); border: 1px solid rgba(122,85,48,.3); }
.stat b { display: flex; align-items: center; justify-content: center; gap: 5px; font-family: "Pixelify Sans", monospace; font-size: 1.4rem; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat b .ico { width: 16px; height: 16px; }
.stat span { font-size: .78rem; color: var(--ink-soft); font-weight: 700; }
.branch { display: grid; grid-template-columns: 34px 1fr; gap: 4px 10px; align-items: center; margin-bottom: 12px; }
.branch .sigil { grid-row: span 2; }
.branch .b-name { display: flex; justify-content: space-between; font-weight: 800; font-size: .92rem; }
.branch .b-name span:last-child { font-family: "Pixelify Sans", monospace; font-weight: 500; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

.evo-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.evo { text-align: center; padding: 8px 2px 6px; border-radius: 10px; background: rgba(255,251,238,.5); border: 1px solid rgba(122,85,48,.3); }
.evo canvas { width: 48px; height: 60px; image-rendering: pixelated; }
.evo.locked canvas { filter: brightness(0) opacity(.28); }
.evo.current { background: rgba(255, 238, 180, .8); border-color: var(--gold-600); box-shadow: 0 0 0 1px var(--gold-500), 0 4px 12px rgba(217,164,65,.35); }
.evo .e-lvl { font-family: "Pixelify Sans", monospace; font-size: .74rem; font-variant-numeric: tabular-nums; }
.evo .e-name { font-size: .7rem; font-weight: 800; color: var(--ink-soft); line-height: 1.15; }
.prestige-box { display: grid; grid-template-columns: 72px 1fr; gap: 12px; align-items: center; }
.prestige-box canvas { width: 72px; height: 90px; image-rendering: pixelated; }

.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .dh { font-family: "Pixelify Sans", monospace; font-size: .72rem; text-align: center; color: var(--ink-soft); padding-bottom: 2px; }
.cal .dc { aspect-ratio: 1; border-radius: 6px; display: grid; place-items: center; font-family: "Pixelify Sans", monospace; font-size: .78rem; font-variant-numeric: tabular-nums; background: rgba(255,251,238,.55); border: 1px solid rgba(122,85,48,.18); }
.cal .dc.perfect { background: linear-gradient(135deg, var(--gold-100), var(--gold-500)); border-color: var(--gold-700); color: #3a2004; }
.cal .dc.partial { background: var(--parch-300); }
.cal .dc.missed { background: #ead0c0; color: #7a3a2a; }
.cal .dc.today { box-shadow: 0 0 0 2px var(--wood-700); }
.cal .dc.blank { background: none; border: none; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 10px; font-size: .8rem; color: var(--ink-soft); }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; vertical-align: -1px; margin-right: 4px; }

/* ---------- Choix de classe ---------- */
.class-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.class-card {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 2px 7px; border-radius: 10px; cursor: pointer;
  border: 1px solid rgba(122,85,48,.4); background: rgba(255,251,238,.6);
  font-family: "Pixelify Sans", monospace; font-size: .68rem; line-height: 1.1;
  transition: transform .12s var(--ease-out);
}
.class-card canvas { width: 46px; height: 57px; image-rendering: pixelated; }
.class-card:active { transform: scale(.95); }
.class-card.active { background: rgba(255,238,180,.9); border-color: var(--gold-600); box-shadow: 0 0 0 2px var(--gold-500); }
.class-desc { margin-top: 8px; font-size: .88rem; line-height: 1.4; padding: 9px 11px; border-radius: 8px; background: rgba(255,251,238,.55); border: 1px dashed rgba(122,85,48,.5); }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch { width: 34px; height: 34px; border-radius: 8px; cursor: pointer; border: 2px solid rgba(43,28,13,.3); box-shadow: inset 0 -3px 0 rgba(0,0,0,.18); }
.swatch.active { border-color: var(--wood-900); box-shadow: 0 0 0 2px var(--gold-500), inset 0 -3px 0 rgba(0,0,0,.18); }
.preview-stage { display: grid; place-items: center; padding: 10px 0; margin-bottom: 10px; border-radius: 10px; background: radial-gradient(circle at 50% 70%, rgba(217,164,65,.3), transparent 65%), rgba(255,251,238,.4); }
.preview-stage canvas { width: 112px; height: 140px; image-rendering: pixelated; }

/* ---------- Connexion ---------- */
.login { text-align: center; padding: 6px 4px 2px; }
.login canvas { width: 120px; height: 150px; }
.login h2 { margin: 6px 0 8px; }
.login .muted { margin: 0 0 18px; line-height: 1.45; }
.login-btn { display: flex; justify-content: center; min-height: 44px; margin-bottom: 14px; }
.account { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; background: rgba(255,251,238,.6); border: 1px solid rgba(122,85,48,.3); }
.account img { width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--gold-500); }

/* ---------- Barre d'action ---------- */
.hotbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; z-index: 10;
  width: 100%; max-width: 560px;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 8px 10px calc(8px + var(--safe-b));
  background: linear-gradient(180deg, var(--wood-700), var(--wood-900));
  border-top: 2px solid var(--gold-600);
  box-shadow: 0 -1px 0 var(--wood-950), 0 -10px 24px rgba(8,4,0,.55);
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: none; border: none; cursor: pointer; padding: 0;
  color: var(--parch-300);
}
.slot {
  width: 46px; height: 46px; display: grid; place-items: center;
  border-radius: 9px;
  background: linear-gradient(180deg, var(--wood-950), var(--wood-800));
  border: 2px solid var(--wood-500);
  box-shadow: inset 0 3px 6px rgba(0,0,0,.65), 0 1px 0 rgba(255,220,150,.14);
  color: #b8925e;
  transition: border-color .2s, box-shadow .25s var(--ease-out), color .2s;
}
.slot .ico { width: 24px; height: 24px; }
.tab-label { font-family: "Pixelify Sans", monospace; font-size: .72rem; }
.tab.active { color: var(--gold-100); }
.tab.active .slot {
  border-color: var(--gold-500); color: var(--gold-100);
  box-shadow: inset 0 0 12px rgba(240,190,90,.35), 0 0 0 1px var(--wood-950), 0 0 14px rgba(240,180,70,.4);
}

/* ---------- Modale ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center; padding: 18px;
  background: rgba(14, 8, 3, .72);
  backdrop-filter: blur(2px);
  animation: fade .2s ease-out;
}
.confirm-layer { z-index: 40; }
.modal { width: 100%; max-width: 440px; max-height: calc(100vh - 36px); overflow: auto; padding: 18px; animation: rise .32s var(--ease-out); }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(14px) scale(.97); opacity: 0; } }

.levelup { text-align: center; }
.lu-kicker { font-family: "Pixelify Sans", monospace; font-size: 1.7rem; font-weight: 700; color: var(--gold-700); text-shadow: 0 2px 0 var(--gold-100); line-height: 1.1; }
.lu-stage { position: relative; display: grid; place-items: center; height: 220px; margin: 6px 0; }
.lu-stage::before {
  content: ""; position: absolute; width: 230px; height: 230px; border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, rgba(240,190,90,.55) 0 9deg, transparent 9deg 18deg);
  -webkit-mask: radial-gradient(circle, #000 30%, transparent 68%); mask: radial-gradient(circle, #000 30%, transparent 68%);
  animation: spin 16s linear infinite;
}
.lu-stage canvas { position: relative; width: 150px; height: 188px; image-rendering: pixelated; animation: rise .5s var(--ease-out); }
.lu-level { font-family: "Pixelify Sans", monospace; font-size: 2.4rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 50%; bottom: calc(100px + var(--safe-b)); transform: translateX(-50%); z-index: 30;
  max-width: calc(100% - 32px); padding: 10px 18px; border-radius: 10px; text-align: center;
  background: linear-gradient(180deg, var(--wood-700), var(--wood-800)); color: var(--gold-100);
  border: 1px solid var(--gold-600); box-shadow: 0 8px 20px rgba(0,0,0,.45);
  font-weight: 700; font-size: .92rem;
  animation: rise .25s var(--ease-out);
}
.floating {
  position: fixed; z-index: 25; pointer-events: none;
  font-family: "Pixelify Sans", monospace; font-weight: 700; font-size: .95rem; color: var(--gold-300);
  text-shadow: 0 2px 0 var(--wood-950), 0 0 6px rgba(0,0,0,.6);
  animation: floatUp 1s var(--ease-out) forwards;
}
@keyframes floatUp { to { transform: translateY(-46px); opacity: 0; } }

.code { font-family: ui-monospace, monospace; font-size: .8rem; background: rgba(122,85,48,.12); padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }
details summary { cursor: pointer; font-weight: 700; color: var(--ink); }
.divider { height: 1px; margin: 14px 0; background: linear-gradient(90deg, transparent, rgba(122,85,48,.45), transparent); }

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