:root {
  --sand: #e8c47a;
  --sand-deep: #c9a15a;
  --nile: #3a7ca5;
  --nile-deep: #245a7a;
  --ink: #1a1208;
  --ink-soft: #3d2a14;
  --papyrus: #f3e2b8;
  --papyrus-dark: #d9c08a;
  --accent: #c45c26;
  --accent-soft: #e08a4a;
  --gold: #f0c14a;
  --frame: #2a1c0c;
  --shadow: rgba(26, 18, 8, 0.55);
  --ui-font: "VT323", "Courier New", monospace;
  --display-font: "Press Start 2P", "Courier New", monospace;
  --hand-font: "Caveat", "Segoe Script", "Comic Sans MS", cursive;
  --pixel: 4px;
  /* Hauteur réservée au HUD haut + bas + gaps + padding (évite hors cadre PC) */
  --chrome-h: 7.5rem;
  --app-pad: 0.6rem;
  --app-gap: 0.45rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  background:
    radial-gradient(ellipse at 20% 0%, #3a2814 0%, transparent 45%),
    radial-gradient(ellipse at 80% 100%, #1e3a48 0%, transparent 40%),
    linear-gradient(160deg, #1a1208 0%, #2a1c0c 45%, #142028 100%);
  color: var(--papyrus);
  font-family: var(--ui-font);
  font-size: clamp(16px, 2.1vw, 22px);
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#app,
.app {
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  align-items: center;
  justify-items: center;
  gap: var(--app-gap);
  padding: var(--app-pad);
  overflow: hidden;
}

.app.hidden {
  display: none;
}

/* —— Écran d'accueil —— */
.title-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: #1a1208;
  overflow: hidden;
}

.title-screen.hidden {
  display: none;
}

.title-screen.leaving {
  animation: title-leave 520ms ease forwards;
  pointer-events: none;
}

#title-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  pointer-events: none;
}

.title-ui {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.55rem;
  padding: 1.5rem;
  max-width: 92vw;
  pointer-events: auto;
}

.title-kicker {
  margin: 0;
  font-family: var(--display-font);
  font-size: clamp(0.45rem, 1.6vw, 0.6rem);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--papyrus);
  text-shadow: 2px 2px 0 var(--ink);
  opacity: 0.9;
  animation: title-fade-up 700ms ease both;
}

.title-logo {
  margin: 0;
  max-width: 16ch;
  font-family: var(--display-font);
  font-size: clamp(1rem, 5.2vw, 2rem);
  line-height: 1.35;
  text-align: center;
  color: var(--gold);
  text-shadow:
    3px 3px 0 var(--ink),
    0 0 24px rgba(240, 193, 74, 0.35);
  animation: title-fade-up 800ms 80ms ease both, logo-glow 2.4s ease-in-out infinite;
}

.title-tagline {
  margin: 0 0 0.8rem;
  font-size: clamp(1.15rem, 3vw, 1.5rem);
  color: var(--papyrus);
  text-shadow: 2px 2px 0 var(--ink);
  animation: title-fade-up 900ms 140ms ease both;
}

.title-start {
  font-family: var(--display-font);
  font-size: clamp(0.65rem, 2.2vw, 0.85rem);
  padding: 0.85rem 1.6rem;
  border: 4px solid var(--ink);
  background: var(--accent);
  color: var(--papyrus);
  box-shadow: 5px 5px 0 var(--ink);
  cursor: pointer;
  position: relative;
  z-index: 5;
  animation: title-fade-up 1000ms 220ms ease both, start-glow 1.4s ease-in-out infinite;
}

.title-start:hover {
  background: var(--accent-soft);
  color: var(--ink);
}

.title-start:active {
  transform: translate(3px, 3px);
  box-shadow: 2px 2px 0 var(--ink);
}

.music-hint {
  margin: 0.6rem 0 0;
  font-size: 1rem;
  opacity: 0.75;
  text-shadow: 1px 1px 0 var(--ink);
  animation: title-fade-up 1100ms 280ms ease both, hint-blink 1.8s ease-in-out infinite;
}

.music-hint.hidden {
  display: none;
}

.title-music-credit {
  position: absolute;
  left: 0.75rem;
  bottom: 0.7rem;
  z-index: 3;
  max-width: min(42vw, 16rem);
  font-family: var(--display-font);
  font-size: clamp(0.28rem, 1.1vw, 0.38rem);
  line-height: 1.45;
  letter-spacing: 0.04em;
  color: rgba(243, 226, 184, 0.72);
  text-decoration: none;
  text-shadow: 1px 1px 0 rgba(26, 18, 8, 0.85);
  pointer-events: auto;
  transition: color 120ms ease;
}

.title-music-credit span {
  color: rgba(240, 193, 74, 0.9);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.title-music-credit:hover,
.title-music-credit:focus-visible {
  color: var(--papyrus);
  outline: none;
}

.title-music-credit:hover span,
.title-music-credit:focus-visible span {
  color: var(--gold);
}

.title-mute {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 3;
  width: 2.6rem;
  height: 2.6rem;
  font-size: 1.2rem;
  border: 3px solid var(--ink);
  background: rgba(232, 196, 122, 0.9);
  color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.title-mute.visible {
  opacity: 1;
  pointer-events: auto;
}

@keyframes title-fade-up {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes logo-glow {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.12); }
}

@keyframes start-glow {
  0%, 100% { filter: brightness(1); box-shadow: 5px 5px 0 var(--ink); }
  50% { filter: brightness(1.12); box-shadow: 5px 5px 0 var(--ink), 0 0 12px rgba(240, 193, 74, 0.35); }
}

@keyframes hint-blink {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 0.9; }
}

@keyframes title-leave {
  to {
    opacity: 0;
    transform: scale(1.03);
  }
}

.hud {
  width: min(1140px, 100%);
  max-width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-shrink: 0;
  min-width: 0;
}

/* Zone jeu + programme du jour à gauche */
.play-layout {
  /* Même budget que le cadre de jeu → programme = même hauteur */
  --stage-max-h: min(720px, calc(100dvh - var(--chrome-h)));
  --stage-max-w: min(920px, calc(100vw - (var(--app-pad) * 2) - 160px));
  --stage-h: min(var(--stage-max-h), calc(var(--stage-max-w) * 3 / 4));
  --stage-w: min(var(--stage-max-w), calc(var(--stage-max-h) * 4 / 3));
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: clamp(0.5rem, 1.2vw, 0.9rem);
  width: min(1140px, 100%);
  max-width: 100%;
  min-width: 0;
  min-height: 0;
  height: var(--stage-h);
  max-height: 100%;
}

.day-agenda {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 0 0 clamp(138px, 16vw, 196px);
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  padding: 0.55rem 0.55rem 0.65rem;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(240, 193, 74, 0.14), transparent 28%),
    linear-gradient(180deg, #f8ecc8 0%, var(--papyrus) 42%, #e2c88a 100%);
  border: 3px solid #3d2a14;
  box-shadow:
    inset 0 0 0 2px rgba(240, 193, 74, 0.55),
    4px 4px 0 var(--shadow);
}

.day-agenda::before,
.day-agenda::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  border: 2px solid var(--gold);
  pointer-events: none;
}

.day-agenda::before {
  top: 5px;
  left: 5px;
  border-right: none;
  border-bottom: none;
}

.day-agenda::after {
  top: 5px;
  right: 5px;
  border-left: none;
  border-bottom: none;
}

.day-agenda-ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  margin-bottom: 0.25rem;
}

.day-agenda-sun {
  width: 10px;
  height: 10px;
  background: var(--gold);
  box-shadow: 0 0 0 2px #3d2a14;
  transform: rotate(45deg);
}

.day-agenda-wing {
  width: 22px;
  height: 3px;
  background: linear-gradient(90deg, transparent, #c45c26, transparent);
}

.day-agenda-kicker {
  margin: 0 0 0.15rem;
  font-family: var(--display-font);
  font-size: clamp(0.28rem, 0.7vw, 0.34rem);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #8a6a3a;
  text-align: center;
}

.day-agenda-title {
  margin: 0 0 0.35rem;
  font-family: var(--display-font);
  font-size: clamp(0.32rem, 0.8vw, 0.4rem);
  line-height: 1.35;
  color: #3d2a14;
  letter-spacing: 0.02em;
  text-align: center;
  padding-bottom: 0.3rem;
  border-bottom: 2px solid rgba(61, 42, 20, 0.25);
}

.day-agenda-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.14rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(61, 42, 20, 0.45) transparent;
}

