/* Base commune des mini-jeux Émoi : portrait du personnage à gauche, zone de jeu à droite ; sur téléphone, bandeau portrait + bulle, puis le jeu. */
:root {
  --night: #140F1B; --night-2: #23162B; --ink: #F4EDF3; --muted: #C3B6C6; --rose: #E46A86; --gold: #E0A85A;
  --sig: #9A2A44; --line: rgba(255,255,255,.12); --ok: #7FD9A3; --bad: #E2675A;
  --font-display: "Bodoni Moda", "Didot", Georgia, serif; --font-body: "Hanken Grotesk", "Helvetica Neue", Arial, sans-serif; --font-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body { background: radial-gradient(110% 80% at 25% 15%, color-mix(in srgb, var(--sig) 38%, var(--night-2)) 0%, var(--night) 62%) fixed, var(--night); color: var(--ink); font-family: var(--font-body); line-height: 1.5; -webkit-font-smoothing: antialiased; overflow-x: hidden; touch-action: manipulation; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
a { color: inherit; }
.brand { font-family: var(--font-display); font-style: italic; font-weight: 600; font-size: 1.4rem; text-decoration: none; color: var(--ink); }
.brand span { color: var(--rose); }
.mono { font-family: var(--font-mono); font-size: .75rem; letter-spacing: .08em; color: var(--muted); }
.btn { border: 0; border-radius: 999px; padding: 13px 26px; font-weight: 600; background: var(--rose); color: #1A0C12; text-decoration: none; display: inline-block; text-align: center; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid rgba(255,255,255,.3); font-weight: 500; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { 0% { transform: translate(-50%, -50%) scale(.6); opacity: 0; } 20% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; } 100% { transform: translate(-50%, -90%) scale(1); opacity: 0; } }
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.page { min-height: 100vh; display: flex; flex-direction: column; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: max(14px, env(safe-area-inset-top, 0px)) max(18px, env(safe-area-inset-right, 0px)) 8px max(18px, env(safe-area-inset-left, 0px)); }
.top-r { display: flex; gap: 10px; align-items: center; }
.top-r a { color: var(--muted); font-size: .8125rem; text-decoration: none; }
.top-r button { background: none; border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; color: var(--muted); font-size: .8125rem; }

.game { flex: 1; display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: clamp(18px, 3vw, 44px); max-width: 1160px; width: 100%; margin: 0 auto; padding: 6px max(18px, env(safe-area-inset-right, 0px)) 22px max(18px, env(safe-area-inset-left, 0px)); align-items: center; }
.game > * { min-width: 0; }
.coach { position: relative; width: min(100%, 390px); justify-self: center; }
.portrait { position: relative; width: 100%; aspect-ratio: 3 / 4; border-radius: 26px; overflow: hidden; box-shadow: 0 40px 90px -30px color-mix(in srgb, var(--sig) 85%, transparent), 0 0 0 1px rgba(255,255,255,.08); background: var(--night-2); }
.portrait img, .portrait video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 20%; }
.portrait video { opacity: 0; transition: opacity .45s ease; }
.portrait video.on { opacity: 1; }
.portrait .clip { z-index: 1; }
.portrait.hit { animation: shake .25s ease; }
.bubble { position: absolute; left: 14px; right: 14px; bottom: 14px; z-index: 2; pointer-events: none; background: rgba(20,15,27,.72); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 16px; border-bottom-left-radius: 6px; padding: 9px 13px; font-size: .95rem; min-height: 2.6em; }
.bubble b { display: block; font-family: var(--font-mono); font-size: .625rem; letter-spacing: .1em; text-transform: uppercase; color: var(--gold); font-weight: 500; }
.bubble span { display: block; animation: fadeIn .3s ease; }

.arena { display: grid; gap: 14px; }
.hud { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat { background: rgba(20,15,27,.5); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.stat small { display: block; font-family: var(--font-mono); font-size: .625rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.stat b { font-family: var(--font-display); font-size: 1.6rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat b.mult { color: var(--gold); }
.prog { height: 4px; border-radius: 9px; background: rgba(255,255,255,.1); overflow: hidden; }
.prog span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--rose), var(--gold)); transition: width .3s ease; }
.stage { position: relative; border-radius: 22px; border: 1px solid var(--line); background: radial-gradient(70% 90% at 50% 50%, color-mix(in srgb, var(--sig) 22%, transparent), transparent 70%); min-height: 260px; overflow: hidden; }
.verdict { position: absolute; left: 50%; top: 50%; font-family: var(--font-display); font-style: italic; font-size: clamp(1.3rem, 3vw, 1.8rem); white-space: nowrap; pointer-events: none; animation: pop .8s ease forwards; text-shadow: 0 2px 12px rgba(0,0,0,.6); z-index: 5; }
.verdict.perfect { color: var(--gold); } .verdict.good { color: var(--ok); } .verdict.miss { color: var(--muted); }
.controls { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 10px; }
.controls:empty { display: none; }
.ctrl { border: 1px solid rgba(255,255,255,.22); background: rgba(255,255,255,.04); border-radius: 18px; padding: 16px 8px; font-weight: 600; font-size: 1rem; display: grid; gap: 2px; justify-items: center; transition: background .1s, transform .08s; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.ctrl small { font-family: var(--font-mono); font-size: .625rem; letter-spacing: .08em; color: var(--muted); font-weight: 400; }
.ctrl:active, .ctrl.press { background: color-mix(in srgb, var(--rose) 22%, transparent); transform: scale(.97); }
.hint { text-align: center; color: var(--muted); font-size: .8125rem; margin: 0; }

.overlay { position: fixed; inset: 0; z-index: 10; overflow-y: auto; background: rgba(12,9,16,.96); display: grid; place-items: center; padding: max(24px, env(safe-area-inset-top, 0px)) 18px 30px; animation: fadeIn .4s ease; }
.card { max-width: 30rem; width: 100%; display: grid; gap: 14px; justify-items: center; text-align: center; }
.card .k { font-family: var(--font-mono); font-size: .75rem; letter-spacing: .22em; text-transform: uppercase; color: var(--gold); margin: 0; animation: rise .6s ease both; }
.card h1, .card h2 { font-family: var(--font-display); font-weight: 500; font-size: clamp(2.2rem, 8vw, 3.4rem); line-height: 1.05; margin: 0; text-wrap: balance; animation: rise .7s ease .1s both; }
.card h1 em, .card h2 em { color: var(--rose); }
.card p { color: var(--muted); margin: 0; max-width: 28em; animation: rise .7s ease .2s both; }
.card .btn { animation: rise .7s ease .35s both; }
.how { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 10px; width: 100%; animation: rise .7s ease .25s both; }
.how div { background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 14px; padding: 10px 8px; font-size: .85rem; }
.how b { display: block; font-family: var(--font-mono); font-size: .6875rem; letter-spacing: .08em; text-transform: uppercase; color: var(--gold); font-weight: 500; }
.memory { position: relative; width: min(100%, 260px); aspect-ratio: 3 / 4.2; border-radius: 20px; overflow: hidden; box-shadow: 0 30px 70px -25px color-mix(in srgb, var(--sig) 85%, transparent), 0 0 0 1px rgba(224,168,90,.55); animation: rise .9s cubic-bezier(.2,.7,.2,1) .2s both; }
.memory img { width: 100%; height: 72%; object-fit: cover; object-position: 50% 18%; display: block; }
.memory .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 14px 14px; background: linear-gradient(180deg, transparent, rgba(20,15,27,.95) 30%); text-align: left; }
.memory .cap span { font-family: var(--font-mono); font-size: .625rem; letter-spacing: .1em; text-transform: uppercase; color: var(--gold); }
.memory .cap p { font-family: var(--font-display); font-style: italic; font-size: 1rem; line-height: 1.3; margin: 4px 0 0; color: var(--ink); animation: none; }
.scores { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; font-size: .9rem; color: var(--muted); }
.scores b { color: var(--ink); font-variant-numeric: tabular-nums; }
.actions { display: grid; gap: 10px; width: min(100%, 22rem); }
.links { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; }
.links a, .links button { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; font-size: .9rem; }
.toast { min-height: 1.2em; color: var(--gold); font-size: .875rem; margin: 0; }

@media (max-width: 860px) {
  .game { grid-template-columns: minmax(0, 1fr); align-items: start; align-content: start; gap: 14px; }
  .game { gap: 10px; }
  .arena { gap: 10px; }
  .coach { width: 100%; display: grid; grid-template-columns: 68px minmax(0, 1fr); gap: 10px; align-items: center; }
  .portrait { width: 68px; border-radius: 16px; }
  .bubble { position: static; backdrop-filter: none; -webkit-backdrop-filter: none; background: rgba(20,15,27,.6); font-size: .9rem; padding: 7px 11px; }
  .hud { gap: 8px; }
  .stat { padding: 6px 10px; border-radius: 12px; }
  .stat b { font-size: 1.25rem; }
  .stage { min-height: 0; }
  .hint { display: none; }
  .ctrl { padding: 16px 6px; }
}
@media (prefers-reduced-motion: reduce) { .portrait video { display: none; } .verdict { animation: none; transform: translate(-50%, -50%); } }

/* Mode app : l'app fournit sa propre barre et sa navigation */
.in-app .top { display: none; }
.in-app .actions a, .in-app .links a { display: none; }
.in-app .page { padding-top: 6px; }

/* Chinois simplifié (html lang="zh-Hans") : polices CJK, pas d'italique, espacement des petites capitales resserré */
html[lang="zh-Hans"] {
  --font-display: "Bodoni Moda", "Didot", Georgia, "Songti SC", "Noto Serif SC", "STSong", serif;
  --font-mono: "IBM Plex Mono", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", ui-monospace, Menlo, monospace;
}
html[lang="zh-Hans"] body { font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", "Hanken Grotesk", "Helvetica Neue", Arial, sans-serif; line-height: 1.6; }
html[lang="zh-Hans"] .card h1, html[lang="zh-Hans"] .card h2, html[lang="zh-Hans"] .card em, html[lang="zh-Hans"] .verdict,
html[lang="zh-Hans"] .memory .cap p, html[lang="zh-Hans"] .stat b, html[lang="zh-Hans"] .controls .ctrl { font-style: normal; }
html[lang="zh-Hans"] .card h1, html[lang="zh-Hans"] .card h2 { line-height: 1.2; letter-spacing: .02em; }
html[lang="zh-Hans"] .card .k { letter-spacing: .08em; }
html[lang="zh-Hans"] .mono, html[lang="zh-Hans"] .bubble b, html[lang="zh-Hans"] .stat small, html[lang="zh-Hans"] .how b,
html[lang="zh-Hans"] .ctrl small, html[lang="zh-Hans"] .memory .cap span, html[lang="zh-Hans"] .lbl, html[lang="zh-Hans"] .flag,
html[lang="zh-Hans"] .meter-top, html[lang="zh-Hans"] .t-top, html[lang="zh-Hans"] .d-top, html[lang="zh-Hans"] .o-top,
html[lang="zh-Hans"] .w-top, html[lang="zh-Hans"] .dossier small, html[lang="zh-Hans"] .alt { letter-spacing: .04em; }
