/* =========================================================
   Pepitas del Chapas — Le Chevalier et l'Artefact
   Interface moderne : verre dépoli, néons doux, arrondis généreux
   ========================================================= */

:root {
  --bg: #071725;
  --bg-2: #0e2a3a;
  --glass: rgba(255, 255, 255, .07);
  --glass-strong: rgba(255, 255, 255, .12);
  --stroke: rgba(255, 255, 255, .12);
  --text: #f4f8fb;
  --muted: rgba(244, 248, 251, .62);
  --gold: #ffd166;
  --gold-deep: #f5a623;
  --cyan: #5ad1e6;
  --coral: #ff7a7a;
  --green: #5fd39b;
  --violet: #b18cff;
  --panel: #fdfbf6;
  --ink: #1b2b3a;
  --ink-soft: #627485;
  --radius: 20px;
  --shadow: 0 18px 40px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(circle at 12% 8%, rgba(90, 209, 230, .12), transparent 38%),
    radial-gradient(circle at 88% 82%, rgba(255, 209, 102, .10), transparent 42%),
    linear-gradient(160deg, #071725, #0b2233 55%, #071725);
  overscroll-behavior: none;
}
button { font: inherit; cursor: pointer; color: inherit; }
img { display: block; pointer-events: none; user-select: none; }

.app {
  position: relative;
  width: 100%; max-width: 480px;
  min-height: 100dvh; margin: 0 auto;
  background: linear-gradient(180deg, rgba(255,255,255,.025), rgba(255,255,255,0));
  overflow: hidden;
  box-shadow: 0 0 80px rgba(0, 0, 0, .55);
}
.screen {
  display: none; flex-direction: column;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.screen.is-active { display: flex; animation: fade .3s cubic-bezier(.2,.8,.2,1) both; }
@keyframes fade { from { opacity: 0; transform: translateY(10px) scale(.99); } to { opacity: 1; transform: none; } }

.eyebrow {
  display: inline-block; font-size: 10px; font-weight: 900;
  letter-spacing: 1.6px; text-transform: uppercase;
  color: #0d2a35; background: linear-gradient(90deg, var(--gold), #ffe9ad);
  padding: 6px 12px; border-radius: 999px;
  box-shadow: 0 4px 14px rgba(255, 209, 102, .25);
}
.btn {
  border: 1px solid transparent; border-radius: 16px; min-height: 54px;
  padding: 0 18px; font-weight: 800; font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  transition: transform .15s cubic-bezier(.2,.8,.2,1), box-shadow .2s, filter .2s, background .2s;
  width: 100%; position: relative; overflow: hidden;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; filter: grayscale(.6); cursor: default; }
.btn--primary {
  color: #241a00;
  background: linear-gradient(135deg, #ffe6a0 0%, var(--gold) 45%, var(--gold-deep) 100%);
  box-shadow: 0 8px 24px rgba(255, 180, 40, .28), inset 0 1px 0 rgba(255,255,255,.6);
}
.btn--primary:active { box-shadow: 0 3px 10px rgba(255, 180, 40, .3); }
.btn--primary::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.45) 50%, transparent 70%);
  transform: translateX(-120%); transition: transform .6s;
}
.btn--primary:hover::after { transform: translateX(120%); }
.btn--ghost {
  background: var(--glass); color: var(--text);
  border-color: var(--stroke); backdrop-filter: blur(12px);
}
.btn--ghost:active { background: var(--glass-strong); }
.btn--danger { background: rgba(255,122,122,.12); color: var(--coral); border-color: rgba(255,122,122,.35); }
.btn img { width: 20px; height: 20px; }
.linklike {
  align-self: center; border: 0; background: none;
  color: var(--muted); font-size: 13px; font-weight: 700;
  text-decoration: underline; text-underline-offset: 4px; padding: 10px;
}
.linklike:hover { color: var(--gold); }