.day-agenda-item {
  margin: 0;
  font-size: clamp(0.68rem, 1.4vw, 0.82rem);
  line-height: 1.15;
  color: var(--ink);
  padding: 0.12rem 0.2rem;
}

.day-agenda-item.is-done {
  text-decoration: line-through;
  color: #7a6a52;
  opacity: 0.72;
}

.day-agenda-item.is-current {
  font-weight: 700;
  color: #1a1208;
  background: rgba(240, 193, 74, 0.28);
  box-shadow: inset 3px 0 0 var(--gold);
}

.day-agenda-item.is-upcoming {
  color: #9a8a72;
}

.day-agenda-foot {
  margin-top: auto;
  flex-shrink: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, #c45c26, var(--gold), #c45c26, transparent);
  opacity: 0.75;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
}

.brand-mark {
  color: var(--gold);
  font-size: 0.9rem;
  animation: pulse-gold 1.6s ease-in-out infinite;
}

.brand h1 {
  margin: 0;
  font-family: var(--display-font);
  font-size: clamp(0.48rem, 1.5vw, 0.72rem);
  letter-spacing: 0.02em;
  color: var(--gold);
  text-shadow: 2px 2px 0 var(--ink);
  white-space: nowrap;
}

.hud-stats {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.15rem;
}

.hud-btn,
.pixel-btn,
.icon-btn {
  font-family: var(--display-font);
  image-rendering: pixelated;
  border: 3px solid var(--ink);
  background: var(--sand);
  color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
}

.hud-btn {
  font-size: 0.55rem;
  padding: 0.45rem 0.7rem;
}

.hud-icon-btn {
  position: relative;
  width: clamp(36px, 5vw, 44px);
  height: clamp(36px, 5vw, 44px);
  padding: 0;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.hud-btn:active,
.pixel-btn:active,
.icon-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

/* Icônes pixel art (livre / sac) */
.pixel-icon {
  display: block;
  width: 24px;
  height: 24px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background-repeat: no-repeat;
  background-size: 24px 24px;
}

.pixel-icon-book {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' shape-rendering='crispEdges'%3E%3Crect width='24' height='24' fill='none'/%3E%3Crect x='3' y='2' width='18' height='20' fill='%231a1208'/%3E%3Crect x='4' y='3' width='7' height='18' fill='%23c45c26'/%3E%3Crect x='12' y='3' width='8' height='18' fill='%23f3e2b8'/%3E%3Crect x='5' y='5' width='5' height='2' fill='%23f0c14a'/%3E%3Crect x='5' y='9' width='5' height='1' fill='%23e08a4a'/%3E%3Crect x='5' y='12' width='5' height='1' fill='%23e08a4a'/%3E%3Crect x='14' y='6' width='5' height='1' fill='%233d2a14'/%3E%3Crect x='14' y='9' width='5' height='1' fill='%233d2a14'/%3E%3Crect x='14' y='12' width='4' height='1' fill='%233d2a14'/%3E%3Crect x='11' y='3' width='1' height='18' fill='%231a1208'/%3E%3C/svg%3E");
}

.pixel-icon-bag {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' shape-rendering='crispEdges'%3E%3Crect width='24' height='24' fill='none'/%3E%3Crect x='7' y='3' width='10' height='3' fill='%231a1208'/%3E%3Crect x='8' y='2' width='8' height='2' fill='%233d2a14'/%3E%3Crect x='4' y='6' width='16' height='15' fill='%231a1208'/%3E%3Crect x='5' y='7' width='14' height='13' fill='%23c9a15a'/%3E%3Crect x='6' y='8' width='12' height='3' fill='%23e8c47a'/%3E%3Crect x='9' y='12' width='6' height='5' fill='%233d2a14'/%3E%3Crect x='10' y='13' width='4' height='3' fill='%23f0c14a'/%3E%3Crect x='5' y='18' width='14' height='1' fill='%239a7a3a'/%3E%3C/svg%3E");
}

.pixel-icon-trophy {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' shape-rendering='crispEdges'%3E%3Crect width='24' height='24' fill='none'/%3E%3Crect x='9' y='3' width='6' height='2' fill='%231a1208'/%3E%3Crect x='8' y='5' width='8' height='8' fill='%23f0c14a'/%3E%3Crect x='9' y='6' width='6' height='6' fill='%23e8c47a'/%3E%3Crect x='5' y='6' width='3' height='2' fill='%23f0c14a'/%3E%3Crect x='16' y='6' width='3' height='2' fill='%23f0c14a'/%3E%3Crect x='4' y='8' width='2' height='3' fill='%23c9a15a'/%3E%3Crect x='18' y='8' width='2' height='3' fill='%23c9a15a'/%3E%3Crect x='10' y='13' width='4' height='3' fill='%231a1208'/%3E%3Crect x='8' y='16' width='8' height='2' fill='%23c45c26'/%3E%3Crect x='7' y='18' width='10' height='3' fill='%231a1208'/%3E%3Crect x='8' y='19' width='8' height='1' fill='%23f0c14a'/%3E%3C/svg%3E");
}

.hud-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 10px;
  height: 10px;
  border-radius: 0;
  background: #e03a3a;
  border: 2px solid var(--ink);
  box-shadow: 0 0 0 1px rgba(240, 193, 74, 0.7);
  animation: badge-pulse 1.1s ease-in-out infinite;
  pointer-events: none;
}

.hud-badge.hidden {
  display: none;
}

@keyframes badge-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: 0.85; }
}

/* —— Succès —— */
.achievements-panel {
  position: fixed;
  inset: 0;
  z-index: 42;
  display: grid;
  place-items: center;
  padding: clamp(0.5rem, 2vh, 1.25rem);
  background: rgba(10, 8, 4, 0.55);
  opacity: 0;
  visibility: hidden;
  transition: opacity 220ms ease, visibility 220ms ease;
}

.achievements-panel.open {
  opacity: 1;
  visibility: visible;
}

.achievements-panel.hidden {
  display: grid;
}

.achievements-tray {
  width: min(520px, 94vw);
  max-height: min(78dvh, 640px);
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(180deg, rgba(240, 193, 74, 0.12), transparent 28%),
    linear-gradient(180deg, #f6e8c4 0%, var(--papyrus) 45%, var(--papyrus-dark) 100%);
  color: var(--ink);
  border: 4px solid var(--ink);
  box-shadow: 8px 8px 0 var(--shadow);
  padding: 0.85rem 0.9rem 1rem;
  overflow: hidden;
}

.achievements-tray-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
  flex-shrink: 0;
}

.achievements-tray-head h2 {
  margin: 0;
  font-family: var(--display-font);
  font-size: 0.55rem;
  flex: 1;
}

.achievements-count {
  margin: 0;
  font-size: 0.95rem;
  color: #7a6a52;
}

.achievements-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  overflow: auto;
  min-height: 0;
}

.achievement-card {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 0.65rem;
  align-items: center;
  min-height: 64px;
  padding: 0.55rem 0.65rem;
  border: 3px solid var(--ink);
  background: rgba(26, 18, 8, 0.06);
  box-shadow: 3px 3px 0 rgba(26, 18, 8, 0.2);
}

.achievement-card.is-ticket {
  grid-template-columns: 70px 1fr;
  align-items: stretch;
}

.achievement-card.is-locked {
  background:
    repeating-linear-gradient(
      -45deg,
      rgba(26, 18, 8, 0.08),
      rgba(26, 18, 8, 0.08) 6px,
      rgba(26, 18, 8, 0.03) 6px,
      rgba(26, 18, 8, 0.03) 12px
    );
}

.achievement-card.is-unlocked {
  background: linear-gradient(180deg, rgba(240, 193, 74, 0.22), rgba(243, 226, 184, 0.55));
  box-shadow: 3px 3px 0 var(--ink);
}

.achievement-icon-wrap {
  width: 48px;
  height: 48px;
  border: 2px solid var(--ink);
  background: #2a2218;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.achievement-card.is-unlocked .achievement-icon-wrap {
  background: #1a1208;
}

