/*
 * Faim de mandat : l'habillage « carnet du scalde », accordé aux illustrations (encre et
 * aquarelle sur parchemin). En thème sombre, la veillée au coin du feu : le même carnet, éclairé
 * à la bougie.
 */

/*
 * IM Fell n'a que des chiffres à l'ancienne, qui descendent sous la ligne (« 3 64o ») : les
 * chiffres sont exclus de la police (unicode-range) et viennent de la police suivante.
 */
@font-face {
    font-family: "IM Fell English";
    src: url("../fonts/im-fell-english-latin-400-normal-TZgS8kd.woff2") format("woff2");
    unicode-range: U+0000-002F, U+003A-10FFFF;
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "IM Fell English";
    src: url("../fonts/im-fell-english-latin-400-italic-dZGZDgx.woff2") format("woff2");
    unicode-range: U+0000-002F, U+003A-10FFFF;
    font-weight: 400;
    font-style: italic;
    font-display: swap;
}
@font-face {
    font-family: "IM Fell English SC";
    src: url("../fonts/im-fell-english-sc-latin-400-normal-diM1cpT.woff2") format("woff2");
    unicode-range: U+0000-002F, U+003A-10FFFF;
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

:root {
    --paper: #eee2c8;
    --card: #f9f2e2;
    --bubble: #fffaf0;
    --ink: #2b2118;
    --ink-soft: #5b4b39;
    --line: #d6c39f;
    --rule: #8d7657;
    --accent: #2b5572;
    --accent-ink: #ffffff;
    --good: #3b6a29;
    --bad: #9a3322;
    --note: #74550f;
    --gold: #7f5b0e;
    --shadow: 0 1px 0 rgb(255 255 255 / 50%) inset, 0 12px 26px -16px rgb(60 40 20 / 45%);
    --radius: 6px;
    --display: "IM Fell English", "Palatino Linotype", "Book Antiqua", Palatino, "Times New Roman", serif;
    --display-sc: "IM Fell English SC", "IM Fell English", "Palatino Linotype", "Book Antiqua", Palatino, "Times New Roman", serif;
    --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    /* Le grain du papier, dessiné par le navigateur (aucune image à charger) */
    --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .25 0 0 0 0 .12 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
    /* Les décors pâlissent ou s'assombrissent selon le thème */
    --scenery-filter: none;
    --scenery-opacity: 1;
    --panorama-filter: none;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --paper: #1c1712;
        --card: #29221b;
        --bubble: #342b22;
        --ink: #f1e7d3;
        --ink-soft: #c9b99e;
        --line: #4a3e31;
        --rule: #806d55;
        --accent: #9fc4dc;
        --accent-ink: #14212b;
        --good: #a3d38e;
        --bad: #f2917b;
        --note: #e4c67c;
        --gold: #e6bb68;
        --shadow: 0 14px 28px -16px rgb(0 0 0 / 70%);
        --scenery-filter: brightness(.6) saturate(.7) sepia(.3);
        --scenery-opacity: .6;
        /* Le village à la tombée du jour, sans s'éteindre */
        --panorama-filter: brightness(.78) saturate(.85);
        color-scheme: dark;
    }
}

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

body {
    margin: 0;
    overflow-x: clip;
    background: var(--grain), var(--paper);
    color: var(--ink);
    font: 17px/1.55 var(--sans);
    -webkit-text-size-adjust: 100%;
    font-synthesis: none;
}

button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* Lu par les lecteurs d'écran, invisible à l'œil */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* ---------- En-tête : le titre, sur la chaîne de montagnes ---------- */

.masthead {
    position: relative;
    display: flex;
    justify-content: center;
    min-height: 184px;
    padding: 16px 16px 24px;
    isolation: isolate;
}
/* Les montagnes se lèvent sous le titre et s'effacent avant la barre d'état */
.masthead::before {
    content: "";
    position: absolute;
    inset: 86px 0 0;
    z-index: -1;
    background: url("../images/game/decor-montagnes-j9Xavng.webp") center 62% / cover no-repeat;
    filter: var(--scenery-filter);
    opacity: var(--scenery-opacity);
    -webkit-mask-image: linear-gradient(to bottom, transparent, #000 35%, #000 60%, transparent), linear-gradient(to right, transparent, #000 15%, #000 85%, transparent);
    -webkit-mask-composite: source-in;
    mask-image: linear-gradient(to bottom, transparent, #000 35%, #000 60%, transparent), linear-gradient(to right, transparent, #000 15%, #000 85%, transparent);
    mask-composite: intersect;
}

.masthead-tools {
    position: absolute;
    top: 16px;
    right: max(16px, env(safe-area-inset-right, 0px));
    display: flex;
    gap: 8px;
}
.tool-button {
    min-width: 44px;
    min-height: 44px;
    padding: 6px 14px;
    white-space: nowrap;
    border: 1px solid var(--rule);
    border-radius: 999px;
    background: color-mix(in srgb, var(--card) 85%, transparent);
    color: var(--accent);
    font-weight: 600;
    cursor: pointer;
}
a.tool-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; }
/* Le pseudo peut faire 20 caractères : coupé dans l'en-tête, en entier sur la page du compte */
.tool-label { max-width: 12ch; overflow: hidden; text-overflow: ellipsis; }
/* L'initiale du pseudo, à la place de la silhouette : on voit qu'on est connecté */
.account-initial {
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-ink);
    font: 700 1rem/1 var(--sans);
}

