:root{color-scheme:dark;--ink:#f8f2df;--muted:#c8c4da;--green:#b8f453;--gold:#ffcf72;--line:#6c5a96;--panel:#211c36;--shadow:#090714;font:16px/1.5 system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}*{box-sizing:border-box}body{margin:0;color:var(--ink);background:#100f21 url(../images/bg-castle-wide.png) center/cover fixed no-repeat;min-height:100vh}body:before{content:"";position:fixed;inset:0;background:linear-gradient(135deg,#0d1020eb,#151126da 55%,#14182be8);z-index:-1}button,input{font:inherit}button{cursor:pointer;color:inherit}button:disabled{cursor:not-allowed;opacity:.45}button:focus-visible,a:focus-visible,input:focus-visible{outline:3px solid #eaff91;outline-offset:3px}img{max-width:100%;object-fit:contain;vertical-align:middle}button img{pointer-events:none}.skip{position:absolute;left:-10000px}.skip:focus{left:8px;top:8px;z-index:99;background:#111;color:white;padding:10px}.top{max-width:1320px;margin:auto;display:flex;align-items:center;padding:12px 26px;gap:20px;border-bottom:1px solid #6c5a9655}.brand{width:210px;background:none;border:0;padding:0;flex:none}.top-title{font-weight:900;font-size:1rem;letter-spacing:.12em;line-height:1.15;color:var(--gold)}.top-title small{color:var(--muted);font-size:.68rem}.wallet{margin-left:auto;display:flex;gap:12px}.wallet span{display:flex;align-items:center;gap:6px;border:1px solid var(--line);background:#211b30;border-radius:14px;padding:5px 10px}.wallet img{width:29px;height:29px}.shell{max-width:1320px;margin:auto;display:grid;grid-template-columns:205px minmax(0,1fr);gap:22px;padding:22px 26px}.nav{display:flex;flex-direction:column;gap:10px;align-self:start;position:sticky;top:12px}.nav button,.image-button{border:0;background:transparent;padding:0;transition:transform .18s,filter .18s}.nav button:hover,.image-button:hover{transform:translateY(-2px);filter:brightness(1.15)}.nav button[aria-current=page]{filter:drop-shadow(0 0 7px #b4ff45)}main{min-width:0}.page[hidden]{display:none!important}.page{min-width:0}.hero{position:relative;overflow:hidden;min-height:590px;padding:45px 36px 25px;border:1px solid var(--line);border-radius:24px;background:linear-gradient(90deg,#101322f2,#18122d7d 60%,#19152b17),url(../images/bg-castle-wide.png) 60% center/cover}.hero-copy{position:relative;z-index:1;max-width:55%;min-height:410px}.eyebrow{color:var(--gold);font-weight:800;letter-spacing:.12em;text-transform:uppercase;font-size:.75rem;margin:0 0 8px}h1,h2,p{margin:0 0 12px}h1{font-size:clamp(1.7rem,4vw,3.2rem);line-height:1.03;letter-spacing:-.035em}h1 em{color:var(--green);font-style:normal;text-shadow:0 3px #172d05}h2{font-size:1.15rem}.hero h1{font-size:clamp(2.25rem,5.5vw,4.6rem);margin:20px 0}.hero-copy p:not(.eyebrow){max-width:380px}.hero-monster{position:absolute;width:56%;height:78%;right:-2%;top:2%;filter:drop-shadow(0 14px 14px #0009)}.image-button{width:230px;margin:16px 0}.muted,small{color:var(--muted)}.feature-row{position:relative;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}.feature-row article{display:flex;align-items:center;gap:10px;padding:12px;background:#211c36e8;border:1px solid var(--line);border-radius:13px}.feature-row img{width:50px;height:50px}.feature-row small{display:block;font-size:.78rem}.section-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:12px;gap:10px}.plain,.tools button{background:linear-gradient(#4b3e6b,#29213d);border:1px solid #8772a4;border-radius:10px;padding:9px 14px;font-weight:750;box-shadow:0 3px #100d1a}.plain:hover,.tools button:hover{filter:brightness(1.2)}.green,.charge-btn:not(:disabled){background:linear-gradient(#537c27,#29451c);border-color:#a8d964}.game-layout{display:grid;grid-template-columns:minmax(155px,220px) minmax(0,620px);gap:18px;align-items:start}.game-side{display:grid;gap:10px}.guide{width:100%;height:105px;object-fit:contain;object-position:bottom}.panel{background:#211c36ed;border:1px solid var(--line);border-radius:13px;padding:13px}.objective{display:flex;align-items:center;gap:7px;margin:5px 0}.objective img{width:32px;height:32px}.objective b{margin-left:auto}.objective.done{color:var(--green)}.stats{display:flex;justify-content:space-around;text-align:center}.stats strong{display:block;color:var(--gold);font-size:1.65rem}.meter-label{display:flex;justify-content:space-between;gap:4px;font-size:.78rem}progress{width:100%;height:15px;accent-color:#b7f549;margin:8px 0}.charge-btn{width:100%;font-size:.85rem;padding:8px 4px}.board-area{min-width:0}.board{display:grid;grid-template-columns:repeat(8,minmax(0,1fr));gap:4px;aspect-ratio:1;background:linear-gradient(#100d23df,#1d1635e6),url(../images/bg-lab-wide.png) center/cover;border:4px solid #82719a;box-shadow:0 0 0 2px #211a30,0 15px 35px #0008;border-radius:16px;padding:7px;touch-action:none;user-select:none}.tile{position:relative;padding:0;min-width:0;min-height:0;aspect-ratio:1;border:1px solid #52446c;border-radius:9px;background:#32254b;overflow:hidden;transition:transform .14s,filter .14s}.tile img{width:100%;height:100%;object-fit:contain;display:block}.tile.selected{outline:3px solid #d3ff67;outline-offset:-3px;transform:scale(.93);z-index:1}.tile.hinted{outline:3px dashed #ffcf72;outline-offset:-3px;animation:hint .6s infinite alternate}.tile.blocked:after{content:"";position:absolute;inset:0;border:3px dashed #f5bd76;border-radius:8px;pointer-events:none}.tile .special{position:absolute;right:0;bottom:0;width:48%;height:48%;filter:drop-shadow(0 0 3px white)}.tile .letter{position:absolute;left:2px;top:0;font-size:clamp(.55rem,1.7vw,.85rem);font-weight:900;color:white;background:#151025bb;border-radius:4px;padding:0 3px;display:none}.symbols .tile .letter{display:block}.tile.pop{animation:pop .22s both}.tile.fall{animation:fall .23s both}@keyframes pop{to{transform:scale(.35);opacity:.15;filter:brightness(2)}}@keyframes fall{from{transform:translateY(-15px);opacity:.35}to{transform:none;opacity:1}}@keyframes hint{to{filter:brightness(1.5)}}#message{min-height:2.2em;text-align:center;margin:12px 0 6px;color:var(--gold);font-weight:650}.tools{display:flex;justify-content:center;gap:8px;flex-wrap:wrap}.tools button{display:flex;align-items:center;gap:5px;font-size:.87rem;padding:7px 10px}.tools img{width:28px;height:28px}.inner{padding:28px;border:1px solid var(--line);border-radius:20px;background:#181529ed;min-height:460px}.cards{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:14px;margin:20px 0}.cards article{background:#2a2242;border:1px solid var(--line);padding:15px;border-radius:14px}.cards article>img{height:160px;width:100%;object-fit:contain}.cards article.locked>img{filter:grayscale(1);opacity:.45}.artifact-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(75px,1fr));gap:12px}.artifact-grid figure{margin:0;text-align:center;font-size:.8rem}.artifact-grid img{width:70px;height:70px}.chapter-grid{display:grid;grid-template-columns:repeat(5,1fr);gap:9px;margin:10px 0 28px}.level-button{background:#33284d;border:1px solid #89749d;border-radius:12px;padding:11px 3px;min-height:72px;font-weight:900;font-size:1.1rem}.level-button img,#result-stars img{width:20px;height:20px}.level-button span{display:block}.help-layout{display:grid;grid-template-columns:1fr 2fr;gap:18px}.settings{display:grid;gap:18px;max-width:560px}.settings input{accent-color:var(--green);width:20px;height:20px;vertical-align:middle;margin-right:10px}footer{max-width:1320px;margin:auto;padding:20px 26px;border-top:1px solid #6c5a9655;color:var(--muted);font-size:.82rem;display:flex;justify-content:space-between;gap:10px}dialog{color:var(--ink);background:#211c36;border:2px solid var(--line);border-radius:20px;padding:24px;max-width:min(420px,94vw);text-align:center}dialog::backdrop{background:#080610d9}dialog>img{width:120px;height:100px}.dialog-actions{display:flex;flex-wrap:wrap;justify-content:center;gap:8px;margin-top:16px}.high-contrast{--line:#c2b0f0;--muted:#fff;--green:#d1ff70}.no-motion *, .no-motion *:before,.no-motion *:after{animation:none!important;transition:none!important}@media(prefers-reduced-motion:reduce){*,*:before,*:after{animation:none!important;transition:none!important}}@media(max-width:1000px){.shell{grid-template-columns:155px minmax(0,1fr);gap:14px;padding:15px}.game-layout{grid-template-columns:150px minmax(0,1fr);gap:10px}.hero{padding:30px 24px}.feature-row article{flex-direction:column;text-align:center}.guide{height:80px}}@media(max-width:760px){.top{padding:8px 12px;gap:8px}.brand{width:135px}.top-title{display:none}.wallet{gap:5px}.wallet span{padding:4px 7px;font-size:.85rem}.wallet img{width:22px;height:22px}.shell{display:flex;flex-direction:column;padding:10px;gap:12px}.nav{position:static;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:4px}.nav button img{width:100%;max-height:44px}.hero{min-height:0;padding:25px 16px 16px}.hero-copy{max-width:62%;min-height:310px}.hero-monster{width:60%;height:65%;right:-9%;top:4%}.hero h1{font-size:clamp(1.9rem,7vw,3.7rem)}.image-button{max-width:150px}.feature-row{gap:5px}.feature-row article{padding:8px 4px;font-size:.8rem}.feature-row img{width:36px;height:36px}.feature-row small{font-size:.7rem}.game-layout{display:flex;flex-direction:column;gap:8px}.game-side{display:grid;grid-template-columns:1.2fr 1fr 1.1fr;width:100%;gap:5px}.guide{display:none}.game-side .panel{padding:7px;font-size:.75rem}.game-side h2{font-size:.9rem;margin-bottom:4px}.game-side .muted{display:none}.objective img{width:20px;height:20px}.objective{gap:3px;margin:1px 0}.stats{flex-direction:column;gap:2px}.stats strong{font-size:1.15rem}.meter-label{flex-wrap:wrap;font-size:.72rem}.charge-btn{font-size:.68rem}.board-area{width:100%;max-width:600px;align-self:center}.board{gap:2px;padding:4px;border-width:3px;border-radius:10px}.tile{border-radius:5px}.tile.blocked:after{border-width:2px}.inner{padding:16px}.help-layout{grid-template-columns:1fr}.help-layout>img{height:180px;margin:auto}footer{padding:15px 12px;flex-wrap:wrap}.chapter-grid{gap:5px}.level-button img{width:13px;height:13px}}@media(max-width:370px){.hero-copy{max-width:70%}.hero-monster{opacity:.75}.tools{gap:4px}.tools button{padding:6px;font-size:.75rem}.tools img{width:20px;height:20px}.game-side .panel{padding:5px}.objective img{width:16px;height:16px}} 

/* V2 : illustrations de la carte du château uniquement. */
#levels .chapter-grid{grid-template-columns:repeat(5,minmax(0,1fr));align-items:stretch}
#levels .level-button{overflow:hidden;min-width:0;padding:0 0 8px;position:relative;text-align:center;display:flex;flex-direction:column;align-items:center;gap:3px}
#levels .level-button .level-art{display:block;width:100%;height:auto;aspect-ratio:8/5;object-fit:cover;border-radius:10px 10px 0 0;border-bottom:1px solid var(--line);margin-bottom:3px}
#levels .level-button .level-number{line-height:1.2;font-size:1.2rem;color:var(--gold)}
#levels .level-button:disabled{opacity:1;background:#252038;border-color:#635575}
#levels .level-button:disabled .level-art{filter:brightness(.76) saturate(.82)}
#levels .level-button:disabled .level-number{color:var(--muted)}
#levels .level-lock{font-size:.68rem;font-weight:650;line-height:1.2;color:var(--muted)}
#levels .level-button:not(:disabled):hover{border-color:var(--green);box-shadow:0 0 12px #b8f45345}
@media(max-width:1000px){#levels .chapter-grid{grid-template-columns:repeat(3,minmax(0,1fr));gap:9px}}
@media(max-width:480px){#levels .chapter-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}#levels .level-button img:not(.level-art){width:17px;height:17px}}

/* Réserve la place des illustrations tout en conservant leurs proportions. */
img{height:auto}
a{color:var(--green)}
.guide-page{max-width:850px;margin:22px auto;padding:clamp(18px,4vw,36px)}
.guide-page h2{margin-top:24px;color:var(--gold)}
.guide-page li{margin-bottom:6px}
.tile:focus-visible{outline-offset:-3px;z-index:2}
@media(max-width:875px){.guide-page{margin-inline:12px}}
@media(max-width:760px){body{background-attachment:scroll}.nav button img{object-fit:contain}}
#levels .level-button .level-art[hidden]{display:none}

.home-info{min-height:0;margin-top:16px}
.home-info h2{color:var(--gold);font-size:clamp(1.3rem,3vw,1.75rem)}
.home-info p{max-width:68ch}
.home-info p:last-child{margin-bottom:0}

/* Voltine */
.voltine-home { display: block; margin-top: 10px; }
.voltine-launcher {
  position: fixed;
  z-index: 20;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 15px 3px 4px;
  border: 1px solid var(--green);
  border-radius: 999px;
  background: #211c36;
  color: var(--ink);
  font: inherit;
  font-weight: 750;
  box-shadow: 0 5px 24px #090714b3;
  cursor: pointer;
}
.voltine-launcher img, .voltine-head img { object-fit: contain; }
.voltine-panel {
  position: fixed;
  z-index: 21;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  width: min(410px, calc(100% - 24px));
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
  display: flex;
  flex-direction: column;
  overflow: auto;
  border: 1px solid #8575ac;
  border-radius: 18px;
  background: #151125;
  color: var(--ink);
  box-shadow: 0 10px 42px #090714e8;
}
.voltine-panel[hidden], .voltine-launcher[hidden] { display: none; }
.voltine-head {
  display: flex;
  flex: none;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-bottom: 1px solid #6c5a96;
}
.voltine-head h2 { color: var(--green); font-size: 1.2rem; line-height: 1.2; margin: 0; }
.voltine-head p { color: var(--muted); font-size: .85rem; margin: 2px 0 0; }
.voltine-head button { margin-left: auto; }
.voltine-history {
  min-height: 55px;
  height: min(280px, 38vh);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 10px;
}
.voltine-message {
  padding: 8px 10px;
  margin: 0 10px 8px 0;
  border-radius: 12px;
  background: #28203e;
  overflow-wrap: anywhere;
}
.voltine-player { margin-inline: 18px 0; background: #30391f; }
.voltine-message strong { color: var(--green); font-size: .81rem; }
.voltine-message p { white-space: pre-line; margin: 2px 0; }
.voltine-message button { margin-top: 7px; }
.voltine-shortcuts, .voltine-form {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px;
  border-top: 1px solid #6c5a96;
}
.voltine-shortcuts button, .voltine-form button, .voltine-head button, .voltine-message button {
  min-height: 44px;
  font-size: .85rem;
  padding: 6px 10px;
}
.voltine-label { width: 100%; color: var(--muted); font-size: .85rem; }
.voltine-form input {
  flex: 1;
  min-width: 100px;
  min-height: 44px;
  border: 1px solid #8575ac;
  border-radius: 8px;
  background: #221b35;
  color: var(--ink);
  padding: 6px 8px;
  font: inherit;
}
.voltine-form input::placeholder { color: var(--muted); }
.voltine-panel :focus-visible, .voltine-launcher:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
body.high-contrast .voltine-panel, body.high-contrast .voltine-message { background: #08070b; }
@media (max-width: 380px) {
  .voltine-head > img { width: 44px; height: 44px; }
  .voltine-head { gap: 6px; }
}

/* Mise en page et commandes V10 */
[hidden] { display: none !important; }
#result {
  width: min(420px, calc(100% - 24px));
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
  overflow: auto;
}
.result-fallback { overflow: hidden; }
.result-fallback::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 29;
  background: #080610d9;
}
.result-fallback #result[open] {
  position: fixed;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  z-index: 30;
  margin: 0;
}
.board { grid-template-rows: repeat(8, minmax(0, 1fr)); }
.tile:focus-visible {
  outline: 0;
  box-shadow: inset 0 0 0 2px #171223, inset 0 0 0 5px #f4ffd3;
}
#game .tools button, .dialog-actions button { min-height: 44px; }
.voltine-panel {
  width: min(410px, calc(100% - 24px));
  width: min(410px, calc(100% - 24px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}
.voltine-head > div { min-width: 0; }
.voltine-form { padding-bottom: 12px; }
.game-site footer { padding-bottom: 70px; }
@media (max-width: 450px) {
  .game-side { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
  .game-side > .panel:last-child { grid-column: span 2; }
  .game-side .charge-btn { min-height: 40px; }
  .game-side .objective { min-width: 0; }
}
@media (max-height: 520px) {
  .voltine-history { height: min(140px, 29vh); }
  .voltine-head { padding-block: 6px; }
  .voltine-head > img { width: 36px; height: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
#result:not([open]) { display: none; }

/* Place le panneau dans la partie de la page visible après zoom ou ouverture du clavier. */
.voltine-panel {
  right: calc(var(--voltine-viewport-right, 0px) + max(12px, env(safe-area-inset-right)));
  width: min(410px, calc(var(--voltine-viewport-width, 100%) - max(12px, env(safe-area-inset-left)) - max(12px, env(safe-area-inset-right))));
  bottom: calc(var(--voltine-viewport-bottom, 0px) + max(12px, env(safe-area-inset-bottom)));
  max-height: calc(var(--voltine-viewport-height, 100dvh) - max(12px, env(safe-area-inset-top)) - max(12px, env(safe-area-inset-bottom)));
}
@media (max-width: 480px) {
  #game .board { scroll-margin-block: 14px 8px; }
}
@media (forced-colors: active) {
  .tile:focus-visible { outline: 3px solid Highlight; outline-offset: -3px; }
  .tile.hinted { outline: 3px dashed Highlight; outline-offset: -3px; }
}

.backup-panel { margin-top: 16px; }
.backup-panel h2 { margin-top: 0; color: var(--gold); }
.backup-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.backup-actions button { min-height: 44px; }
.backup-file { display: grid; gap: 6px; margin: 14px 0; }
.backup-file input { max-width: 100%; padding-block: 6px; }
#backup-preview { border-top: 1px solid var(--line); padding-top: 8px; }
#backup-status:empty { display: none; }

/* Autorise le zoom à deux doigts tout en conservant les échanges par glissement. */
.board { touch-action: pinch-zoom; }
.backup-file { grid-template-columns: minmax(0, 1fr); }
.backup-file input { min-width: 0; width: 100%; }
@media (max-width: 480px) {
  .game-site { padding-inline: env(safe-area-inset-left, 0px) env(safe-area-inset-right, 0px); }
  .voltine-form input { min-width: min(100px, 100%); }
}

@media (max-width: 380px) {
  #game .section-head { flex-wrap: wrap; align-items: flex-start; }
  #game .section-head > div { min-width: 0; }
  #game .section-head > button { max-width: 100%; min-height: 44px; }
  .voltine-head > img { flex: none; }
  .voltine-head p { overflow-wrap: anywhere; }
}

/* Secours pour les visuels indisponibles. */
.tile.tile-art-missing .letter {
  display: grid;
  inset: 1px;
  place-items: center;
  padding: 0;
  font-size: clamp(.78rem, 3vw, 1.5rem);
}
button.art-button-missing {
  min-height: 44px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
}
.art-button-label { overflow-wrap: anywhere; }

.release-update {
  width: min(1268px, calc(100% - 20px));
  margin: 12px auto 0;
  padding: 8px 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}
.release-update p { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.release-update button { min-height: 44px; }

/* Les commandes restent accessibles sur petits écrans et au zoom. */
.moosters-game { scroll-padding-bottom: 68px; }
#game .tools button { min-inline-size: 44px; max-inline-size: 100%; }
#game .stats strong, .wallet b { overflow-wrap: anywhere; }
@media (max-width: 380px) {
  .top .brand { width: min(135px, 40%); }
  .top .wallet { min-width: 0; }
  .top .wallet span { min-width: 0; }
  .top .wallet img { flex: none; }
}
@supports not (aspect-ratio: 1 / 1) {
  .board { grid-template-rows: repeat(8, auto); }
  .tile { padding-top: 100%; }
  .tile > img:first-child { position: absolute; inset: 0; }
}

@media (orientation: landscape) and (max-height: 460px) and (max-width: 950px) {
  #board {
    max-width: clamp(224px, calc(100vh - 32px), 600px);
    max-width: clamp(224px, calc(100dvh - 32px), 600px);
    margin-inline: auto;
  }
}

#game .objective { overflow-wrap: anywhere; }
#game .charge-btn { max-width: 100%; }
#game .charge-btn[aria-pressed="true"], #game #hammer[aria-pressed="true"] {
  border-color: var(--green);
}
