/* Direction artistique : lettre d’amour. Mobile d’abord, sans dépendance. */
:root {
    color-scheme: light;
    --ivory: #faf7f2;
    --rose: #d8b4ad;
    --rose-light: #f2e7e1;
    --brown: #51433f;
    --muted: #786762;
    --line: #e4d8d0;
    --paper: #fffdfa;
    --accent: #926157;
    --success: #4b6555;
    --radius: 12px;
    --serif: Georgia, 'Times New Roman', serif;
    --sans: 'Segoe UI', Arial, sans-serif;
    --shadow: 0 16px 60px #51433f08;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: 32px; }
body { margin: 0; background: var(--ivory); color: var(--brown); font: 16px/1.7 var(--sans); -webkit-font-smoothing: antialiased; }
body:has(dialog[open]) { overflow: hidden; }
::selection { background: var(--rose); color: var(--brown); }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button, a, input { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
button, a, input { transition: background-color 200ms, border-color 200ms, color 200ms, box-shadow 200ms; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 5px; }
p, h1, h2, h3, figure { margin: 0; }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; }
h1 { font-size: clamp(2.5rem, 8.5vw, 4.8rem); line-height: 1.15; letter-spacing: -.045em; text-wrap: balance; }
h1 em { font-weight: 400; color: var(--accent); }
h2 { font-size: 2.15rem; line-height: 1.2; letter-spacing: -.035em; text-wrap: balance; }
h3 { font-size: 1.45rem; line-height: 1.35; }
svg { display: block; }
.icon { width: 22px; height: 22px; flex: 0 0 auto; }
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.container { width: min(1120px, calc(100% - 40px)); margin-inline: auto; }
.skip-link { position: absolute; top: -100px; left: 20px; z-index: 20; background: var(--brown); color: var(--ivory); padding: 12px; }
.skip-link:focus { top: 12px; }
.site-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; min-height: 88px; border-bottom: 1px solid var(--line); }
.wordmark { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; font-family: var(--serif); font-size: 1.4rem; letter-spacing: -.035em; }
.wordmark .icon { color: var(--accent); width: 25px; height: 25px; }
.header-note { color: var(--muted); font-size: .7rem; text-align: right; }
.session-clock { display: flex; align-items: flex-end; flex-direction: column; gap: 2px; font-size: .68rem; color: var(--muted); }
.session-clock time { font-variant-numeric: tabular-nums; font-size: 1rem; line-height: 1.3; color: var(--brown); }
.session-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; padding-block: 10px; }
.session-actions .session-clock > span { display: none; }
.restart-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: var(--muted); font-size: .7rem; }
.restart-button .icon { width: 16px; height: 16px; }
.restart-button:hover { background: var(--rose-light); border-color: var(--rose); color: var(--brown); }
.eyebrow { font: 500 .65rem/1.6 var(--sans); text-transform: uppercase; letter-spacing: .17em; }
.muted { color: var(--muted); }
.lead { font-size: 1rem; line-height: 1.8; color: var(--muted); }
.bee-sticker { display: inline-block; width: 34px; height: 34px; vertical-align: middle; object-fit: contain; }
.pet-name { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 5px; }
.paper-slip .bee-sticker { width: 25px; height: 25px; }
.rules-link { margin-top: 28px; background: transparent; }
.start-link { justify-self: start; }
.welcome-layout { padding-block: 44px 56px; display: grid; gap: 40px; }
.welcome-copy { text-align: center; }
.welcome-copy > .eyebrow { margin-bottom: 24px; }
.welcome-copy h1 { margin-bottom: 24px; }
.welcome-copy > .lead { max-width: 430px; margin-inline: auto; }
.keepsake { position: relative; width: 260px; height: 210px; margin: 12px auto 36px; }
.paper-slip { position: absolute; top: 0; left: 36px; width: 188px; height: 155px; background: var(--paper); padding: 20px 16px; display: flex; flex-direction: column; align-items: center; gap: 4px; box-shadow: 0 2px 16px #51433f08; transform: rotate(-8deg); font: italic .7rem/1.4 var(--serif); }
.paper-slip span:last-child { font: .53rem/1.4 var(--sans); letter-spacing: .03em; }
.paper-heart { font: 2rem/1.3 var(--serif); color: var(--accent); }
.decorative-envelope { position: absolute; top: 78px; left: 8px; width: 244px; height: 133px; border-radius: 3px 3px 7px 7px; background: #e8cec3; box-shadow: 0 12px 28px #51433f0a; transform: rotate(3deg); }
.decorative-envelope::before, .decorative-envelope::after { content: ''; position: absolute; inset: 0; }
.decorative-envelope::before { background: #eddbcf; clip-path: polygon(0 0, 50% 60%, 100% 0, 100% 100%, 0 100%); }
.decorative-envelope::after { background: #efded3; clip-path: polygon(0 100%, 50% 38%, 100% 100%); border-radius: inherit; }
.decorative-flap { position: absolute; inset: 0; background: #e4c5b9; clip-path: polygon(0 0, 100% 0, 50% 64%); }
.wax-seal { position: absolute; left: 50%; top: 43%; display: grid; place-items: center; width: 39px; height: 39px; background: #bd8e83; border: 3px double #dbafa2; border-radius: 47% 53% 48% 52%; color: #fff2e7; transform: translate(-50%, -10%); box-shadow: 0 2px 5px #51433f18; z-index: 3; }
.wax-seal .icon { width: 20px; height: 20px; }
.handwriting { font-family: 'Segoe Script', 'Bradley Hand', cursive; font-size: 1rem; color: var(--accent); }
.keepsake > .handwriting { position: absolute; right: -8px; bottom: -30px; transform: rotate(-6deg); font-size: 1.05rem; }
.memory-photo { width: min(360px, 100%); margin: 64px auto 0; }
.memory-photo img { display: block; width: 100%; height: auto; border-radius: 8px; }
.memory-photo figcaption { font-size: .75rem; color: var(--muted); margin-top: 8px; }
.unlock-card { padding: 28px 24px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); text-align: center; }
.card-icon { display: grid; place-items: center; width: 44px; height: 44px; margin: 0 auto 20px; border: 1px solid var(--line); border-radius: 50%; color: var(--accent); }
.unlock-card h2 { margin: 12px 0 16px; }
.unlock-card > .muted { font-size: .85rem; }
#unlock-form { margin-top: 28px; text-align: left; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { font-size: .8rem; font-weight: 500; margin-bottom: 16px; }
.date-inputs { display: grid; grid-template-columns: 1fr auto 1fr auto 1.45fr; gap: 8px; align-items: end; }
label { display: block; font-size: .75rem; margin-bottom: 8px; }
.date-divider { color: var(--line); padding-bottom: 14px; }
input { width: 100%; min-width: 0; min-height: 52px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); color: var(--brown); font-size: 16px; }
input::placeholder { color: var(--muted); opacity: .8; }
input:hover { border-color: var(--rose); }
input:focus { border-color: var(--accent); }
input[aria-invalid='true'] { border-color: var(--accent); }
.date-inputs input { text-align: center; padding-inline: 8px; font-variant-numeric: tabular-nums; }
.date-inputs label { text-align: center; color: var(--muted); }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 16px; min-height: 52px; padding: 13px 20px; border: 1px solid var(--rose); border-radius: 6px; background: var(--rose); color: var(--brown); font-size: .85rem; font-weight: 500; }
.button:hover:not(:disabled) { background: #cfa198; border-color: #cfa198; }
.button:active:not(:disabled) { background: #c8978b; }
.button .icon { width: 18px; height: 18px; }
.full-width { width: 100%; }
.feedback { font-size: .85rem; line-height: 1.65; color: var(--accent); margin-top: 16px; }
.feedback:empty { margin: 0; }
#date-error:not(:empty) { margin: 16px 0; }
#unlock-form .button { margin-top: 20px; }
.feedback.success { color: var(--success); }
.small-note { font-size: .7rem; color: var(--muted); margin-top: 20px; }
.rules-section { padding-block: 48px; border-top: 1px solid var(--line); display: grid; gap: 32px; }
.section-intro .eyebrow { margin-bottom: 16px; }
.section-intro .muted { margin-top: 20px; font-size: .85rem; }
.rules-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 28px; }
.rules-list li { display: flex; gap: 20px; }
.rule-number { flex-shrink: 0; padding-top: 5px; font-size: .65rem; color: var(--accent); font-variant-numeric: tabular-nums; }
.rules-list h3 { font-size: 1.15rem; margin-bottom: 8px; }
.rules-list p { max-width: 560px; color: var(--muted); font-size: .85rem; }
.site-footer { border-top: 1px solid var(--line); padding-block: 32px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 24px; }
.site-footer .icon { color: var(--accent); width: 17px; height: 17px; }
.site-footer p { font-size: .7rem; color: var(--muted); }
.site-footer .handwriting { font-size: .9rem; margin-top: 4px; }
.notice { padding: 20px; margin-top: 24px; border: 1px solid var(--line); border-radius: 8px; background: var(--rose-light); font-size: .9rem; }
.notice .text-button { display: flex; }
.loading { min-height: 60vh; display: grid; place-items: center; color: var(--muted); font: italic 1.4rem var(--serif); text-align: center; }
/* Le jeu */
.game-section, .victory-section { padding-block: 40px 56px; }
.center-heading { text-align: center; max-width: 740px; margin-inline: auto; }
.center-heading .eyebrow { margin-bottom: 20px; }
.center-heading h1 { font-size: clamp(2.2rem, 6vw, 3.75rem); }
.center-heading .lead { margin-top: 20px; }
.phrase-card { max-width: 680px; margin: 28px auto; padding: 28px 16px 20px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); text-align: center; }
.mystery-phrase { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px 16px; margin-block: 24px; }
.phrase-word { display: inline-flex; align-items: center; gap: 4px; }
.letter-slot { display: inline-grid; place-items: center; width: 27px; min-height: 38px; border-bottom: 1px solid var(--rose); font: 1.25rem/1.5 var(--serif); }
.letter-slot.unknown { color: transparent; }
.letter-slot.revealed { background: var(--rose-light); border-radius: 4px 4px 0 0; animation: letter-appear 650ms ease both; }
.phrase-punctuation { font: 1.5rem var(--serif); align-self: flex-start; }
.progress-description { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-top: 16px; color: var(--muted); font-size: .65rem; }
progress { display: block; width: 100%; height: 3px; margin-top: 12px; border: 0; border-radius: 3px; overflow: hidden; background: var(--rose-light); accent-color: var(--accent); }
progress::-webkit-progress-bar { background: var(--rose-light); }
progress::-webkit-progress-value { background: var(--accent); }
progress::-moz-progress-bar { background: var(--accent); }
.riddle-navigation { display: grid; grid-template-columns: repeat(4, 44px); justify-content: center; gap: 8px; margin: 32px auto 24px; }
.riddle-step { min-width: 44px; height: 44px; background: transparent; border: 1px solid var(--line); border-radius: 50%; color: var(--muted); font-size: .75rem; }
.riddle-step:hover:not(:disabled) { border-color: var(--accent); background: var(--rose-light); }
.riddle-step[aria-current='step'] { border-color: var(--accent); color: var(--brown); background: var(--rose-light); }
.riddle-step.solved { background: var(--brown); color: var(--ivory); border-color: var(--brown); }
.riddle-step.solved[aria-current='step'] { outline: 2px solid var(--rose); outline-offset: 3px; }
.riddle-card { position: relative; isolation: isolate; overflow: hidden; display: flex; flex-direction: column; max-width: 680px; margin-inline: auto; padding: 28px 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); }
.riddle-card > :not(.game-decoration) { position: relative; z-index: 1; }
.riddle-stage { position: relative; }
.game-decoration { position: absolute; inset: 0; z-index: 0; pointer-events: none; user-select: none; }
.game-sticker { position: absolute; top: 18px; left: 18px; display: block; width: clamp(100px, 30%, 170px); height: clamp(100px, 30vw, 170px); object-fit: contain; opacity: .085; filter: saturate(.5); transform: rotate(var(--sticker-rotation, 0deg)); }
.game-decoration[data-side='right'] .game-sticker { left: auto; right: 18px; }
.game-decoration[data-edge='bottom'] .game-sticker { top: auto; bottom: 18px; }
.riddle-meta { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; color: var(--muted); }
.tiny-heart { font-size: 1.4rem; line-height: 1; color: var(--accent); }
.riddle-card h2 { font-size: 2rem; }
.riddle-question { margin: 24px 0 28px; font: 1.2rem/1.8 var(--serif); }
.answer-shape { margin-bottom: 24px; }
.answer-shape .eyebrow { color: var(--muted); font-size: .6rem; }
.answer-pattern { margin-top: 8px; font-family: 'Courier New', monospace; font-size: clamp(1rem, 4vw, 1.3rem); letter-spacing: .1em; word-spacing: .35em; color: var(--brown); }
.answer-row { display: grid; gap: 12px; }
.text-button { display: inline-flex; align-items: center; gap: 16px; min-height: 44px; padding: 8px 0; margin-top: 12px; border: 0; background: transparent; color: var(--brown); font-size: .85rem; text-decoration: underline; text-underline-offset: 5px; }
.text-button:hover { color: var(--accent); }
.next-button { align-self: flex-start; margin-top: 20px; }
.under-card { text-align: center; font-size: .75rem; color: var(--muted); margin-top: 24px; }
/* L’enveloppe s’ouvre avec un vrai bouton, au clic ou au clavier. */
.victory-section { padding-top: 56px; }
.victory-section > .center-heading h1 { font-size: clamp(2.2rem, 7vw, 4.8rem); letter-spacing: .025em; }
.envelope-button { display: block; width: min(320px, 100%); padding: 0; border: 0; background: transparent; margin: 72px auto 0; color: var(--brown); }
.envelope-art { position: relative; display: block; height: 205px; perspective: 800px; }
.envelope-body { position: absolute; inset: 10px 0 0; background: #e8cec3; border-radius: 4px 4px 8px 8px; box-shadow: 0 12px 32px #51433f0c; }
.envelope-body::after { content: ''; position: absolute; inset: 0; background: #eedbd0; clip-path: polygon(0 0, 50% 55%, 100% 0, 100% 100%, 0 100%); border-radius: inherit; z-index: 2; }
.envelope-flap { position: absolute; top: 10px; left: 0; width: 100%; height: 120px; background: #e4c5b9; clip-path: polygon(0 0, 100% 0, 50% 100%); transform-origin: center top; transition: transform 700ms ease, z-index 0s 350ms; z-index: 4; }
.envelope-letter { position: absolute; inset: 28px 24px 12px; display: block; padding-top: 28px; background: var(--paper); color: var(--brown); font: italic 1.6rem var(--serif); transition: transform 650ms 200ms ease; z-index: 1; }
.envelope-art .wax-seal { top: 54%; z-index: 5; width: 46px; height: 46px; transition: opacity 250ms; }
.envelope-caption { display: flex; justify-content: center; align-items: center; gap: 16px; min-height: 48px; margin-top: 24px; font-size: .85rem; }
.envelope-button:hover .envelope-caption { text-decoration: underline; text-underline-offset: 6px; }
.envelope-button.is-open .envelope-flap { transform: rotateX(180deg); z-index: 0; }
.envelope-button.is-open .envelope-letter { transform: translateY(-65px); }
.envelope-button.is-open .wax-seal { opacity: 0; }
.centered { text-align: center; }
.letters-section { padding-top: 72px; }
.letters-section .center-heading { margin-bottom: 32px; }
.letters-section h2 { margin-bottom: 16px; }
.letters-section .muted { font-size: .85rem; }
.letter-card { padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.letter-card h3 { margin: 12px 0 24px; }
.letter-card > .download-button { margin-top: 20px; }
.download-button { font-size: .8rem; }
.dialog-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.dialog-actions .download-button { min-height: 44px; padding: 8px 12px; }
.current-letter { max-width: 760px; margin: 0 auto 32px; padding: 32px 24px; }
.letter-image-button { display: block; width: 100%; padding: 0; border: 0; background: var(--ivory); border-radius: 6px; overflow: hidden; }
.letter-image-button:hover { box-shadow: 0 0 0 3px var(--rose); }
.letter-image-button img { display: block; width: 100%; height: auto; }
.letters-archive { display: grid; gap: 24px; }
.empty-letters { max-width: 650px; margin: auto; padding: 40px 24px; border: 1px dashed var(--rose); border-radius: var(--radius); text-align: center; }
.empty-letters p { max-width: 420px; margin: 16px auto 0; color: var(--muted); font-size: .9rem; }
.missing-letter { min-height: 200px; padding: 32px 24px; display: grid; place-items: center; background: var(--rose-light); color: var(--muted); font-size: .9rem; text-align: center; border-radius: 6px; }
.letter-dialog { width: calc(100% - 24px); max-width: 1080px; max-height: 92vh; max-height: 92dvh; margin: auto; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--ivory); color: var(--brown); }
.letter-dialog::backdrop { background: #302521b8; }
.dialog-bar { position: sticky; top: 0; z-index: 2; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px; padding: 16px; background: var(--ivory); border-bottom: 1px solid var(--line); }
.dialog-bar h2 { font-size: 1.1rem; }
.close-button { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 5px; color: var(--brown); background: var(--paper); font-size: .8rem; }
.close-button:hover { background: var(--rose-light); }
.close-button span { font-size: 1.5rem; line-height: 1; }
.dialog-help { font-size: .75rem; padding: 16px; color: var(--muted); }
.letter-zoom { padding: 0 16px 16px; overflow: auto; }
.letter-zoom img { display: block; width: 100%; height: auto; }
#welcome, #game, #victory, #letters-section { animation: appear 800ms ease both; }
@keyframes appear { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes letter-appear { from { background: var(--paper); opacity: .4; } to { background: var(--rose-light); opacity: 1; } }
@media (min-width: 480px) {
    .container { width: min(1120px, calc(100% - 64px)); }
    .header-note { font-size: .8rem; }
    .unlock-card { padding: 40px; }
    .letter-slot { width: 32px; min-height: 44px; font-size: 1.5rem; }
    .riddle-navigation { grid-template-columns: repeat(8, 44px); gap: 8px; }
    .answer-row { grid-template-columns: 1fr auto; }
}
@media (min-width: 768px) {
    .site-header { min-height: 104px; }
    .welcome-layout { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: center; gap: 48px; padding-block: 64px 72px; }
    .welcome-copy h1 { font-size: clamp(2.8rem, 4.6vw, 4.4rem); }
    .welcome-copy { grid-column: 1 / -1; max-width: 850px; margin-inline: auto; }
    .eyebrow { font-size: .68rem; }
    .unlock-card { padding: 36px 28px; }
    .keepsake { margin: 32px auto; }
    .rules-section { grid-template-columns: .8fr 1.2fr; gap: 64px; padding-block: 64px; }
    .start-link { grid-column: 2; }
    .game-section { padding-block: 64px 72px; }
    .phrase-card { padding: 32px; margin-top: 40px; }
    .mystery-phrase { gap: 24px; }
    .letter-slot { width: 36px; min-height: 48px; font-size: 1.8rem; }
    .riddle-card { padding: 40px; }
    .riddle-question { font-size: 1.35rem; }
    .letters-archive { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .letters-archive:empty { display: none; }
    .session-clock { flex-direction: row; align-items: center; gap: 16px; font-size: .75rem; }
    .session-clock time { padding: 5px 12px; border: 1px solid var(--line); border-radius: 30px; }
    .session-actions { flex-direction: row; align-items: center; gap: 16px; }
    .session-actions .session-clock > span { display: inline; }
    .current-letter { padding: 40px; }
    .letter-dialog { width: calc(100% - 64px); }
    .dialog-bar { padding: 16px 24px; }
    .dialog-bar h2 { font-size: 1.4rem; }
    .dialog-help { padding-inline: 24px; }
    .letter-zoom { padding: 0 24px 24px; }
}
@media (min-width: 1024px) {
    .container { width: min(1120px, calc(100% - 120px)); }
    .welcome-layout { gap: 56px 88px; padding-top: 64px; }
    .unlock-card { padding: 40px; }
    .welcome-copy h1 { font-size: 4.3rem; }
}
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