/* Succès — vrai ticket vertical Pimprenel */
.achievement-card.is-ticket.is-unlocked {
  background:
    linear-gradient(180deg, #fff8dc 0%, #f6e8c4 55%, #e8d09a 100%);
  border-color: #3d2a14;
  box-shadow:
    0 0 0 1px rgba(240, 193, 74, 0.55),
    3px 3px 0 #3d2a14;
}

.achievement-card.is-ticket .achievement-icon-wrap,
.achievement-icon-wrap.is-ticket {
  position: relative;
  width: 64px;
  height: 96px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0;
  border: 2px solid #3d2a14;
  border-radius: 5px;
  background:
    linear-gradient(180deg, #fff4c8 0%, #f0c14a 45%, #c9a15a 100%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.4),
    2px 2px 0 rgba(61, 42, 20, 0.25);
  overflow: visible;
}

/* Trous latéraux du mini-ticket */
.achievement-icon-wrap.is-ticket::before,
.achievement-icon-wrap.is-ticket::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #f6e8c4;
  transform: translateX(-50%);
  z-index: 3;
  box-shadow: inset 0 0 0 1.5px #3d2a14;
  pointer-events: none;
}

.achievement-icon-wrap.is-ticket::before { top: -6px; }
.achievement-icon-wrap.is-ticket::after { bottom: -6px; }

.ticket-mini-stub,
.ticket-mini-foot {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  font-family: var(--display-font);
  font-size: 0.32rem;
  letter-spacing: 0.08em;
  color: #3d2a14;
  padding: 0.2rem 0.15rem;
}

.ticket-mini-stub {
  border-bottom: 2px dashed rgba(61, 42, 20, 0.4);
}

.ticket-mini-foot {
  border-top: 2px dashed rgba(61, 42, 20, 0.4);
}

.ticket-mini-perf {
  display: none;
}

.ticket-mini-photo {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0.2rem 0.25rem;
  border: 1.5px solid #3d2a14;
  background: #0d0a06;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.ticket-mini-photo .achievement-icon {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  image-rendering: auto;
  background: #0d0a06;
}

.ticket-mini-photo .achievement-locked-mark {
  font-size: 0.85rem;
}

.achievement-card.is-ticket .achievement-title {
  color: #3d2a14;
}

.achievement-toast-card.is-ticket {
  background: linear-gradient(135deg, #fff4c8, #f0c14a 50%, #c9a15a);
  border-color: #3d2a14;
  color: #3d2a14;
}

.achievement-toast-card.is-ticket .achievement-toast-kicker {
  color: #3d2a14;
}

.achievement-toast-card.is-ticket .achievement-toast-icon {
  border-color: #3d2a14;
  border-radius: 3px;
}

.achievement-icon {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: auto;
}

.achievement-locked-mark {
  font-family: var(--display-font);
  font-size: 1.1rem;
  color: #6a5a48;
}

.achievement-body {
  min-width: 0;
}

.achievement-title {
  margin: 0 0 0.2rem;
  font-family: var(--display-font);
  font-size: 0.42rem;
  line-height: 1.4;
}

.achievement-desc {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.2;
  color: #3d2a14;
}

.achievement-date {
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
  color: #7a6a52;
}

.achievement-locked-hint {
  margin: 0;
  font-size: 0.85rem;
  color: #8a7a62;
  font-style: italic;
}

.achievement-toast {
  position: fixed;
  right: clamp(0.6rem, 2vw, 1.25rem);
  bottom: clamp(0.8rem, 3vh, 1.5rem);
  z-index: 60;
  pointer-events: none;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 220ms ease, transform 260ms ease;
}

.achievement-toast.open {
  opacity: 1;
  transform: translateY(0);
}

.achievement-toast.hidden {
  display: block;
  visibility: hidden;
}

.achievement-toast.open:not(.hidden) {
  visibility: visible;
}

.achievement-toast-card {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: min(280px, 86vw);
  padding: 0.55rem 0.7rem;
  background: linear-gradient(180deg, #2a2218, #1a1208);
  border: 3px solid var(--gold);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.45), 0 0 18px rgba(240, 193, 74, 0.25);
  color: var(--papyrus);
}

.achievement-toast-icon {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border: 2px solid var(--gold);
  background: #0d0a06;
  image-rendering: auto;
}

.achievement-toast-kicker {
  margin: 0;
  font-family: var(--display-font);
  font-size: 0.34rem;
  color: var(--gold);
  letter-spacing: 0.04em;
}

.achievement-toast-title {
  margin: 0.2rem 0 0;
  font-size: 1rem;
  line-height: 1.2;
}

.patpat-photo-frame {
  position: relative;
  width: min(220px, 70vw);
  display: grid;
  place-items: center;
}

.gold-ticket-ornament {
  display: none;
}

.patpat-serial {
  margin: 0;
  font-family: var(--display-font);
  font-size: 0.34rem;
  letter-spacing: 0.06em;
  color: #3d2a14;
}

.patpat-serial.hidden {
  display: none;
}

/* Ticket d'or vertical — photo entière (contain) + trous + décor */
.patpat-card.is-golden {
  --ticket-gold: #f0c14a;
  --ticket-gold-deep: #c9a15a;
  --ticket-ink: #3d2a14;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
  padding: 0.65rem 0.7rem 0.55rem;
  width: min(248px, 78vw);
  max-width: min(248px, 78vw);
  aspect-ratio: unset;
  overflow: visible;
  border: 3px solid var(--ticket-ink);
  border-radius: 8px;
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 7px,
      rgba(61, 42, 20, 0.04) 7px,
      rgba(61, 42, 20, 0.04) 8px
    ),
    linear-gradient(180deg, #fff8dc 0%, #f0c14a 42%, #d4a84a 100%);
  box-shadow:
    0 0 0 2px rgba(240, 193, 74, 0.9),
    6px 6px 0 rgba(26, 18, 8, 0.4),
    inset 0 0 0 1px rgba(255, 255, 255, 0.45);
}

/* Trous de perforation haut / bas */
.patpat-card.is-golden::before,
.patpat-card.is-golden::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(10, 8, 4, 0.78);
  transform: translateX(-50%);
  z-index: 4;
  box-shadow: inset 0 0 0 2px var(--ticket-ink);
  pointer-events: none;
}

.patpat-card.is-golden::before { top: -10px; }
.patpat-card.is-golden::after { bottom: -10px; }

.patpat-card.is-golden .patpat-title {
  position: relative;
  z-index: 2;
  margin: 0;
  padding: 0.15rem 0.4rem 0.4rem;
  color: var(--ticket-ink);
  text-align: center;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 0.42rem;
  line-height: 1.35;
  background: transparent;
  border-bottom: 2px dashed rgba(61, 42, 20, 0.45);
}

.patpat-card.is-golden .patpat-photo-frame {
  position: relative;
  width: 100%;
  margin: 0;
  padding: 0.35rem;
  border: 2px solid var(--ticket-ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.2), transparent),
    #1a1208;
  box-shadow: inset 0 0 0 1px rgba(240, 193, 74, 0.55);
  overflow: hidden;
}

.patpat-card.is-golden .gold-ticket-ornament {
  display: block;
  position: absolute;
  left: 0.35rem;
  right: 0.35rem;
  height: 8px;
  z-index: 2;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      90deg,
      var(--ticket-ink) 0 2px,
      transparent 2px 6px
    );
  opacity: 0.35;
}

.patpat-card.is-golden .gold-ticket-ornament-top { top: 0.35rem; }
.patpat-card.is-golden .gold-ticket-ornament-bot { bottom: 0.35rem; }

.patpat-card.is-golden .patpat-img,
.patpat-img.is-golden {
  position: relative;
  display: block;
  width: 100%;
  height: auto;
  max-height: min(42vh, 320px);
  aspect-ratio: unset;
  object-fit: contain;
  object-position: center;
  border: none;
  box-shadow: none;
  filter: none;
  image-rendering: auto;
  background: #0d0a06;
  transform: scale(1.18);
  transform-origin: center center;
}

.patpat-card.is-golden .patpat-serial {
  text-align: center;
  opacity: 0.9;
}

.patpat-card.is-golden .patpat-hint {
  position: relative;
  z-index: 2;
  margin: 0;
  padding: 0.35rem 0.4rem 0.1rem;
  color: var(--ticket-ink);
  text-align: center;
  background: transparent;
  border-top: 2px dashed rgba(61, 42, 20, 0.45);
}

