/* =========================================================
   Fenêtres : résultat, grimoire, activités, réglages
   ========================================================= */
.overlay {
  position: absolute; inset: 0; z-index: 50; display: grid; place-items: center;
  background: rgba(10, 4, 20, .62); padding: calc(var(--safe-t) + 12px) 12px calc(var(--safe-b) + 12px);
}
.round-btn {
  width: 64px; height: 64px; padding: 6px; border-radius: 50%; border: 0; background: none;
  filter: drop-shadow(0 5px 0 rgba(26, 11, 46, .5));
}
.round-btn.big { width: 92px; height: 92px; }
.round-btn svg { width: 100%; height: 100%; display: block; transition: transform .15s; }
.round-btn:active svg { transform: translateY(3px) scale(.92); }
.close-btn { position: absolute; top: -18px; right: -18px; width: 64px; height: 64px; z-index: 5; }

/* ---------- Carte de résultat ---------- */
.result-card {
  position: relative; width: min(460px, 92vw); max-height: 92vh; padding: 26px 22px 18px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.result-card::before {
  content: ''; position: absolute; inset: 10% 0 0; z-index: -1;
  background: url('../assets/images/ui/parchment.svg') center / 100% 100% no-repeat;
  filter: drop-shadow(0 10px 0 rgba(26, 11, 46, .5));
}
.result-rays {
  position: absolute; left: 50%; top: 2%; width: 420px; height: 420px; margin-left: -210px; z-index: -2; pointer-events: none;
  background: repeating-conic-gradient(from 0deg, rgba(255, 230, 128, .35) 0 10deg, transparent 10deg 24deg);
  -webkit-mask: radial-gradient(circle, #000 20%, transparent 68%); mask: radial-gradient(circle, #000 20%, transparent 68%);
}
.result-ribbon {
  position: relative; z-index: 2; margin-top: -6px; padding: 6px 26px; border-radius: 12px; font-family: var(--font-title);
  font-size: clamp(20px, 3.2vh, 28px); color: #fff; background: linear-gradient(#ff8be0, #e0459a); border: 4px solid var(--ink);
  box-shadow: 0 5px 0 rgba(26, 11, 46, .5); transform: rotate(-3deg);
}
.result-card.rarity-3 .result-ribbon { background: linear-gradient(#ffe680, #e8a21a); color: var(--ink); }
.result-bottle { width: min(170px, 28vh); aspect-ratio: 120 / 150; margin-top: 4px; }
.result-bottle svg { width: 100%; height: 100%; overflow: visible; }
.result-name { margin: 0; font-family: var(--font-title); color: var(--ink); font-size: clamp(22px, 3.6vh, 32px); line-height: 1.05; padding: 0 10px; }
.result-desc { margin: 0; color: var(--ink-soft); font-weight: 600; font-size: clamp(15px, 2.2vh, 19px); padding: 0 20px; }
.result-ings { display: flex; align-items: center; gap: 4px; list-style: none; margin: 4px 0; padding: 0; }
.result-ings li { width: clamp(38px, 6vh, 50px); height: clamp(38px, 6vh, 50px); }
.result-ings li img { width: 100%; height: 100%; }
.result-ings li.plus { width: auto; color: var(--ink); font-weight: 700; font-size: 22px; }
.result-actions { display: flex; gap: 28px; align-items: center; justify-content: center; margin-top: 4px; }

/* ---------- Livre (grimoire) ---------- */
.book {
  position: relative; width: min(1100px, 96vw); height: min(720px, 90vh);
  display: grid; grid-template-columns: 1fr 1fr; padding: 3.2% 3.4% 3.6%;
  background: linear-gradient(135deg, #8a4bc4, #5a2c8a 50%, #3e1c66); border-radius: 30px 30px 26px 26px;
  border: 6px solid var(--ink); box-shadow: inset 0 0 0 6px #ffd23f55, 0 16px 0 rgba(10, 4, 20, .6), 0 30px 60px rgba(0, 0, 0, .5);
  perspective: 1800px;
}
.book::before, .book::after {
  content: ''; position: absolute; width: 70px; height: 70px; background: url('../assets/images/ui/corner.svg') center / contain no-repeat; pointer-events: none;
}
.book::before { left: -10px; top: -10px; }
.book::after { right: -10px; bottom: -10px; transform: rotate(180deg); }
.book-page {
  position: relative; overflow: hidden; padding: 18px 22px 16px; color: var(--ink);
  background: radial-gradient(ellipse at 50% 40%, #fffaf0, #f6e3bf 70%, #e8c98e);
  box-shadow: inset 0 0 30px rgba(168, 112, 48, .35);
  display: flex; flex-direction: column; min-height: 0;
}
.book-page.left { border-radius: 14px 4px 4px 14px; box-shadow: inset -24px 0 30px -18px rgba(120, 70, 20, .45), inset 0 0 30px rgba(168, 112, 48, .3); }
.book-page.right { border-radius: 4px 14px 14px 4px; box-shadow: inset 24px 0 30px -18px rgba(120, 70, 20, .45), inset 0 0 30px rgba(168, 112, 48, .3); }
.book-tabs { position: absolute; right: -58px; top: 40px; display: flex; flex-direction: column; gap: 8px; z-index: 6; }
.book-tab {
  width: 64px; height: 58px; padding: 6px 8px 6px 14px; border: 4px solid var(--ink); border-left: 0; border-radius: 0 18px 18px 0;
  background: var(--tab, #ffd23f); box-shadow: 0 4px 0 rgba(10, 4, 20, .5); transition: transform .15s;
}
.book-tab svg { width: 100%; height: 100%; }
.book-tab[aria-selected="true"] { transform: translateX(8px); filter: brightness(1.15); }
.page-title { margin: 0 0 8px; font-family: var(--font-title); font-size: clamp(22px, 3.4vh, 32px); color: #5a2c8a; display: flex; align-items: center; gap: 10px; }
.page-title svg { width: 40px; height: 40px; flex: none; }
.page-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; margin-right: -10px; padding-right: 10px; scrollbar-width: thin; }
.page-nav { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; font-weight: 700; }
.page-nav .round-btn { width: 52px; height: 52px; }
.flip-sheet {
  position: absolute; top: 3.2%; bottom: 3.6%; width: 46.6%; z-index: 4; pointer-events: none;
  background: linear-gradient(90deg, #f6e3bf, #fffaf0 60%, #e8c98e); border-radius: 4px 14px 14px 4px;
  transform-origin: 0% 50%; backface-visibility: hidden; box-shadow: -10px 0 30px rgba(60, 30, 10, .3);
}

.potion-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.potion-tile {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px 6px; border-radius: 16px;
  border: 3px solid transparent; background: rgba(255, 255, 255, .45); text-align: center; color: var(--ink); font-size: 13px; font-weight: 600; line-height: 1.1;
}
.potion-tile:hover, .potion-tile:focus-visible { border-color: var(--ink); background: rgba(255, 255, 255, .8); }
.potion-tile .pt-bottle { width: 64px; height: 80px; }
.potion-tile .pt-bottle svg { width: 100%; height: 100%; }
.potion-tile .pt-fav { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; }
.potion-tile.locked { opacity: .75; }
.potion-tile.locked .pt-bottle { filter: brightness(0) opacity(.35); }
.potion-detail { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; height: 100%; }
.potion-detail .pd-bottle { width: min(160px, 26vh); aspect-ratio: 120 / 150; }
.potion-detail .pd-bottle svg { width: 100%; height: 100%; overflow: visible; }
.potion-detail h3 { margin: 0; font-family: var(--font-title); font-size: clamp(20px, 3vh, 28px); }
.potion-detail p { margin: 0; font-weight: 600; color: var(--ink-soft); }
.pd-ings { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center; }
.pd-ings img { width: 54px; height: 54px; }
.pd-actions { display: flex; gap: 18px; margin-top: auto; }
.pd-meta { font-size: 14px; color: var(--ink-soft); }
.pd-meta b { color: var(--ink); }

.ing-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.ing-card { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border-radius: 14px; border: 3px solid transparent; background: rgba(255, 255, 255, .4); font-size: 12px; font-weight: 600; text-align: center; color: var(--ink); line-height: 1.1; }
.ing-card img { width: 60px; height: 60px; }
.ing-card.locked img { filter: grayscale(1) brightness(.5) opacity(.55); }
.ing-card[aria-pressed="true"] { border-color: var(--ink); background: #fff; }
.ing-info { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; }
.ing-info img { width: min(150px, 22vh); height: min(150px, 22vh); }
.ing-info h3 { margin: 0; font-family: var(--font-title); font-size: 26px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px 4px 6px; border-radius: 999px; background: rgba(255, 255, 255, .7); border: 2px solid var(--ink); font-weight: 600; font-size: 14px; }
.chip svg { width: 26px; height: 26px; }

.stat-list { display: grid; gap: 10px; }
.stat { display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 10px; font-weight: 600; }
.stat svg, .stat img { width: 48px; height: 48px; }
.stat-bar { height: 22px; border-radius: 11px; border: 3px solid var(--ink); background: rgba(255, 255, 255, .6); overflow: hidden; }
.stat-bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--mint), var(--cyan)); border-radius: 8px; }
.history-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.history-list li { display: grid; grid-template-columns: 44px 1fr auto; gap: 8px; align-items: center; padding: 4px 8px; border-radius: 12px; background: rgba(255, 255, 255, .45); font-weight: 600; font-size: 14px; }
.history-list .hl-bottle { width: 40px; height: 50px; }
.surprise-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.surprise-card { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px; border-radius: 14px; background: rgba(255, 255, 255, .45); text-align: center; font-size: 13px; font-weight: 600; }
.surprise-card .sc-icon { width: 48px; height: 48px; }
.surprise-card.locked { opacity: .55; }
.empty-note { padding: 20px; text-align: center; font-weight: 600; color: var(--ink-soft); }
.empty-note svg { width: 90px; height: 90px; display: block; margin: 0 auto 8px; }

@media (orientation: portrait), (max-width: 760px) {
  .book { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) minmax(0, 1.15fr); height: min(860px, 86vh); padding: 14px; margin-bottom: 40px; }
  .book-page.left { border-radius: 14px 14px 4px 4px; }
  .book-page.right { border-radius: 4px 4px 14px 14px; }
  .book-tabs { right: auto; left: 50%; top: auto; bottom: -46px; transform: translateX(-50%); flex-direction: row; }
  .book-tab { width: 56px; height: 56px; border: 4px solid var(--ink); border-top: 0; border-radius: 0 0 16px 16px; padding: 10px 6px 4px; }
  .book-tab[aria-selected="true"] { transform: translateY(6px); }
  .flip-sheet { display: none; }
}

/* ---------- Activités et réglages ---------- */
.panel {
  position: relative; width: min(860px, 94vw); max-height: 90vh; overflow: auto; padding: 30px 26px 22px; color: var(--ink);
  background: url('../assets/images/ui/parchment.svg') center / 100% 100% no-repeat;
  filter: drop-shadow(0 12px 0 rgba(10, 4, 20, .55));
}
.panel h2 { margin: 0 0 14px; text-align: center; font-family: var(--font-title); font-size: clamp(26px, 4vh, 38px); color: #5a2c8a; }
.activity-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.activity-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 8px 12px; border-radius: 22px;
  border: 4px solid var(--ink); background: linear-gradient(#fff8e6, #f0d9a8); box-shadow: 0 6px 0 rgba(26, 11, 46, .35);
  font-weight: 700; font-size: 16px; color: var(--ink); text-align: center; transition: transform .15s;
}
.activity-card:hover { transform: translateY(-4px) rotate(-1deg); }
.activity-card .ac-art { width: 96px; height: 96px; }
.activity-card .ac-art svg { width: 100%; height: 100%; }
.activity-card small { font-weight: 600; color: var(--ink-soft); font-size: 13px; }
.mission-list { display: grid; gap: 8px; margin-top: 14px; }
.mission-item { display: grid; grid-template-columns: 52px 1fr 44px; gap: 10px; align-items: center; padding: 6px 10px; border-radius: 16px; background: rgba(255, 255, 255, .5); border: 3px solid transparent; font-weight: 600; text-align: left; color: var(--ink); }
.mission-item .mi-icon { width: 52px; height: 52px; }
.mission-item .mi-state { width: 40px; height: 40px; }
.mission-item.done { background: rgba(111, 255, 192, .35); }
.mission-item.active { border-color: var(--ink); }

.settings-grid { display: grid; gap: 16px; }
.setting-row { display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 12px; font-weight: 600; font-size: 18px; }
.setting-row > svg { width: 56px; height: 56px; }
.toggle { position: relative; width: 92px; height: 52px; border-radius: 26px; border: 4px solid var(--ink); background: #c9b8e8; padding: 0; }
.toggle::after { content: ''; position: absolute; top: 4px; left: 4px; width: 36px; height: 36px; border-radius: 50%; background: #fff; border: 3px solid var(--ink); transition: transform .2s; }
.toggle[aria-checked="true"] { background: var(--mint); }
.toggle[aria-checked="true"]::after { transform: translateX(40px); }
input[type="range"].big-range { width: min(320px, 50vw); height: 44px; accent-color: #a56bff; }
.parents-zone { margin-top: 10px; padding: 14px; border-radius: 18px; border: 3px dashed var(--ink-soft); background: rgba(255, 255, 255, .35); }
.parents-zone h3 { margin: 0 0 8px; font-size: 18px; }
.parents-zone p { margin: 4px 0; font-size: 14px; }
.parent-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.text-btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 6px 14px; border-radius: 14px;
  border: 3px solid var(--ink); background: #fff8e6; font-weight: 700; color: var(--ink); box-shadow: 0 4px 0 rgba(26, 11, 46, .35);
}
.text-btn svg { width: 30px; height: 30px; }
.text-btn.danger { background: #ffd0dc; }
.hold-btn { position: relative; overflow: hidden; }
.hold-btn .hold-fill { position: absolute; inset: 0; background: rgba(165, 107, 255, .35); transform-origin: 0 50%; transform: scaleX(0); pointer-events: none; }
.status-line { font-size: 14px; color: var(--ink-soft); }
select.quality-select { font: inherit; font-size: 16px; padding: 8px 10px; border-radius: 12px; border: 3px solid var(--ink); background: #fff8e6; color: var(--ink); }
