:root {
  --bg: #faf1e2;
  --teal: #0e6f6a;
  --terracotta: #c1633f;
  --gold: #c9a24b;
  --text: #2b2420;
  --muted: #8a7a5f;
  --tile: min(26vw, 108px);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  -webkit-tap-highlight-color: transparent;
}

.stage {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding: 48px 20px 64px;
  text-align: center;
}

.intro {
  animation: fadeIn 1s ease both;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
}

.intro h1 {
  margin: 0 0 10px;
  font-size: 2.6rem;
  font-weight: 500;
  color: var(--teal);
}

.instructions {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  max-width: 320px;
}

/* --- Puzzle --------------------------------------------------------- */

.puzzle {
  display: grid;
  grid-template-columns: repeat(3, var(--tile));
  grid-template-rows: repeat(3, var(--tile));
  gap: 3px;
  background: var(--gold);
  padding: 3px;
  border-radius: 6px;
  box-shadow: 0 18px 40px rgba(43, 36, 32, 0.18);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.puzzle.solved {
  opacity: 0;
  transform: scale(0.94);
  pointer-events: none;
}

.cell {
  width: var(--tile);
  height: var(--tile);
  position: relative;
  overflow: hidden;
  border: none;
  padding: 0;
  margin: 0;
  background: var(--bg);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.cell.selected {
  outline: 3px solid var(--terracotta);
  outline-offset: -3px;
  z-index: 1;
}

.cell-img {
  position: absolute;
  top: 0;
  left: 0;
  width: calc(var(--tile) * 3);
  height: calc(var(--tile) * 3);
  max-width: none;
  pointer-events: none;
  user-select: none;
  transition: transform 0.25s ease;
}

/* --- Révélation ------------------------------------------------------ */

.reveal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  max-width: 420px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 1s ease, transform 1s ease;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

.ornament {
  width: 140px;
  height: 14px;
  position: relative;
}

.ornament::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--gold);
}

.ornament::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 10px;
  background: var(--terracotta);
  transform: translate(-50%, -50%) rotate(45deg);
}

.message {
  margin: 0;
  font-family: "Amiri", "Cormorant Garamond", serif;
  font-style: italic;
  font-size: 1.5rem;
  line-height: 1.7;
  color: var(--text);
}

.message-line {
  display: block;
  opacity: 0;
  animation: lineIn 0.9s ease both;
}

.signature {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 1rem;
  letter-spacing: 0.04em;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