/* ------------------------------ Titre ------------------------------ */
.screen--title { background: transparent; }
.title-art { position: relative; height: 270px; flex: none; }
.title-art::before {
  content: ""; position: absolute; left: 50%; top: 24px;
  width: 230px; height: 230px; transform: translateX(-50%);
  background: radial-gradient(circle, rgba(90,209,230,.22), transparent 68%);
  filter: blur(8px);
}
.title-art__island { position: absolute; left: 50%; bottom: -46px; width: 340px; transform: translateX(-50%); opacity: .9; }
.title-art__knight {
  position: absolute; left: 50%; bottom: 42px; width: 156px;
  transform: translateX(-50%); filter: drop-shadow(0 16px 14px rgba(0,0,0,.5));
  animation: bob 3.2s ease-in-out infinite;
}
.title-art__coin { position: absolute; right: 16%; bottom: 124px; width: 34px; animation: float 3s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translate(-50%,0); } 50% { transform: translate(-50%,-8px); } }
@keyframes float { 0%,100% { transform: translateY(0) rotate(-8deg); } 50% { transform: translateY(-12px) rotate(8deg); } }

.title-content {
  position: relative; margin-top: -16px;
  background: var(--panel); color: var(--ink);
  border-radius: 28px 28px 0 0;
  padding: 26px 20px 32px;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, .35);
  display: flex; flex-direction: column; gap: 14px; flex: 1;
}
.title-content .eyebrow { align-self: flex-start; }
.title-content h1 { margin: 4px 0 0; font-size: 32px; line-height: 1.02; letter-spacing: -1.2px; }
.title-content h1 em { color: var(--gold-deep); font-style: normal; display: block; }
.title-sub { margin: 0 0 6px; color: var(--ink-soft); font-size: 14px; font-weight: 700; }
.choice-group { display: flex; flex-direction: column; gap: 7px; }
.choice-label { font-size: 10px; font-weight: 900; letter-spacing: 1.2px; text-transform: uppercase; color: var(--ink-soft); }
.segmented { display: flex; background: #f1ece1; border-radius: 14px; padding: 4px; gap: 4px; }
.segmented button {
  flex: 1; border: 0; background: transparent; border-radius: 10px;
  padding: 10px 4px; font-size: 12px; font-weight: 800; color: var(--ink-soft);
  transition: all .2s;
}
.segmented button.is-selected { background: #fff; color: var(--ink); box-shadow: 0 3px 10px rgba(0,0,0,.09); }
.skins { display: flex; gap: 8px; }
.skins button {
  flex: 1; border: 1.5px solid #e7e0d0; background: #fff;
  border-radius: 13px; padding: 10px 4px; font-size: 12px; font-weight: 800; color: var(--ink-soft);
  transition: all .2s;
}
.skins button.is-selected { border-color: var(--gold-deep); background: #fff8e2; color: #7a5600; transform: translateY(-1px); }
.skins button:disabled { opacity: .4; }
.skins button[data-skin="silver"].is-selected { border-color: var(--cyan); background: #eaf8fb; color: #1b6c82; }
.skins button[data-skin="blue"].is-selected { border-color: #4d76b8; background: #eaf0fc; color: #2c4f85; }
.title-content .btn--ghost { color: var(--ink); background: #fff; border-color: #e7e0d0; box-shadow: none; }
.title-content .linklike { color: var(--ink-soft); }

/* ------------------------------- Jeu ------------------------------- */
.screen--game { background: transparent; }
.hud {
  background: rgba(10, 30, 45, .72);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--stroke);
  padding: 12px 14px 10px; flex: none;
}
.hud__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hud__identity { display: flex; align-items: center; gap: 10px; min-width: 0; }
.hud__identity img {
  width: 44px; height: 44px; object-fit: contain; object-position: left center;
  background: rgba(255,255,255,.08); border: 1px solid var(--stroke);
  border-radius: 50%; padding: 3px;
}
.hud__identity strong { display: block; font-size: 13px; letter-spacing: .2px; }
.hud__identity span { display: block; font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 195px; }
.hud__gold {
  display: flex; align-items: center; gap: 6px; font-weight: 900; font-size: 14px; color: #10202c;
  background: linear-gradient(135deg, #ffe6a0, var(--gold));
  padding: 7px 12px; border-radius: 999px;
  box-shadow: 0 4px 14px rgba(255,209,102,.22);
}
.hud__gold img { width: 17px; height: 17px; }
.bars { display: flex; flex-direction: column; gap: 5px; margin-top: 10px; }
.bar {
  position: relative; height: 15px; border-radius: 999px;
  background: rgba(0, 0, 0, .38); overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0,0,0,.4);
}
.bar__fill {
  height: 100%; width: 100%; border-radius: 999px;
  transition: width .35s cubic-bezier(.2,.8,.2,1);
  box-shadow: 0 0 12px currentColor;
}
.bar span {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 900; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.9);
}
.bar--hp .bar__fill { background: linear-gradient(90deg, #ff6b6b, #ff9f7a); color: #ff6b6b; }
.bar--mana .bar__fill { background: linear-gradient(90deg, #4aa3e8, #6fe0f0); color: #5ad1e6; }
.bar--xp .bar__fill { background: linear-gradient(90deg, var(--gold-deep), var(--gold)); color: var(--gold); }
.statuses { display: flex; flex-wrap: wrap; gap: 5px; min-height: 18px; margin-top: 7px; }
.status-chip {
  font-size: 9px; font-weight: 900; padding: 3px 8px; border-radius: 999px;
  background: rgba(90, 209, 230, .16); border: 1px solid rgba(90, 209, 230, .35);
  color: #bdefff;
}
.map-label { font-size: 9px; color: var(--muted); text-align: right; margin-top: 4px; letter-spacing: .3px; }

.arena-wrap { position: relative; flex: 1; min-height: 320px; }
.arena {
  position: absolute;
  inset: 10px;
  width: auto;
  height: auto;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(12, 1fr);
  width: 100%;
  height: 100%;
  background-color: #143a2e;
  background-size: 130px 130px;
  background-position: center;
  background-repeat: repeat;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow), inset 0 0 60px rgba(0, 0, 0, .45);
}
.arena::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(3, 14, 22, .45) 100%);
}
.tile { position: relative; background: transparent; }
.entity--decor { opacity: .75; z-index: 2; }
.entity--decor img { filter: drop-shadow(0 3px 2px rgba(0,0,0,.35)) saturate(.85); }
.entity--obstacle { z-index: 2; }
.entity--obstacle img { filter: drop-shadow(0 6px 5px rgba(0,0,0,.5)); }
.entity--exit { z-index: 3; }
.exit-arrow {
  display: flex; align-items: center; justify-content: center;
  width: 60%; height: 60%; margin: 20%;
  border-radius: 50%;
  background: rgba(255, 209, 102, .18);
  border: 1px solid rgba(255, 209, 102, .55);
  color: var(--gold); font-size: 14px; font-weight: 900;
  box-shadow: 0 0 14px rgba(255, 209, 102, .3);
}
.entity {
  position: absolute; z-index: 3;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; pointer-events: none;
}
.entity img {
  width: 100%; height: 100%; object-fit: contain;
  filter: drop-shadow(0 4px 4px rgba(0,0,0,.5));
  transition: transform .18s ease;
}
.entity--hero { z-index: 5; }
.entity--hero img { width: 116%; }
.entity--npc img { width: 82%; }
.entity--chest img { width: 84%; }
.entity--boss img { width: 124%; }
.entity--secret img { width: 72%; }
.entity--puzzle { font-size: 22px; }
.hero-gold img { filter: drop-shadow(0 4px 6px rgba(255,200,60,.6)) sepia(1) saturate(3) hue-rotate(355deg) brightness(1.1); }
.hero-blue img { filter: drop-shadow(0 4px 6px rgba(90,160,255,.5)) hue-rotate(190deg) saturate(1.4) brightness(.92); }

.controls {
  display: flex; align-items: center; justify-content: space-around; gap: 12px;
  background: rgba(10, 30, 45, .72);
  backdrop-filter: blur(18px);
  border-top: 1px solid var(--stroke);
  padding: 12px 14px calc(14px + env(safe-area-inset-bottom)); flex: none;
}
.dpad { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.dpad > div { display: flex; gap: 4px; }
.dpad button {
  width: 44px; height: 40px; border-radius: 13px;
  border: 1px solid var(--stroke); background: var(--glass);
  color: var(--text); font-size: 15px; font-weight: 900;
  backdrop-filter: blur(8px); transition: all .15s;
}
.dpad button:active { background: var(--glass-strong); transform: scale(.93); box-shadow: 0 0 14px rgba(90,209,230,.3); }
.control-actions { display: flex; flex-direction: column; gap: 6px; }
.control-actions button {
  display: flex; align-items: center; gap: 8px;
  min-width: 122px; padding: 9px 12px; border-radius: 13px;
  border: 1px solid var(--stroke); background: var(--glass);
  color: var(--text); font-size: 12px; font-weight: 800;
  backdrop-filter: blur(8px); transition: all .15s;
}
.control-actions button:active { background: var(--glass-strong); transform: translateY(1px); }
.control-actions img { width: 18px; height: 18px; filter: invert(1); opacity: .85; }

/* ---------------------------- Combat ---------------------------- */
.screen--combat { background: linear-gradient(180deg, #0b2233 0%, #123b4f 46%, #2a4c3a 46%, #1a3328 100%); color: var(--text); }
.battle-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px 6px; font-size: 12px; font-weight: 800; color: var(--muted);
}
.battle-top .eyebrow { color: #1b2b00; }
.battle-scene { flex: 1; display: flex; flex-direction: column; justify-content: space-between; padding: 6px 14px 4px; min-height: 0; }
.battle-row { display: flex; align-items: flex-end; gap: 10px; min-height: 0; }
.battle-row--enemy { justify-content: space-between; }
.battle-row--hero { justify-content: space-between; align-items: flex-start; }
.battle-sprite { max-height: 150px; max-width: 46%; object-fit: contain; filter: drop-shadow(0 10px 8px rgba(0,0,0,.45)); animation: battle-in .35s cubic-bezier(.2,.8,.2,1) both; }
.battle-sprite--hero { max-height: 140px; }
@keyframes battle-in { from { opacity: 0; transform: translateY(12px) scale(.9); } to { opacity: 1; transform: none; } }
.battle-card {
  width: 54%; background: rgba(253, 251, 246, .96); color: var(--ink);
  border: 2px solid rgba(255, 209, 102, .55); border-radius: 14px;
  padding: 8px 10px; box-shadow: 0 8px 18px rgba(0,0,0,.35);
}
.battle-card__head { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; margin-bottom: 6px; }
.battle-card__head strong { font-size: 13px; }
.battle-card__head span { font-size: 10px; color: var(--ink-soft); font-weight: 800; }
.battle-card__stats { font-size: 9px; color: var(--ink-soft); margin-top: 5px; font-weight: 700; }
.battle-card .bar { height: 12px; margin-bottom: 4px; }
.battle-statuses { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; }
.battle-statuses .status-chip { background: #fff0cf; border-color: #f0d68a; color: #8a6200; }
.battle-message {
  margin: 4px 12px 6px; padding: 12px 14px;
  background: var(--panel); color: var(--ink);
  border: 2px solid rgba(255, 209, 102, .5); border-radius: 14px;
  font-size: 12px; line-height: 1.5; min-height: 46px;
  box-shadow: 0 8px 18px rgba(0,0,0,.3);
}
.battle-message strong { color: #a78632; }
.battle-panel { margin: 0 12px 6px; max-height: 190px; overflow-y: auto; display: none; }
.battle-panel.is-open { display: block; }
.battle-panel__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.battle-panel__btn {
  display: flex; align-items: center; gap: 7px; text-align: left;
  background: var(--panel); color: var(--ink); border: 1.5px solid #e7dcc4;
  border-radius: 11px; padding: 9px; font-size: 11px; font-weight: 800;
}
.battle-panel__btn img { width: 19px; height: 19px; }
.battle-panel__btn small { display: block; color: var(--ink-soft); font-size: 9px; font-weight: 600; }
.battle-panel__btn:disabled { opacity: .4; }
.battle-panel__btn--spell { border-color: #cfe0f0; background: #f7fbff; }
.battle-panel__btn--potion { border-color: #f0e0c2; background: #fffaf0; }
.battle-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 7px;
  padding: 8px 12px calc(12px + env(safe-area-inset-bottom));
  background: rgba(6, 20, 30, .75); border-top: 1px solid var(--stroke);
}
.battle-actions button {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--glass); color: var(--text); border: 1px solid var(--stroke);
  border-radius: 12px; padding: 12px; font-size: 13px; font-weight: 800;
  backdrop-filter: blur(8px);
}
.battle-actions button:active { background: var(--glass-strong); transform: scale(.97); }
.battle-actions img { width: 19px; height: 19px; filter: invert(1); }
.battle-actions button[data-menu="attacks"] { border-color: rgba(255,209,102,.5); color: var(--gold); }

/* ----------------------- Interaction PNJ ----------------------- */
.npc-bar {
  position: absolute; left: 10px; right: 10px; bottom: 96px; z-index: 12;
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px;
  background: rgba(10, 30, 45, .92);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 209, 102, .35);
  border-radius: 16px;
  box-shadow: 0 12px 30px rgba(0,0,0,.4);
  animation: bar-in .22s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes bar-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.npc-bar[hidden] { display: none; }
.npc-bar__portrait {
  width: 42px; height: 42px; object-fit: contain; flex: none;
  background: rgba(255,255,255,.1); border-radius: 12px; padding: 2px;
}
.npc-bar__text { flex: 1; min-width: 0; }
.npc-bar__text strong { display: block; font-size: 12px; color: var(--gold); }
.npc-bar__text span { display: block; font-size: 10px; color: var(--muted); line-height: 1.35; max-height: 28px; overflow: hidden; }
.npc-bar__actions { display: flex; gap: 5px; flex: none; }
.npc-bar__actions button {
  border: 1px solid var(--stroke); background: var(--glass);
  border-radius: 10px; padding: 8px 9px; font-size: 11px; font-weight: 800;
  white-space: nowrap;
}
.npc-bar__actions button[data-act="shop"] { background: var(--gold); color: #2b2100; border-color: transparent; }
.npc-bar__actions button:active { transform: scale(.94); }
.npc-bar.is-talking { align-items: flex-start; }
.npc-bar.is-talking .npc-bar__actions { flex-direction: column; width: 100%; }
.npc-bar.is-talking .npc-bar__actions button { width: 100%; text-align: left; white-space: normal; }

.npc-bubble {
  position: absolute; z-index: 11; pointer-events: none;
  transform: translate(-50%, -100%);
  max-width: 150px;
  background: var(--panel); color: var(--ink);
  border-radius: 12px; padding: 6px 9px;
  font-size: 9px; font-weight: 700; line-height: 1.3; text-align: center;
  box-shadow: 0 6px 16px rgba(0,0,0,.35);
  animation: bubble-in .2s ease both;
}
.mote {
  position: absolute; z-index: 6; pointer-events: none;
  width: 4px; height: 4px; border-radius: 50%;
  background: rgba(255, 233, 170, .8);
  box-shadow: 0 0 8px rgba(255, 209, 102, .8);
  animation: mote 5s ease-in-out infinite;
}
@keyframes mote {
  0%, 100% { transform: translateY(0) scale(.6); opacity: .25; }
  50% { transform: translateY(-14px) scale(1.1); opacity: .85; }
}
.hp-mini {
  position: absolute; z-index: 7; pointer-events: none;
  width: 5.5%; height: 4px;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, .65);
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 999px; overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.5);
}
.hp-mini__fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #ff6b6b, #ffa06b);
  transition: width .3s ease;
}
.hp-mini--boss { width: 8%; height: 5px; }
.hp-mini--boss .hp-mini__fill { background: linear-gradient(90deg, #b54bff, #ff7ac8); }
.hp-mini--hero .hp-mini__fill { background: linear-gradient(90deg, #5fd39b, #a6f5cf); }

.fog-layer { position: absolute; inset: -8px; z-index: 20; pointer-events: none; filter: blur(8px); }
.fog-cell {
  position: absolute;
  border-radius: 28%;
  background: radial-gradient(circle at 50% 45%, rgba(4, 15, 24, .96) 52%, rgba(4, 15, 24, .72) 100%);
}
.npc-bubble::after {
  content: ""; position: absolute; left: 50%; bottom: -6px;
  transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: var(--panel); border-bottom: 0;
}
@keyframes bubble-in { from { opacity: 0; transform: translate(-50%, -90%) scale(.9); } to { opacity: 1; transform: translate(-50%, -100%) scale(1); } }

/* ---------------------------- Boutique ---------------------------- */
.screen--shop { background: var(--panel); color: var(--ink); }
.shop-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: rgba(10, 30, 45, .78);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--stroke);
}
.shop-header__back {
  border: 1px solid var(--stroke); background: var(--glass);
  border-radius: 12px; padding: 9px 12px; font-size: 12px; font-weight: 800;
}
.shop-header strong { display: block; font-size: 16px; }
.shop-header span { display: block; font-size: 11px; color: var(--gold); font-weight: 800; }
.shop-content { flex: 1; overflow-y: auto; padding: 16px; background: var(--panel); color: var(--ink); }
.shop-content .modal__section-title { margin-top: 18px; }
.shop-content .shop-grid { gap: 10px; }
.shop-content .choice { margin-bottom: 8px; }

/* -------------------------------- Fin -------------------------------- */
.screen--ending { align-items: center; justify-content: center; padding: 24px; }
.ending-card {
  width: 100%; background: var(--panel); color: var(--ink);
  border: 1px solid rgba(255,255,255,.5);
  border-radius: 26px; padding: 28px 22px; text-align: center; box-shadow: var(--shadow);
}
.ending-card > img { width: 96px; height: 96px; object-fit: contain; margin: 0 auto 12px; filter: drop-shadow(0 8px 10px rgba(0,0,0,.2)); }
.ending-card h2 { margin: 10px 0 8px; font-size: 27px; letter-spacing: -.6px; }
.ending-card p { color: var(--ink-soft); font-size: 14px; line-height: 1.6; }
.ending-stats { display: flex; justify-content: center; gap: 14px; margin: 18px 0 22px; font-size: 11px; font-weight: 800; color: var(--ink-soft); }
.ending-stats strong { display: block; font-size: 21px; color: var(--sea-2); }
.ending-card .btn--ghost { color: var(--ink); background: #fff; border-color: #e7e0d0; }

/* ------------------------------- Modale ------------------------------- */
.modal { position: fixed; inset: 0; z-index: 50; display: none; align-items: flex-end; justify-content: center; }
.modal.is-open { display: flex; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(4, 14, 22, .72); backdrop-filter: blur(6px); }
.modal__panel {
  position: relative; width: 100%; max-width: 480px;
  max-height: 90dvh; overflow-y: auto;
  background: var(--panel); color: var(--ink);
  border-radius: 26px 26px 0 0;
  padding: 22px 18px calc(24px + env(safe-area-inset-bottom));
  box-shadow: 0 -16px 50px rgba(0,0,0,.45);
  animation: sheet .28s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes sheet { from { transform: translateY(100%); } to { transform: none; } }
.modal__close {
  position: absolute; top: 12px; right: 14px;
  width: 34px; height: 34px; border-radius: 50%; border: 0;
  background: #f0ebe0; color: var(--ink); font-size: 21px; line-height: 1; z-index: 2;
}
.modal__icon { width: 58px; height: 58px; object-fit: contain; margin: 0 auto 10px; }
.modal__panel h2 { margin: 0 0 6px; font-size: 22px; text-align: center; letter-spacing: -.4px; }
.modal__lead { margin: 0 0 16px; text-align: center; color: var(--ink-soft); font-size: 13px; line-height: 1.55; }
.modal__section-title { font-size: 10px; font-weight: 900; letter-spacing: 1.3px; text-transform: uppercase; color: #a78632; margin: 18px 0 9px; }
.modal__panel .btn--ghost { color: var(--ink); background: #fff; border-color: #e7e0d0; box-shadow: none; }
.modal__panel .btn--danger { color: var(--coral); }

.dialogue-box { display: flex; gap: 12px; align-items: flex-start; background: linear-gradient(135deg, #fff8e8, #fffdf6); border: 1px solid #f0e5c8; border-radius: 16px; padding: 13px; }
.dialogue-box img { width: 62px; height: 62px; object-fit: contain; flex: none; }
.dialogue-box p { margin: 0; font-size: 13px; line-height: 1.55; }
.dialogue-box strong { display: block; color: #a78632; font-size: 11px; margin-bottom: 4px; text-transform: uppercase; letter-spacing: .5px; }
.choice-list { display: flex; flex-direction: column; gap: 8px; margin-top: 13px; }
.choice {
  text-align: left; border: 1.5px solid #e7e0d0; background: #fff;
  border-radius: 13px; padding: 12px 13px; font-size: 13px; font-weight: 700; color: var(--ink);
  transition: all .15s;
}
.choice:active, .choice:hover { background: #fff8e2; border-color: var(--gold); transform: translateX(2px); }
.choice:disabled { opacity: .45; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; }
.modal-actions .btn { flex: 1; min-height: 46px; font-size: 13px; }

.shop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.shop-item {
  border: 1.5px solid #eae3d4; border-radius: 15px; padding: 11px;
  background: #fff; display: flex; flex-direction: column; gap: 5px; align-items: center; text-align: center;
  transition: transform .15s, box-shadow .15s;
}
.shop-item:hover { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(0,0,0,.08); }
.shop-item img { width: 32px; height: 32px; }
.shop-item strong { font-size: 12px; }
.shop-item small { font-size: 10px; color: var(--ink-soft); }
.shop-item button {
  width: 100%; border: 0; border-radius: 9px; padding: 8px;
  background: linear-gradient(135deg, #ffe6a0, var(--gold)); color: #2b2100; font-weight: 900; font-size: 11px;
}
.shop-item button:disabled { opacity: .4; }

.combat-scene { text-align: center; }
.modal--combat .modal__backdrop { background: rgba(4, 14, 22, .42); backdrop-filter: blur(2px); }
.modal--combat .modal__panel { max-height: 76dvh; }
.combat-stage { display: flex; align-items: flex-end; justify-content: center; gap: 6px; height: 138px; }
.combat-hero { max-height: 120px; max-width: 32%; object-fit: contain; filter: drop-shadow(0 6px 6px rgba(0,0,0,.3)); }
.combat-vs { align-self: center; color: var(--gold-deep); font-size: 17px; font-weight: 900; }
.combat-enemy { position: relative; height: 138px; display: flex; align-items: flex-end; justify-content: center; flex: 1; }
.combat-enemy img { max-height: 146px; max-width: 76%; object-fit: contain; filter: drop-shadow(0 10px 10px rgba(0,0,0,.28)); }
.combat-enemy.is-boss img { max-height: 158px; }
.combat-name { font-size: 19px; font-weight: 900; margin: 6px 0 2px; letter-spacing: -.3px; }
.combat-hp { font-size: 11px; color: var(--ink-soft); font-weight: 700; }
.combat-meta { font-size: 10px; color: #a78632; font-weight: 800; margin-top: 6px; }
.statuses--enemy { justify-content: center; min-height: 14px; margin-top: 5px; }
.statuses--enemy .status-chip { background: rgba(245,166,35,.14); border-color: rgba(245,166,35,.35); color: #9a6a12; }
.combat-log .log-dmg { color: #c0392b; font-weight: 800; }
.combat-quote { font-size: 12px; font-style: italic; color: #a78632; margin: 9px 0 12px; }
.combat-log {
  height: 66px; overflow-y: auto; text-align: left; font-size: 11px; line-height: 1.55;
  background: #fff8e8; border-radius: 12px; padding: 9px 11px; color: var(--ink-soft);
  border: 1px solid #f0e5c8; margin-bottom: 13px;
}
.combat-log div + div { margin-top: 2px; }
.combat-groups { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.action-btn {
  display: flex; align-items: center; gap: 8px; text-align: left;
  border: 1.5px solid #eae3d4; background: #fff; border-radius: 13px;
  padding: 10px; font-size: 11px; font-weight: 800; color: var(--ink);
  transition: all .15s;
}
.action-btn:hover:not(:disabled) { border-color: var(--gold-deep); transform: translateY(-1px); box-shadow: 0 6px 14px rgba(245,166,35,.15); }
.action-btn img { width: 21px; height: 21px; flex: none; }
.action-btn small { display: block; font-weight: 600; color: var(--ink-soft); font-size: 9px; }
.action-btn:disabled { opacity: .4; }
.action-btn--spell { border-color: #d3e4f2; background: #f7fbff; }
.action-btn--potion { border-color: #f0e0c2; background: #fffaf0; }

.inventory-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.inv-slot {
  aspect-ratio: 1; border: 1.5px solid #eae3d4; border-radius: 12px;
  background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center;
  position: relative; font-size: 9px; font-weight: 800; text-align: center; padding: 3px;
  transition: transform .15s;
}
.inv-slot:hover { transform: translateY(-2px); }
.inv-slot img { width: 25px; height: 25px; }
.inv-slot small { position: absolute; right: 4px; bottom: 2px; font-size: 9px; }
.inv-slot--rare { border-color: #6aa6d8; background: #f2f9ff; }
.inv-slot--legendary { border-color: var(--gold); background: #fff8d9; box-shadow: 0 0 14px rgba(255,209,102,.3); }
.inv-slot--empty { opacity: .35; }
.equip-row { display: flex; gap: 6px; margin-top: 9px; }
.equip-slot { flex: 1; border: 1.5px dashed #d8cfbc; border-radius: 12px; padding: 7px; text-align: center; font-size: 10px; }
.equip-slot img { width: 22px; height: 22px; margin: 0 auto 3px; }

.tree-branches { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.tree-branch { border: 1.5px solid #eae3d4; border-radius: 16px; padding: 11px; background: #fff; }
.tree-branch h3 { margin: 0 0 9px; font-size: 13px; text-align: center; color: var(--sea-2); }
.tree-skill {
  border: 1px solid #efe6d2; border-radius: 10px; padding: 8px; margin-bottom: 6px;
  font-size: 11px; background: #fffdf6; transition: all .15s;
}
.tree-skill strong { display: block; }
.tree-skill small { color: var(--ink-soft); }
.tree-skill.is-owned { border-color: var(--gold); background: #fff7da; }
.tree-skill.is-locked { opacity: .45; }
.tree-skill button { margin-top: 5px; border: 0; border-radius: 7px; padding: 5px 9px; background: linear-gradient(135deg, #ffe6a0, var(--gold)); font-size: 10px; font-weight: 900; color: #2b2100; }

.story-lines { display: flex; flex-direction: column; gap: 11px; }
.story-lines p { margin: 0; font-size: 13px; line-height: 1.65; color: var(--ink-soft); }
.story-lines p:first-child::first-letter { font-size: 22px; font-weight: 900; color: var(--gold-deep); }

.story-banner {
  position: fixed; left: 50%; top: 110px; transform: translate(-50%, -12px);
  z-index: 40; width: calc(100% - 40px); max-width: 440px;
  background: rgba(9, 28, 42, .94); backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 209, 102, .4);
  border-left: 3px solid var(--gold);
  border-radius: 12px; padding: 12px 14px;
  color: #f4f8fb; font-size: 12px; line-height: 1.55;
  box-shadow: 0 14px 32px rgba(0,0,0,.45);
  opacity: 0; transition: opacity .35s, transform .35s; pointer-events: none;
}
.story-banner.is-visible { opacity: 1; transform: translate(-50%, 0); }

.journal-note { background: #fff8e8; border: 1px solid #f0e5c8; border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; }
.journal-note strong { display: block; font-size: 11px; color: #a78632; margin-bottom: 3px; }
.journal-note p { margin: 0; font-size: 12px; line-height: 1.5; color: var(--ink-soft); }

.puzzle-options { display: flex; flex-direction: column; gap: 8px; margin-top: 13px; }
.reward-row { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; margin: 14px 0; }
.reward-chip { background: linear-gradient(135deg, #fff1c2, var(--gold)); color: #3d2d00; border-radius: 999px; padding: 7px 12px; font-size: 11px; font-weight: 900; box-shadow: 0 4px 10px rgba(255,209,102,.22); }

.toast {
  position: fixed; left: 50%; top: 18px; transform: translate(-50%, -20px);
  z-index: 80; background: rgba(12, 32, 46, .94); color: #fff;
  border: 1px solid var(--stroke); backdrop-filter: blur(12px);
  padding: 12px 18px; border-radius: 999px; font-size: 13px; font-weight: 700;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; max-width: 90vw; text-align: center;
  box-shadow: 0 12px 30px rgba(0,0,0,.4);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.screen--game ~ .toast { top: 96px; }

.hit-flash { animation: hitflash .3s ease; }
@keyframes hitflash { 50% { filter: brightness(1.7) sepia(1) hue-rotate(-40deg) drop-shadow(0 0 14px #ff7a7a); } }
.spell-fx {
  position: fixed; inset: 0; z-index: 45; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  animation: fx .6s ease forwards;
}
@keyframes fx { from { opacity: 0; transform: scale(.4) rotate(-10deg); } 40% { opacity: 1; transform: scale(1.15) rotate(5deg); } to { opacity: 0; transform: scale(1.6); } }

@media (min-width: 520px) {
  .app { min-height: min(900px, 100dvh); margin: 20px auto; border-radius: 28px; border: 1px solid rgba(255,255,255,.08); }
  .screen { min-height: min(900px, 100dvh); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
