@font-face { font-family: 'Pacifico'; src: url('../fonts/pacifico.woff2') format('woff2'); font-display: block; }
@font-face { font-family: 'Playfair Display'; src: url('../fonts/playfair-display-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Playfair Display'; src: url('../fonts/playfair-display-latin-700-normal.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --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);
  --gold: #e8b765;
  --gold-2: #f6d9a0;
  --ink: #1a0d07;
  --paper: #f3e6cc;
  --neon: #ff4fa3;
  --serif: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  overflow: hidden; overscroll-behavior: none;
  background: #0b0503; color: var(--paper);
  font-family: var(--sans);
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
}
body { position: fixed; inset: 0; touch-action: none; }

#game { position: fixed; inset: 0; }
#game canvas { display: block; touch-action: none; }

#safe-probe {
  position: fixed; visibility: hidden; pointer-events: none;
  padding: var(--sat) var(--sar) var(--sab) var(--sal);
}

.hidden { display: none !important; }

/* ------------------------------------------------------------ boutons */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 54px; margin: 8px 0; padding: 12px 20px;
  border-radius: 14px; border: 1px solid rgba(232,183,101,0.45);
  background: linear-gradient(180deg, rgba(70,38,20,0.92), rgba(40,20,10,0.92));
  color: var(--gold-2); font: 600 18px/1 var(--serif); letter-spacing: 0.04em;
  box-shadow: 0 6px 18px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,220,160,0.18);
  cursor: pointer; touch-action: manipulation;
  transition: transform .08s ease, filter .15s;
}
.btn:active { transform: scale(0.97); filter: brightness(1.15); }
.btn.primary {
  background: linear-gradient(180deg, #f0c477, #c98a36);
  color: #2a1206; border-color: #ffe0a0; text-transform: uppercase; font-weight: 700;
  box-shadow: 0 8px 24px rgba(232,150,60,0.35), inset 0 1px 0 rgba(255,255,255,0.5);
}
.btn.ghost { background: rgba(20,10,5,0.55); border-color: rgba(232,183,101,0.25); font-size: 16px; }
.btn.danger-btn { color: #f19a8a; border-color: rgba(240,120,100,0.3); font-size: 14px; min-height: 44px; }
.pill { font: 600 13px var(--sans); background: rgba(232,183,101,0.2); padding: 4px 8px; border-radius: 999px; color: var(--gold-2); }

.icon-btn {
  width: 46px; height: 46px; border-radius: 50%;
  border: 1px solid rgba(232,183,101,0.45);
  background: rgba(25,12,6,0.72);
  display: grid; place-items: center; cursor: pointer; padding: 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  touch-action: manipulation;
}
.icon-btn:active { transform: scale(0.94); }
.i-pause, .i-pause::after { display: block; width: 5px; height: 17px; background: var(--gold-2); border-radius: 2px; }
.i-pause { position: relative; transform: translateX(-5px); }
.i-pause::after { content: ''; position: absolute; left: 10px; top: 0; }
.i-close { position: relative; width: 20px; height: 20px; }
.i-close::before, .i-close::after { content: ''; position: absolute; left: 9px; top: 0; width: 2.5px; height: 20px; background: var(--gold-2); border-radius: 2px; transform: rotate(45deg); }
.i-close::after { transform: rotate(-45deg); }
.i-book { width: 20px; height: 16px; border: 2.5px solid var(--gold-2); border-radius: 2px 2px 3px 3px; position: relative; }
.i-book::after { content: ''; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 2px; margin-left: -1px; background: var(--gold-2); }

/* ------------------------------------------------------------ HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud button, #next-box { pointer-events: auto; }
.hud-row {
  position: absolute; left: 0; right: 0; top: 0;
  padding: calc(var(--sat) + 8px) calc(var(--sar) + 12px) 0 calc(var(--sal) + 12px);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.scores { display: flex; gap: 10px; align-items: stretch; }
.scores > div {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 5px 14px; border-radius: 12px; min-width: 86px;
  background: rgba(20,10,5,0.66); border: 1px solid rgba(232,183,101,0.3);
}
.lbl { font: 600 10px var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: rgba(246,217,160,0.7); }
#hud-score { font: 700 22px/1.1 var(--serif); color: #fff1d4; display: inline-block; }
#hud-best { font: 700 16px/1.25 var(--serif); color: var(--gold); }
#hud-score.bump { animation: bump .35s ease; }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.25); color: #ffd27a; } 100% { transform: scale(1); } }

#next-box {
  position: absolute; left: calc(var(--sal) + 10px); bottom: calc(var(--sab) + 10px);
  display: flex; flex-direction: column; align-items: center; gap: 4px; width: 84px;
}
.coaster {
  width: 70px; height: 70px; border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #6b3d22, #2b150a 70%);
  border: 2px solid rgba(232,183,101,0.55);
  box-shadow: 0 6px 16px rgba(0,0,0,0.5), inset 0 0 12px rgba(0,0,0,0.6);
  display: grid; place-items: center; overflow: hidden;
}
.coaster img { max-width: 58px; max-height: 58px; object-fit: contain; filter: drop-shadow(0 3px 3px rgba(0,0,0,0.5)); transition: transform .25s; }
.coaster img.swap { transform: scale(0.6); }
#next-name { font: 600 11px var(--sans); color: rgba(246,217,160,0.85); text-align: center; text-shadow: 0 1px 2px #000; }

#danger-banner {
  position: absolute; left: 50%; top: calc(var(--sat) + 66px); transform: translateX(-50%);
  padding: 8px 16px; border-radius: 999px; white-space: nowrap;
  background: rgba(160,20,10,0.85); color: #fff; font: 700 13px var(--sans); letter-spacing: 0.04em;
  box-shadow: 0 0 20px rgba(255,60,40,0.6);
  animation: pulse 0.6s ease-in-out infinite alternate;
}
@keyframes pulse { from { opacity: 0.75; } to { opacity: 1; } }

#hint {
  position: absolute; left: 50%; bottom: calc(var(--sab) + 160px); transform: translateX(-50%);
  width: max-content; max-width: 80vw; text-align: center;
  padding: 10px 14px; border-radius: 12px; background: rgba(10,5,2,0.72);
  font: 500 14px var(--sans); color: var(--gold-2); border: 1px solid rgba(232,183,101,0.3);
  animation: hintIn 0.5s ease;
}
@keyframes hintIn { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ------------------------------------------------------------ écrans */
.screen {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  padding: calc(var(--sat) + 16px) calc(var(--sar) + 16px) calc(var(--sab) + 16px) calc(var(--sal) + 16px);
  background: radial-gradient(ellipse at 50% 35%, rgba(40,18,8,0.55), rgba(5,2,1,0.82));
  -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px);
  animation: fadeIn .22s ease;
}
@keyframes fadeIn { from { opacity: 0; } }

.panel, .menu-inner { width: 100%; max-width: 360px; text-align: center; }
.panel {
  padding: 22px 20px 16px; border-radius: 22px;
  background: linear-gradient(180deg, rgba(48,25,13,0.95), rgba(24,12,6,0.96));
  border: 1px solid rgba(232,183,101,0.35);
  box-shadow: 0 20px 60px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,220,160,0.12);
}
h2 { font: 700 28px/1.1 var(--serif); color: var(--gold-2); margin: 0 0 14px; }
.sub { margin: -6px 0 14px; color: rgba(243,230,204,0.7); font-size: 14px; }