.brand {
    align-self: flex-start;
    padding: 4px 12px;
    background: none;
    border: 0;
    border-radius: var(--radius);
    text-align: center;
    cursor: pointer;
}
a.brand { color: inherit; text-decoration: none; }

.brand-title {
    display: block;
    font: 400 clamp(2rem, 6vw, 2.8rem)/1.05 var(--display-sc);
    letter-spacing: .01em;
    text-shadow: 0 0 12px var(--paper), 0 0 3px var(--paper);
}
.brand-subtitle {
    display: block;
    color: var(--gold);
    font: italic 400 1.1rem/1.4 var(--display);
    letter-spacing: .12em;
    text-shadow: 0 0 8px var(--paper), 0 0 2px var(--paper);
}

/* Sur l'accueil, c'est l'illustration qui porte le titre : l'en-tête ne garde que ses boutons */
body:has(#menu:not([hidden])) .masthead {
    position: absolute;
    inset: 0 0 auto;
    z-index: 3;
    min-height: 0;
    padding: 0;
}
body:has(#menu:not([hidden])) .masthead::before,
body:has(#menu:not([hidden])) .brand { display: none; }

@media (max-width: 520px) {
    .masthead { justify-content: flex-start; align-items: flex-start; gap: 8px; min-height: 132px; padding: 12px 16px 16px; }
    .masthead::before { inset: 64px 0 0; background-position: 40% 60%; }
    .brand { text-align: left; padding: 4px 0; }
    .brand-title { font-size: 1.75rem; white-space: nowrap; }
    .brand-subtitle { font-size: .95rem; }
    .masthead-tools { top: 12px; gap: 6px; }
    .tool-button { padding: 4px 12px; font-size: .9rem; }
    /* Trois boutons ne tiennent pas à côté du titre : le compte n'y garde que son icône */
    .account-button { padding: 4px; }
    .account-button .tool-label { display: none; }
}

#app {
    max-width: 760px;
    margin: 0 auto;
    padding: 0 16px 64px;
}

/* ---------- Aide ---------- */

.help {
    max-width: min(680px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 22px;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    background: var(--grain), var(--card);
    color: var(--ink);
    box-shadow: var(--shadow);
}
.help::backdrop { background: rgb(20 14 8 / 55%); }
.help-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.help h2 { margin: 0; font: 400 1.7rem/1.2 var(--display); }
.help h3 { margin: 18px 0 4px; font: 400 1.25rem var(--display); }
.help li { margin-bottom: 6px; }

/* ---------- Code de récupération ---------- */

.recovery { max-width: min(540px, calc(100vw - 32px)); }
/* Le code, gravé comme une ligne de runes : lisible d'un coup d'œil, facile à recopier */
.recovery-code {
    min-height: 3.2em;
    margin: 18px 0 12px;
    padding: 12px 14px;
    border: 1px dashed var(--rule);
    border-radius: var(--radius);
    background: var(--bubble);
    font: 600 1.35rem/1.35 var(--sans);
    letter-spacing: .06em;
    text-align: center;
    overflow-wrap: anywhere;
    user-select: all;
}
.recovery-secret { color: var(--note); }
.recovery-renew { margin-top: 18px; padding-top: 4px; border-top: 1px solid var(--line); }
.recovery-renew p { margin-bottom: 0; }
.recovery-label { display: block; margin: 14px 0 6px; font-weight: 600; }
.recovery-input {
    width: 100%;
    min-height: 44px;
    padding: 8px 12px;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    background: var(--bubble);
    color: var(--ink);
    font: 600 1.1rem var(--sans);
    letter-spacing: .04em;
    text-transform: uppercase;
}
.recovery-input::placeholder { color: var(--ink-soft); opacity: 1; font-weight: 400; font-style: italic; text-transform: none; letter-spacing: normal; }
.recovery-notice { padding: 10px 12px; border-left: 3px solid var(--note); background: color-mix(in srgb, var(--note) 8%, transparent); }
/* Vide, le message ne prend pas de place, mais reste là pour que les lecteurs d'écran l'annoncent */
.recovery-message { margin: 14px 0 0; font-weight: 600; color: var(--good); }
.recovery-message:empty { margin: 0; }
.recovery-message.bad { color: var(--bad); }
.recovery-actions, .history-actions { justify-content: center; margin-top: 0; }
/* L'encadré des apartés (voir .aside), à la couleur des boutons qu'il propose */
.aside.recovery-invite {
    margin-bottom: 14px;
    border-left-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 8%, transparent);
}
.recovery-invite p { margin: 0 0 8px; }

/* ---------- Accueil ---------- */

/* L'illustration déborde de la colonne et se fond dans le papier, comme peinte sur la page */
.hero {
    position: relative;
    margin: 0 calc(50% - min(50vw, 560px)) 4px;
}
.hero img {
    display: block;
    width: 100%;
    height: auto;
    -webkit-mask-image: linear-gradient(to bottom, #000 72%, transparent), linear-gradient(to right, transparent, #000 6%, #000 94%, transparent);
    -webkit-mask-composite: source-in;
    mask-image: linear-gradient(to bottom, #000 72%, transparent), linear-gradient(to right, transparent, #000 6%, #000 94%, transparent);
    mask-composite: intersect;
}
@media (prefers-color-scheme: dark) {
    .hero img { filter: brightness(.92) sepia(.08); }
}
.hero-title {
    position: absolute;
    top: 5%;
    left: 0;
    right: 0;
    margin: 0;
    padding: 0 16px;
    text-align: center;
    /* Le ciel de l'illustration est clair dans les deux thèmes : le titre reste à l'encre */
    color: #2b2118;
    pointer-events: none;
}
.hero-name {
    display: block;
    font: 400 clamp(2.7rem, 8.5vw, 5rem)/1 var(--display-sc);
    text-shadow: 0 0 22px #f8f0de, 0 0 6px #f8f0de;
}
.hero-subtitle {
    display: block;
    margin-top: 4px;
    color: #6d4c0c;
    font: italic 400 clamp(1.1rem, 3vw, 1.5rem)/1.3 var(--display);
    letter-spacing: .14em;
    text-shadow: 0 0 12px #f8f0de, 0 0 3px #f8f0de;
}
@media (max-width: 600px) {
    .hero img {
        aspect-ratio: 4 / 5;
        object-fit: cover;
        object-position: 50% 18%;
        -webkit-mask-image: linear-gradient(to bottom, #000 78%, transparent);
        mask-image: linear-gradient(to bottom, #000 78%, transparent);
    }
    .hero-title { top: 66px; }
}

.tagline {
    margin: -6px 0 6px;
    text-align: center;
    font: italic 400 1.25rem/1.45 var(--display);
    color: var(--ink-soft);
}
.theme-line { margin: 0 0 22px; text-align: center; }

.modes, .scenarios { display: grid; gap: 12px; }
@media (min-width: 640px) {
    .modes { grid-template-columns: repeat(2, 1fr); }
}

/* Le défi du jour, sous un ciel d'aquarelle */
.daily-card {
    position: relative;
    margin-bottom: 8px;
    padding: 20px 22px;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    background:
        linear-gradient(color-mix(in srgb, var(--card) 76%, transparent), color-mix(in srgb, var(--card) 92%, transparent)),
        url("../images/game/decor-ciel-_dyh8oo.webp") center 30% / cover;
    box-shadow: inset 0 0 0 4px color-mix(in srgb, var(--card) 70%, transparent), inset 0 0 0 5px var(--gold), var(--shadow);
}
.daily-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.daily-head .card-title { font-size: 1.6rem; }
.card-date { color: var(--gold); font: italic 400 1.15rem var(--display); }
.daily-card p { margin: 8px 0 0; }
.daily-result { font: 400 1.35rem/1.35 var(--display); }
.daily-card .actions { margin-top: 14px; }
.countdown { font-variant-numeric: tabular-nums; }

.card-button {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    min-height: 44px;
    padding: 14px 18px;
    text-align: left;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform .12s ease, border-color .12s ease;
}
.card-button:hover { border-color: var(--rule); transform: translateY(-1px); }
.card-button.hot .card-title { color: var(--bad); }
.card-button.resume { margin-bottom: 16px; border: 1px solid var(--accent); box-shadow: inset 0 0 0 3px var(--card), inset 0 0 0 4px var(--accent), var(--shadow); }
a.card-button { color: inherit; text-decoration: none; }
.card-title { font: 400 1.4rem/1.2 var(--display); }
.card-text { color: var(--ink-soft); font-size: .95rem; }
.card-goal { color: var(--note); font-size: .9rem; font-weight: 600; }

/* Titre de section avec un filet d'encre de part et d'autre */
.section-title {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 32px 0 8px;
    font: 400 1.6rem/1.2 var(--display);
}
.section-title::before, .section-title::after { content: ""; flex: 1; height: 1px; background: linear-gradient(to right, transparent, var(--rule)); }
.section-title::after { background: linear-gradient(to left, transparent, var(--rule)); }
.section-text { margin: -2px 0 14px; color: var(--ink-soft); text-align: center; }

.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    z-index: 10;
    max-width: calc(100vw - 32px);
    padding: 12px 18px;
    border-radius: 8px;
    background: var(--ink);
    color: var(--paper);
    font-weight: 600;
    transform: translateX(-50%);
    box-shadow: var(--shadow);
}

/* ---------- Barre d'état ---------- */

.status {
    position: sticky;
    top: 0;
    z-index: 2;
    display: grid;
    grid-template-columns: repeat(5, auto);
    justify-content: space-between;
    gap: 6px 12px;
    margin: 0 -16px 16px;
    padding: 10px 16px;
    background: color-mix(in srgb, var(--paper) 92%, transparent);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    font-size: .9rem;
}

.stat { display: flex; flex-direction: column; min-width: 0; }
.stat-label { color: var(--ink-soft); font: .95rem/1.2 var(--display-sc); letter-spacing: .03em; }
.stat-value { font-weight: 700; font-size: 1.05rem; font-variant-numeric: tabular-nums; white-space: nowrap; }

.gauge {
    display: block;
    width: 64px;
    height: 8px;
    margin-top: 6px;
    background: var(--line);
    border-radius: 4px;
    overflow: hidden;
}
.gauge > i { display: block; height: 100%; background: var(--good); }
.gauge.low > i { background: var(--bad); }

@media (max-width: 520px) {
    /* Sur petit écran, la barre d'état défile avec la page pour laisser la place au jeu */
    .status { position: static; grid-template-columns: repeat(3, 1fr); }
    .budget { padding: 10px 16px 12px; margin: 14px -16px -16px; }
    .panel { padding: 16px; }
}

/* ---------- Le village dessiné (assets/panorama.js) ---------- */

/*
 * Un bandeau sous la barre d'état ; un écran étroit en coupe un peu les bords, le ciel s'il est
 * large. Sur une fenêtre basse (téléphone couché, fort zoom), il rapetisse pour laisser le récit à l'écran.
 */
.panorama {
    height: clamp(72px, min(max(112px, 24vw), 24vh), 176px);
    margin: -16px -16px 16px;
    overflow: hidden;
    border-bottom: 1px solid var(--line);
    background: var(--paper);
}
.panorama svg { display: block; width: 100%; height: 100%; filter: var(--panorama-filter); }
/* Au verdict, le village entier, ciel compris */
.panorama.large { height: auto; aspect-ratio: 1400 / 440; max-height: 34vh; }
.panorama .appear { animation: appear .8s ease-out both; transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes appear {
    from { opacity: 0; transform: translateY(6px) scale(.96); }
    to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
    .panorama .appear { animation: none; }
}

/* ---------- Écrans : une page du carnet, à double filet d'encre ---------- */

.panel {
    background: var(--grain), var(--card);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    box-shadow: inset 0 0 0 4px var(--card), inset 0 0 0 5px var(--line), var(--shadow);
    padding: 22px 24px;
    animation: rise .25s ease-out;
}

@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

.panel h2 {
    margin: 0 0 8px;
    font: 400 1.9rem/1.15 var(--display);
}
.panel h2:focus { outline: none; }
.panel.good h2 { color: var(--good); }
.panel.bad h2 { color: var(--bad); }
.panel.note h2 { color: var(--note); }

.panel p { margin: 0 0 10px; }
.panel p.note { color: var(--note); }
.panel p.bad { color: var(--bad); font-weight: 600; }
.talk { font: italic 400 1.2rem/1.45 var(--display); }

/* Grande illustration en tête d'écran : la vignette déborde jusqu'aux filets du cadre */
.scene { margin: -12px -14px 14px; }
.scene img { display: block; width: 100%; height: auto; border-radius: 3px; }
@media (prefers-color-scheme: dark) {
    .scene img { filter: brightness(.9) sepia(.1); }
}
@media (max-width: 520px) {
    .scene { margin: -8px -8px 12px; }
}

/* Qui parle : le nom, à la plume */
.speaker {
    margin: 0 0 6px;
    color: var(--gold);
    font: italic 400 1.2rem/1.3 var(--display);
}

/*
 * Une réplique illustrée : le portrait du personnage à gauche, son texte autour, comme dans un
 * livre. Sur téléphone, le portrait passe au-dessus.
 */
.dialogue { display: flow-root; margin: 6px 0 8px; }
.dialogue-portrait {
    float: left;
    width: auto;
    height: 176px;
    max-width: 42%;
    margin: 0 20px 8px -6px;
    object-fit: contain;
    object-position: left bottom;
    filter: drop-shadow(0 3px 4px rgb(40 25 10 / 25%));
}
.preface .dialogue-portrait, .aside .dialogue-portrait { height: 120px; }
@media (max-width: 520px) {
    .dialogue-portrait { float: none; display: block; height: 150px; max-width: 100%; margin: 0 0 4px -4px; }
    .preface .dialogue-portrait, .aside .dialogue-portrait { float: left; height: 96px; max-width: 45%; margin: 0 12px 4px -4px; }
}

.tiles {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 14px 0 6px;
    clear: both;
}
.tile { padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: color-mix(in srgb, var(--paper) 35%, transparent); text-align: center; }
.tile-label { font: .95rem/1.2 var(--display-sc); color: var(--ink-soft); }
.tile-value { font: 700 1.5rem/1.3 var(--sans); font-variant-numeric: tabular-nums; }
.tile-value.hot { color: var(--bad); }
.tile-note { font-size: .8rem; color: var(--ink-soft); }

.rows { margin: 12px 0; border-top: 1px solid var(--line); clear: both; }
.row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 7px 0;
    border-bottom: 1px solid var(--line);
}
.row-label { color: var(--ink-soft); }
.row-value { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.row.strong .row-value { font-size: 1.15rem; }
.row.enemy .row-label, .row.enemy .row-value, .row.hot .row-label { color: var(--bad); }
.row-hint { flex-basis: 100%; margin-top: -4px; font-size: .85rem; color: var(--ink-soft); }
.row.wrap { flex-wrap: wrap; }

.aside {
    margin: 14px 0 0;
    padding: 12px 14px;
    border-left: 3px solid var(--gold);
    background: color-mix(in srgb, var(--gold) 8%, transparent);
    border-radius: 0 var(--radius) var(--radius) 0;
}

/* ---------- Boutons ---------- */

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
    clear: both;
}

.btn {
    min-height: 44px;
    padding: 10px 20px;
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 0 color-mix(in srgb, var(--accent) 55%, #000);
}
.btn:active { transform: translateY(1px); box-shadow: 0 1px 0 color-mix(in srgb, var(--accent) 55%, #000); }
.btn.secondary { background: transparent; color: var(--accent); box-shadow: none; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; box-shadow: 0 2px 0 color-mix(in srgb, var(--bad) 55%, #000); }
@media (prefers-color-scheme: dark) {
    .btn.danger { color: #2a120b; }
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
a.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.btn kbd {
    margin-left: 8px;
    padding: 0 5px;
    border: 1px solid currentColor;
    border-radius: 4px;
    font: .75rem/1.4 var(--sans);
    opacity: .75;
}
@media (pointer: coarse) { .btn kbd { display: none; } }

/* ---------- Décisions ---------- */

.field { margin: 0 0 14px; }
.field-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.field label { font-weight: 600; }
.field input[type="number"] {
    width: 9ch;
    min-height: 44px;
    padding: 6px 10px;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    background: var(--bubble);
    color: var(--ink);
    font: 600 1.05rem var(--sans);
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.hint { margin-top: 2px; font-size: .85rem; color: var(--ink-soft); }

.check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-height: 44px;
    padding: 8px 0;
    cursor: pointer;
}
.check input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.check-text { display: flex; flex-direction: column; }
.check-title { font-weight: 600; }

.subhead { margin: 20px 0 6px; font: 400 1.35rem var(--display); }

.field-input { display: flex; align-items: center; gap: 10px; }
.cost { min-width: 5ch; text-align: right; font-size: .9rem; font-weight: 600; color: var(--bad); font-variant-numeric: tabular-nums; }
.cost.gain { color: var(--good); }

.chip {
    min-height: 36px;
    margin-top: 6px;
    padding: 4px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: color-mix(in srgb, var(--card) 70%, transparent);
    color: var(--accent);
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
}
.chip:hover { border-color: var(--accent); }

.btn.same { margin: 4px 0 4px; }

/* Bandeau collé en bas : toujours visible pendant qu'on remplit le formulaire */
.budget {
    position: sticky;
    bottom: 0;
    z-index: 1;
    margin: 18px -24px -22px;
    padding: 12px 24px 14px;
    background: var(--card);
    border-top: 1px solid var(--rule);
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: 0 -8px 16px -8px rgb(40 25 10 / 20%);
}
.budget-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.budget-text { display: flex; flex-direction: column; }
.budget-remaining { font-weight: 600; }
.budget-available { font-size: .85rem; color: var(--ink-soft); }
.budget-value { font-variant-numeric: tabular-nums; }
.budget-value.negative { color: var(--bad); }
.budget-bar {
    display: flex;
    height: 10px;
    margin: 8px 0 2px;
    overflow: hidden;
    border-radius: 5px;
    background: var(--line);
}
.budget-bar i { display: block; height: 100%; }
.budget-bar .food { background: #c9962a; }
.budget-bar .seeds { background: #6c9a3c; }
.budget-bar .land { background: #8a6a4a; }
.budget-bar .defense { background: #a1372a; }
.budget-bar .works { background: #4f6d8a; }
.budget-bar .left { background: color-mix(in srgb, var(--accent) 35%, transparent); }
.budget-legend { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: .78rem; color: var(--ink-soft); }
.legend-item::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 5px; border-radius: 2px; vertical-align: -1px; background: var(--line); }
.legend-item.food::before { background: #c9962a; }
.legend-item.seeds::before { background: #6c9a3c; }
.legend-item.land::before { background: #8a6a4a; }
.legend-item.defense::before { background: #a1372a; }
.legend-item.works::before { background: #4f6d8a; }
.legend-item.left::before { background: color-mix(in srgb, var(--accent) 35%, transparent); }

.quick { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 6px 0; }

/* Quand l'orge manque pour nourrir et semer : combien de terres vendre ; et quand le village gronde */
.shortage, .grumbling {
    margin: 10px 0 4px;
    padding: 10px 14px 12px;
    border: 1px solid var(--bad);
    border-left-width: 4px;
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--bad) 7%, transparent);
}
.shortage p, .grumbling p { margin: 0; color: var(--bad); font-weight: 600; }
.shortage .chip { min-height: 44px; margin-top: 8px; }
/* Les terres vendues comblent le manque : le cadre reste en place, mais ne s'alarme plus */
.shortage.solved { border-color: var(--good); background: color-mix(in srgb, var(--good) 5%, transparent); }
.shortage.solved p { color: var(--good); }
/* La vente suffit pour nourrir et semer, mais d'autres choix font passer le bandeau en négatif */
.shortage.elsewhere { border-color: var(--note); background: color-mix(in srgb, var(--note) 5%, transparent); }
.shortage.elsewhere p { color: var(--note); }
.theme-line .chip { min-height: 44px; }
.link { min-height: 44px; padding: 0 4px; border: 0; background: none; color: var(--accent); text-decoration: underline; cursor: pointer; }

/* Ce qui précède la question : bilan de l'hiver, résultat d'une affaire */
.preface { margin: -4px 0 18px; padding: 0 0 14px; border-bottom: 1px dashed var(--rule); }
.preface .preface-title { margin: 0 0 4px; font: 400 1.35rem/1.25 var(--display); color: var(--ink-soft); }
.preface.note .preface-title { color: var(--note); }
.preface p { font-size: .97rem; }

/* ---------- Freya, qui guide le joueur : une bulle de bande dessinée ---------- */

.guide {
    display: flex;
    align-items: flex-end;
    gap: 14px;
    margin: 18px 0 14px;
    clear: both;
}
.guide-avatar {
    flex: none;
    display: grid;
    place-items: center;
    width: 76px;
    height: 76px;
    object-fit: cover;
    border-radius: 50%;
    background: var(--ink);
    color: var(--card);
    font: 400 1.8rem var(--display);
    border: 2px solid var(--rule);
    box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--accent);
}
.guide.happy .guide-avatar { box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--good); }
.guide.worried .guide-avatar { box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--bad); }
.guide.mischievous .guide-avatar { box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--gold); }
.guide-body {
    position: relative;
    flex: 1;
    min-width: 0;
    margin-bottom: 18px;
    padding: 10px 16px 12px;
    background: var(--bubble);
    border: 1px solid var(--rule);
    border-radius: 16px 16px 16px 4px;
    box-shadow: 0 6px 14px -10px rgb(40 25 10 / 40%);
}
/* La pointe de la bulle, tournée vers Freya */
.guide-body::before {
    content: "";
    position: absolute;
    left: -9px;
    bottom: 10px;
    width: 16px;
    height: 16px;
    background: var(--bubble);
    border-left: 1px solid var(--rule);
    border-bottom: 1px solid var(--rule);
    transform: skewY(-35deg);
}
.guide .guide-name { margin: 0; font: italic 400 1.15rem/1.2 var(--display); color: var(--accent); }
.guide .guide-text { margin: 2px 0 0; }
@media (max-width: 520px) {
    .guide { gap: 10px; }
    .guide-avatar { width: 52px; height: 52px; }
    .guide-body { margin-bottom: 10px; padding: 8px 12px 10px; }
}

.odds { margin-top: 6px; }
.odds-text { font-weight: 600; }

.message { margin-top: 6px; font-weight: 600; color: var(--bad); }
.message:empty { display: none; }
.message.warn { color: var(--note); }

/* ---------- Duel ---------- */

.duel-call {
    margin: 24px 0;
    text-align: center;
    font: 400 clamp(2.6rem, 12vw, 5rem)/1 var(--display-sc);
    color: var(--ink-soft);
}
.duel-call.now { color: var(--bad); }
.btn.strike { width: 100%; min-height: 72px; font-size: 1.3rem; }

/* ---------- Verdict ---------- */

.verdict-head { margin: 4px 0 10px; font: 400 2.4rem/1.1 var(--display); }
.panel.good .verdict-head { color: var(--good); }
.panel.bad .verdict-head { color: var(--bad); }
.panel.note .verdict-head { color: var(--note); }
.standing { font-weight: 600; color: var(--accent); }
.chart-box { margin: 18px 0 8px; }
.chart { width: 100%; height: auto; }
.chart-box figcaption { text-align: center; font: 1rem var(--display-sc); color: var(--ink-soft); }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.chart-dot { fill: var(--accent); }
.chart-axis { stroke: var(--rule); }
.chart-grid { stroke: var(--line); stroke-dasharray: 3 4; }
.chart-label { fill: var(--ink-soft); font-size: 14px; }
/* Couleur de la courbe, et un liseré couleur papier qui coupe les graduations et la ligne sous le texte */
.chart-value { fill: var(--accent); font-size: 14px; font-weight: 600; paint-order: stroke; stroke: var(--paper); stroke-width: 4px; stroke-linejoin: round; }
.chart-title { fill: var(--ink); font: 18px var(--display); }
/* Le repère (score médian des jarls) : plus marqué que les graduations, d'une autre couleur que la courbe */
.chart-reference { stroke: var(--ink-soft); stroke-width: 2; stroke-dasharray: 8 6; }
.chart-key { display: block; margin-top: 4px; font: .95rem var(--sans); }
.chart-key-line { display: inline-block; width: 28px; margin-right: 8px; vertical-align: middle; border-top: 2px dashed var(--ink-soft); }

.error-box {
    padding: 14px;
    border: 1px solid var(--bad);
    border-radius: var(--radius);
    color: var(--bad);
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Pages de texte (légales, compte, parcours) et pied de page ---------- */

.page {
    max-width: 720px;
    margin: 0 auto;
    padding-block: 0 40px;
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.page h1 { font: 400 2.2rem/1.15 var(--display); margin: 0 0 16px; }
.page h2 { font: 400 1.5rem/1.25 var(--display); margin: 26px 0 6px; }
.page h3 { font: 400 1.25rem/1.25 var(--display); margin: 20px 0 4px; }
.page p, .page li { max-width: 65ch; }
.page-lead { font-size: 1.08rem; padding: 12px 14px; border-left: 3px solid var(--gold); background: var(--card); border-radius: 0 var(--radius) var(--radius) 0; }
.page a:not(.btn) { color: var(--accent); }
.page-back { margin-top: 32px; }

/* Pages du compte : formulaires de Symfony (étiquette, erreurs, champ, aide) */
.account-form { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; margin: 18px 0; }
.account-form > div { display: flex; flex-direction: column; gap: 6px; width: 100%; max-width: 420px; }
.account-form label { font-weight: 600; }
.account-form input:not([type="hidden"]) {
    width: 100%;
    min-height: 44px;
    padding: 8px 12px;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    background: var(--bubble);
    color: var(--ink);
    font: 1.05rem var(--sans);
}
.account-form input[aria-invalid="true"] { border: 2px solid var(--bad); }
/* Le code de connexion : six chiffres bien espacés, faciles à relire contre l'e-mail */
.account-form input.login-code { max-width: 12ch; font: 600 1.5rem var(--sans); letter-spacing: .2em; text-align: center; }
/* Sous le formulaire du code : redemander un code à la même adresse, ou en changer */
.account-resend { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin: 18px 0; }
.account-resend p { flex-basis: 100%; margin: 0; }
.account-resend a { display: inline-flex; align-items: center; min-height: 44px; }
/* Une longue adresse passe à la ligne plutôt que de déborder sur téléphone */
.account-email { overflow-wrap: anywhere; }
.account-form ul { margin: 0; padding: 0; list-style: none; color: var(--bad); font-weight: 600; }
.account-form .help-text { color: var(--ink-soft); font-size: .9rem; }
.account-alert { padding: 12px 14px; border: 1px solid var(--bad); border-radius: var(--radius); font-weight: 600; }
.account-alert ul { margin: 0; padding: 0; list-style: none; }
.account-note { color: var(--ink-soft); font-size: .95rem; }
/* « Continuer avec Google », aux couleurs que demandent les règles de présentation de Google */
.btn.google { gap: 10px; background: #fff; border-color: #747775; color: #1f1f1f; box-shadow: none; }
@media (prefers-color-scheme: dark) {
    .btn.google { background: #131314; border-color: #8e918f; color: #e3e3e3; }
}

/* « Continuer avec Discord », au bleu de Discord (« blurple ») : le blanc y garde un contraste de 4,6 */
.btn.discord { gap: 10px; background: #5865f2; border-color: #5865f2; color: #fff; box-shadow: none; }

/* Après la connexion : la partie gardée et celle abandonnée */
.account-notice { padding: 12px 14px; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--card); }

/* Le message qui suit une action sur le compte (_account_notice.html.twig) */
.account-message {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 12px 0 18px;
    padding: 4px 4px 4px 14px;
    border: 1px solid var(--good);
    border-left-width: 4px;
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--good) 8%, var(--card));
}
.account-message p { flex: 1; margin: 10px 0; font-weight: 600; }
.account-message-close {
    flex: none;
    min-width: 44px;
    min-height: 44px;
    border: 0;
    border-radius: var(--radius);
    background: none;
    color: var(--ink);
    font: 1.6rem/1 var(--sans);
    cursor: pointer;
}
.account-message-close:hover { background: color-mix(in srgb, var(--good) 15%, transparent); }

.my-data { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 16px; }
.my-data-confirm { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px 14px; border: 1px solid var(--bad); border-radius: var(--radius); }
.my-data-confirm p { flex-basis: 100%; margin: 0; }
.my-data-message { flex-basis: 100%; font-weight: 600; }

/* Page « Mon parcours » : la série en gros chiffres (les tuiles du jeu, en liste de définitions), puis les chiffres sous chaque courbe */
.history-stats dd { margin: 0; }
/* Un libellé sur deux lignes (« Meilleure série » sur téléphone) ne décale pas les chiffres : ils restent alignés en bas */
.history-stats .tile { display: flex; flex-direction: column; justify-content: space-between; }
.history-numbers { margin: 4px 0 16px; }
.history-numbers summary { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; margin-bottom: 6px; cursor: pointer; color: var(--accent); }
/* En flex, le triangle du navigateur disparaît : on le redessine, muet pour les lecteurs d'écran
   (qui annoncent déjà « réduit » ou « développé ») ; la première ligne sert aux navigateurs anciens */
.history-numbers summary::before { content: "▸"; content: "▸" / ""; }
.history-numbers[open] summary::before { content: "▾"; content: "▾" / ""; }
.history-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.history-table caption { text-align: left; padding-bottom: 6px; color: var(--ink-soft); }
.history-table th, .history-table td { padding: 7px 8px 7px 0; border-bottom: 1px solid var(--line); text-align: left; }
.history-table thead th { color: var(--ink-soft); font-weight: 400; }
.history-table tbody th { font-weight: 400; }
.history-note { margin: 8px 0 0; font-size: .9rem; color: var(--ink-soft); }

/* Tableau d'honneur : les onglets sont des liens, celui de la page en cours souligné et en gras */
.leaderboard-tabs ul { display: flex; flex-wrap: wrap; gap: 4px 6px; margin: 0 0 8px; padding: 0; list-style: none; }
.leaderboard-tabs a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 12px;
    border-radius: var(--radius);
    color: var(--accent);
}
.leaderboard-tabs a[aria-current="page"] { font-weight: 700; text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 2px; background: color-mix(in srgb, var(--accent) 10%, transparent); }
.leaderboard-periods { margin: 4px 0 18px; }
.leaderboard-join { margin-bottom: 14px; }
.leaderboard-mine { font-weight: 700; }
/* Le lien « Voir ma ligne » s'arrête sur elle sans la coller au bord de l'écran */
.leaderboard-table tr.mine { scroll-margin-top: 30vh; }
.leaderboard-join p { margin: 0; }
.leaderboard-table td:first-child { width: 3.5em; }
/* Un pseudo de vingt lettres sans espace se coupe plutôt que de pousser le tableau hors de l'écran */
.leaderboard-table tbody th { overflow-wrap: anywhere; }
/* Les chiffres à droite, séparés de la colonne voisine : « 2 178 » et « 1 » ne se lisent pas comme un seul nombre */
.leaderboard-table .number { text-align: right; padding-left: 16px; white-space: nowrap; }
/* La ligne du joueur : un fond, un trait et la mention « (vous) », pas seulement une couleur */
.leaderboard-table tr.mine { background: color-mix(in srgb, var(--gold) 14%, transparent); box-shadow: inset 3px 0 0 var(--gold); }
.leaderboard-table tr.mine td:first-child { padding-left: 8px; }
.leaderboard-table tr.mine th { font-weight: 700; }
.leaderboard-you { font-weight: 400; color: var(--ink-soft); }
.leaderboard-gap td { color: var(--ink-soft); text-align: center; }
.leaderboard-invite p { margin: 0 0 8px; }
.leaderboard-invite .btn { margin-top: 2px; }

.site-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 22px;
    padding-block: 18px 32px;
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
    border-top: 1px solid var(--line);
    font-size: .9rem;
}
.site-footer a { color: var(--ink-soft); min-height: 44px; display: inline-flex; align-items: center; }
