:root{
    color-scheme:dark;
    font-family:system-ui,sans-serif;
    background:#0b0b13;
    color:#eee9de;
    --gold:#e3b966
}
*{
    box-sizing:border-box
}
body{
    margin:0;
    min-height:100dvh;
    display:grid;
    place-items:center;
    overscroll-behavior:none
}
#shell{
    width:min(100vw,480px,calc((100dvh - 122px)*.6364));
    min-width:0;
    padding:8px 8px max(8px,env(safe-area-inset-bottom));
    display:flex;
    flex-direction:column;
    gap:8px
}
header,footer,#hud{
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:12px
}
h1{
    font:600 clamp(15px,4vw,24px) Georgia,serif;
    letter-spacing:.1em;
    margin:2px 0;
    color:var(--gold)
}
small,footer,.hint{
    font-size:10px;
    color:#a9a5b8;
    letter-spacing:.05em
}
button{
    font:inherit;
    color:#f7e6bf;
    background:#242133;
    border:1px solid #79694b;
    border-radius:7px;
    cursor:pointer;
    min-height:40px;
    padding:8px 13px
}
button:disabled{
    opacity:.35
}
button:focus-visible{
    outline:2px solid #f4cb76
}
.meters{
    flex:1;
    display:grid;
    gap:5px
}
.meter span{
    font-size:10px;
    display:flex;
    justify-content:space-between;
    letter-spacing:.04em
}
.meter i{
    display:block;
    background:#35303e;
    border-radius:4px;
    height:6px;
    overflow:hidden
}
.meter em{
    display:block;
    width:100%;
    height:100%;
    background:#c95565
}
.light em{
    background:#e2b962
}
.clock{
    text-align:right;
    min-width:83px
}
.clock strong{
    display:block;
    font-size:22px;
    font-variant-numeric:tabular-nums
}
.clock small{
    display:block
}
#arena{
    position:relative;
    width:100%;
    aspect-ratio:420/660;
    border:1px solid #453e54;
    border-radius:10px;
    overflow:hidden;
    touch-action:none;
    user-select:none;
    background:#161421
}
#render{
    position:absolute;
    inset:0;
    overflow:hidden
}

#render canvas{
    display:block;
    touch-action:none
}
#formLabel{
    position:absolute;
    top:10px;
    left:0;
    right:0;
    text-align:center;
    font-size:11px;
    letter-spacing:.19em;
    color:#f3ce7f;
    pointer-events:none;
    text-shadow:0 2px 5px #000
}
#formLabel.abyss{
    color:#d7a4ff
}
#notice{
    position:absolute;
    top:38px;
    left:10px;
    right:10px;
    text-align:center;
    font-size:13px;
    color:#f4e4be;
    pointer-events:none
}
#stick{
    position:absolute;
    display:none;
    width:82px;
    height:82px;
    border:1px solid #ffffff60;
    background:#ffffff0d;
    border-radius:50%;
    transform:translate(-50%,-50%);
    pointer-events:none
}
#knob{
    position:absolute;
    left:50%;
    top:50%;
    width:31px;
    height:31px;
    background:#f4e3c36b;
    border:1px solid #fff7;
    border-radius:50%;
    transform:translate(-50%,-50%)
}
#overlay{
    position:absolute;
    inset:0;
    background:#100e19c9;
    display:grid;
    place-items:center;
    padding:20px;
    text-align:center
}
#overlay[hidden]{
    display:none
}
.panel{
    width:100%;
    max-width:320px;
    border:1px solid #756044;
    border-radius:10px;
    padding:22px 15px;
    background:#191724e8
}
.panel h2{
    font:normal clamp(20px,6vw,30px) Georgia,serif;
    color:#f3d18a;
    margin:10px 0
}
.panel p{
    font-size:13px;
    line-height:1.55;
    color:#d6d0df
}
.panel button{
    width:100%;
    background:#d6ac61;
    color:#19141c;
    font-weight:700
}
.panel .hint{
    font-size:10px;
    color:#b2aaba
}
footer{
    font-size:10px
}
footer b{
    color:#93cef0
}
#engine{
    color:#a9a5b8;
    text-align:right
}
@media(max-width:600px) and (orientation:portrait){
    #shell{
    width:min(100vw,calc((100dvh - 120px)*.6364 + 16px));
    padding-top:max(6px,env(safe-area-inset-top))
}

}
@media(orientation:landscape) and (max-height:520px){
    #shell{
    width:min(100vw,calc((100dvh - 94px)*.6364 + 16px));
    gap:3px;
    padding:3px
}
h1{
    font-size:13px
}
header button{
    min-height:25px;
    padding:2px 8px
}
.clock strong{
    font-size:16px
}
.panel{
    padding:6px
}
.panel h2{
    font-size:17px;
    margin:3px
}
.panel p{
    font-size:10px;
    margin:4px
}
.panel button{
    min-height:28px;
    padding:2px
}
.panel .hint{
    font-size:8px
}

}


