:root {
  --green-dark: #1b2a1f;
  --green: #2e4a34;
  --gold: #c9a24b;
  --cream: #f7f4ec;
  --text: #232323;
  --radius: 14px;
}

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

html, body {
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", Roboto, system-ui, sans-serif;
  background: var(--cream);
  color: var(--text);
  height: 100%;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

#app {
  flex: 1 1 auto;
  min-height: 0;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  position: relative;
}

.app-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--green-dark);
  color: var(--cream);
  padding: 14px 16px;
  z-index: 5;
}

.header-logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
}

.app-header h1 {
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
}

.app-header p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--gold);
}

.header-text {
  flex: 1 1 auto;
  min-width: 0;
}

.app-shell {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
}

.app-shell.hidden { display: none; }

.install-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--green-dark);
  color: var(--cream);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 28px;
  padding-bottom: calc(32px + env(safe-area-inset-bottom));
}

.install-gate.hidden { display: none; }

.gate-logo {
  width: 88px;
  height: 88px;
  border-radius: 20px;
  margin-bottom: 18px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.4);
}

.install-gate h1 {
  font-size: 22px;
  margin: 0 0 6px;
}

.gate-subtitle {
  font-size: 14px;
  color: var(--gold);
  margin: 0 0 28px;
}

.gate-section {
  max-width: 360px;
}

.gate-section.hidden { display: none; }

.gate-section p {
  font-size: 15px;
  line-height: 1.5;
  margin: 0 0 18px;
  color: #e8e4d8;
}

.gate-steps {
  background: rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 14px 16px;
}

.gate-btn {
  background: var(--gold);
  color: var(--green-dark);
  border: none;
  border-radius: 12px;
  padding: 14px 28px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(0,0,0,0.3);
}

.gate-skip {
  background: none;
  border: none;
  color: #aab3a3;
  font-size: 13px;
  text-decoration: underline;
  margin-top: 26px;
  cursor: pointer;
  padding: 12px 16px;
  min-height: 44px;
}

.gate-skip.hidden { display: none; }

.ios-share-icon { font-size: 14px; }

h2 {
  font-size: 18px;
  color: var(--green-dark);
  border-bottom: 2px solid var(--gold);
  padding-bottom: 6px;
  margin: 18px 0 10px;
}

.tab-panel { display: none; height: 100%; }
.tab-panel.active { display: block; }

.tab-panel.active:not(#tab-plan) {
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 14px 18px;
}

#tab-plan.active {
  display: flex;
  flex-direction: column;
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.timeline {
  position: relative;
}

#programme-list {
  position: relative;
  padding-left: 22px;
  margin-top: 4px;
}

#programme-list::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: #d8d2c0;
}

.timeline-item {
  position: relative;
  margin-bottom: 14px;
  cursor: pointer;
}

.timeline-dot {
  position: absolute;
  left: -22px;
  top: 6px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--green);
  border: 3px solid var(--cream);
  box-shadow: 0 0 0 2px var(--green);
}

.timeline-card {
  background: #fff;
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.timeline-item .time {
  font-weight: 600;
  color: var(--green);
  font-size: 12px;
}

.timeline-item .title {
  font-weight: 600;
  font-size: 15px;
}

.timeline-item .subtitle {
  font-size: 13px;
  color: #555;
}

.timeline-item.acte {
  margin-bottom: 18px;
}

.timeline-item.acte .timeline-dot {
  width: 20px;
  height: 20px;
  left: -25px;
  top: 4px;
  background: var(--gold);
  box-shadow: 0 0 0 2px var(--gold);
}

.timeline-item.acte .timeline-card {
  border: 2px solid var(--gold);
  background: #fffaf0;
  padding: 12px 16px;
}

.timeline-item.acte .time {
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 11px;
  font-weight: 800;
  color: #a07a2e;
}

.timeline-item.acte .title {
  font-size: 16px;
  color: var(--green-dark);
}

.timeline-item.entracte {
  margin-bottom: 8px;
}

.timeline-item.entracte .timeline-dot {
  width: 9px;
  height: 9px;
  left: -19px;
  top: 8px;
  background: #bbb;
  box-shadow: 0 0 0 2px #bbb;
}

.timeline-item.entracte .timeline-card {
  background: transparent;
  box-shadow: none;
  padding: 2px 14px;
}

.timeline-item.entracte .title {
  font-style: italic;
  font-weight: 500;
  color: #888;
  font-size: 13px;
}

.timeline-item.entracte .time {
  color: #999;
}

.card {
  background: #fff;
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  border-left: 4px solid var(--gold);
}

.card .time {
  font-weight: 600;
  color: var(--green);
  font-size: 13px;
}

.card .title {
  font-weight: 600;
  font-size: 15px;
}

.card .subtitle {
  font-size: 13px;
  color: #555;
}

.card.no-click { cursor: default; }

#stands-search {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #ccc;
  margin-bottom: 14px;
  font-size: 14px;
}