/* Petits trous latéraux décoratifs */
.patpat-card.is-golden .patpat-photo-frame::before,
.patpat-card.is-golden .patpat-photo-frame::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(10, 8, 4, 0.75);
  transform: translateY(-50%);
  z-index: 3;
  box-shadow: inset 0 0 0 1.5px var(--ticket-ink);
  pointer-events: none;
}

.patpat-card.is-golden .patpat-photo-frame::before { left: -6px; }
.patpat-card.is-golden .patpat-photo-frame::after { right: -6px; }

.stage {
  position: relative;
  flex: 0 1 auto;
  width: var(--stage-w);
  height: var(--stage-h);
  max-width: 100%;
  max-height: 100%;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 4 / 3;
  border: 4px solid var(--frame);
  box-shadow:
    0 0 0 3px var(--sand-deep),
    5px 5px 0 var(--shadow);
  background: #000;
  overflow: hidden;
  justify-self: center;
}

#game {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #000;
}

/* Chats dansants (WebP) au restaurant */
.map-cats-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  overflow: hidden;
}

/* Chat-sphinx photo (lisse) — hors du canvas pixelisé */
.map-sphinx-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  overflow: hidden;
}

.map-sphinx-cat {
  position: absolute;
  left: 0;
  top: 0;
  object-fit: contain;
  image-rendering: auto;
  image-rendering: high-quality;
  pointer-events: none;
  will-change: transform;
  filter:
    drop-shadow(3px 5px 0 rgba(32, 22, 10, 0.5))
    drop-shadow(7px 9px 1px rgba(32, 22, 10, 0.28));
}

.map-sphinx-glitch {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  opacity: 0.55;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(200, 255, 220, 0.35) 0 1px,
      transparent 1px 3px
    ),
    repeating-linear-gradient(
      90deg,
      rgba(255, 80, 120, 0.2) 0 2px,
      transparent 2px 5px
    );
  mix-blend-mode: screen;
}

.map-sphinx-glitch.flash {
  opacity: 0.85;
  background-color: rgba(240, 193, 74, 0.2);
}

.map-dancing-cat {
  position: absolute;
  left: 0;
  top: 0;
  width: 16px;
  height: 16px;
  object-fit: contain;
  image-rendering: auto;
  pointer-events: none;
  will-change: transform;
  filter: drop-shadow(1px 1px 0 rgba(26, 18, 8, 0.45));
}

.prompt {
  position: absolute;
  left: 50%;
  bottom: 10%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.8rem;
  background: rgba(26, 18, 8, 0.88);
  border: 2px solid var(--gold);
  color: var(--papyrus);
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  animation: float-prompt 1.2s ease-in-out infinite;
  pointer-events: none;
  z-index: 2;
}

.prompt.hidden {
  opacity: 0;
  visibility: hidden;
}

.prompt kbd {
  font-family: var(--display-font);
  font-size: 0.45rem;
  padding: 0.25rem 0.35rem;
  background: var(--gold);
  color: var(--ink);
  border: 2px solid var(--ink);
}

/* Overlay « pat pat » chats */
.patpat-overlay {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: grid;
  place-items: center;
  background: rgba(10, 8, 4, 0.55);
  opacity: 0;
  visibility: hidden;
  transition: opacity 200ms ease, visibility 200ms ease;
}

.patpat-overlay.open {
  opacity: 1;
  visibility: visible;
}

.patpat-overlay.hidden {
  display: grid;
}

.patpat-overlay.hidden:not(.open) {
  visibility: hidden;
  pointer-events: none;
}

.patpat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  padding: 0.85rem 1rem 0.9rem;
  background: linear-gradient(180deg, #f7e7c3, #e0c890);
  color: var(--ink);
  border: 4px solid var(--ink);
  box-shadow: 6px 6px 0 rgba(26, 18, 8, 0.45);
  transform: translateY(10px) scale(0.96);
  transition: transform 220ms cubic-bezier(0.2, 0.85, 0.2, 1);
  max-width: min(280px, 86%);
}

.patpat-overlay.open .patpat-card {
  transform: translateY(0) scale(1);
}

.patpat-title {
  margin: 0;
  font-family: var(--display-font);
  font-size: 0.55rem;
  color: var(--accent);
}

.patpat-photo-frame {
  width: min(220px, 70vw);
}

.patpat-card:not(.is-golden) .patpat-photo-frame {
  border: none;
  padding: 0;
  background: transparent;
}

.patpat-img {
  width: min(220px, 70vw);
  height: auto;
  aspect-ratio: 1;
  object-fit: contain;
  image-rendering: auto;
  background: #1a1208;
  border: 3px solid var(--ink);
  box-shadow: 3px 3px 0 rgba(26, 18, 8, 0.3);
}

.patpat-card:not(.is-golden) .patpat-img {
  width: 100%;
}

.patpat-hint {
  margin: 0;
  font-size: 0.95rem;
  opacity: 0.75;
}

/* Transition nuit / jour suivant */
.night-transition {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(40, 30, 80, 0.35), transparent 55%),
    rgba(6, 4, 12, 0.88);
  opacity: 0;
  visibility: hidden;
  transition: opacity 480ms ease, visibility 480ms ease;
}

.night-transition.open {
  opacity: 1;
  visibility: visible;
}

.night-transition.hidden {
  display: grid;
}

.night-transition.hidden:not(.open) {
  visibility: hidden;
  pointer-events: none;
}

.night-card {
  text-align: center;
  padding: 1.4rem 1.6rem 1.2rem;
  max-width: min(360px, 90%);
  color: var(--papyrus);
  background:
    linear-gradient(180deg, rgba(40, 28, 60, 0.5), rgba(20, 14, 30, 0.7)),
    linear-gradient(180deg, #2a1c0c, #1a1208);
  border: 4px solid var(--gold);
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.45);
  transform: translateY(12px) scale(0.96);
  transition: transform 420ms cubic-bezier(0.2, 0.85, 0.2, 1);
}

.night-transition.open .night-card {
  transform: translateY(0) scale(1);
}

.night-stars {
  margin: 0 0 0.6rem;
  letter-spacing: 0.35em;
  color: var(--gold);
  opacity: 0.85;
  animation: pulse-gold 2s ease-in-out infinite;
}

.night-title {
  margin: 0 0 0.55rem;
  font-family: var(--display-font);
  font-size: clamp(0.55rem, 2vw, 0.72rem);
  color: var(--gold);
  line-height: 1.45;
}

.night-text {
  margin: 0 0 0.85rem;
  font-size: 1.15rem;
  line-height: 1.35;
  opacity: 0.9;
}

.night-next {
  margin: 0 0 0.45rem;
  font-family: var(--display-font);
  font-size: 0.4rem;
  color: var(--accent-soft);
  letter-spacing: 0.06em;
}

.night-hint {
  margin: 0;
  font-size: 0.95rem;
  opacity: 0.65;
}

.bottom-hud {
  justify-content: center;
  opacity: 0.75;
  min-width: 0;
}

.bottom-hud p {
  margin: 0;
  font-size: clamp(0.85rem, 1.6vw, 1rem);
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* —— Inventaire (grand panneau horizontal) —— */
.inventory-panel {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: clamp(0.5rem, 2vh, 1.25rem);
  background: rgba(10, 8, 4, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity 220ms ease, visibility 220ms ease;
}

.inventory-panel.open {
  opacity: 1;
  visibility: visible;
}

.inventory-panel.hidden {
  display: grid;
}

.inventory-tray {
  width: min(1100px, 96vw);
  height: min(58dvh, 520px);
  max-height: min(70dvh, 560px);
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(180deg, #f6e8c4 0%, var(--papyrus) 40%, var(--papyrus-dark) 100%);
  color: var(--ink);
  border: 4px solid var(--ink);
  box-shadow: 6px 6px 0 var(--shadow);
  padding: 0.85rem 1rem 1rem;
  transform: translateY(18px) scale(0.98);
  transition: transform 240ms cubic-bezier(0.2, 0.9, 0.2, 1);
}

.inventory-panel.open .inventory-tray {
  transform: translateY(0) scale(1);
}

.inventory-tray-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  flex-shrink: 0;
}

.inventory-tray-head h2,
.modal-card h2 {
  margin: 0;
  font-family: var(--display-font);
  font-size: 0.65rem;
  line-height: 1.5;
}

.inventory-scroll {
  overflow-x: auto;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding-bottom: 0.15rem;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) rgba(26, 18, 8, 0.12);
}

.inventory-scroll::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.inventory-scroll::-webkit-scrollbar-track {
  background: rgba(26, 18, 8, 0.1);
  border: 2px solid var(--ink-soft);
}

.inventory-scroll::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--gold), var(--accent));
  border: 2px solid var(--ink);
}