#screen-menu { background: linear-gradient(180deg, rgba(5,2,1,0.35), rgba(5,2,1,0.55) 45%, rgba(5,2,1,0.85)); -webkit-backdrop-filter: none; backdrop-filter: none; align-items: flex-end; }
#screen-menu .menu-inner { margin-bottom: 4vh; }

.neon-logo {
  font: 400 clamp(48px, 16vw, 76px)/1.25 'Pacifico', 'Snell Roundhand', cursive;
  color: #ffe6f2; margin: 0 0 4px;
  text-shadow: 0 0 4px #fff, 0 0 10px var(--neon), 0 0 22px var(--neon), 0 0 44px var(--neon), 0 0 80px rgba(255,79,163,0.6);
  animation: flicker 6s infinite;
}
.neon-logo.small { font-size: 44px; }
@keyframes flicker { 0%, 92%, 95%, 100% { opacity: 1; } 93% { opacity: 0.55; } 94% { opacity: 0.95; } 96% { opacity: 0.7; } }
.tagline { margin: 0 0 20px; font: italic 16px var(--serif); color: rgba(246,217,160,0.85); }
.menu-best { margin-top: 12px; font: 14px var(--sans); color: rgba(243,230,204,0.75); }
.menu-best strong { font: 700 18px var(--serif); color: var(--gold); margin-left: 6px; }

