:root {
  --ink: #1d2b30;
  --muted: #6b7a7e;
  --bg: #f6f1e7;
  --paper: #fffdf8;
  --line: #e7dfcf;
  --teal: #1f4e5a;
  --teal-2: #2f6f7d;
  --coral: #e8664f;
  --sun: #f2b544;
  --leaf: #4f9a6a;
  --plum: #8a5aa8;
  --sky: #4a8cc7;
  --r: 16px;
  --shadow: 0 1px 2px rgba(29, 43, 48, .06), 0 6px 18px rgba(29, 43, 48, .06);
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
#app { max-width: 560px; margin: 0 auto; min-height: 100vh; }
.screen { padding: 20px 16px 110px; }
.screen.center { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; gap: 24px; padding-bottom: 40px; }

/* Marque */
.brand { text-align: center; }
.logo { font-size: 48px; font-weight: 800; letter-spacing: -1.5px; color: var(--teal); }
.logo span { color: var(--coral); }
.tagline { margin: 6px 0 12px; color: var(--muted); }
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 99px; background: var(--teal); color: #fff; letter-spacing: .3px; }
.title { font-size: 26px; margin: 8px 4px 16px; color: var(--teal); }

/* Cartes et formulaires */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); }
label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 12px; }
input { display: block; width: 100%; margin-top: 6px; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; font-size: 16px; }
input:focus { outline: none; border-color: var(--teal-2); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-label { font-weight: 700; font-size: 14px; margin: 6px 0 8px; }
.error { color: var(--coral); font-weight: 600; min-height: 1.2em; margin: 10px 0 0; font-size: 14px; }
.btn { border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 700; background: #ece5d6; transition: transform .08s, background .15s; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--coral); color: #fff; width: 100%; padding: 14px; font-size: 16px; }
.btn.teal { background: var(--teal); color: #fff; }
.btn.ghost { background: transparent; border: 1.5px solid var(--line); }
.btn.small { padding: 8px 12px; font-size: 14px; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 8px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: #efe8da; border-radius: 12px; padding: 4px; margin-bottom: 16px; }
.seg button { border: 0; background: transparent; padding: 10px; border-radius: 9px; font-weight: 700; color: var(--muted); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.choices button, .traits button { border: 1.5px solid var(--line); background: #fff; border-radius: 12px; padding: 12px; font-weight: 700; text-align: left; }
.choices.big button { display: flex; flex-direction: column; gap: 4px; }
.choices small, .traits small { font-weight: 500; color: var(--muted); font-size: 12.5px; line-height: 1.35; }
.choices button.on, .traits button.on { border-color: var(--teal); background: #e8f1f1; box-shadow: inset 0 0 0 1px var(--teal); }
.traits { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.traits button { display: flex; flex-direction: column; gap: 4px; }

/* En-tête de jeu */
.top { position: sticky; top: 0; z-index: 5; background: var(--teal); color: #fff; margin: -20px -16px 14px; padding: 14px 16px 12px; border-radius: 0 0 22px 22px; box-shadow: 0 6px 20px rgba(31, 78, 90, .25); }
.who { display: flex; align-items: center; gap: 12px; }
.avatar { width: 46px; height: 46px; border-radius: 50%; background: #fff2; display: grid; place-items: center; font-size: 26px; flex: none; }
.name { font-weight: 800; font-size: 18px; line-height: 1.1; }
.sub { font-size: 13px; opacity: .85; margin-top: 2px; }
.money { margin-left: auto; font-weight: 800; font-size: 17px; background: #ffffff1f; padding: 6px 10px; border-radius: 10px; white-space: nowrap; }
.money.neg { color: #ffd0c6; }
.gauges { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.gauge { font-size: 11.5px; font-weight: 700; opacity: .95; }
.gauge .bar { height: 7px; border-radius: 9px; background: #ffffff2a; margin-top: 4px; overflow: hidden; }
.gauge .bar i { display: block; height: 100%; border-radius: 9px; transition: width .4s; }

/* Onglets */
.section { font-size: 15px; margin: 20px 4px 10px; color: var(--teal); text-transform: uppercase; letter-spacing: .6px; }
.hint { color: var(--muted); font-size: 14px; margin: -4px 4px 12px; }
.bottom { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 560px; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--paper); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 6; }
.bottom button { border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11.5px; font-weight: 700; color: var(--muted); padding: 6px 0; position: relative; }
.bottom button span { font-size: 21px; filter: grayscale(.6); }
.bottom button.on { color: var(--teal); }
.bottom button.on span { filter: none; }
.badge { position: absolute; top: 2px; left: calc(50% + 6px); background: var(--coral); color: #fff; font-style: normal; font-size: 10.5px; min-width: 17px; height: 17px; border-radius: 9px; display: none; place-items: center; padding: 0 4px; }
.badge.show { display: grid; }

/* Événements */
.event { background: linear-gradient(135deg, #fff7e8, #fff); border: 1.5px solid #f3d9a6; border-radius: var(--r); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); animation: pop .3s ease; }
.event .tag { font-size: 11px; font-weight: 800; color: #b07a12; letter-spacing: .6px; text-transform: uppercase; }
.event h3 { margin: 4px 0 6px; font-size: 18px; }
.event p { margin: 0 0 12px; line-height: 1.45; }
.event .opts { display: grid; gap: 8px; }
.event .opts button { text-align: left; border: 1.5px solid #f0d49b; background: #fff; border-radius: 12px; padding: 11px 12px; font-weight: 700; }
.event .opts button:active { background: #fff1d6; }
@keyframes pop { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Lieu */
.place-head { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.place-icon { font-size: 34px; width: 54px; height: 54px; display: grid; place-items: center; background: #eef4f2; border-radius: 14px; flex: none; }
.place-head h2 { margin: 0; font-size: 19px; }
.place-head p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.act { border: 1.5px solid var(--line); background: #fff; border-radius: 12px; padding: 10px 11px; text-align: left; font-weight: 700; font-size: 14.5px; display: flex; flex-direction: column; gap: 3px; }
.act small { font-weight: 600; color: var(--muted); font-size: 12px; }
.act:disabled { opacity: .45; }
.act:not(:disabled):active { background: #eef4f2; }

/* Personnes */
.people { display: grid; gap: 8px; }
.person { display: flex; align-items: center; gap: 12px; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; text-align: left; width: 100%; }
.person .pa { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 22px; background: #eef4f2; flex: none; position: relative; }
.person .pa.player::after { content: ""; position: absolute; right: 0; bottom: 0; width: 11px; height: 11px; border-radius: 50%; background: #bbb; border: 2px solid var(--paper); }
.person .pa.player.online::after { background: var(--leaf); }
.person .pi { flex: 1; min-width: 0; }
.person .pn { font-weight: 800; display: block; }
.person .ps { display: block; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .rel { font-size: 12px; font-weight: 800; padding: 4px 8px; border-radius: 99px; background: #eef4f2; color: var(--teal); white-space: nowrap; }
.rel.love { background: #fde6e1; color: var(--coral); }
.empty { color: var(--muted); font-size: 14px; text-align: center; padding: 14px; background: var(--paper); border: 1px dashed var(--line); border-radius: 14px; }
.tagp { display: inline-block; font-size: 10.5px; font-weight: 800; padding: 2px 6px; border-radius: 6px; background: var(--sun); color: #5a3d00; margin-left: 6px; vertical-align: 2px; }

/* Chat */
.chat { padding: 10px; }
.chat-log { max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 4px; }
.msg { font-size: 14.5px; line-height: 1.35; }
.msg b { color: var(--teal); }
.msg.mine b { color: var(--coral); }
.msg .rep { border: 0; background: none; color: var(--muted); font-size: 11px; padding: 0 4px; }
.chat-form { display: flex; gap: 8px; margin-top: 8px; }
.chat-form input { margin: 0; }

/* Plan du bourg */
.map-wrap { position: relative; margin: 0 -8px; }
.map-head { display: flex; flex-direction: column; padding: 0 10px 10px; }
.map-head b { color: var(--teal); font-size: 17px; }
.map-head span { color: var(--muted); font-size: 13.5px; }
#map svg { display: block; width: 100%; height: auto; border-radius: 18px; box-shadow: var(--shadow); touch-action: manipulation; user-select: none; -webkit-user-select: none; }
#map .bld { cursor: pointer; }
#map .bld:active .bld-body { filter: brightness(.95); }
#map .lbl { font: 700 11.5px ui-rounded, system-ui, sans-serif; fill: #24353a; pointer-events: none; }
#map .ico { font-size: 30px; pointer-events: none; }
#map .pp { cursor: pointer; }
#map .me-tag { font: 800 10px ui-rounded, system-ui, sans-serif; fill: #fff; pointer-events: none; }
#map .bob { animation: bob 2.4s ease-in-out infinite; transform-box: fill-box; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
#map .here-ring { animation: pulse 1.6s ease-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes pulse { 0% { opacity: .7; transform: scale(.6); } 100% { opacity: 0; transform: scale(1.6); } }
.map-card { position: sticky; bottom: calc(76px + env(safe-area-inset-bottom)); margin: 12px 8px 0; background: var(--ink); color: #fff; border-radius: 16px; padding: 12px 14px; display: flex; align-items: center; gap: 12px; box-shadow: 0 10px 28px rgba(0,0,0,.25); z-index: 4; }
.map-card .ic { font-size: 28px; }
.map-card div { flex: 1; min-width: 0; }
.map-card b { display: block; }
.map-card small { opacity: .8; }
.map-card .btn { background: var(--coral); color: #fff; }

/* Journal */
.journal { display: grid; gap: 8px; }
.jn { background: var(--paper); border: 1px solid var(--line); border-left: 4px solid var(--teal-2); border-radius: 12px; padding: 10px 12px; font-size: 14.5px; line-height: 1.4; }
.jn time { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 2px; }
.jn.amour { border-left-color: var(--coral); }
.jn.carriere { border-left-color: var(--sun); }
.jn.etudes { border-left-color: var(--sky); }
.jn.deces { border-left-color: #555; background: #f4f2ee; }
.jn.naissance { border-left-color: var(--leaf); }

/* Moi */
.me-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.me-grid div { background: #f6f1e7; border-radius: 12px; padding: 10px; font-size: 13px; color: var(--muted); }
.me-grid b { display: block; color: var(--ink); font-size: 15px; margin-top: 2px; }
.trait-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.chip { font-size: 12.5px; font-weight: 700; padding: 4px 10px; border-radius: 99px; background: #e8f1f1; color: var(--teal); }
.skills { display: grid; gap: 10px; }
.sk { font-size: 14px; font-weight: 700; }
.sk .bar { height: 8px; background: #eee6d6; border-radius: 9px; margin-top: 5px; overflow: hidden; }
.sk .bar i { display: block; height: 100%; background: var(--teal-2); border-radius: 9px; }
.timeline { display: grid; gap: 6px; }
.tl { display: flex; gap: 10px; font-size: 14px; line-height: 1.4; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; }
.tl b { color: var(--coral); flex: none; min-width: 44px; }
.footer-links { text-align: center; margin-top: 20px; }

/* Panneau */
.sheet { position: fixed; inset: 0; background: rgba(20, 30, 34, .45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet-panel { background: var(--paper); width: 100%; max-width: 560px; border-radius: 22px 22px 0 0; padding: 22px 18px calc(24px + env(safe-area-inset-bottom)); max-height: 85vh; overflow-y: auto; position: relative; animation: up .22s ease; }
@keyframes up { from { transform: translateY(40px); opacity: .5; } to { transform: none; opacity: 1; } }
.close { position: absolute; top: 12px; right: 12px; border: 0; background: #efe8da; width: 34px; height: 34px; border-radius: 50%; font-weight: 800; }
.sheet h2 { margin: 0 40px 4px 0; }
.sheet .muted { color: var(--muted); margin: 0 0 14px; font-size: 14px; }
.sheet-actions { display: grid; gap: 8px; }
.sheet-actions .btn { text-align: left; }
.offer { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; }
.offer div { flex: 1; }
.offer small { display: block; color: var(--muted); font-size: 12.5px; }
.result h2 { margin-bottom: 8px; }
.result p { line-height: 1.5; }
.changes { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 16px; }
.changes span { font-size: 12.5px; font-weight: 700; background: #e8f1f1; color: var(--teal); padding: 4px 9px; border-radius: 99px; }
.ok { color: var(--leaf); } .ko { color: var(--coral); }
textarea { width: 100%; min-height: 120px; border-radius: 12px; border: 1.5px solid var(--line); padding: 12px; font: inherit; font-size: 15px; margin: 8px 0 12px; }

/* Notifications */
#toasts { position: fixed; bottom: calc(132px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); z-index: 30; display: grid; gap: 8px; width: calc(100% - 24px); max-width: 520px; pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 12px 14px; border-radius: 12px; font-weight: 600; font-size: 14.5px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); animation: pop .25s ease; }
.toast.err { background: var(--coral); }
#bug-btn { position: fixed; right: 14px; bottom: calc(78px + env(safe-area-inset-bottom)); width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--paper); box-shadow: var(--shadow); font-size: 20px; z-index: 7; }

/* Décès */
.obit { text-align: center; padding: 30px 22px; }
.candle { font-size: 52px; }
.obit h1 { color: var(--teal); }
.obit p { line-height: 1.55; margin-bottom: 22px; }

@media (min-width: 520px) { .map { grid-template-columns: repeat(4, 1fr); } }

/* 0.3 : consentement, boîte de réception, compte */
.consent { margin: 4px 0 14px; display: grid; gap: 8px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 600; font-size: 13.5px; margin: 0; line-height: 1.4; }
.check input { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--teal); }
.check a, .legal-links a { color: var(--teal-2); }
.legal-links { text-align: center; font-size: 13px; margin: 0; }
.inbox { margin-bottom: 12px; border-left: 4px solid var(--sky); }
.inbox-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.inbox-item { font-size: 14px; line-height: 1.4; padding: 6px 0; border-top: 1px solid var(--line); }
.inbox-item time { display: block; font-size: 11.5px; color: var(--muted); }
.account { display: grid; gap: 8px; }
.account .danger { color: var(--coral); border-color: #f3c5bb; }
.account .link { text-align: center; font-size: 13px; }
