:root {
    font-family: "Segoe UI", Arial, sans-serif;
    color: #f6efda;
    background: #122e32;
    font-synthesis: none;
    --gold: #eac889;
    --cyan: #83e5dd;
    --glass: rgba(12, 32, 35, .83);
}
* { box-sizing: border-box; }
body { margin: 0; overflow: hidden; }
button { font: inherit; cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
button:focus-visible { outline: 3px solid var(--cyan); outline-offset: 5px; }
[hidden] { display: none !important; }
#app, #game-container { position: fixed; inset: 0; }
#game-container > canvas { width: 100%; height: 100%; display: block; outline: none; touch-action: none; }
#vignette { position: fixed; inset: 0; pointer-events: none; box-shadow: inset 0 0 130px #10232970; }
.eyebrow { font-size: 10px; letter-spacing: .22em; font-weight: 600; color: var(--gold); }
#hud { position: absolute; inset: 24px 30px auto; display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; pointer-events: none; }
.status-panel, .quest-panel { padding: 16px 20px; border-top: 1px solid #eac88980; background: linear-gradient(120deg, var(--glass), #10252a60); backdrop-filter: blur(10px); min-width: 200px; }
#health { display: flex; gap: 8px; margin: 12px 0 16px; }
.heart { width: 13px; height: 13px; background: #ff967f; transform: rotate(45deg); border: 1px solid #ffc3a2; }
.heart.empty { background: #284447; border-color: #537173; }
.dash-status { display: flex; align-items: center; gap: 10px; font-size: 9px; letter-spacing: .16em; color: #b0c8c4; }
.meter { width: 120px; height: 3px; background: #4d686b; overflow: hidden; }
#dash-fill { height: 100%; background: var(--cyan); transform-origin: left; }
#charge-fill { height: 100%; width: 100%; background: var(--gold); transform-origin: left; transform: scaleX(0); transition: transform .3s; }
.genie-status { margin-top: 8px; }
#quiz-panel .quiz-dialog { max-width: 620px; max-height: 92vh; overflow: auto; touch-action: pan-x pan-y; overscroll-behavior: contain; }
#quiz-panel h2 { font-size: clamp(22px, 3.5vw, 34px); margin: 10px 0; }
.quiz-question { font-size: 16px; color: #fff2d0; }
.choice.correct { border-color: #6fd49a; background: #6fd49a2e; }
.choice.wrong { border-color: #ff967f; background: #ff967f26; }
#quiz-feedback { font-weight: 700; color: var(--gold); margin: 10px 0 0; min-height: 1em; }
#quiz-panel .choice-list { margin-top: 14px; }
#genie-button, .lang-toggle { background: none; border: none; color: var(--gold); font-size: 12px; padding: 0 6px; }
#touch-controls #touch-genie, #touch-controls .lang-toggle { border: 1px solid #eac88970; background: #102c32d9; font-size: 20px; color: var(--gold); }
.dialog .lang-toggle { margin-top: 12px; }
.quiz-actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px 16px; position: sticky; bottom: 0; z-index: 3; margin-top: 10px; padding: 8px 0 max(8px, env(safe-area-inset-bottom)); background: linear-gradient(to top, #0a1f29f2 80%, #0a1f2900); }
.quiz-actions button { margin: 0; }
#quiz-panel .quiz-actions .lang-toggle { margin-top: 0; font-size: 18px; border: 1px solid #eac88970; border-radius: 8px; padding: 3px 10px; }
@media (max-height: 500px) {
    #quiz-panel.centered { padding: 8px; }
    #quiz-panel .quiz-dialog { padding-top: 10px; padding-bottom: 0; max-height: 84vh; }
    #quiz-panel h2 { font-size: 20px; margin: 4px 0; }
    #quiz-panel .quiz-question { font-size: 14px; margin: 4px 0; }
    #quiz-panel .choice-list { margin-top: 8px; }
}
.region { padding-top: 10px; text-align: center; text-shadow: 0 2px 10px #102329; }
.region > span { display: block; }
.region > span:last-child { font-family: Georgia, serif; font-size: 23px; margin-top: 9px; }
.quest-panel { min-width: 238px; }
.quest-panel > * { display: block; }
.quest-panel strong { font: 30px Georgia, serif; margin: 5px 0; }
.quest-panel strong span { display: inline; }
.muted { color: #b3c1b6; font-size: 21px; }
.crystal-icon { color: var(--cyan); float: right; font-size: 26px; }
#word-slots { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 8px 0 4px; }
#word-slots .word { display: inline-flex; gap: 3px; }
#word-slots .slot { display: inline-block; width: 18px; height: 26px; border-bottom: 2px solid #eac889; text-align: center; font: 700 20px/26px Georgia, serif; color: #ffe9a8; }
#word-slots .slot.found { border-bottom-color: var(--cyan); }
#word-slots .joined { display: inline-block; min-height: 26px; border-bottom: 2px solid var(--cyan); font: 700 22px/26px Georgia, "Segoe UI", serif; color: #ffe9a8; letter-spacing: 0; padding: 0 2px; }
#quest-detail { font-size: 11px; color: #c3d3ce; }
#map-panel { position: absolute; bottom: 92px; right: 30px; padding: 9px; background: var(--glass); border: 1px solid #b39c6240; backdrop-filter: blur(8px); pointer-events: none; }
#minimap { display: block; width: auto; height: auto; max-width: 100%; }
#map-panel .eyebrow { display: block; font-size: 8px; text-align: center; margin: 6px 0 2px; }
.map-legend { display: block; text-align: center; font-size: 9px; color: #c7e2db; margin-top: 7px; }
#controls { position: absolute; bottom: 23px; left: 30px; right: 30px; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 12px 22px; padding: 13px 18px; background: var(--glass); border-bottom: 1px solid #eac88960; font-size: 11px; color: #d2ded6; backdrop-filter: blur(10px); }
kbd { display: inline-block; border: 1px solid #98b3aa55; border-radius: 3px; padding: 3px 5px; margin-right: 4px; font: 10px "Segoe UI", sans-serif; color: #fff8e5; background: #ffffff0a; }
#pause-button { background: none; border: none; color: var(--gold); font-size: 11px; padding: 0; }
#message { position: absolute; top: 155px; left: 50%; transform: translateX(-50%); margin: 0; max-width: 85vw; text-align: center; padding: 13px 24px; border: 1px solid #eac88960; background: var(--glass); color: #fff4d3; font-size: 14px; pointer-events: none; transition: opacity .3s; opacity: 0; }
#message.visible { opacity: 1; }
.overlay { position: absolute; inset: 0; z-index: 5; background: linear-gradient(90deg, #081d22f5 0%, #081d22cf 28%, #10232920 65%, transparent); }
.menu-content { position: absolute; left: 7vw; top: 50%; transform: translateY(-51%); }
.edition { font-size: 10px; letter-spacing: .2em; display: flex; align-items: center; gap: 12px; color: #d8ddc9; margin-bottom: 44px; }
.sun-mark { font-size: 31px; color: var(--gold); }
.subtitle { font-size: clamp(14px, 1.5vw, 19px); letter-spacing: .02em; line-height: 1.35; max-width: 30em; margin: 14px 0 12px; color: var(--gold); text-transform: none; }
h1 { font: 400 clamp(40px, 4.6vw, 66px)/1 Georgia, serif; letter-spacing: -.03em; margin: 0; }
[dir="rtl"] h1, [dir="rtl"] .subtitle { letter-spacing: 0; }
h1 em { font-style: normal; color: var(--gold); }
.title-dot { color: var(--cyan); }
.gold-rule { width: 62px; height: 1px; background: var(--gold); margin: 29px 0 21px; }
.intro { font-size: 14px; line-height: 1.8; color: #b6cbc4; margin-bottom: 27px; }
.primary-button { display: block; padding: 17px 29px; border: 1px solid var(--gold); color: #142e32; background: var(--gold); font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; transition: background .2s, transform .2s; }
.primary-button:hover:not(:disabled) { background: #ffe1a9; transform: translateY(-2px); }
.menu-content .primary-button { width: min(340px, 100%); text-align: center; }
#resume-run-button { margin-bottom: 18px; }
#resume-run-button:not([hidden]) + #start-button { background: transparent; color: var(--gold); }
#resume-run-button:not([hidden]) + #start-button:hover:not(:disabled) { background: #eac8892e; }
.menu-note { color: #8daaa4; font-size: 10px; letter-spacing: .12em; margin-top: 18px; }
.menu-location { position: absolute; bottom: 27px; left: 7vw; right: 4vw; display: flex; justify-content: space-between; gap: 12px; font-size: 9px; letter-spacing: .14em; color: #c2c8b8; }
.centered { display: grid; place-items: center; background: #091e28c9; backdrop-filter: blur(12px); padding: 24px; }
.dialog { max-width: 590px; text-align: center; }
h2 { font: 400 clamp(32px, 5vw, 54px)/1.1 Georgia, serif; color: #fff2d0; margin: 20px 0; }
.dialog p { font-size: 14px; line-height: 1.9; color: #c2d7d2; }
.dialog .primary-button { margin: 26px auto 0; }
.text-button { background: none; border: none; color: #b3cfc8; margin-top: 21px; font-size: 12px; text-decoration: underline; text-underline-offset: 4px; display: block; margin-left: auto; margin-right: auto; }
.setup-panel { position: absolute; right: 2.2vw; top: 4.5vh; transform: none; width: min(380px, 34vw); max-height: 91vh; overflow-y: auto; padding: 18px 20px; background: var(--glass); border-top: 1px solid #eac88980; backdrop-filter: blur(10px); }
.setup-panel .eyebrow { display: block; margin: 14px 0 7px; }
.setup-panel .eyebrow:first-child { margin-top: 0; }
.stage-picker { display: grid; gap: 6px; }
.stage-select { width: 100%; padding: 9px 11px; border: 1px solid var(--gold); background: #10231f; color: #eaf1ea; font: inherit; font-size: 13px; }
.stage-select option { background: #10231f; color: #eaf1ea; }
.stage-hint { font-size: 10px; color: #a9c0ba; line-height: 1.35; }
.choice-list { display: grid; gap: 6px; }
.choice-list.inline { grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); }
.choice { text-align: left; padding: 8px 11px; border: 1px solid #98b3aa55; background: #ffffff0a; color: #eaf1ea; font-size: 12px; line-height: 1.35; }
.choice small { display: block; font-size: 10px; color: #a9c0ba; }
.choice:hover { border-color: var(--gold); }
.choice[aria-checked="true"] { border-color: var(--gold); background: #eac8892e; }
.choice .badge { float: right; color: var(--cyan); font-size: 10px; }
.setup-panel .menu-note { margin: 12px 0 0; }
#error-panel { z-index: 10; }
#error-detail { overflow-wrap: anywhere; }
.no-script { position: fixed; inset: 30%; z-index: 20; padding: 30px; background: #122e32; }
.seo-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#touch-controls { position: absolute; bottom: 25px; left: 20px; right: 20px; justify-content: space-between; align-items: end; pointer-events: none; display: none; }
#touch-controls button { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; pointer-events: auto; border: 1px solid #eac88970; border-radius: 8px; background: #102c32d9; color: #fff2d0; min-width: 46px; min-height: 46px; }
.touch-joystick { position: relative; width: 124px; height: 124px; border-radius: 50%; border: 2px solid #eac88980; background: radial-gradient(circle, #1b4a50cc 0%, #102c32d9 70%); pointer-events: auto; touch-action: none; user-select: none; -webkit-touch-callout: none; flex: none; }
.touch-joystick::before { content: ""; position: absolute; inset: 22px; border-radius: 50%; border: 1px dashed #eac88940; }
#joystick-knob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; transform: translate(-50%, -50%); border-radius: 50%; background: radial-gradient(circle at 35% 30%, #f8d69b, #b8893f); box-shadow: 0 3px 8px #0008; pointer-events: none; }
.touch-camera { position: absolute; left: 0; bottom: 138px; display: grid; grid-template-columns: repeat(2, 40px); gap: 4px; }
.touch-camera button { min-width: 40px; min-height: 40px; font-size: 1.1em; opacity: 0.85; padding: 0; }
.orbit-pad { display: inline-flex; gap: 4px; }
.orbit-pad button { min-width: 30px; padding: 4px 8px; }
.touch-actions { display: grid; grid-template-columns: repeat(2, 60px); grid-template-rows: repeat(2, 60px); gap: 4px; flex: none; }
.touch-actions button { min-width: 0; min-height: 0; padding: 0; font-size: 13px; font-weight: 700; border-radius: 50%; border: 2px solid #ffffff55; color: #fff; text-shadow: 0 1px 2px #000a; background: radial-gradient(circle at 35% 28%, #ffffff66 0%, transparent 38%), radial-gradient(circle at 50% 60%, var(--pad, #2a7a86), color-mix(in srgb, var(--pad, #2a7a86) 55%, #000)); box-shadow: 0 5px 0 color-mix(in srgb, var(--pad, #2a7a86) 40%, #000), 0 8px 10px #0009, inset 0 -3px 5px #0006; transition: transform .05s, box-shadow .05s; }
.touch-actions button:active { transform: translateY(4px); box-shadow: 0 1px 0 color-mix(in srgb, var(--pad, #2a7a86) 40%, #000), 0 2px 4px #0009, inset 0 -2px 4px #0006; }
.touch-actions button[data-key="Space"] { --pad: #3c9a4e; }
.touch-actions button[data-key="KeyJ"] { --pad: #c0463c; }
.touch-actions button[data-key="KeyK"] { --pad: #d39a2c; }
.touch-actions button[data-key="KeyE"] { --pad: #3d6fc0; font-size: 20px; }
.touch-system { position: absolute; right: 0; bottom: 138px; display: flex; gap: 6px; }
.touch-system button { min-width: 40px; min-height: 40px; padding: 0; font-size: 18px; color: var(--gold); }
@media (max-height: 640px) {
    #menu { overflow-y: auto; -webkit-overflow-scrolling: touch; }
    .menu-content { position: relative; top: auto; transform: none; padding-top: 16px; padding-bottom: 40px; }
    .setup-panel { top: 12px; }
    .edition { margin-bottom: 15px; }
    h1 { font-size: 52px; }
    .gold-rule { margin: 16px 0; }
    .intro { margin: 12px 0 18px; font-size: 12px; }
    .menu-note { margin-top: 10px; }
}
@media (max-width: 820px) {
    #menu { overflow-y: auto; }
    .menu-content { position: static; transform: none; padding: 22px 6vw 0; }
    .edition { margin-bottom: 18px; }
    h1 { font-size: clamp(34px, 9vw, 52px); }
    .setup-panel { position: static; transform: none; width: auto; max-height: none; margin: 18px 4vw 56px; }
    .menu-location { display: none; }
    #hud { inset: 14px 14px auto; }
    .region { display: none; }
    .status-panel, .quest-panel { min-width: 0; padding: 12px; }
    .eyebrow { font-size: 8px; }
    #health { gap: 7px; }
    .heart { width: 11px; height: 11px; }
    .quest-panel { width: 160px; }
    .meter { width: 80px; }
    #map-panel { right: 14px; bottom: 120px; }
    #controls { bottom: 14px; left: 14px; right: 14px; gap: 8px; font-size: 10px; }
    .menu-location span:last-child { display: none; }
    #message { top: 142px; font-size: 12px; }
}
@media (pointer: coarse) {
    #touch-controls { display: flex; }
    #controls { display: none; }
    #map-panel { bottom: 142px; }
}
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}

/* Smartphones : pas de sélection de texte, zones sûres (encoche), HUD compact. */
html, body { height: 100%; overscroll-behavior: none; -webkit-text-size-adjust: 100%; }
#app { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
#app button { touch-action: manipulation; -webkit-user-select: none; user-select: none; }
.sound-toggle { background: none; border: none; color: var(--gold); font-size: 15px; padding: 0 4px; line-height: 1; }
.volume-row { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 16px; }
.volume-slider { width: 130px; accent-color: var(--gold); vertical-align: middle; }
#intro-menu .dialog .text-button { display: block; margin: 14px auto 0; }
#intro-menu .dialog .primary-button[hidden], #intro-menu .dialog .text-button[hidden] { display: none; }
.menu-note .sound-toggle { display: inline; margin: 0; font-size: 14px; text-decoration: none; }
@media (pointer: coarse) {
    #hud { top: max(14px, env(safe-area-inset-top)); left: max(14px, env(safe-area-inset-left)); right: max(14px, env(safe-area-inset-right)); }
    #touch-controls { bottom: max(18px, env(safe-area-inset-bottom)); left: max(20px, env(safe-area-inset-left)); right: max(20px, env(safe-area-inset-right)); }
    #touch-controls .sound-toggle, #touch-controls .lang-toggle { border: 1px solid #eac88970; background: #102c32d9; font-size: 18px; }
    #map-panel { top: calc(max(14px, env(safe-area-inset-top)) + 175px); left: max(14px, env(safe-area-inset-left)); right: auto; bottom: auto; padding: 5px; }
    #map-panel .eyebrow, #map-panel .map-legend { display: none; }
    #minimap { width: auto; }
    #map-panel:not(.portrait) #minimap { height: 100px; }
    #message { top: auto; bottom: calc(max(18px, env(safe-area-inset-bottom)) + 190px); max-width: 60vw; }
}
@media (pointer: coarse) and (orientation: portrait) {
    .touch-system { flex-direction: column; }
    .status-panel, .quest-panel { padding: 9px 11px; }
    #health { margin: 7px 0 9px; }
    .heart { width: 10px; height: 10px; }
    .meter { width: 70px; }
    .quest-panel { width: 150px; }
    .quest-panel strong { font-size: 24px; margin: 3px 0; }
    #word-slots .slot { width: 13px; height: 20px; font-size: 15px; line-height: 20px; }
    #quest-detail { font-size: 10px; }
    #minimap { height: 150px; }
}
@media (pointer: coarse) and (orientation: landscape) {
    .touch-camera { display: none; }
    .touch-system { right: auto; left: 50%; transform: translateX(-50%); bottom: 0; }
    #message { top: max(8px, env(safe-area-inset-top)); bottom: auto; max-width: 30vw; left: 50%; padding: 6px 12px; font-size: 11px; line-height: 1.3; z-index: 4; }
}
@media (pointer: coarse) and (max-height: 500px) {
    #hud { gap: 10px; }
    .status-panel, .quest-panel { padding: 6px 10px; min-width: 0; }
    .status-panel .eyebrow, .quest-panel .eyebrow { font-size: 8px; }
    #health { margin: 5px 0 6px; gap: 6px; }
    .heart { width: 9px; height: 9px; }
    .meter { width: 80px; }
    .dash-status { font-size: 8px; gap: 6px; }
    .genie-status { margin-top: 4px; }
    .quest-panel { width: min(260px, 36vw); }
    .quest-panel strong { font-size: 18px; margin: 1px 0; }
    .crystal-icon { font-size: 18px; }
    #word-slots { margin: 4px 0 2px; gap: 3px 10px; }
    #word-slots .slot { width: 11px; height: 17px; font-size: 13px; line-height: 17px; }
    #quest-detail { display: none; }
    .touch-joystick { width: 96px; height: 96px; }
    #joystick-knob { width: 42px; height: 42px; }
    .touch-actions { grid-template-columns: repeat(2, 62px); grid-template-rows: repeat(2, 62px); gap: 10px; margin-bottom: 6px; }
    .touch-system button { min-width: 36px; min-height: 36px; }
}
@media (max-height: 500px) and (min-width: 600px) {
    .menu-content { left: max(4vw, env(safe-area-inset-left)); }
    .edition { margin-bottom: 6px; }
    .sun-mark { font-size: 22px; }
    .subtitle { font-size: 12px; margin-bottom: 6px; max-width: 34em; }
    h1 { font-size: 38px; }
    .gold-rule { margin: 10px 0; }
    .intro { display: none; }
    .primary-button { padding: 12px 20px; font-size: 11px; }
    .menu-location { display: none; }
    .setup-panel { position: absolute; top: 12px; margin: 0 0 24px; width: min(400px, 48vw); max-height: none; overflow: visible; right: max(3vw, env(safe-area-inset-right)); padding: 12px 14px; }
    .menu-content { left: 0; padding-left: max(4vw, env(safe-area-inset-left)); width: 46vw; max-width: 46vw; box-sizing: border-box; }
    .menu-content .primary-button { width: 100%; }
    .volume-slider { width: 90px; }
    #menu { overflow-x: hidden; }
    .choice { padding: 6px 9px; font-size: 11px; }
    .choice small { font-size: 9px; }
    .setup-panel .eyebrow { margin: 9px 0 5px; }
}