.inventory-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

.inventory-list {
  list-style: none;
  margin: 0;
  padding: 0.15rem 0.1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-content: flex-start;
}

.inventory-list li {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.55rem;
  width: 220px;
  min-height: 72px;
  padding: 0.45rem 0.55rem;
  background: rgba(26, 18, 8, 0.07);
  border: 2px solid var(--ink-soft);
  text-align: left;
  flex-shrink: 0;
}

.inventory-list .item-body {
  min-width: 0;
  flex: 1;
}

.inventory-list li strong {
  font-family: var(--display-font);
  font-size: 0.38rem;
  line-height: 1.45;
  display: block;
}

.inventory-list li small {
  font-size: 0.85rem;
  line-height: 1.2;
  opacity: 0.85;
}

.inventory-list .item-value {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.8rem;
}

.collectible-glyph {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  font-size: 1.45rem;
  background: var(--sand);
  border: 2px solid var(--ink);
  box-shadow: 2px 2px 0 rgba(26, 18, 8, 0.25);
  flex-shrink: 0;
}

.inventory-empty {
  margin: 0.65rem 0.25rem;
  opacity: 0.75;
  text-align: center;
}

.inventory-empty.hidden {
  display: none;
}

/* —— Carnet (livre) —— */
.journal-panel {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(10, 8, 4, 0.58);
  opacity: 0;
  visibility: hidden;
  transition: opacity 220ms ease, visibility 220ms ease;
}

.journal-panel.open {
  opacity: 1;
  visibility: visible;
}

.journal-panel.hidden {
  display: grid;
}

.book {
  position: relative;
  width: min(1120px, 96vw);
  max-width: 100%;
  height: min(88dvh, 720px);
  max-height: min(92dvh, 760px);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 0.55rem 0.5rem;
  align-items: stretch;
  transform: translateY(14px) scale(0.97);
  transition: transform 260ms cubic-bezier(0.2, 0.9, 0.2, 1);
}

.journal-panel.open .book {
  transform: translateY(0) scale(1);
}

.book-close {
  position: absolute;
  top: -0.35rem;
  right: -0.15rem;
  z-index: 3;
  width: 36px;
  height: 36px;
  font-size: 1.4rem;
  line-height: 1;
  padding: 0;
}

.book-nav {
  width: 44px;
  height: 64px;
  font-family: var(--display-font);
  font-size: 1.1rem;
  line-height: 1;
  border: 3px solid var(--ink);
  background: var(--sand);
  color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
  align-self: center;
}

.book-nav:disabled {
  opacity: 0.35;
  cursor: default;
  box-shadow: none;
}

.book-nav:not(:disabled):active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

.book-spread {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 0;
  height: 100%;
  max-height: none;
  background: #2a1c0c;
  border: 5px solid #1a1208;
  box-shadow:
    8px 10px 0 rgba(0, 0, 0, 0.35),
    inset 0 0 0 3px #5a3a1a;
  overflow: hidden;
}

.book-spine {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 18px;
  transform: translateX(-50%);
  z-index: 2;
  background:
    linear-gradient(90deg,
      rgba(0, 0, 0, 0.28) 0%,
      rgba(0, 0, 0, 0.05) 35%,
      rgba(255, 255, 255, 0.08) 50%,
      rgba(0, 0, 0, 0.12) 65%,
      rgba(0, 0, 0, 0.32) 100%);
  pointer-events: none;
}

