/* TheNewLearners : interface facon Kingdom Rush (bois, or, parchemin) */
:root {
  --wood: #7a4a22; --wood-d: #5a3418; --wood-l: #9a6535; --wood-ll: #b98146;
  --gold: #f2c14e; --gold-d: #b8862a; --gold-l: #ffe08a;
  --parch: #f3e2b3; --parch-d: #e2c98c; --ink: #3b2414; --ink-l: #6b4a2c;
  --out: #2b1d14; --green: #6cbf3c; --green-d: #3f8a1e; --red: #e0634a; --red-d: #a8382a; --blue: #3e6db5; --blue-d: #24477f;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  --tap: 60px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #24331c; color: var(--ink); font-family: 'Nunito', system-ui, sans-serif; font-weight: 700; touch-action: manipulation; user-select: none; -webkit-user-select: none; overscroll-behavior: none; }
body { background: radial-gradient(ellipse at 50% 30%, #3d5a2a, #1a2614); }
button { font-family: inherit; color: inherit; touch-action: manipulation; }
.hidden { display: none !important; }
#game { position: fixed; inset: 0; display: block; cursor: grab; touch-action: none; }
#game.dragging { cursor: grabbing; }
#vignette { position: fixed; inset: 0; pointer-events: none; z-index: 1; background: radial-gradient(ellipse at 50% 45%, rgba(255,214,150,0.06) 0%, rgba(255,200,140,0.02) 55%, rgba(60,30,80,0.14) 85%, rgba(30,14,50,0.32) 100%); }
.title-font, h1, h2, h3, .btn, .pill b, .badge-name { font-family: 'Lilita One', 'Nunito', system-ui, sans-serif; font-weight: 400; letter-spacing: 0.3px; }
.outlined { color: #fff8e6; text-shadow: 0 2px 0 var(--out), 2px 0 0 var(--out), -2px 0 0 var(--out), 0 -2px 0 var(--out), 1.5px 1.5px 0 var(--out), -1.5px 1.5px 0 var(--out), 1.5px -1.5px 0 var(--out), -1.5px -1.5px 0 var(--out), 0 4px 0 rgba(0,0,0,.35); }

/* ---------- panneaux ---------- */
.wood {
  background: linear-gradient(180deg, var(--wood-l) 0%, var(--wood) 45%, var(--wood-d) 100%);
  border: 3px solid var(--out); border-radius: 16px; position: relative;
  box-shadow: inset 0 2px 0 rgba(255,220,160,.35), inset 0 -3px 0 rgba(0,0,0,.25), 0 5px 0 rgba(0,0,0,.35), 0 10px 24px rgba(0,0,0,.35);
}
.wood::before { content: ''; position: absolute; inset: 3px; border-radius: 12px; border: 2px solid rgba(242,193,78,.55); pointer-events: none;
  background-image: repeating-linear-gradient(180deg, rgba(0,0,0,0) 0 11px, rgba(0,0,0,.06) 11px 13px); }
.rivets::after { content: ''; position: absolute; inset: 7px; pointer-events: none;
  background: radial-gradient(circle, var(--gold-l) 0 2px, var(--gold-d) 2.5px 3.5px, transparent 4px) 0 0 / 8px 8px no-repeat,
    radial-gradient(circle, var(--gold-l) 0 2px, var(--gold-d) 2.5px 3.5px, transparent 4px) 100% 0 / 8px 8px no-repeat,
    radial-gradient(circle, var(--gold-l) 0 2px, var(--gold-d) 2.5px 3.5px, transparent 4px) 0 100% / 8px 8px no-repeat,
    radial-gradient(circle, var(--gold-l) 0 2px, var(--gold-d) 2.5px 3.5px, transparent 4px) 100% 100% / 8px 8px no-repeat; }
.parch {
  background: radial-gradient(ellipse at 50% 40%, #fbf0cf 0%, var(--parch) 60%, var(--parch-d) 100%);
  border: 3px solid var(--out); border-radius: 14px; color: var(--ink);
  box-shadow: inset 0 0 0 3px #fff3d0, inset 0 0 22px rgba(160,110,40,.35), 0 6px 0 rgba(0,0,0,.3), 0 14px 30px rgba(0,0,0,.4);
}

/* ---------- boutons ---------- */
.btn {
  min-height: 52px; padding: 8px 20px; border-radius: 14px; border: 3px solid var(--out); cursor: pointer; font-size: 20px; color: #fff8e6;
  background: linear-gradient(180deg, #8fd65a, var(--green) 50%, var(--green-d)); box-shadow: inset 0 2px 0 rgba(255,255,255,.45), inset 0 -4px 0 rgba(0,0,0,.2), 0 4px 0 var(--out);
  text-shadow: 0 2px 0 rgba(0,0,0,.45); display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: transform .08s, filter .15s;
}
.btn:active { transform: translateY(3px); box-shadow: inset 0 2px 0 rgba(255,255,255,.45), inset 0 -2px 0 rgba(0,0,0,.2), 0 1px 0 var(--out); }
.btn:hover { filter: brightness(1.06); }
.btn.gold { background: linear-gradient(180deg, var(--gold-l), var(--gold) 50%, var(--gold-d)); color: var(--ink); text-shadow: 0 1px 0 rgba(255,255,255,.5); }
.btn.red { background: linear-gradient(180deg, #f08a6e, var(--red) 50%, var(--red-d)); }
.btn.blue { background: linear-gradient(180deg, #6d9be0, var(--blue) 50%, var(--blue-d)); }
.btn.wood-btn { background: linear-gradient(180deg, var(--wood-ll), var(--wood) 55%, var(--wood-d)); }
.btn.small { min-height: 44px; font-size: 17px; padding: 6px 14px; }
.btn[disabled] { filter: grayscale(.8) brightness(.85); cursor: not-allowed; }
.btn img { width: 26px; height: 26px; }
.round-btn {
  width: var(--tap); height: var(--tap); border-radius: 50%; border: 3px solid var(--out); cursor: pointer; display: grid; place-items: center; position: relative;
  background: radial-gradient(circle at 35% 30%, var(--wood-ll), var(--wood) 55%, var(--wood-d)); box-shadow: inset 0 2px 0 rgba(255,220,160,.4), 0 4px 0 var(--out), 0 6px 12px rgba(0,0,0,.35);
  transition: transform .08s;
}
.round-btn::before { content: ''; position: absolute; inset: 3px; border-radius: 50%; border: 2px solid rgba(242,193,78,.6); }
.round-btn img { width: 62%; height: 62%; pointer-events: none; filter: drop-shadow(0 2px 0 rgba(0,0,0,.35)); }
.round-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--out); }
.round-btn.active { background: radial-gradient(circle at 35% 30%, var(--gold-l), var(--gold) 55%, var(--gold-d)); }
.round-btn .lbl { position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%); font-family: 'Lilita One'; font-size: 14px; white-space: nowrap; pointer-events: none; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud > * { pointer-events: auto; }
.topbar { position: absolute; top: calc(8px + var(--safe-t)); left: 8px; right: 8px; display: flex; align-items: flex-start; gap: 10px; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.town-badge { display: flex; align-items: center; gap: 10px; padding: 6px 14px 6px 6px; cursor: pointer; min-width: 190px; }
.crest { width: 52px; height: 58px; flex: none; position: relative; z-index: 1; }
.badge-name { font-size: 20px; line-height: 1; }
.badge-sub { font-size: 12px; color: #ffe9b8; margin-top: 2px; }
.bar { height: 10px; border-radius: 6px; background: rgba(0,0,0,.4); border: 2px solid var(--out); overflow: hidden; margin-top: 4px; }
.bar > i { display: block; height: 100%; background: linear-gradient(180deg, var(--gold-l), var(--gold)); border-radius: 4px; transition: width .4s; }
.res-bar { display: flex; gap: 6px; flex-wrap: wrap; padding: 6px 8px; align-items: center; }
.pill { display: flex; align-items: center; gap: 4px; padding: 2px 10px 2px 4px; border-radius: 22px; background: rgba(0,0,0,.28); border: 2px solid rgba(0,0,0,.35); min-height: 38px; position: relative; z-index: 1; }
.pill img { width: 30px; height: 30px; }
.pill b { font-size: 20px; color: #fff8e6; text-shadow: 0 2px 0 var(--out); min-width: 18px; }
.pill small { font-size: 12px; color: #ffe9b8; }
.pill.bump { animation: bump .35s; }
@keyframes bump { 40% { transform: scale(1.18); } }
.top-actions { margin-left: auto; display: flex; gap: 8px; }
.top-actions .round-btn { --tap: 52px; }

.quest-panel { position: absolute; top: calc(84px + var(--safe-t)); left: 8px; width: 290px; padding: 10px 12px 10px; }
.quest-panel h3 { margin: 0 0 6px; font-size: 19px; display: flex; align-items: center; gap: 6px; cursor: pointer; position: relative; z-index: 1; }
.quest-panel h3 img { width: 26px; }
.quest { display: flex; gap: 8px; align-items: flex-start; padding: 6px 4px; border-top: 2px dashed rgba(90,52,24,.25); position: relative; z-index: 1; }
.quest:first-of-type { border-top: 0; }
.quest .box { width: 22px; height: 22px; border-radius: 6px; border: 2.5px solid var(--ink); background: #fff8e6; flex: none; margin-top: 1px; display: grid; place-items: center; }
.quest.done .box { background: var(--green); }
.quest p { margin: 0; font-size: 15px; line-height: 1.2; }
.quest small { display: block; font-size: 12.5px; color: var(--ink-l); font-weight: 600; margin-top: 2px; }
.quest-panel.collapsed .quest { display: none; }

.toolbar { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(14px + var(--safe-b)); display: flex; gap: 14px; padding: 10px 16px 24px; align-items: flex-end; }
.toolbar .round-btn { --tap: 66px; }
.toolbar .round-btn.main { --tap: 80px; background: radial-gradient(circle at 35% 30%, #8fd65a, var(--green) 55%, var(--green-d)); }
.toolbar .round-btn.main.active { background: radial-gradient(circle at 35% 30%, var(--gold-l), var(--gold) 55%, var(--gold-d)); }
.toolbar .lbl { color: #fff8e6; text-shadow: 0 2px 0 var(--out), 1px 0 0 var(--out), -1px 0 0 var(--out); }

.hint { position: absolute; top: calc(84px + var(--safe-t)); left: 50%; transform: translateX(-50%); padding: 10px 14px 10px 18px; display: flex; gap: 12px; align-items: center; max-width: min(560px, 92vw); font-size: 17px; animation: drop .25s ease-out; }
.hint span { position: relative; z-index: 1; }
.hint .round-btn { --tap: 44px; flex: none; }
@keyframes drop { from { transform: translate(-50%, -20px); opacity: 0; } }

#toasts { position: absolute; top: calc(150px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; z-index: 30; }
.toast { padding: 9px 18px; border-radius: 30px; border: 3px solid var(--out); font-size: 16px; background: #fff8e6; box-shadow: 0 4px 0 rgba(0,0,0,.3); animation: toastIn .3s ease-out, toastOut .4s ease-in forwards 3s; display: flex; align-items: center; gap: 8px; }
.toast.good { background: linear-gradient(180deg, #d9f5b8, #b6e38a); }
.toast.warn { background: linear-gradient(180deg, #ffe1b3, #ffc27a); }
.toast img { width: 24px; }
@keyframes toastIn { from { transform: translateY(-14px) scale(.9); opacity: 0; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px); } }

.confirm-bubble { position: absolute; display: flex; gap: 10px; transform: translate(-50%, -100%); padding: 8px; z-index: 15; animation: pop .2s ease-out; }
.confirm-bubble .btn { min-width: 64px; min-height: 58px; font-size: 18px; position: relative; z-index: 1; }
.confirm-bubble::after { content: ''; position: absolute; left: 50%; bottom: -12px; transform: translateX(-50%); border: 10px solid transparent; border-top-color: var(--out); }
@keyframes pop { from { transform: translate(-50%, -100%) scale(.6); opacity: 0; } }

/* ---------- tiroir de construction ---------- */
.drawer { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(126px + var(--safe-b)); width: min(860px, 96vw); padding: 12px; animation: rise .22s ease-out; z-index: 12; }
@keyframes rise { from { transform: translate(-50%, 30px); opacity: 0; } }
.tabs { touch-action: pan-x; display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; position: relative; z-index: 1; scrollbar-width: none; }
.tab { flex: none; display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 12px; border: 3px solid var(--out); background: var(--wood-d); color: #ffe9b8; cursor: pointer; font-size: 15px; min-height: 48px; }
.tab img { width: 26px; }
.tab.active { background: var(--parch); color: var(--ink); }
.tab .subj { font-size: 11px; display: block; opacity: .85; }
.cards { touch-action: pan-x; display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 6px; position: relative; z-index: 1; scrollbar-width: thin; }
.card { flex: none; width: 150px; padding: 8px; cursor: pointer; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; transition: transform .12s; position: relative; }
.card:hover { transform: translateY(-3px); }
.card:active { transform: translateY(2px); }
.card .thumb { width: 120px; height: 96px; object-fit: contain; filter: drop-shadow(0 3px 0 rgba(0,0,0,.2)); }
.card h4 { margin: 0; font-family: 'Lilita One'; font-weight: 400; font-size: 17px; line-height: 1.05; }
.cost { display: flex; gap: 6px; justify-content: center; font-size: 15px; }
.cost span { display: flex; align-items: center; gap: 1px; }
.cost img { width: 22px; }
.card.locked { filter: grayscale(.85); opacity: .85; }
.card .lock { position: absolute; top: 6px; right: 6px; width: 30px; }
.card .why { font-size: 11.5px; color: var(--red-d); line-height: 1.1; }
.subj-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 10px; color: #fff; font-size: 12px; border: 2px solid var(--out); }

/* ---------- panneau lateral ---------- */
.side-panel { touch-action: pan-y; overscroll-behavior: contain; position: absolute; right: 8px; top: calc(84px + var(--safe-t)); width: 330px; max-height: calc(100% - 220px); overflow-y: auto; padding: 14px; animation: slideIn .2s ease-out; z-index: 11; }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } }
.side-panel .close { position: absolute; top: 8px; right: 8px; --tap: 44px; z-index: 2; }
.side-panel h2 { margin: 0 44px 4px 0; font-size: 26px; }
.side-panel .head { display: flex; gap: 10px; align-items: center; }
.side-panel .head img { width: 90px; height: 76px; object-fit: contain; }
.side-panel p { margin: 6px 0; font-size: 15px; line-height: 1.3; }
.side-panel .row { display: flex; align-items: center; gap: 8px; font-size: 16px; margin: 6px 0; }
.side-panel .row img { width: 28px; }
.side-panel .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.status { padding: 6px 10px; border-radius: 10px; background: rgba(255,255,255,.55); border: 2px solid rgba(90,52,24,.3); font-size: 15px; margin: 8px 0; }
.status.alert { background: #ffe1d6; border-color: var(--red); }
.progress { height: 18px; border-radius: 10px; border: 3px solid var(--out); background: #c9b384; overflow: hidden; }
.progress i { display: block; height: 100%; background: linear-gradient(180deg, #a5e070, var(--green)); transition: width .3s; }
.slots { display: flex; gap: 4px; flex-wrap: wrap; }
.slots img { width: 30px; height: 30px; }
.slot-empty { width: 30px; height: 30px; border-radius: 8px; border: 2px dashed rgba(90,52,24,.4); }
.info-card { background: rgba(255,255,255,.5); border-radius: 12px; padding: 8px 10px; border: 2px solid rgba(90,52,24,.25); font-weight: 600; }

/* ---------- mini-carte ---------- */
.minimap { position: absolute; right: 10px; bottom: calc(14px + var(--safe-b)); width: 170px; height: 170px; padding: 8px; }
.minimap canvas { width: 100%; height: 100%; border-radius: 8px; border: 2px solid var(--out); display: block; position: relative; z-index: 1; image-rendering: auto; background: #aebfd4; cursor: pointer; }

/* ---------- fenetres modales ---------- */
.modal-layer { position: fixed; inset: 0; z-index: 50; display: flex; background: rgba(20,14,8,.55); padding: max(12px, env(safe-area-inset-top)) 10px max(16px, env(safe-area-inset-bottom)); animation: fade .2s; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y; height: 100vh; height: 100dvh; }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(640px, 96vw); margin: auto; padding: 20px 22px; position: relative; animation: modalIn .28s cubic-bezier(.2,1.4,.4,1); flex: none; }
@keyframes modalIn { from { transform: scale(.85); opacity: 0; } }
.modal h2 { margin: 0 0 8px; font-size: 30px; text-align: center; }
.modal .ribbon { margin: -8px auto 10px; width: fit-content; padding: 8px 26px; border-radius: 10px; border: 3px solid var(--out); background: linear-gradient(180deg, #e0634a, #a8382a); font-family: 'Lilita One'; font-size: 24px; position: relative; box-shadow: 0 4px 0 rgba(0,0,0,.3); }
.modal .close { position: absolute; top: 10px; right: 10px; --tap: 46px; z-index: 3; }
.modal-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }

/* ---------- quiz ---------- */
.quiz { width: min(980px, 97vw); padding-top: 14px; }
.quiz-body { display: grid; gap: 14px; align-items: start; }
.quiz-body.has-fig { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.quiz-body .quiz-fig svg { max-height: 46vh; }
@media (max-width: 820px) { .quiz-body.has-fig { grid-template-columns: 1fr; } .quiz-body .quiz-fig svg { max-height: 28vh; } }
.quiz-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.quiz-head .for { font-size: 15px; color: var(--ink-l); }
.quiz-head .tier { margin-left: auto; margin-right: 52px; display: flex; gap: 2px; }
.quiz-title { font-family: 'Lilita One'; font-size: 26px; margin: 4px 0 6px; }
.quiz-text { font-size: 20px; line-height: 1.35; margin: 2px 0 8px; }
.quiz-text small { font-size: 15px; color: var(--ink-l); }
.quiz-fig { display: flex; justify-content: center; margin: 6px 0 10px; }
.quiz-fig svg { width: min(100%, 380px); height: auto; max-height: 34vh; background: rgba(255,255,255,.45); border-radius: 12px; border: 2px solid rgba(90,52,24,.25); }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.choice { min-height: 64px; font-size: 21px; border-radius: 14px; border: 3px solid var(--out); background: linear-gradient(180deg, #fffaf0, #f0dcaa); cursor: pointer; box-shadow: 0 4px 0 var(--out); font-weight: 800; padding: 8px; }
.choice:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--out); }
.choice.good { background: linear-gradient(180deg, #c8f0a0, #8fd14f); animation: bump .4s; }
.choice.bad { background: linear-gradient(180deg, #ffc9b8, #f08a6e); animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.num-entry { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.num-display { min-width: 220px; min-height: 66px; font-size: 34px; font-family: 'Lilita One'; border-radius: 14px; border: 3px solid var(--out); background: #fffaf0; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 4px 16px; box-shadow: inset 0 3px 6px rgba(0,0,0,.15); }
.num-display .unit { font-size: 20px; color: var(--ink-l); font-family: 'Nunito'; }
.num-display .caret { width: 3px; height: 34px; background: var(--ink); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.num-display.bad { animation: shake .4s; background: #ffd9cc; }
.num-display.good { background: #d9f5b8; }
.keypad { display: grid; grid-template-columns: repeat(4, 66px); gap: 8px; }
.keypad .key.zero { grid-column: span 2; }
.key { height: 54px; font-size: 26px; font-family: 'Lilita One'; border-radius: 12px; border: 3px solid var(--out); background: linear-gradient(180deg, #fffaf0, #e8d29c); box-shadow: 0 4px 0 var(--out); cursor: pointer; }
.key:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--out); }
.key.ok { grid-row: span 2; height: auto; background: linear-gradient(180deg, #a5e070, var(--green)); color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.4); }
.key.del { background: linear-gradient(180deg, #ffd9cc, #f0a08a); font-size: 20px; }
.feedback { margin-top: 12px; padding: 12px 14px; border-radius: 14px; border: 3px solid var(--out); font-size: 17px; line-height: 1.4; animation: modalIn .3s; }
.feedback.good { background: linear-gradient(180deg, #e3f8cc, #c4ec9c); }
.feedback.bad { background: linear-gradient(180deg, #fff1e0, #ffd9b8); }
.feedback h3 { margin: 0 0 4px; font-family: 'Lilita One'; font-weight: 400; font-size: 24px; }
.hint-box { margin-top: 8px; padding: 8px 12px; background: #fff7d6; border: 2px dashed var(--gold-d); border-radius: 12px; font-size: 16px; }
.stars-burst { display: flex; justify-content: center; gap: 6px; margin: 6px 0; }
.stars-burst img { width: 44px; animation: starPop .5s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes starPop { from { transform: scale(0) rotate(-90deg); } }

/* ---------- ecran des profils ---------- */
.screen { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; align-items: center; justify-content: safe center; padding: 20px; overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; height: 100vh; height: 100dvh; }
#profiles { background: linear-gradient(180deg, rgba(20,30,15,.25), rgba(20,14,8,.6)); }
.logo { text-align: center; margin-bottom: 18px; animation: modalIn .5s cubic-bezier(.2,1.4,.4,1); }
.logo h1 { font-size: clamp(42px, 8vw, 84px); margin: 0; line-height: .95; background: linear-gradient(180deg, #fff6c8 10%, var(--gold) 55%, #d48a1c); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-stroke: 3px var(--out); filter: drop-shadow(0 6px 0 rgba(0,0,0,.45)); }
.logo p { margin: 6px 0 0; font-size: clamp(16px, 2.6vw, 22px); }
.profiles-box { width: min(880px, 96vw); padding: 18px; }
.profiles-box h2 { margin: 0 0 12px; text-align: center; font-size: 26px; position: relative; z-index: 1; }
.profile-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; position: relative; z-index: 1; }
.profile-card { padding: 12px; text-align: center; cursor: pointer; position: relative; transition: transform .12s; }
.profile-card:hover { transform: translateY(-3px); }
.profile-card .avatar { width: 74px; height: 84px; margin: 0 auto 4px; display: block; }
.profile-card h3 { margin: 2px 0; font-size: 24px; font-family: 'Lilita One'; font-weight: 400; }
.profile-card .meta { font-size: 13px; color: var(--ink-l); }
.profile-card .del { position: absolute; top: 6px; right: 6px; width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--out); background: #ffd9cc; cursor: pointer; font-size: 16px; line-height: 1; }
.profile-card.new { display: grid; place-items: center; border-style: dashed; min-height: 180px; font-family: 'Lilita One'; font-size: 22px; }
.profile-card.new .plus { font-size: 54px; line-height: 1; color: var(--green-d); }
.form-row { margin: 12px 0; }
.form-row label { display: block; font-size: 16px; margin-bottom: 6px; }
.form-row input[type=text] { width: 100%; font-size: 22px; padding: 10px 14px; border-radius: 12px; border: 3px solid var(--out); background: #fffaf0; font-family: 'Lilita One'; color: var(--ink); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { min-height: 52px; min-width: 70px; padding: 6px 14px; border-radius: 14px; border: 3px solid var(--out); background: #fffaf0; font-family: 'Lilita One'; font-size: 20px; cursor: pointer; }
.chip.on { background: linear-gradient(180deg, var(--gold-l), var(--gold)); box-shadow: 0 3px 0 var(--out); }
.chip small { display: block; font-family: 'Nunito'; font-size: 11px; }
.chip[disabled] { opacity: .5; }
.swatch { width: 52px; height: 52px; border-radius: 50%; border: 3px solid var(--out); cursor: pointer; }
.swatch.on { box-shadow: 0 0 0 4px #fff8e6, 0 0 0 7px var(--out); }

.loading { background: radial-gradient(ellipse at 50% 40%, #4a6b32, #1a2614); z-index: 60; transition: opacity .5s; }
.loading .spin { width: 90px; height: 90px; animation: spin 1.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading p { font-family: 'Lilita One'; font-size: 24px; }

/* ---------- options / stats ---------- */
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 4px; border-bottom: 2px dashed rgba(90,52,24,.25); font-size: 17px; }
.seg { display: flex; border: 3px solid var(--out); border-radius: 12px; overflow: hidden; }
.seg button { border: 0; min-height: 44px; padding: 4px 14px; font-family: 'Lilita One'; font-size: 17px; background: #fffaf0; cursor: pointer; }
.seg button.on { background: linear-gradient(180deg, var(--gold-l), var(--gold)); }
.timeline { display: flex; gap: 8px; overflow-x: auto; padding: 6px 2px; }
.era { flex: 1 0 120px; padding: 10px 8px; border-radius: 12px; border: 3px solid var(--out); text-align: center; background: #fffaf0; font-size: 13px; }
.era b { display: block; font-family: 'Lilita One'; font-weight: 400; font-size: 17px; }
.era.locked { background: #d9ccb0; opacity: .75; }
.era.current { background: linear-gradient(180deg, #e3f8cc, #c4ec9c); }
.stat-row { display: grid; grid-template-columns: 120px 1fr 60px; gap: 8px; align-items: center; margin: 6px 0; font-size: 15px; }
.slider-row { margin: 12px 0; }
.slider-row label { display: flex; justify-content: space-between; font-size: 17px; }
input[type=range] { width: 100%; height: 34px; accent-color: var(--gold-d); }
.frac { font-family: 'Lilita One'; font-size: 26px; text-align: center; margin: 8px 0; }

@media (max-width: 760px) {
  :root { --tap: 54px; }
  .topbar { flex-wrap: wrap; gap: 6px; left: 6px; right: 6px; }
  .town-badge { min-width: 0; padding: 4px 10px 4px 4px; gap: 6px; }
  .town-badge .badge-sub { display: none; }
  .town-badge .bar { width: 90px; height: 8px; }
  .crest { width: 36px; height: 40px; }
  .badge-name { font-size: 16px; }
  .res-bar { order: 3; width: 100%; flex-wrap: nowrap; overflow-x: auto; justify-content: space-between; padding: 4px 6px; gap: 4px; scrollbar-width: none; }
  .res-bar::-webkit-scrollbar { display: none; }
  .pill { min-height: 32px; padding: 2px 7px 2px 3px; flex: none; }
  .pill img { width: 24px; height: 24px; }
  .pill b { font-size: 16px; }
  .pill small { display: none; }
  .top-actions { gap: 5px; }
  .top-actions .round-btn { --tap: 44px; }
  .quest-panel { top: calc(112px + var(--safe-t)); left: 6px; width: calc(100vw - 136px); padding: 6px 10px; }
  .quest-panel h3 { font-size: 16px; margin: 0; }
  .quest p { font-size: 14px; }
  .toolbar { gap: 8px; padding: 8px 10px 22px; bottom: calc(6px + var(--safe-b)); }
  .toolbar .round-btn { --tap: 54px; }
  .toolbar .round-btn.main { --tap: 64px; }
  .toolbar .lbl { font-size: 12px; bottom: -17px; }
  .drawer { bottom: calc(100px + var(--safe-b)); padding: 8px; }
  .tab { min-height: 44px; font-size: 14px; padding: 4px 8px; }
  .card { width: 124px; }
  .card .thumb { width: 100px; height: 78px; }
  .side-panel { left: 6px; right: 6px; width: auto; top: auto; bottom: calc(100px + var(--safe-b)); max-height: 46vh; }
  .minimap { width: 118px; height: 118px; bottom: auto; top: calc(112px + var(--safe-t)); right: 6px; padding: 5px; }
  .hint { top: auto; bottom: calc(104px + var(--safe-b)); font-size: 15px; width: calc(100vw - 16px); }
  #toasts { top: calc(240px + var(--safe-t)); width: calc(100vw - 20px); }
  .toast { font-size: 14px; }
  .keypad { grid-template-columns: repeat(4, 60px); gap: 6px; }
  .key { height: 50px; font-size: 22px; }
  .quiz { padding: 12px; }
  .quiz-title { font-size: 21px; }
  .quiz-text { font-size: 17px; }
  .choice { min-height: 56px; font-size: 18px; }
  .modal { padding: 14px; }
  .modal h2 { font-size: 24px; }
}
@media (max-height: 560px) {
  .quest-panel { display: none; }
  .quiz-fig svg { max-height: 26vh; }
}

/* aide : sur petit ecran, le bouton de validation reste accessible en bas */
.modal .modal-actions.sticky { position: sticky; bottom: -20px; margin: 10px 0 -20px; padding: 12px 0 18px; background: linear-gradient(180deg, rgba(243,226,179,0), #f6e8c0 40%); }
.help p { margin: 8px 0; }
@media (max-width: 760px) { .help p { font-size: 15px; } }
