:root {
  --bg: #14110f;
  --bg2: #1d1916;
  --card: #241f1b;
  --line: #3a322b;
  --text: #f3ece3;
  --muted: #a89a8a;
  --gold: #d8b273;
  --gold2: #f1d9a8;
  --good: #7fc28f;
  --bad: #e07a6b;
  --r: 18px;
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 15px; }
body { min-height: 100vh; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; }

header#top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(20,17,15,.88); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
header h1 { flex: 1; margin: 0; font-family: var(--serif); font-size: 26px; font-weight: 600; letter-spacing: .5px; color: var(--gold2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
header button { background: none; border: 0; font-size: 26px; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; color: var(--gold); }
header button:hover { background: var(--card); }
header button[hidden] { display: none; }

main { max-width: 760px; margin: 0 auto; padding: 16px; }

#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  background: rgba(29,25,22,.95); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
#tabbar button { background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); padding: 4px 6px; min-width: 60px; }
#tabbar .ico { font-size: 20px; line-height: 1; }
#tabbar button.on { color: var(--gold); }

h2 { font-family: var(--serif); font-weight: 600; font-size: 24px; margin: 22px 0 10px; color: var(--gold2); }
h2:first-child { margin-top: 4px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); margin: 18px 0 8px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row { display: flex; gap: 10px; align-items: center; }

/* Héro */
.hero { position: relative; overflow: hidden; display: flex; gap: 14px; align-items: center; cursor: pointer;
  background: radial-gradient(circle at 85% 20%, rgba(216,178,115,.25), transparent 60%), var(--card); }
.hero .kicker { font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: var(--gold); }
.hero .nm { font-family: var(--serif); font-size: 28px; font-weight: 700; line-height: 1.05; margin: 4px 0; }

/* Flacon */
.bottle { flex: none; display: block; }
.photo { flex: none; display: block; object-fit: contain; background: #fff; border-radius: 12px; padding: 3px; box-shadow: 0 2px 10px rgba(0,0,0,.35); }
.item .photo { border-radius: 9px; padding: 2px; }

/* Liste classement */
.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; cursor: pointer; transition: transform .1s, border-color .2s; }
.item:hover { border-color: var(--gold); }
.item:active { transform: scale(.99); }
.rank { width: 30px; text-align: center; font-family: var(--serif); font-size: 22px; font-weight: 700; color: var(--muted); flex: none; }
.rank.r1 { color: #f5cf6b; } .rank.r2 { color: #cfd6de; } .rank.r3 { color: #d39a6a; }
.item .info { flex: 1; min-width: 0; }
.item .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .br { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.score { flex: none; font-family: var(--serif); font-size: 22px; font-weight: 700; color: var(--gold2); text-align: right; }
.score small { display: block; font-family: var(--sans); font-size: 10px; color: var(--muted); font-weight: 500; letter-spacing: .5px; }

/* Chips / onglets */
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; background: var(--bg2); border: 1px solid var(--line); border-radius: 999px; padding: 7px 13px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.chip.on { background: var(--gold); border-color: var(--gold); color: #1a140e; font-weight: 600; }
.tag { display: inline-block; font-size: 11.5px; padding: 3px 9px; border-radius: 999px; background: var(--bg2); border: 1px solid var(--line); color: var(--muted); margin: 2px 4px 2px 0; }

.filters { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.search { width: 100%; background: var(--bg2); border: 1px solid var(--line); color: var(--text); border-radius: 12px; padding: 11px 14px; outline: none; }
.search:focus { border-color: var(--gold); }

.btn { background: var(--gold); color: #1a140e; border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 600; }
.btn.ghost { background: var(--bg2); color: var(--text); border: 1px solid var(--line); }
.btn.block { width: 100%; }
.btn:active { transform: scale(.98); }

/* Raccourcis */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 10px; text-align: center; font-size: 13px; font-weight: 500; }
.tile b { display: block; font-size: 24px; margin-bottom: 4px; }
.tile:hover { border-color: var(--gold); }

/* Fiche */
.detail-head { display: flex; gap: 16px; align-items: center; }
.detail-head .nm { font-family: var(--serif); font-size: 32px; font-weight: 700; line-height: 1; }
.big-score { font-family: var(--serif); font-size: 44px; font-weight: 700; color: var(--gold2); line-height: 1; }
.meter { margin: 8px 0; }
.meter .lbl { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.meter .bar { height: 8px; background: var(--bg2); border-radius: 99px; overflow: hidden; }
.meter .fill { height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold2)); border-radius: 99px; }
.pyr { display: flex; flex-direction: column; gap: 8px; }
.pyr .lvl { display: grid; grid-template-columns: 70px 1fr; gap: 8px; align-items: start; }
.pyr .lvl span:first-child { font-size: 12px; color: var(--gold); padding-top: 4px; }
.seasons { display: flex; gap: 6px; }
.season { flex: 1; text-align: center; padding: 8px 4px; border-radius: 12px; background: var(--bg2); border: 1px solid var(--line); font-size: 12px; color: var(--muted); opacity: .45; }
.season.on { opacity: 1; color: var(--text); border-color: var(--gold); }
.season b { display: block; font-size: 18px; }

.status-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.status-row button { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 4px; font-size: 13px; }
.status-row button.on { background: rgba(216,178,115,.18); border-color: var(--gold); color: var(--gold2); font-weight: 600; }

.stars { display: flex; gap: 4px; }
.stars button { background: none; border: 0; font-size: 28px; color: var(--line); padding: 0; }
.stars button.on { color: var(--gold); }
textarea.note { width: 100%; min-height: 70px; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; color: var(--text); padding: 10px; font: inherit; resize: vertical; margin-top: 10px; }

/* Duel */
.duel { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: stretch; }
.duel-card { background: var(--card); border: 2px solid var(--line); border-radius: 20px; padding: 14px 10px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; transition: transform .15s, border-color .15s; }
.duel-card:hover { border-color: var(--gold); transform: translateY(-2px); }
.duel-card .nm { font-family: var(--serif); font-size: 20px; font-weight: 700; line-height: 1.1; }
.duel-card.win { border-color: var(--good); }
.duel-card.lose { opacity: .4; }
.vs { text-align: center; font-family: var(--serif); font-size: 22px; color: var(--gold); margin: 8px 0; }

/* Quiz */
.q-opts { display: flex; flex-direction: column; gap: 8px; }
.q-opts button { text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; font-size: 15px; }
.q-opts button:hover { border-color: var(--gold); }
.progress { height: 4px; background: var(--bg2); border-radius: 4px; overflow: hidden; margin-bottom: 18px; }
.progress div { height: 100%; background: var(--gold); transition: width .3s; }

/* Comparateur */
.cmp { width: 100%; border-collapse: collapse; font-size: 14px; }
.cmp td { padding: 10px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.cmp td:first-child { color: var(--muted); font-size: 12px; width: 26%; }
.cmp td.w { color: var(--good); font-weight: 600; }
.cmp-tray { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 9; background: var(--gold); color: #1a140e; border-radius: 999px; padding: 10px 18px; font-weight: 600; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.4); border: 0; white-space: nowrap; }

.stat-big { font-family: var(--serif); font-size: 30px; font-weight: 700; color: var(--gold2); }
.empty { text-align: center; padding: 30px 10px; color: var(--muted); }
.empty b { display: block; font-size: 40px; margin-bottom: 8px; }

.fam-bar { display: flex; height: 14px; border-radius: 99px; overflow: hidden; margin: 8px 0; }

#toast { position: fixed; left: 50%; top: calc(70px + env(safe-area-inset-top)); transform: translateX(-50%) translateY(-20px); opacity: 0; pointer-events: none; background: var(--gold2); color: #1a140e; padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: 14px; transition: all .25s; z-index: 50; white-space: nowrap; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.fade { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (max-width: 380px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  #tabbar button { min-width: 0; font-size: 10px; }
}