.book-page {
  position: relative;
  padding: 1.1rem 1.25rem 1rem 1.45rem;
  color: var(--ink);
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: #8b5a2b rgba(26, 18, 8, 0.1);
  background:
    linear-gradient(90deg, rgba(80, 50, 20, 0.08) 0%, transparent 16px),
    repeating-linear-gradient(
      180deg,
      transparent 0 27px,
      rgba(120, 80, 40, 0.16) 27px 28px
    ),
    linear-gradient(180deg, #f8ecd0 0%, #f0dfb0 55%, #e6cf96 100%);
}

.book-page::before {
  content: "";
  position: absolute;
  top: 0.55rem;
  bottom: 0.55rem;
  left: 1.05rem;
  width: 2px;
  background: rgba(180, 60, 40, 0.38);
  pointer-events: none;
  z-index: 0;
}

.book-page > * {
  position: relative;
  z-index: 1;
}

.book-page::-webkit-scrollbar {
  width: 8px;
}

.book-page::-webkit-scrollbar-track {
  background: rgba(26, 18, 8, 0.08);
}

.book-page::-webkit-scrollbar-thumb {
  background: #8b5a2b;
  border: 2px solid #3d2a14;
}

.book-page-left {
  box-shadow: inset -10px 0 18px rgba(80, 50, 20, 0.12);
}

.book-page-right {
  box-shadow: inset 10px 0 18px rgba(80, 50, 20, 0.12);
  display: flex;
  flex-direction: column;
  padding-top: 1.25rem;
  overflow-x: hidden;
}

.book-page-num {
  margin: 0 0 0.55rem;
  font-family: var(--display-font);
  font-size: 0.38rem;
  opacity: 0.55;
  letter-spacing: 0.06em;
}

.book-page-left h2 {
  margin: 0 0 0.45rem;
  font-family: var(--display-font);
  font-size: clamp(0.55rem, 1.8vw, 0.72rem);
  line-height: 1.45;
  color: #3d1f0a;
}

.book-date {
  margin: 0 0 0.85rem;
  font-style: italic;
  font-size: 1.05rem;
  color: var(--accent);
  border-bottom: 2px dashed rgba(61, 42, 20, 0.35);
  padding-bottom: 0.45rem;
}

.book-desc {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.book-photos {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem 1.1rem;
  flex: 1;
  align-content: start;
  min-height: 0;
  padding: 0.55rem 0.4rem 0.65rem;
  overflow: visible;
}

.book-photo {
  position: relative;
  margin: 0;
  padding: 0.4rem 0.4rem 0.2rem;
  background: linear-gradient(180deg, #fffcf4 0%, #f3ebda 100%);
  border: 2px solid #2a1c0c;
  box-shadow:
    3px 4px 0 rgba(26, 18, 8, 0.28),
    inset 0 0 0 1px rgba(255, 255, 255, 0.45);
  overflow: visible;
  aspect-ratio: auto;
}

.book-photo:nth-child(odd) {
  transform: rotate(-2.2deg);
}

.book-photo:nth-child(even) {
  transform: rotate(1.8deg);
  margin-top: 0.35rem;
}

.book-photo-tape {
  position: absolute;
  top: -9px;
  left: 22%;
  width: 44px;
  height: 15px;
  background: rgba(240, 193, 74, 0.58);
  border: 1px solid rgba(61, 42, 20, 0.28);
  transform: rotate(-9deg);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.28) inset;
  z-index: 3;
  pointer-events: none;
}

.book-photo:nth-child(even) .book-photo-tape {
  left: auto;
  right: 18%;
  transform: rotate(11deg);
  background: rgba(196, 92, 38, 0.42);
}

.book-photo-tape.tape-b {
  top: auto;
  bottom: -8px;
  left: auto;
  right: 24%;
  width: 36px;
  height: 12px;
  transform: rotate(7deg);
  background: rgba(232, 196, 122, 0.5);
}

.book-photo:nth-child(even) .book-photo-tape.tape-b {
  right: auto;
  left: 20%;
  transform: rotate(-6deg);
}

.book-photo-shot {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 2px solid #1a1208;
  background: #2a1c0c;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.book-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  image-rendering: auto;
  filter: sepia(0.12) contrast(1.04);
}

.book-photo.placeholder .book-photo-shot,
.book-photo-shot.placeholder {
  display: grid;
  place-items: center;
  background:
    repeating-linear-gradient(45deg, #2a1c0c, #2a1c0c 6px, #3d2a14 6px, #3d2a14 12px);
  color: var(--papyrus);
  font-family: var(--display-font);
  font-size: 0.32rem;
  text-align: center;
  padding: 0.4rem;
  line-height: 1.5;
}

.book-photo figcaption {
  position: static;
  margin: 0.35rem 0.1rem 0.15rem;
  padding: 0;
  background: none;
  color: #3d1f0a;
  font-family: var(--hand-font);
  font-size: clamp(1.15rem, 2.2vw, 1.55rem);
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  letter-spacing: 0.01em;
}

.book-empty {
  margin: auto;
  text-align: center;
  opacity: 0.7;
  font-size: 1.1rem;
}

.book-empty.hidden {
  display: none;
}

.book-index {
  grid-column: 1 / -1;
  margin: 0;
  text-align: center;
  font-family: var(--display-font);
  font-size: 0.4rem;
  color: var(--gold);
  text-shadow: 2px 2px 0 var(--ink);
}

@media (max-width: 720px) {
  .book {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    width: min(96vw, 420px);
    height: min(88dvh, 680px);
  }

  .book-nav {
    position: absolute;
    top: 50%;
    z-index: 3;
    transform: translateY(-50%);
  }

  .book-prev { left: -0.2rem; }
  .book-next { right: -0.2rem; }

  .book-spread {
    grid-template-columns: 1fr;
    height: 100%;
    max-height: none;
  }

  .book-spine { display: none; }

  .book-page-right {
    border-top: 3px solid rgba(26, 18, 8, 0.2);
  }

  .book-photos {
    grid-template-columns: 1fr 1fr;
  }
}

/* —— Modale —— */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 260ms ease, visibility 260ms ease;
}

.modal.open {
  opacity: 1;
  visibility: visible;
}

.modal.hidden {
  display: grid;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 8, 4, 0.62);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(380px, 92vw);
  max-width: calc(100vw - 1.5rem);
  max-height: min(78dvh, 560px);
  overflow: hidden;
  padding: 0.7rem 0.75rem 0.8rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 30%),
    linear-gradient(180deg, var(--papyrus) 0%, #e8d09a 100%);
  color: var(--ink);
  border: 4px solid var(--ink);
  box-shadow: 8px 8px 0 var(--shadow);
  transform: translateY(18px) scale(0.94);
  opacity: 0;
  transition:
    transform 280ms cubic-bezier(0.2, 0.85, 0.2, 1),
    opacity 240ms ease;
}

.modal.open .modal-card {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.modal-close {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  width: 2rem;
  height: 2rem;
  font-size: 1.4rem;
  line-height: 1;
  padding: 0;
}

.modal-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  margin-bottom: 0.3rem;
  font-size: 1rem;
  background: var(--sand);
  border: 2px solid var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
}

.modal-card h2 {
  font-size: 0.5rem !important;
  line-height: 1.35 !important;
}

.modal-anecdote {
  margin: 0.3rem 0 0.4rem;
  font-size: 0.78rem;
  line-height: 1.15;
  display: grid;
  gap: 0.2rem;
  max-height: 4.2em;
  overflow: hidden;
}

.place-name {
  position: absolute;
  left: 50%;
  top: 8%;
  transform: translateX(-50%) translateY(-6px);
  z-index: 4;
  margin: 0;
  padding: 0.35rem 0.75rem 0.4rem;
  max-width: min(90%, 280px);
  text-align: center;
  font-family: var(--display-font);
  font-size: clamp(0.42rem, 1.6vw, 0.58rem);
  line-height: 1.45;
  letter-spacing: 0.04em;
  color: var(--gold);
  text-shadow:
    2px 2px 0 var(--ink),
    0 0 12px rgba(240, 193, 74, 0.35);
  background: rgba(26, 18, 8, 0.78);
  border: 2px solid var(--gold);
  box-shadow: 3px 3px 0 rgba(26, 18, 8, 0.55);
  pointer-events: none;
  opacity: 0;
  transition: opacity 220ms ease, transform 220ms ease;
}

.place-name.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.place-name.hidden {
  display: none;
}

.dialogue-line {
  display: block;
  animation: fade-photo 280ms ease;
}

.item-value {
  color: var(--accent);
  font-weight: bold;
}

.load-error {
  width: min(960px, 100%);
  margin: 0.5rem auto 0;
  padding: 0.6rem 0.8rem;
  background: #a33c2a;
  color: var(--papyrus);
  border: 3px solid var(--ink);
  font-family: var(--display-font);
  font-size: 0.55rem;
}

/* —— Intro / dialogue RPG (in-game) —— */
.intro-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.intro-overlay.hidden {
  display: none;
}

/* Conteneur plein bas d'écran : perso en coin + boîte texte */
.dialogue-box {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  top: 0;
  z-index: 8;
  display: block;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  cursor: pointer;
  pointer-events: auto;
}

.dialogue-box.hidden {
  display: none;
}

/* Grand portrait — coin bas-gauche, contenu dans le stage */
.dialogue-portrait {
  position: absolute;
  left: 0;
  bottom: 0;
  z-index: 3;
  height: clamp(180px, 78%, 420px);
  width: auto;
  max-width: min(58%, 380px);
  object-fit: contain;
  object-position: left bottom;
  border: none;
  background: transparent;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  pointer-events: none;
  filter: drop-shadow(5px 3px 0 rgba(26, 18, 8, 0.55));
}

.dialogue-portrait.fallback {
  background: transparent;
}

/* Boîte de texte — cadre ornemental Égypte ancienne */
.dialogue-body {
  --egypt-gold: #e8c14a;
  --egypt-gold-deep: #b8862a;
  --egypt-lapis: #1e3a5f;
  --egypt-turquoise: #2a8a8a;
  --egypt-ink: #1a1208;
  position: absolute;
  left: clamp(36%, 42%, 50%);
  right: 3%;
  bottom: 3%;
  z-index: 2;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  padding: 1.15rem 1rem 0.85rem;
  color: var(--egypt-ink);
  background:
    linear-gradient(180deg, rgba(232, 193, 74, 0.12), transparent 28%),
    linear-gradient(180deg, #f6e6c0 0%, #e8d09a 55%, #d4b878 100%);
  border: 3px solid var(--egypt-gold-deep);
  outline: 3px solid var(--egypt-lapis);
  outline-offset: 3px;
  box-shadow:
    0 0 0 6px var(--egypt-ink),
    5px 5px 0 rgba(26, 18, 8, 0.5),
    inset 0 0 0 2px rgba(232, 193, 74, 0.45),
    inset 0 0 18px rgba(30, 58, 95, 0.08);
}

/* Frise haute : disque solaire ailé */
.dialogue-ornament-top {
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  z-index: 4;
  pointer-events: none;
  filter: drop-shadow(0 1px 0 var(--egypt-ink));
}

.dialogue-sun {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, #fff1c0 0%, var(--egypt-gold) 45%, var(--egypt-gold-deep) 100%);
  border: 2px solid var(--egypt-ink);
  box-shadow: 0 0 0 2px var(--egypt-gold);
  flex-shrink: 0;
}

.dialogue-wing {
  width: 38px;
  height: 12px;
  background:
    repeating-linear-gradient(
      90deg,
      var(--egypt-turquoise) 0 3px,
      var(--egypt-lapis) 3px 6px,
      var(--egypt-gold) 6px 8px
    );
  border: 2px solid var(--egypt-ink);
  clip-path: polygon(0 50%, 12% 0, 100% 15%, 100% 85%, 12% 100%);
}

.dialogue-wing-l {
  transform: scaleX(-1);
}

.dialogue-wing-r {
  clip-path: polygon(0 15%, 88% 0, 100% 50%, 88% 100%, 0 85%);
}

/* Coins lotus / cartouche */
.dialogue-corner {
  position: absolute;
  width: 14px;
  height: 14px;
  z-index: 3;
  pointer-events: none;
  background:
    linear-gradient(135deg, var(--egypt-gold) 0 35%, transparent 35%),
    linear-gradient(135deg, transparent 55%, var(--egypt-turquoise) 55% 70%, transparent 70%);
  border: 2px solid var(--egypt-ink);
  box-shadow: inset 0 0 0 1px var(--egypt-gold-deep);
}

.dialogue-corner-tl { top: 4px; left: 4px; }
.dialogue-corner-tr { top: 4px; right: 4px; transform: scaleX(-1); }
.dialogue-corner-bl { bottom: 4px; left: 4px; transform: scaleY(-1); }
.dialogue-corner-br { bottom: 4px; right: 4px; transform: scale(-1); }

/* Frise basse géométrique */
.dialogue-ornament-bottom {
  height: 8px;
  margin-top: 0.15rem;
  flex-shrink: 0;
  background:
    repeating-linear-gradient(
      90deg,
      var(--egypt-gold-deep) 0 6px,
      var(--egypt-ink) 6px 8px,
      var(--egypt-turquoise) 8px 14px,
      var(--egypt-ink) 14px 16px,
      var(--egypt-lapis) 16px 22px,
      var(--egypt-ink) 22px 24px
    );
  border: 2px solid var(--egypt-ink);
  box-shadow: inset 0 0 0 1px rgba(232, 193, 74, 0.35);
}

/* Cartouche du locuteur */
.dialogue-speaker {
  margin: 0 auto 0.1rem;
  padding: 0.2rem 0.65rem 0.15rem;
  width: fit-content;
  max-width: 100%;
  font-family: var(--display-font);
  font-size: 0.45rem;
  color: var(--egypt-gold);
  background: var(--egypt-lapis);
  border: 2px solid var(--egypt-gold);
  border-radius: 999px 999px 999px 999px / 60% 60% 60% 60%;
  box-shadow:
    0 0 0 2px var(--egypt-ink),
    inset 0 0 0 1px rgba(232, 193, 74, 0.35);
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.45);
}

.dialogue-text {
  margin: 0;
  font-size: 1.2rem;
  line-height: 1.25;
  min-height: 2.8em;
  padding: 0 0.15rem;
}

.dialogue-hint {
  margin: 0;
  font-size: 0.95rem;
  opacity: 0.7;
  text-align: right;
  color: var(--egypt-lapis);
}

.journal-intro {
  position: absolute;
  inset: 0;
  z-index: 9;
  display: grid;
  place-items: center;
  padding: 0.4rem;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(40, 24, 10, 0.2), rgba(10, 8, 4, 0.72));
  opacity: 0;
  visibility: hidden;
  transition: opacity 260ms ease, visibility 260ms ease;
}