/* Scelta di livello: pannello indipendente, scorrevole su schermi piccoli. */
#levelOverlay {
    position: absolute;
    inset: 0;
    z-index: 5;
    background: #100e19ed;
    padding: 12px;
    overflow-y: auto;
    touch-action: pan-y;
    overscroll-behavior: contain;
}
#levelOverlay[hidden] {
    display: none;
}
.level-panel {
    max-width: 400px;
    margin: auto;
}
.level-panel h2 {
    font: 26px Georgia, serif;
    color: #f3d18a;
    margin: 6px 0;
}
.level-panel p {
    font-size: 12px;
    color: #c9c3d1;
    margin: 6px 0 10px;
}
#upgradeChoices {
    display: grid;
    gap: 8px;
}
.upgrade-card {
    display: grid;
    gap: 4px;
    text-align: left;
    width: 100%;
    min-height: 78px;
    padding: 10px;
    border-left: 4px solid var(--family);
    background: #252031;
    color: #f5eddf;
}
.upgrade-card.divine { --family: #e3b966; }
.upgrade-card.abyss { --family: #c292ed; }
.upgrade-card.eclipse { --family: #82c5bc; }
.upgrade-card small { color: var(--family); font-size: 11px; }
.upgrade-card strong { font-size: 16px; }
.upgrade-card span { font-size: 12px; line-height: 1.35; }
.upgrade-card.rare { border-top-color: #76acd9; }
.upgrade-card.epic { border-top-color: #c493f2; }
.upgrade-card .synergy-hint { color: #b9d8cf; font-size: 10px; }
.xp-meter { flex: 1; min-width: 0; }
.xp-track { height: 5px; border-radius: 3px; background: #35303e; margin: 3px 0; overflow: hidden; }
#xpBar { width: 0; height: 100%; background: #83c9f1; }
#engine { font-size: 9px; }
/* L'arena mantiene touch-action:none per il joystick. Durante la scelta
   il pan verticale deve essere consentito anche dal suo antenato. */
#arena:has(#levelOverlay:not([hidden])) { touch-action: pan-y; }
@media (max-height: 520px) {
    #levelOverlay { padding: 6px; }
    .level-panel h2 { font-size: 18px; }
    .upgrade-card { min-height: 60px; padding: 6px; }
    .upgrade-card strong { font-size: 13px; }
    .upgrade-card span { font-size: 10px; }
}

/* L’overlay è opaco e nasconde anche le etichette sottostanti. */
#levelOverlay {
    background: #100e19;
    z-index: 10;
}
#arena:has(#levelOverlay:not([hidden])) #formLabel,
#arena:has(#levelOverlay:not([hidden])) #notice,
#arena:has(#levelOverlay:not([hidden])) #bossHud {
    visibility: hidden;
}
#bossHud {
    position: absolute;
    bottom: 12px;
    left: 12px;
    right: 12px;
    text-align: center;
    font-size: 11px;
    color: #ffd1a1;
    pointer-events: none;
}
.boss-track {
    height: 7px;
    background: #35303e;
    border-radius: 4px;
    overflow: hidden;
}
#bossBar {
    height: 100%;
    background: #ff6475;
}
/* Hub e checkpoint: solo stile, la disposizione non influenza la simulazione. */
#overlay {
    z-index: 6;
    background: #100e19;
    overflow-y: auto;
    touch-action: pan-y;
    align-items: safe center;
    padding: 12px;
}
#arena:has(#overlay:not([hidden])) {
    touch-action: pan-y;
}
#menuActions {
    display: grid;
    gap: 6px;
    margin-top: 8px;
}
#menuActions button {
    font-size: 12px;
    background: #242133;
    color: #eee9de;
    font-weight: normal;
}
#backupText {
    width: 100%;
    min-height: 100px;
    margin-top: 8px;
    background: #242133;
    color: #eee9de;
    font-size: 12px;
    user-select: text;
    touch-action: pan-y;
}
#primary[hidden], #backupText[hidden] {
    display: none;
}