.stat { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 4px; border-bottom: 1px solid rgba(232,183,101,0.15); font-size: 15px; color: rgba(243,230,204,0.85); }
.stat strong { font: 700 20px var(--serif); color: var(--gold-2); }
.stat.big strong { font-size: 38px; color: #fff1d4; }
.stat:last-of-type { margin-bottom: 14px; }
.newbest { margin: 8px auto; display: inline-block; padding: 6px 14px; border-radius: 999px; background: linear-gradient(90deg, #f0c477, #ff9a5a); color: #2a1206; font: 700 13px var(--sans); letter-spacing: 0.06em; text-transform: uppercase; animation: bump .6s ease 2; }

/* toggles */
.toggle, .slider { display: flex; align-items: center; justify-content: space-between; padding: 14px 4px; border-bottom: 1px solid rgba(232,183,101,0.15); font-size: 16px; }
.toggle input { display: none; }
.toggle i { width: 52px; height: 30px; border-radius: 999px; background: #3a2418; position: relative; transition: background .2s; border: 1px solid rgba(232,183,101,0.3); }
.toggle i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #d8c4a0; transition: transform .2s; }
.toggle input:checked + i { background: #c98a36; }
.toggle input:checked + i::after { transform: translateX(22px); background: #fff4dc; }
.slider input { width: 50%; accent-color: #e8b765; }
.slider { margin-bottom: 12px; }

/* ------------------------------------------------------------ livre */
#screen-book { align-items: stretch; padding: 0; }
.book {
  width: 100%; max-width: 560px; margin: 0 auto; display: flex; flex-direction: column;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255,220,170,0.08), transparent 60%),
    linear-gradient(180deg, #2a160b, #160a05);
  border-left: 1px solid rgba(232,183,101,0.15); border-right: 1px solid rgba(232,183,101,0.15);
}
.book-head {
  display: flex; align-items: center; gap: 14px;
  padding: calc(var(--sat) + 12px) 16px 12px;
  border-bottom: 1px solid rgba(232,183,101,0.25);
}
.book-head h2 { font-size: 22px; margin: 0 0 6px; text-align: left; }
.book-head > div { flex: 1; }
.progress { display: flex; align-items: center; gap: 10px; font: 700 14px var(--sans); color: var(--gold); }
.progress .bar { flex: 1; height: 6px; border-radius: 3px; background: rgba(255,255,255,0.08); overflow: hidden; }
.progress .bar div { height: 100%; background: linear-gradient(90deg, #c98a36, #ffd27a); width: 0; transition: width .4s; }
.book-grid {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; overscroll-behavior: contain;
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
  padding: 14px 14px calc(var(--sab) + 18px);
}
.card {
  position: relative; border-radius: 16px; padding: 10px 8px 12px; text-align: center;
  background: linear-gradient(180deg, rgba(90,52,28,0.55), rgba(35,18,9,0.75));
  border: 1px solid rgba(232,183,101,0.25);
  box-shadow: inset 0 1px 0 rgba(255,220,160,0.1), 0 6px 14px rgba(0,0,0,0.35);
  cursor: pointer; touch-action: manipulation;
}
.card:active { transform: scale(0.97); }
.card .num { position: absolute; top: 8px; left: 10px; font: 700 12px var(--serif); color: rgba(232,183,101,0.7); }
.card .img { height: 122px; display: grid; place-items: end center; }
.card img { max-width: 100%; max-height: 118px; object-fit: contain; filter: drop-shadow(0 6px 6px rgba(0,0,0,0.5)); }
.card.locked img { filter: brightness(0) drop-shadow(0 0 1px rgba(232,183,101,0.35)); opacity: 0.75; }
.card.locked { cursor: default; background: linear-gradient(180deg, rgba(40,22,12,0.6), rgba(20,10,5,0.75)); }
.card .name { margin-top: 8px; font: 700 15px var(--serif); color: var(--gold-2); min-height: 20px; }
.card.locked .name { color: rgba(232,183,101,0.4); letter-spacing: 0.2em; }
.card.fresh { animation: glowCard 1.6s ease 2; }
@keyframes glowCard { 50% { box-shadow: 0 0 24px rgba(255,200,120,0.7); } }

/* ------------------------------------------------------------ fiche recette */
#screen-recipe { align-items: flex-start; overflow-y: auto; touch-action: pan-y; }
.recipe {
  position: relative; width: 100%; max-width: 420px; margin: auto;
  padding: 18px 22px 24px; border-radius: 6px;
  background:
    radial-gradient(ellipse at 30% 10%, rgba(255,255,255,0.4), transparent 50%),
    linear-gradient(180deg, #f4e7cc, #e8d4ae);
  color: #2b1608;
  box-shadow: 0 25px 70px rgba(0,0,0,0.7), inset 0 0 40px rgba(140,90,40,0.25);
  animation: cardIn .3s ease;
}
@keyframes cardIn { from { transform: translateY(20px) rotate(-1deg); opacity: 0; } }
.recipe .close { position: absolute; right: 12px; top: 12px; background: rgba(40,20,10,0.85); }
.recipe-hero { height: 220px; display: grid; place-items: end center; margin: 4px 0 6px;
  background: radial-gradient(ellipse at 50% 92%, rgba(60,30,10,0.35), transparent 60%); }
.recipe-hero img { max-height: 210px; max-width: 80%; object-fit: contain; filter: drop-shadow(0 8px 8px rgba(0,0,0,0.35)); }
.recipe-level { text-align: center; font: 700 11px var(--sans); letter-spacing: 0.2em; text-transform: uppercase; color: #9a5a22; }
.recipe h2 { color: #2b1608; text-align: center; font-size: 30px; margin: 4px 0 2px; }
.recipe-glass { text-align: center; font: italic 14px var(--serif); color: #7a4a22; margin-bottom: 10px; }
.recipe-desc { font: 15px/1.5 var(--serif); margin: 10px 0 14px; }
.recipe h3 { font: 700 13px var(--sans); letter-spacing: 0.16em; text-transform: uppercase; color: #9a5a22; margin: 14px 0 6px; border-bottom: 1px solid rgba(120,70,30,0.3); padding-bottom: 4px; }
.recipe ul, .recipe ol { margin: 0; padding-left: 20px; font: 15px/1.55 var(--sans); }

/* ------------------------------------------------------------ découverte */
#discovery { z-index: 30; background: radial-gradient(ellipse at 50% 45%, rgba(60,30,10,0.6), rgba(5,2,1,0.88)); }
.disc-card { position: relative; text-align: center; width: 100%; max-width: 340px; }
.disc-rays {
  position: absolute; left: 50%; top: 42%; width: 520px; height: 520px; margin: -260px 0 0 -260px; z-index: -1;
  background: repeating-conic-gradient(from 0deg, rgba(255,210,140,0.16) 0deg 8deg, transparent 8deg 20deg);
  -webkit-mask-image: radial-gradient(circle, #000 20%, transparent 65%); mask-image: radial-gradient(circle, #000 20%, transparent 65%);
  animation: spin 14s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.disc-kicker { font: 700 12px var(--sans); letter-spacing: 0.22em; text-transform: uppercase; color: var(--gold); }
#disc-img { display: block; margin: 14px auto 6px; max-height: 38vh; max-width: 70%; filter: drop-shadow(0 12px 16px rgba(0,0,0,0.6)) drop-shadow(0 0 30px rgba(255,190,110,0.35)); animation: discPop .7s cubic-bezier(.2,1.6,.4,1); }
@keyframes discPop { from { transform: scale(0.2) translateY(40px); opacity: 0; } }
#disc-name { font-size: 34px; margin: 6px 0 2px; text-shadow: 0 0 18px rgba(255,190,110,0.5); animation: fadeUp .6s .25s ease both; }
.disc-level { color: rgba(243,230,204,0.7); font-size: 14px; margin-bottom: 18px; animation: fadeUp .6s .35s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } }
#btn-disc { max-width: 240px; margin: 0 auto; animation: fadeUp .5s .5s ease both; }

#toast {
  position: fixed; left: 50%; top: calc(var(--sat) + 70px); transform: translateX(-50%); z-index: 25;
  display: flex; align-items: center; gap: 10px; padding: 8px 16px 8px 8px; border-radius: 999px;
  background: rgba(25,12,6,0.9); border: 1px solid rgba(232,183,101,0.5);
  font: 600 14px var(--sans); color: var(--gold-2); white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  animation: toastIn .35s ease;
}
#toast img { height: 40px; }
#toast small { display: block; font: 600 10px var(--sans); letter-spacing: 0.15em; text-transform: uppercase; color: rgba(246,217,160,0.65); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -12px); } }

#loading { position: fixed; inset: 0; z-index: 100; background: #0b0503; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; transition: opacity .4s; }
.loading-txt { font: italic 15px var(--serif); color: rgba(246,217,160,0.7); }

@media (min-height: 760px) { .card .img { height: 140px; } .card img { max-height: 136px; } }