.journal-intro.open {
  opacity: 1;
  visibility: visible;
}

.journal-intro.hidden {
  display: grid;
}

.journal-intro.hidden:not(.open) {
  visibility: hidden;
  pointer-events: none;
}

/* Carnet ouvert — borné au stage (pas de dvh qui dépasse) */
.journal-intro-book {
  position: relative;
  width: min(500px, 96%);
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  transform: translateY(10px) scale(0.97);
  transition: transform 300ms cubic-bezier(0.2, 0.85, 0.2, 1);
}

.journal-intro.open .journal-intro-book {
  transform: translateY(0) scale(1);
}

.journal-intro-cover {
  position: absolute;
  inset: 5px -5px -5px 5px;
  background:
    repeating-linear-gradient(
      -18deg,
      #3d2410 0 2px,
      #2a180c 2px 4px
    );
  border: 4px solid #1a1208;
  box-shadow: 5px 6px 0 rgba(0, 0, 0, 0.3);
  z-index: 0;
}

.journal-intro-page {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0.7rem 0.85rem 0.75rem 1.1rem;
  color: #2a180c;
  background:
    linear-gradient(90deg, rgba(80, 50, 20, 0.1) 0%, transparent 14px),
    repeating-linear-gradient(
      180deg,
      transparent 0 27px,
      rgba(120, 80, 40, 0.14) 27px 28px
    ),
    linear-gradient(180deg, #f8ecd0 0%, #f0dfb0 55%, #e6cf96 100%);
  border: 4px solid #1a1208;
  box-shadow:
    inset 0 0 0 2px rgba(255, 245, 220, 0.35),
    3px 3px 0 rgba(26, 18, 8, 0.22);
  scrollbar-width: thin;
  scrollbar-color: #8b5a2b rgba(26, 18, 8, 0.08);
}

/* Marge rouge type carnet */
.journal-intro-page::before {
  content: "";
  position: absolute;
  top: 0.6rem;
  bottom: 0.6rem;
  left: 1rem;
  width: 2px;
  background: rgba(180, 60, 40, 0.35);
  pointer-events: none;
}

.journal-intro-head {
  position: relative;
  padding-bottom: 0.45rem;
  border-bottom: 2px dashed rgba(61, 42, 20, 0.28);
}

.journal-intro-pagenum {
  margin: 0 0 0.35rem;
  font-family: var(--display-font);
  font-size: 0.35rem;
  letter-spacing: 0.08em;
  opacity: 0.55;
}

.journal-intro-page h2 {
  margin: 0 0 0.35rem;
  font-family: var(--display-font);
  font-size: clamp(0.55rem, 2.2vw, 0.7rem);
  line-height: 1.45;
  color: #3d1f0a;
}

.journal-intro-date {
  margin: 0;
  font-style: italic;
  font-size: 1.05rem;
  color: var(--accent);
}

/* Polaroids collés de travers */
.journal-intro-photos {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem 0.75rem;
  padding: 0.25rem 0.35rem 0.1rem;
  align-items: start;
  flex: 0 1 auto;
  min-height: 0;
}

.polaroid {
  position: relative;
  margin: 0;
  padding: 0.4rem 0.4rem 0.15rem;
  background:
    linear-gradient(180deg, #fffcf4 0%, #f3ebda 100%);
  border: 2px solid #2a1c0c;
  box-shadow:
    3px 4px 0 rgba(26, 18, 8, 0.28),
    inset 0 0 0 1px rgba(255, 255, 255, 0.45);
}

.polaroid-a {
  transform: rotate(-2deg);
  z-index: 2;
}

.polaroid-b {
  transform: rotate(1.6deg);
  margin-top: 0.25rem;
  z-index: 1;
}

.polaroid-tape {
  position: absolute;
  top: -8px;
  left: 28%;
  width: 42px;
  height: 14px;
  background: rgba(240, 193, 74, 0.55);
  border: 1px solid rgba(61, 42, 20, 0.25);
  transform: rotate(-8deg);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25) inset;
  z-index: 3;
}

.polaroid-tape-r {
  left: auto;
  right: 22%;
  transform: rotate(10deg);
  background: rgba(196, 92, 38, 0.4);
}

.polaroid-shot,
.journal-frame-scene {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 3 / 4;
  max-height: 132px;
  display: block;
  border: 2px solid #1a1208;
  background: #6eb4d8;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.polaroid-shot::before,
.journal-frame-scene::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 50px 16px at 22% 18%, rgba(255, 248, 230, 0.9), transparent 70%),
    radial-gradient(ellipse 40px 14px at 40% 24%, rgba(255, 240, 210, 0.75), transparent 70%),
    radial-gradient(ellipse 55px 18px at 78% 14%, rgba(255, 250, 235, 0.85), transparent 70%),
    radial-gradient(circle 22px at 88% 30%, rgba(255, 220, 140, 0.5), transparent 70%),
    linear-gradient(180deg, #5aa8d0 0%, #8ec8e8 35%, #c8dce8 60%, #e8d4a8 82%, #e0c080 100%);
}

.polaroid-shot::after,
.journal-frame-scene::after {
  content: "";
  position: absolute;
  left: -8%;
  right: -8%;
  bottom: 0;
  z-index: 0;
  height: 42%;
  background:
    radial-gradient(ellipse 90% 60% at 30% 100%, #e8c878 0%, #d4a85c 50%, transparent 72%),
    radial-gradient(ellipse 85% 55% at 80% 110%, #c99648 0%, #b8843c 55%, transparent 74%),
    linear-gradient(180deg, transparent 0%, #e0b05a 40%, #d4a04a 100%);
  border-radius: 55% 45% 0 0 / 38% 32% 0 0;
}

/* Légère patine photo */
.polaroid-shot::before {
  box-shadow: inset 0 0 24px rgba(80, 40, 10, 0.18);
}

.polaroid-shot img,
.journal-frame-scene img {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%) scale(1.35);
  transform-origin: center bottom;
  z-index: 1;
  display: block;
  width: 115%;
  height: 100%;
  max-width: none;
  object-fit: contain;
  object-position: center bottom;
  border: none;
  background: transparent;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(2px 2px 0 rgba(26, 18, 8, 0.35)) sepia(0.12) contrast(1.05);
  pointer-events: none;
}

.polaroid figcaption {
  margin: 0.35rem 0 0.2rem;
  text-align: center;
  font-family: var(--ui-font);
  font-size: 1.05rem;
  font-style: italic;
  color: #3d2a14;
  letter-spacing: 0.02em;
}

.journal-intro-ruled {
  position: relative;
  margin-top: 0.05rem;
  padding: 0.1rem 0.15rem 0.1rem 0.35rem;
  flex: 1 1 auto;
  min-height: 0;
}

.journal-intro-note {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.4;
  color: #2a180c;
}

#journal-intro-img,
.journal-intro-composed {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  image-rendering: pixelated;
  border: 3px solid var(--ink);
}

#journal-intro-img.missing,
.journal-intro-composed.missing {
  opacity: 0.3;
}

.journal-intro-composed.hidden {
  display: none;
}

.journal-intro-cta {
  align-self: center;
  flex-shrink: 0;
  margin-top: 0.2rem;
  position: sticky;
  bottom: 0;
  z-index: 2;
}

@media (max-width: 720px) {
  .dialogue-portrait {
    height: clamp(240px, 78%, 380px);
    max-width: 72%;
  }

  .dialogue-body {
    left: 6%;
    right: 2%;
    bottom: 2%;
    padding-left: 28%;
  }

  .journal-intro-page {
    padding: 0.8rem 0.85rem 0.9rem 1.05rem;
  }

  .polaroid-shot,
  .journal-frame-scene {
    max-height: 160px;
  }

  .polaroid-shot img,
  .journal-frame-scene img {
    transform: translateX(-50%) scale(1.4);
    width: 120%;
  }

  .polaroid-a { transform: rotate(-2deg); }
  .polaroid-b { transform: rotate(1.5deg); margin-top: 0.25rem; }
}

/* —— Mini-map —— */
.minimap-wrap {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 4;
  width: 152px;
  padding: 0.28rem 0.28rem 0.2rem;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(248, 236, 200, 0.96), rgba(226, 200, 138, 0.96));
  border: 3px solid #3d2a14;
  box-shadow:
    inset 0 0 0 2px rgba(240, 193, 74, 0.7),
    3px 3px 0 rgba(26, 18, 8, 0.55);
}

.minimap-wrap.hidden {
  display: none;
}

#minimap {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 152 / 114;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border: 2px solid #1a1208;
  background: #c8a060;
  box-shadow: inset 0 0 0 1px #f0c14a;
}

.minimap-label {
  display: block;
  margin-top: 0.2rem;
  text-align: center;
  font-family: var(--display-font);
  font-size: 0.34rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #3d2a14;
  text-shadow: none;
}

@media (max-width: 520px) {
  .minimap-wrap {
    width: 112px;
    top: 0.3rem;
    right: 0.3rem;
    padding: 0.2rem 0.2rem 0.14rem;
  }

  .minimap-label {
    font-size: 0.28rem;
  }
}

.gallery {
  display: grid;
  grid-template-columns: 28px 1fr 28px;
  gap: 0.25rem;
  align-items: center;
  margin-bottom: 0.3rem;
}

.gallery-frame {
  position: relative;
  aspect-ratio: 16 / 10;
  max-height: 140px;
  background: var(--ink);
  border: 2px solid var(--ink);
  overflow: hidden;
}

#gallery-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: auto;
  display: none;
}