/* Fase 7: l'HUD è fuori dal mondo; il pannello di gioco occupa lo spazio restante.
   Le schermate non combattive scorrono in verticale senza ridurre i caratteri. */
body { min-height: 100vh; min-height: 100dvh; }
#shell {
    width: min(100%, 480px);
    height: 100vh;
    height: 100dvh;
    padding: max(6px, env(safe-area-inset-top)) 8px max(6px, env(safe-area-inset-bottom));
    gap: 5px;
    overflow: hidden;
}
header, #hud, footer, #combatInfo { flex: 0 0 auto; }
header { gap: 8px; }
header small, small, footer, .hint { font-size: 12px; letter-spacing: normal; }
h1 { font-size: 19px; }
button, header button, .panel button, .upgrade-card { min-height: 44px; min-width: 44px; }
button { font-size: 15px; }
.meter span, .clock small { font-size: 12px; }
.clock { min-width: 100px; max-width: 45%; }
.clock strong { font-size: 20px; }
#arena { flex: 1 1 0; min-height: 0; aspect-ratio: auto; }
#render { display: grid; place-items: center; }
#combatInfo { display: grid; grid-template-columns: 1fr; gap: 3px; font-size: 13px; }
#roomIndicator { font-weight: 700; }
#formLabel, #notice, #bossHud {
    position: static; font-size: 13px; text-align: left; letter-spacing: normal; text-shadow: none;
}
#notice { color: #f4d99e; }
#notice:empty { display: none; }
#bossHud { color: #ffb6c0; }
#shell:not([data-mode="playing"]) #formLabel,
#shell:not([data-mode="playing"]) #notice,
#shell:not([data-mode="playing"]) #bossHud { visibility: hidden; display: none; }
#shell:not([data-mode="playing"]) #combatInfo { display: none; }
#shell:not([data-mode="playing"]) #hud { display: none; }
#overlay, #levelOverlay { padding: 12px; overflow-y: auto; background: #100e19; }
#overlay { display: block; }
#overlay[hidden] { display: none; }
.panel, .level-panel { max-width: 420px; margin: 0 auto; padding: 14px; text-align: left; }
.panel h2, .level-panel h2 { font-size: 24px; margin: 6px 0; }
.panel p, .level-panel p, .panel .hint { font-size: 14px; line-height: 1.45; }
#menuActions { gap: 8px; }
#menuActions button { font-size: 14px; padding: 10px; text-align: left; }
#menuActions .choice-button { min-height: 76px; font-weight: 700; border-color: var(--gold); }
.choice-button span, .detail-row span { display: block; font-size: 14px; font-weight: normal; line-height: 1.4; margin-top: 4px; color: #d6d0df; }
.detail-row { padding: 10px; margin-top: 8px; border: 1px solid #51435e; border-radius: 7px; font-size: 15px; }
.detail-row[data-status="current"] { border-color: var(--gold); }
.detail-row[data-status="done"] { border-color: #82c5bc; }
#overlay[data-presentation="ascension"] .panel { border-color: var(--gold); text-align: center; }
#overlay[data-presentation="ascension"] .panel h2 { font-size: 30px; }
.upgrade-card small, .upgrade-card span, .upgrade-card .synergy-hint { font-size: 13px; }
.upgrade-card strong { font-size: 16px; }
#engine { font-size: 11px; }
@media (max-width: 380px) { h1 { font-size: 17px; } .panel, .level-panel { padding: 10px; } }
/* Altezza stabile delle righe di stato durante il combattimento. */
#render { display: block; }
#shell[data-mode="playing"] #roomIndicator { min-height: 32px; }
#shell[data-mode="playing"] #notice { display: block; min-height: 18px; }
#shell[data-mode="playing"] #bossHud[hidden] { display: block; visibility: hidden; }
#shell[data-mode="playing"] #bossHud { min-height: 25px; }
#shell[data-mode="playing"] #bossName { display: block; min-height: 17px; }
/* Suggerimento fuori dall'arena: non intercetta mai il joystick. */
#tutorial {
    display:flex;
    align-items:center;
    flex:0 0 auto;
    gap:8px;
    padding:6px 8px;
    border:1px solid #79694b;
    border-radius:7px;
    background:#242133;
}
#tutorial[hidden], #shell:not([data-mode="playing"]) #tutorial {display:none;}
#tutorialText {flex:1; margin:0; font-size:14px; line-height:1.35;}
#tutorialClose {min-width:44px; min-height:44px; padding:0; font-size:22px;}

/* In orizzontale manteniamo l'arena verticale e spostiamo l'HUD di lato.
   La pausa e le scelte continuano a utilizzare il pannello scorrevole. */
@media (orientation: landscape) and (max-height: 520px) and (min-width: 560px) {
    #shell { width: min(100%, 900px); }
    #shell[data-mode="playing"] {
        display: grid;
        grid-template-columns: minmax(0, 250px) minmax(0, 1fr);
        grid-template-rows: auto auto auto auto minmax(0, 1fr);
        column-gap: 10px;
    }
    #shell[data-mode="playing"] > header { grid-column: 1; grid-row: 1; }
    #shell[data-mode="playing"] > #hud { grid-column: 1; grid-row: 2; }
    #shell[data-mode="playing"] > #combatInfo { grid-column: 1; grid-row: 3; }
    #shell[data-mode="playing"] > #tutorial { grid-column: 1; grid-row: 4; }
    #shell[data-mode="playing"] > footer { grid-column: 1; grid-row: 5; align-self: end; }
    #shell[data-mode="playing"] > #arena { grid-column: 2; grid-row: 1 / -1; height: 100%; }
    #shell[data-mode="playing"] #roomIndicator { min-height: 0; }
    #shell[data-mode="playing"] #tutorialText { font-size: 12px; }
}

/* Celebrazione breve, provvisoria e senza alterare il layout. */
#overlay[data-presentation="ascension"] .panel {
    animation: ascension-glow 3.5s ease-out both;
}
@keyframes ascension-glow {
    0% { box-shadow: 0 0 0 0 #e6bf7200; }
    35% { box-shadow: 0 0 24px 3px #e6bf7270; }
    100% { box-shadow: 0 0 0 0 #e6bf7200; }
}
@media (prefers-reduced-motion: reduce) {
    #overlay[data-presentation="ascension"] .panel { animation: none; }
}

/* Sprite diagnostico o approvato nel riepilogo: nessun cambio di layout in combattimento. */
.sprite-death-preview { display: block; margin: 0 auto; width: 96px; height: 96px; image-rendering: pixelated; }

/* Telefono reale: nessuno scroll della pagina, menu con scroll interno e area sicura. */
html, body { width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none; }
body { min-height: 0; height: var(--usable-height, 100dvh); }
#shell {
    height: var(--usable-height, 100dvh);
    padding-top: max(6px, env(safe-area-inset-top, 0px));
    padding-bottom: max(6px, env(safe-area-inset-bottom, 0px));
    padding-left: max(8px, env(safe-area-inset-left, 0px));
    padding-right: max(8px, env(safe-area-inset-right, 0px));
}
button { touch-action: manipulation; }
#shell[data-mode="playing"] { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#overlay, #levelOverlay { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
#orientationHint { display: none; margin: 2px 0; font-size: 12px; color: #f4d99e; }
@media (orientation: landscape) and (max-height: 520px) and (pointer: coarse) {
    #orientationHint { display: block; }
}
#storageNotice, #pwaStatus { display: none; }
#shell[data-mode="hub"] #storageNotice,
#shell[data-mode="hub"] #pwaStatus:not([hidden]) { display: block; font-size: 13px; color: #d6d0df; }

/* Testi lunghi e accessibilità: la geometria dell'arena non è modificata. */
#shell, #shell > *, .panel, .level-panel, .meters, .meter, #menuActions, #menuDetails { min-width: 0; }
button, .panel, .level-panel, #combatInfo, #tutorialText, #storageNotice, #pwaStatus { overflow-wrap: anywhere; }
button { white-space: normal; max-width: 100%; }
:root[data-large-text="true"] button, :root[data-large-text="true"] #menuActions button,
:root[data-large-text="true"] .panel p, :root[data-large-text="true"] .level-panel p,
:root[data-large-text="true"] .detail-row, :root[data-large-text="true"] .detail-row span,
:root[data-large-text="true"] .choice-button span, :root[data-large-text="true"] #tutorialText { font-size: 18px; }
:root[data-large-text="true"] small, :root[data-large-text="true"] footer,
:root[data-large-text="true"] .meter span, :root[data-large-text="true"] .clock small,
:root[data-large-text="true"] #combatInfo, :root[data-large-text="true"] #formLabel,
:root[data-large-text="true"] #notice, :root[data-large-text="true"] #bossHud,
:root[data-large-text="true"] .upgrade-card span, :root[data-large-text="true"] .upgrade-card small,
:root[data-large-text="true"] .upgrade-card .synergy-hint, :root[data-large-text="true"] #storageNotice,
:root[data-large-text="true"] #pwaStatus, :root[data-large-text="true"] #engine { font-size: 15px; }
:root[data-large-text="true"] .panel h2, :root[data-large-text="true"] .level-panel h2 { font-size: 28px; }
:root[data-large-text="true"] .upgrade-card strong { font-size: 19px; }
:root[data-high-contrast="true"] { color: #fff; --gold: #fff4a0; background: #000; }
:root[data-high-contrast="true"] #overlay, :root[data-high-contrast="true"] #levelOverlay,
:root[data-high-contrast="true"] .panel, :root[data-high-contrast="true"] .level-panel,
:root[data-high-contrast="true"] #tutorial { background: #000; color: #fff; border-color: #fff; }
:root[data-high-contrast="true"] button { background: #101010; color: #fff; border: 2px solid #fff; }
:root[data-high-contrast="true"] button:disabled { opacity: 1; color: #bbb; border-style: dashed; }
:root[data-high-contrast="true"] small, :root[data-high-contrast="true"] .hint,
:root[data-high-contrast="true"] .detail-row span, :root[data-high-contrast="true"] .choice-button span,
:root[data-high-contrast="true"] .upgrade-card span, :root[data-high-contrast="true"] #formLabel,
:root[data-high-contrast="true"] #notice, :root[data-high-contrast="true"] #bossHud { color: #fff; }
:root[data-high-contrast="true"] .meter i, :root[data-high-contrast="true"] .boss-track,
:root[data-high-contrast="true"] .xp-track { background: #222; outline: 1px solid #fff; }
:root[data-high-contrast="true"] .detail-row { border-color: #fff; }
:root[data-high-contrast="true"] .detail-row[data-status="current"] { border: 2px solid #fff; }
:root[data-high-contrast="true"] button:focus-visible { outline: 3px solid #fff4a0; outline-offset: 2px; }

:root[data-high-contrast="true"] #render canvas { filter: contrast(1.18) brightness(1.13); }
:root[data-high-contrast="true"] #orientationHint, :root[data-high-contrast="true"] #pwaStatus,
:root[data-high-contrast="true"] #storageNotice { color: #fff; }
:root[data-large-text="true"] #orientationHint { font-size: 15px; }

/* Prima impressione: segnaposto tipografico, nessuna nuova arte definitiva. */
#shell[data-mode="title"] header h1 { display: none; }
#shell[data-mode="title"] footer,
#shell[data-mode="prologue"] footer,
#shell[data-mode="help"] footer,
#shell[data-mode="credits"] footer { display: none; }
#shell[data-mode="title"] .hint,
#shell[data-mode="prologue"] .hint,
#shell[data-mode="help"] .hint,
#shell[data-mode="credits"] .hint { display: none; }
#overlay[data-presentation="title"] .panel,
#overlay[data-presentation="prologue"] .panel { text-align: center; padding: 22px 16px; }
#overlay[data-presentation="title"] h2 { font-family: Georgia, serif; font-size: 32px; letter-spacing: .08em; line-height: 1.12; margin: 16px 0; }
.keyart-frame { display: none; }
#overlay[data-presentation="title"] #titleArt,
#overlay[data-presentation="hub"] #hubArt { display: block; }
.keyart {
    display: block;
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    height: auto;
    aspect-ratio: 240 / 150;
    image-rendering: pixelated;
    border-radius: 10px;
    border: 1px solid #756044;
}
#hubArt .keyart { aspect-ratio: 240 / 120; }
.keyart[hidden] { display: none; }
.keyart:not([hidden]) + .keyart-fallback { display: none; }
.keyart-fallback {
    display: block;
    width: 60px;
    height: 60px;
    margin: 8px auto 14px;
    border: 2px solid var(--gold);
    border-radius: 50%;
    box-shadow: inset 0 0 0 9px #171522, inset 0 0 0 11px var(--gold);
}
#overlay[data-presentation="prologue"] #message { font-family: Georgia, serif; font-size: 19px; line-height: 1.6; margin: 18px 0; }
#overlay[data-presentation="title"] #menuDetails,
#overlay[data-presentation="prologue"] #menuDetails { text-align: left; }
:root[data-large-text="true"] #overlay[data-presentation="title"] h2 { font-size: 36px; }
:root[data-large-text="true"] #overlay[data-presentation="prologue"] #message { font-size: 23px; }
:root[data-high-contrast="true"] .keyart-fallback { box-shadow: inset 0 0 0 9px #000, inset 0 0 0 11px #fff; border-color: #fff; }

/* Nota del titolo e pausa visibile soltanto in arena. */
.title-audio-note { font-size: .85em; opacity: .8; text-align: center; margin: .6rem 0; }
#pause[hidden], #overline:empty { display: none !important; }

:root[data-high-contrast="true"] .keyart { border-color: #fff; }

/* Cinque slot leggibili anche senza distinguere il colore. */
#giftSlots { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:2px; text-align:center; }
#giftSlots[hidden] { display:none; }
.gift-slot { display:flex; flex-direction:column; align-items:center; min-width:0; }
.gift-slot small { font-size:9px; overflow-wrap:anywhere; letter-spacing:0; }
.gift-icon { display:inline-flex; flex-shrink:0; align-items:center; justify-content:center; min-width:26px; height:26px; border:2px solid var(--aspect); border-radius:50%; color:var(--aspect); font-size:11px; font-weight:bold; background:#15121d; }
.upgrade-card.gift .gift-icon { align-self:flex-start; }
:root[data-large-text="true"] .gift-slot small { font-size:11px; }
:root[data-high-contrast="true"] .gift-icon { border-color:#fff;color:#fff; }
footer { flex-wrap:wrap; gap:4px 8px; }
#giftSlots { flex:0 0 100%; }

/* Icone 0.9.1: dimensioni fisse, niente stretching delle carte. */
.gift-icon { position:relative; display:inline-flex; box-sizing:border-box; flex:0 0 var(--icon-size,32px); width:var(--icon-size,32px); height:var(--icon-size,32px); min-width:0; max-width:var(--icon-size,32px); aspect-ratio:1; border:0; border-radius:50%; background:transparent; align-self:center; }
.gift-icon img { display:block; width:100%; height:100%; image-rendering:pixelated; }
.gift-icon [hidden] { display:none!important; }
.gift-icon-fallback { display:grid; place-items:center; width:100%; height:100%; border:2px solid var(--aspect); border-radius:50%; box-sizing:border-box; background:#15121d; }
.gift-rank { position:absolute; bottom:-2px; right:-2px; background:#15121d; color:#fff; border:1px solid var(--aspect); border-radius:50%; min-width:13px; height:13px; font-size:10px; line-height:12px; text-align:center; }
.gift-empty { opacity:.55; }
.gift-card-icons { display:flex; align-items:center; gap:5px; align-self:flex-start; width:max-content; max-width:100%; }
.gift-badge { color:var(--gold); overflow-wrap:anywhere; font-weight:600; }
:root[data-high-contrast="true"] .gift-icon-fallback { color:#fff; border-color:#fff; }
.detail-row .gift-card-icons { display:flex; align-items:center; gap:5px; margin:0 0 4px; }
.detail-row .gift-icon { display:inline-flex; margin:0; }
.detail-row .gift-icon-fallback { display:grid; margin:0; font-size:11px; font-weight:bold; color:var(--aspect); }
:root[data-high-contrast="true"] .detail-row .gift-icon-fallback { color:#fff; }

/* Alba provvisoria: tinta decorativa senza alterare il PNG originale. */
#titleArt.risen:not(.dawn-ready) .keyart { filter: sepia(.35) saturate(1.25) brightness(1.28); }
#titleArt.risen:not(.dawn-ready) .keyart-fallback { background: radial-gradient(circle,#f0bf6d,#6b3546); }

#overlay[data-presentation="prologue"] #message { white-space: pre-line; }

/* Velo d’alba soltanto sulla keyart originale dopo una vittoria. */
#titleArt { position: relative; }
#titleArt.risen:not(.dawn-ready):has(.keyart:not([hidden]))::after {
    content: ""; position: absolute; inset: 0; max-width: 480px; margin: 0 auto;
    background: linear-gradient(180deg,rgba(255,185,105,.16),rgba(241,109,73,.08));
    border-radius: 10px; pointer-events: none;
}

/* Rami scartati: il testo resta leggibile anche in alto contrasto. */
.detail-row[data-status="discarded"] {opacity:.8;text-decoration:line-through;}

/* 0.13.1 — tutta la superficie è arena; HUD e menu sono strati indipendenti. */
#shell, #shell[data-mode="playing"] {
    position:relative; display:block; width:100vw; width:100dvw;
    height:var(--usable-height,100dvh); max-width:none; padding:0; gap:0;
    overflow:hidden; isolation:isolate;
}
#shell > header, #shell > footer, #shell > #hud, #shell > #combatInfo { display:none; }
#shell > #arena, #shell[data-mode="playing"] > #arena {
    position:absolute; inset:0; width:100%; height:100%; border:0; border-radius:0; overflow:hidden;
}
#render { position:absolute; inset:0; display:block; }
#render canvas { display:block; }
#shell[data-mode="playing"] { touch-action:none; overscroll-behavior:none; }
#shell[data-mode="playing"] > #hud {
    display:flex; position:absolute; z-index:3; top:env(safe-area-inset-top,0px);
    left:max(6px,env(safe-area-inset-left,0px)); right:max(6px,env(safe-area-inset-right,0px));
    height:50px; padding:3px 5px; gap:7px; border-radius:8px;
    background:rgba(12,10,19,.78); pointer-events:none;
}
#hud .meters { display:grid; grid-template-columns:1fr 1fr; gap:6px; min-width:0; flex:1; }
#hud .meter { min-width:0; }
#hud .meter span { font-size:10px; letter-spacing:0; justify-content:center; white-space:nowrap; }
#hud .meter .meter-name { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); }
#hud .meter i { height:7px; }
#hud .clock { min-width:0; max-width:39%; flex:0 1 120px; text-align:right; }
#hud .clock strong { font-size:15px; line-height:17px; }
#hud .clock small { font-size:10px; line-height:12px; overflow-wrap:anywhere; }
#pause { pointer-events:auto; padding:0; flex:0 0 44px; width:44px; height:44px; min-height:44px; min-width:44px; }
#shell[data-mode="playing"] > #combatInfo {
    display:block; position:absolute; z-index:3; top:calc(env(safe-area-inset-top,0px) + 52px);
    left:max(10px,env(safe-area-inset-left,0px)); right:max(10px,env(safe-area-inset-right,0px));
    pointer-events:none; text-align:center;
}
#roomBanner { position:absolute; top:30px; left:50%; transform:translateX(-50%); width:max-content; max-width:94%; padding:8px 12px; border-radius:8px; background:#100e19dd; }
#roomBanner[hidden] { display:none; }
#shell[data-mode="playing"] #roomIndicator, #shell[data-mode="playing"] #formLabel { min-height:0; font-size:12px; text-align:center; }
#shell[data-mode="playing"] #notice { position:absolute; top:86px; left:0; right:0; min-height:0; text-align:center; font-size:11px; text-shadow:0 1px 4px #000,0 1px 4px #000; }
#shell[data-mode="playing"] #notice:empty { display:none; }
#shell[data-mode="playing"] #bossHud { max-width:300px; margin:auto; min-height:0; text-align:center; font-size:10px; }
#shell[data-mode="playing"] #bossHud[hidden] { display:none; }
#shell[data-mode="playing"] #bossName { min-height:0; }
#bossHud .boss-track { height:5px; }
#shell[data-mode="playing"] > #tutorial:not([hidden]) {
    position:absolute; z-index:4; bottom:calc(env(safe-area-inset-bottom,0px) + 74px); top:auto;
    left:50%; right:auto; transform:translateX(-50%); width:min(90%,340px); padding:7px 10px;
    background:#100e19df; pointer-events:none; border-radius:8px;
}
#tutorial #tutorialText { font-size:12px; margin:0; }
#tutorial #tutorialClose { pointer-events:auto; }
#shell[data-mode="playing"] > footer {
    display:flex; position:absolute; z-index:3; bottom:env(safe-area-inset-bottom,0px);
    left:max(6px,env(safe-area-inset-left,0px)); right:max(6px,env(safe-area-inset-right,0px));
    flex-direction:column; align-items:stretch; gap:1px; padding:3px 4px 2px;
    background:rgba(12,10,19,.76); border-radius:8px 8px 0 0; pointer-events:none;
}
#shell[data-mode="playing"] #giftSlots { display:flex; flex:0 0 auto; justify-content:center; gap:9px; }
#shell[data-mode="playing"] .gift-slot small, #shell[data-mode="playing"] .xp-meter small, #shell[data-mode="playing"] #engine { display:none; }
#shell[data-mode="playing"] .gift-slot { position:relative; height:32px; }
#shell[data-mode="playing"] .gift-slot .gift-icon { --icon-size:32px; }
#shell[data-mode="playing"] .gift-slot.inactive { opacity:.5; }
#shell[data-mode="playing"] .gift-slot .cooldown { position:absolute; bottom:0; left:0; right:0; height:3px; background:#201a2b; border-radius:2px; overflow:hidden; }
#shell[data-mode="playing"] .gift-slot .cooldown::after { content:""; display:block; height:100%; width:var(--ready,100%); background:#f5d07c; }
#shell[data-mode="playing"] .xp-meter { position:relative; flex:none; text-align:center; font-size:10px; line-height:12px; }
#shell[data-mode="playing"] .xp-track { height:4px; margin:1px 0 0; }
#xpDetail { display:none; }
#overlay, #levelOverlay { padding:max(12px,env(safe-area-inset-top,0px)) max(12px,env(safe-area-inset-right,0px)) max(12px,env(safe-area-inset-bottom,0px)) max(12px,env(safe-area-inset-left,0px)); overscroll-behavior:contain; }
#overlay .panel, #levelOverlay .level-panel { width:100%; max-width:480px; margin:auto; }
#overlay .panel button { min-height:44px; }
#shell[data-mode="checkpoint"] #overlay, #shell[data-mode="map"] #overlay, #shell[data-mode="paused"] #overlay, #levelOverlay { background:rgba(10,8,16,.78); }
#levelOverlay .level-panel { background:#191724f0; border:1px solid #756044; border-radius:10px; }
#stick { z-index:2; }
:root[data-high-contrast="true"] #hud, :root[data-high-contrast="true"] #shell[data-mode="playing"] footer { background:#000; }
@media (max-height:500px) { #shell[data-mode="playing"] > #hud { height:44px; padding-block:0; } #shell[data-mode="playing"] > #combatInfo { top:calc(env(safe-area-inset-top,0px) + 46px); } }

#shell[data-mode="playing"] .gift-empty { opacity:1; }
#hud .hp b::before { content:"♥ "; color:#ff9aa7; }
#hud .light b::before { content:"☀ "; color:#ffe2a4; }
#shell[data-mode="playing"] .gift-slot .cooldown[hidden] { display:none; }
/* Grande testo: conserva un HUD compatto senza ingrandire le etichette ornamentali. */
:root[data-large-text="true"] #hud .meter span, :root[data-large-text="true"] #hud .clock small { font-size:12px; }

/* Avvisi sotto la barra principale, senza occupare permanentemente una fascia. */
#shell[data-mode="playing"] #notice { position:relative; top:auto; left:auto; right:auto; margin:2px auto 0; max-width:min(100%,480px); line-height:13px; }
#roomBanner { top:48px; }

/* 0.13.2: il buffer fisico non determina mai l'ingombro CSS del canvas. */
#render canvas { width:100% !important; height:100% !important; image-rendering:pixelated; }
/* Solo schermi larghi: scala leggibile proporzionale all'altezza, fino a 1,6×. */
@media (min-width:900px) and (orientation:landscape) and (min-height:560px) {
    #shell[data-mode="playing"] { --hud-unit:clamp(1px, .18vh, 1.6px); }
    #shell[data-mode="playing"] > #hud { height:calc(50 * var(--hud-unit)); gap:calc(7 * var(--hud-unit)); }
    #shell[data-mode="playing"] > #combatInfo { top:calc(env(safe-area-inset-top,0px) + 52 * var(--hud-unit)); }
    #hud .meter span, #hud .clock small { font-size:calc(10 * var(--hud-unit)); line-height:calc(12 * var(--hud-unit)); }
    #hud .meter i { height:calc(7 * var(--hud-unit)); }
    #hud .clock { flex-basis:calc(120 * var(--hud-unit)); }
    #hud .clock strong { font-size:calc(15 * var(--hud-unit)); line-height:calc(17 * var(--hud-unit)); }
    #pause { flex-basis:calc(44 * var(--hud-unit)); width:calc(44 * var(--hud-unit)); height:calc(44 * var(--hud-unit)); font-size:calc(15 * var(--hud-unit)); }
    #shell[data-mode="playing"] > footer { padding:1px 4px; gap:0; }
    #shell[data-mode="playing"] #giftSlots { gap:calc(9 * var(--hud-unit)); }
    #shell[data-mode="playing"] .gift-slot { height:calc(32 * var(--hud-unit)); }
    #shell[data-mode="playing"] .gift-slot .gift-icon { --icon-size:calc(32 * var(--hud-unit)); }
    #shell[data-mode="playing"] .xp-meter { font-size:calc(10 * var(--hud-unit)); line-height:calc(11 * var(--hud-unit)); }
    #shell[data-mode="playing"] .xp-track { margin:0; }
}