.stand-section {
  margin-bottom: 22px;
}

.stand-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  color: var(--green-dark);
  margin: 0 0 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid #ccc;
}

.stand-section-title.regiment { border-color: #4b6b4e; }
.stand-section-title.exposant { border-color: #5a3a26; }
.stand-section-title.enfant { border-color: #d9a93a; }
.stand-section-title.salon { border-color: #c97a3a; }
.stand-section-title.restauration { border-color: #a3372f; }

.stand-card {
  flex-direction: row;
  align-items: center;
  gap: 12px;
  border-left: none;
}

.stand-badge {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.stand-badge.regiment { background: #4b6b4e; }
.stand-badge.exposant { background: #5a3a26; }
.stand-badge.enfant { background: #d9a93a; }
.stand-badge.salon { background: #c97a3a; }
.stand-badge.restauration { background: #a3372f; }

.no-results {
  text-align: center;
  color: #888;
  font-size: 14px;
  margin-top: 24px;
}

.legal-link {
  display: block;
  text-align: center;
  margin-top: 28px;
  font-size: 12px;
  color: #999;
  text-decoration: underline;
}

.plan-zoom-wrap {
  position: relative;
  overflow: hidden;
  background: #000;
  touch-action: none;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  cursor: grab;
}

.plan-zoom-wrap.dragging { cursor: grabbing; }

.plan-zoom-inner {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
}

#plan-image {
  width: 100%;
  max-width: none;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}

#plan-hotspots {
  position: absolute;
  inset: 0;
  pointer-events: none; /* le calque laisse passer le doigt vers le pan */
}

.hotspot {
  position: absolute;
  width: 95px;
  height: 95px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: transparent;
  border: none;
  cursor: pointer;
  -webkit-touch-callout: none;
  transition: background 0.15s ease, box-shadow 0.15s ease;
  pointer-events: auto; /* réactive les événements sur chaque pastille */
}

.hotspot:active {
  background: rgba(255, 255, 255, 0.3);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.5);
}

.hint {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  font-size: 11px;
  color: #fff;
  background: rgba(27, 42, 31, 0.72);
  padding: 5px 10px;
  border-radius: 10px;
  text-align: center;
  pointer-events: none;
  white-space: nowrap;
  max-width: calc(100% - 20px);
}

.tab-bar {
  flex: 0 0 auto;
  display: flex;
  background: var(--green-dark);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}

.tab-btn {
  flex: 1;
  background: none;
  border: none;
  color: #b7c2ba;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 0 10px;
  font-size: 11px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.tab-btn .icon {
  font-size: 20px;
}

.tab-btn.active {
  color: var(--gold);
}

/* ── iOS install banner ──────────────────────────────────────────── */
.ios-banner {
  position: fixed;
  bottom: calc(58px + env(safe-area-inset-bottom) + 10px);
  left: 12px;
  right: 12px;
  max-width: 480px;
  margin: 0 auto;
  background: var(--green-dark);
  color: var(--cream);
  border-radius: 14px;
  box-shadow: 0 4px 22px rgba(0,0,0,0.28);
  padding: 13px 14px;
  z-index: 45;
  transform: translateY(calc(100% + 90px));
  transition: transform 0.38s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.ios-banner.visible {
  transform: translateY(0);
  pointer-events: auto;
}

.ios-banner-body {
  display: flex;
  gap: 10px;
  align-items: center;
  padding-right: 28px;
}

.ios-banner-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.ios-banner-text strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 3px;
}

.ios-banner-text p {
  margin: 0;
  font-size: 12px;
  color: #c8d4cb;
  line-height: 1.45;
}

.ios-banner-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  color: #8a9e90;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
  min-width: 34px;
  min-height: 34px;
}

/* ── Notification popup ──────────────────────────────────────────── */
.notif-popup {
  position: fixed;
  bottom: calc(58px + env(safe-area-inset-bottom) + 10px);
  left: 12px;
  right: 12px;
  max-width: 480px;
  margin: 0 auto;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 6px 28px rgba(0,0,0,0.20);
  padding: 14px 14px 12px;
  z-index: 40;
  transform: translateY(calc(100% + 90px));
  transition: transform 0.38s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.notif-popup.visible {
  transform: translateY(0);
  pointer-events: auto;
}

.notif-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: #aaa;
  cursor: pointer;
  padding: 4px 6px;
  min-width: 36px;
  min-height: 36px;
}

.notif-body {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  margin-bottom: 11px;
  padding-right: 24px;
}

.notif-emoji {
  font-size: 26px;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 1px;
}

.notif-text strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--green-dark);
  margin-bottom: 3px;
  line-height: 1.3;
}

.notif-text p {
  margin: 0;
  font-size: 13px;
  color: #555;
  line-height: 1.45;
}

.notif-action-btn {
  display: block;
  width: 100%;
  background: var(--green-dark);
  color: var(--gold);
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  letter-spacing: 0.01em;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: flex-end;
  z-index: 20;
}

.modal.hidden { display: none; }

.modal-content {
  background: #fff;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  border-radius: 16px 16px 0 0;
  padding: 20px;
  position: relative;
  animation: slideUp 0.2s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 14px;
  font-size: 26px;
  background: none;
  border: none;
  color: #888;
  cursor: pointer;
}

.modal-logo {
  display: block;
  width: 64px;
  height: 64px;
  object-fit: contain;
  margin-bottom: 10px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid #eee;
  padding: 4px;
}

.modal-body h3 {
  margin-top: 0;
  color: var(--green-dark);
}

.modal-body .meta {
  font-size: 13px;
  color: var(--green);
  font-weight: 600;
  margin-bottom: 8px;
}

/* ── Jeux ─────────────────────────────────────────────────────────── */
.game-menu {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.game-menu.hidden { display: none; }

.game-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  background: #fff;
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  border-left: 4px solid var(--gold);
  cursor: pointer;
  text-align: left;
  width: 100%;
  font: inherit;
  color: inherit;
  text-decoration: none;
}

.game-card-icon { font-size: 24px; }

.game-card-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--green-dark);
}

.game-card-desc {
  font-size: 12px;
  color: #666;
}

.game-view.hidden { display: none; }

.game-back {
  display: block;
  background: none;
  border: none;
  color: var(--green);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 0;
  margin-bottom: 6px;
}

.game-btn {
  background: var(--gold);
  color: var(--green-dark);
  border: none;
  border-radius: 12px;
  padding: 12px 26px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: block;
  margin: 0 auto;
}

/* Quiz */
.quiz-progress {
  font-size: 12px;
  color: #666;
  margin-bottom: 10px;
}

.quiz-question {
  font-size: 16px;
  font-weight: 700;
  color: var(--green-dark);
  margin-bottom: 14px;
}

.quiz-choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quiz-choice {
  background: #fff;
  border: 2px solid #ddd;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}

.quiz-choice.correct { border-color: #3a7d44; background: #eaf6ec; }
.quiz-choice.wrong { border-color: #a3372f; background: #faeceb; }
.quiz-choice:disabled { cursor: default; }

.quiz-result { text-align: center; padding: 24px 0; }

.quiz-score {
  font-size: 30px;
  font-weight: 800;
  color: var(--green-dark);
  margin-bottom: 8px;
}

.quiz-result p { margin: 0 0 20px; color: #555; }

/* Pendu */
.pendu-hint {
  text-align: center;
  font-size: 13px;
  color: #666;
  margin: 0 0 8px;
}

.pendu-lives {
  text-align: center;
  font-size: 18px;
  letter-spacing: 3px;
  margin-bottom: 12px;
}

.pendu-word {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 0 0 20px;
}

.pendu-letter {
  width: 26px;
  height: 32px;
  border-bottom: 3px solid var(--green-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
}

.pendu-status {
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  color: var(--green-dark);
  margin-bottom: 18px;
}

.pendu-keyboard {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.pendu-key {
  width: 30px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid #ccc;
  background: #fff;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}

.pendu-key:disabled { opacity: 0.35; cursor: default; }
.pendu-key.correct { background: #3a7d44; color: #fff; border-color: #3a7d44; }
.pendu-key.wrong { background: #a3372f; color: #fff; border-color: #a3372f; }

/* Chasse aux stands */
.chasse-progress-wrap { margin-bottom: 16px; }

.chasse-progress-bar {
  height: 10px;
  background: #e4e0d2;
  border-radius: 6px;
  overflow: hidden;
}

.chasse-progress-fill {
  height: 100%;
  background: var(--gold);
  transition: width 0.3s ease;
}

.chasse-progress-label {
  font-size: 12px;
  color: #666;
  margin-top: 6px;
  text-align: center;
}

.game-btn-secondary {
  background: none;
  border: 2px solid var(--green);
  color: var(--green-dark);
}

/* Photomaton */
.selfie-permission {
  text-align: center;
  padding: 30px 10px;
}

.selfie-permission p {
  color: #555;
  font-size: 14px;
  margin-bottom: 18px;
}

.selfie-error {
  color: #a3372f;
  font-size: 13px;
  margin-top: 14px;
}

.selfie-error.hidden { display: none; }

.selfie-app.hidden { display: none; }

.selfie-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  max-height: 60vh;
  margin: 0 auto 12px;
  border-radius: var(--radius);
  overflow: hidden;
  background: #111;
  touch-action: none;
}

#selfie-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  display: block;
}

.selfie-mask {
  position: absolute;
  transform: translate(-50%, -50%);
  touch-action: none;
  cursor: grab;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.35));
}

.selfie-mask:active { cursor: grabbing; }

.selfie-mask-picker {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 10px;
}

.selfie-mask-thumb {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 10px;
  border: 2px solid #ddd;
  background-color: var(--cream);
  background-size: contain;
  background-position: center 30%;
  background-repeat: no-repeat;
  cursor: pointer;
}

.selfie-mask-thumb.active { border-color: var(--gold); }

.selfie-size-label {
  display: block;
  font-size: 12px;
  color: #666;
  margin-bottom: 14px;
}

.selfie-size-label input[type="range"] {
  display: block;
  width: 100%;
  margin-top: 6px;
}

.selfie-result.hidden { display: none; }

.selfie-result img {
  width: 100%;
  border-radius: var(--radius);
  display: block;
  margin-bottom: 14px;
}

.selfie-controls {
  display: flex;
  gap: 10px;
}

.selfie-controls .game-btn {
  flex: 1;
  text-decoration: none;
  text-align: center;
}

.stand-card.visited { opacity: 0.55; }

.stand-check {
  margin-left: auto;
  font-size: 17px;
  flex: 0 0 auto;
}

.stand-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.stand-links a {
  display: inline-flex;
  align-items: center;
  background: var(--cream);
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 10px 14px;
  min-height: 44px;
  font-size: 13px;
  color: var(--green-dark);
  text-decoration: none;
  font-weight: 600;
}