#gallery-img.visible {
  display: block;
  animation: fade-photo 280ms ease;
}

.gallery-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--display-font);
  font-size: 0.55rem;
  text-align: center;
  padding: 1rem;
  color: var(--papyrus);
  background:
    repeating-linear-gradient(
      45deg,
      #2a1c0c,
      #2a1c0c 8px,
      #3d2a14 8px,
      #3d2a14 16px
    );
}

.gallery-placeholder.hidden {
  display: none;
}

.gallery-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0.2rem 0.35rem;
  background: rgba(26, 18, 8, 0.78);
  color: var(--papyrus);
  font-size: 0.72rem;
}

.gallery-nav {
  height: 32px;
  font-family: var(--display-font);
  font-size: 0.85rem;
  border: 2px solid var(--ink);
  background: var(--sand);
  color: var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
  cursor: pointer;
}

.gallery-nav:disabled {
  opacity: 0.35;
  cursor: default;
  box-shadow: none;
}

.gallery-dots {
  display: flex;
  justify-content: center;
  gap: 0.25rem;
  margin-bottom: 0.4rem;
  min-height: 6px;
}

.gallery-dots span {
  width: 6px;
  height: 6px;
  background: var(--ink-soft);
  border: 1px solid var(--ink);
  opacity: 0.35;
}

.gallery-dots span.active {
  background: var(--accent);
  opacity: 1;
}

.modal-collectible {
  margin: 0 0 0.45rem;
  padding: 0.3rem 0.45rem;
  background: rgba(196, 92, 38, 0.15);
  border: 2px dashed var(--accent);
  font-size: 0.78rem;
  line-height: 1.15;
}

.modal-card .pixel-btn {
  font-size: 0.45rem;
  padding: 0.45rem 0.7rem;
}

.modal-collectible.hidden {
  display: none;
}

.pixel-btn {
  display: block;
  width: 100%;
  padding: 0.7rem;
  font-size: 0.6rem;
  background: var(--accent);
  color: var(--papyrus);
}

/* —— D-Pad —— */
.dpad {
  display: none;
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 30;
  width: 168px;
  height: 168px;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 4px;
  opacity: 0.92;
}

.dpad-btn {
  font-family: var(--display-font);
  font-size: 0.7rem;
  border: 3px solid var(--ink);
  background: rgba(232, 196, 122, 0.92);
  color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  touch-action: none;
}

.dpad-btn[data-dir="up"] { grid-column: 2; grid-row: 1; }
.dpad-btn[data-dir="left"] { grid-column: 1; grid-row: 2; }
.dpad-btn[data-dir="right"] { grid-column: 3; grid-row: 2; }
.dpad-btn[data-dir="down"] { grid-column: 2; grid-row: 3; }
.dpad-btn.dpad-action {
  grid-column: 2;
  grid-row: 2;
  background: rgba(196, 92, 38, 0.95);
  color: var(--papyrus);
  font-size: 0.55rem;
}

.dpad-btn:active,
.dpad-btn.active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

@keyframes pulse-gold {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

@keyframes float-prompt {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-4px); }
}

@keyframes fade-photo {
  from { opacity: 0.35; }
  to { opacity: 1; }
}

/* Fenêtres basses (laptop) : réduit encore le chrome */
@media (max-height: 820px) {
  :root {
    --chrome-h: 6.5rem;
    --app-pad: 0.4rem;
    --app-gap: 0.3rem;
  }

  .hud-icon-btn {
    width: 36px;
    height: 36px;
  }

  .book {
    height: min(90dvh, 640px);
  }

  .inventory-tray {
    height: min(52dvh, 420px);
  }
}

@media (max-height: 680px) {
  :root {
    --chrome-h: 5.5rem;
  }

  .bottom-hud {
    display: none;
  }

  .brand h1 {
    font-size: 0.42rem;
  }
}

@media (max-width: 820px), (pointer: coarse) {
  :root {
    --chrome-h: 5.25rem;
  }

  .dpad {
    display: grid;
  }

  .bottom-hud {
    display: none;
  }

  .hud-stats #visit-count {
    font-size: 1rem;
  }
}

@media (max-width: 520px) {
  .brand h1 {
    font-size: 0.38rem;
  }

  .play-layout {
    gap: 0.35rem;
  }

  .day-agenda {
    flex-basis: 100px;
    padding: 0.35rem 0.3rem;
  }

  .day-agenda-title {
    font-size: 0.32rem;
  }

  .day-agenda-item {
    font-size: 0.68rem;
  }

  .prompt span {
    display: none;
  }

  .prompt kbd::after {
    content: " / A";
  }

  .dpad {
    width: 150px;
    height: 150px;
    right: 0.6rem;
    bottom: 0.6rem;
  }
}
