:root { --bg:#070722; --fg:#fff; --muted:#8f9bd4; --gold:#ffd447; --red:#ff5c5c; --green:#6ee7a0; --star:#fff; --panel:#111134; --accent:#6ee7a0; --dim:#555b91; }
body.era-storico { --bg:#180b2e; --muted:#b39ddb; --star:#e8d5a0; --panel:#241238; --accent:#e8d5a0; --dim:#6c5b8d; }
* { box-sizing:border-box; }
html, body { margin:0; min-height:100%; background:var(--bg); color:var(--fg); font-family:'Press Start 2P','Courier New',monospace; overflow-x:hidden; }
body { min-height:100vh; display:flex; flex-direction:column; align-items:center; gap:clamp(16px,2.5vh,26px); padding:clamp(22px,4vh,42px) 16px 20px; position:relative; }
.stars { position:fixed; inset:0; pointer-events:none; overflow:hidden; z-index:0; }
.stars i { position:absolute; display:block; background:var(--star); animation:starmove var(--dur) steps(18) infinite; animation-delay:var(--delay); }
.scan { position:fixed; inset:0; pointer-events:none; z-index:3; opacity:.72; background:repeating-linear-gradient(to bottom,rgba(0,0,0,.13) 0 2px,transparent 2px 4px); }
header, section, footer { position:relative; z-index:1; text-align:center; width:100%; max-width:1200px; }
header { min-height:46px; }
.logo { margin:0; font-weight:normal; line-height:1.25; font-size:clamp(25px,5vw,46px); text-shadow:4px 4px 0 #009246,8px 8px 0 #ce2b37; }
.tag { margin:10px 0 0; font-size:clamp(7px,.85vw,9px); color:var(--muted); line-height:1.7; }
.badge { margin:8px 0 0; color:var(--accent); font-size:clamp(7px,.8vw,9px); }
.debt { color:var(--gold); font-size:clamp(22px,4.6vw,58px); line-height:1.3; text-shadow:4px 4px 0 #7a1010; word-break:break-word; }
.scene { position:relative; height:clamp(235px,36vh,330px); max-width:none; overflow:visible; }
.trail { position:absolute; right:50%; top:50%; width:min(52vw,760px); height:96px; transform:translateY(-50%); overflow:hidden; }
.row { position:relative; left:-12px; width:calc(100% + 18px); height:32px; animation:flag-wave .5s steps(2,jump-none) infinite alternate; }
.row::after { content:''; position:absolute; inset:0; background:rgba(255,255,255,.10); opacity:0; animation:flag-shimmer 1s steps(2,jump-none) infinite; }
.row.g { background:#009246; }
.row.mid { background:#f1f2f1; animation-delay:-.25s; }
.row.r { background:#ce2b37; animation-delay:-.5s; }
.row.mid::after { animation-delay:-.33s; }
.row.r::after { animation-delay:-.66s; }
.mascotte { position:absolute; z-index:2; left:50%; top:50%; width:clamp(230px,27vw,350px); transform:translate(-50%,-50%); }
.mascotte svg { display:block; width:100%; height:auto; image-rendering:pixelated; shape-rendering:crispEdges; animation:fly .5s steps(2,jump-none) infinite alternate; }
.stats { min-height:110px; }
.stats p { margin:0 0 13px; font-size:clamp(9px,1.25vw,14px); line-height:1.65; }
.stats .gold { color:var(--gold); }
.stats .red { color:var(--red); }
.stats .eq { color:var(--green); min-height:22px; }

.ach { position:relative; z-index:1; max-width:640px; margin:0 auto; padding:13px 16px; background:var(--panel); border:4px solid var(--gold); color:var(--gold); font-size:clamp(8px,1vw,11px); line-height:1.7; text-align:center; }

.controls { display:flex; flex-direction:column; justify-content:center; align-items:center; gap:12px; }
.control { min-height:38px; padding:12px 16px; border:2px solid var(--dim); background:rgba(7,7,34,.72); color:var(--muted); font:inherit; font-size:clamp(7px,.85vw,9px); cursor:pointer; }
.control:hover,.control:focus-visible { color:var(--fg); border-color:var(--gold); outline:none; }
.toast { margin:6px auto 0; max-width:760px; color:var(--green); font-size:7px; line-height:1.6; }

.share { display:flex; flex-direction:column; align-items:center; gap:12px; }
.share-title { margin:0; font-size:clamp(8px,1vw,10px); color:var(--gold); }
.share-row { display:flex; gap:10px; }
.share-row[hidden],.share-title[hidden],.control[hidden] { display:none; }
.card-modal { position:fixed; inset:0; z-index:11; display:flex; align-items:center; justify-content:center; padding:16px; background:rgba(3,3,16,.85); }
.card-modal[hidden] { display:none; }
.card-box { display:flex; flex-direction:column; align-items:center; gap:14px; max-height:100%; overflow:auto; padding:16px; background:var(--panel); border:3px solid var(--gold); }
.card-box img { display:block; width:min(270px,60vw); height:auto; border:2px solid var(--dim); image-rendering:auto; }
.card-hint { margin:0; font-size:7px; color:var(--muted); line-height:1.7; text-align:center; max-width:280px; }
.card-close { background:none; border:0; color:var(--dim); font:inherit; font-size:7px; text-decoration:underline; text-underline-offset:4px; cursor:pointer; padding:4px; }
.card-close:hover,.card-close:focus-visible { color:var(--fg); outline:none; }
.share-btn { display:flex; flex-direction:column; align-items:center; gap:8px; width:104px; padding:12px 8px 10px; border:2px solid var(--dim); background:rgba(7,7,34,.72); color:var(--muted); font:inherit; font-size:7px; cursor:pointer; }
.share-btn svg { width:24px; height:24px; display:block; }
.share-btn:hover,.share-btn:focus-visible { color:var(--fg); border-color:var(--gold); outline:none; }
.share-btn:active { transform:translateY(2px); }

.audio-fab { position:fixed; top:14px; right:14px; z-index:8; width:40px; height:40px; border:2px solid var(--dim); background:rgba(7,7,34,.75); color:var(--muted); font:inherit; font-size:15px; line-height:1; cursor:pointer; }
.audio-fab:hover,.audio-fab:focus-visible { color:var(--fg); border-color:var(--gold); outline:none; }
.audio-fab.off { opacity:.45; text-decoration:line-through; }
.audio-fab.needs-gesture { color:var(--gold); border-color:var(--gold); animation:audio-pulse 1s steps(2) infinite; }
.audio-fab.ko { color:var(--red); border-color:var(--red); opacity:.6; cursor:default; }

.credit { margin:12px 0 0; font-size:6px; color:var(--dim); letter-spacing:.5px; }
.credit a { color:var(--muted); text-decoration:underline; text-underline-offset:3px; }
.credit a:hover { color:var(--fg); }
.info { max-width:880px; color:var(--dim); font-size:7px; line-height:1.8; margin:0 auto; }
.info summary { display:inline-block; cursor:pointer; color:var(--muted); }
.info summary::-webkit-details-marker { display:none; }
.info p { margin:10px auto 0; max-width:820px; }
.info a { color:var(--muted); }

.control.primary { color:#070722; background:var(--gold); border-color:var(--gold); border-bottom:5px solid #b8912a; font-size:clamp(8px,1vw,11px); padding:14px 22px; }
.control.primary:hover,.control.primary:focus-visible { color:#070722; background:#ffe27a; }
.control.primary:active { transform:translateY(3px); border-bottom-width:2px; }

.picker-overlay { position:fixed; inset:0; z-index:9; background:rgba(3,3,16,.6); }
.picker { position:fixed; top:0; left:0; bottom:0; z-index:10; width:min(300px,84vw); background:var(--panel); border-right:3px solid var(--dim); transform:translateX(-100%); transition:transform .22s steps(6); display:flex; flex-direction:column; }
.picker.open { transform:translateX(0); }
.picker-head { display:flex; align-items:center; justify-content:space-between; padding:16px 14px; font-size:9px; color:var(--gold); border-bottom:2px solid var(--dim); }
.picker-close { background:none; border:2px solid var(--dim); color:var(--muted); font:inherit; font-size:11px; width:30px; height:30px; cursor:pointer; }
.picker-close:hover { color:var(--fg); border-color:var(--gold); }
.picker-list { overflow-y:auto; padding:8px; display:flex; flex-direction:column; gap:6px; }
.picker-item { display:flex; align-items:center; gap:10px; padding:8px; background:transparent; border:2px solid transparent; color:var(--muted); font:inherit; text-align:left; cursor:pointer; }
.picker-item:hover,.picker-item:focus-visible { border-color:var(--dim); color:var(--fg); outline:none; }
.picker-item.selected { border-color:var(--gold); color:var(--gold); background:rgba(255,212,71,.08); }
.picker-thumb { flex:none; width:46px; height:33px; display:block; }
.picker-thumb svg { width:100%; height:100%; image-rendering:pixelated; shape-rendering:crispEdges; }
.picker-label { display:flex; flex-direction:column; gap:3px; line-height:1.3; }
.picker-nome { font-size:9px; }
.picker-anno { font-size:7px; color:var(--dim); }
.picker-item.selected .picker-anno { color:var(--gold); opacity:.75; }
.picker-cta { margin:10px 0 14px; padding:11px 10px; border:2px dashed var(--dim); background:transparent; color:var(--muted); font:inherit; font-size:7px; line-height:1.7; text-align:center; cursor:pointer; }
.picker-cta:hover,.picker-cta:focus-visible { color:var(--fg); border-color:var(--gold); outline:none; }
.picker-cta[disabled] { opacity:.6; cursor:default; border-style:solid; color:var(--green); border-color:var(--green); }

@keyframes fly { from { transform:translate(-3px,3px); } to { transform:translate(4px,-4px); } }
@keyframes flag-wave { from { transform:translate(-4px,-3px); filter:brightness(.92); } to { transform:translate(4px,3px); filter:brightness(1.08); } }
@keyframes flag-shimmer { 0%,49% { opacity:0; } 50%,100% { opacity:1; } }
@keyframes starmove { from { transform:translateX(0); } to { transform:translateX(-110vw); } }
@keyframes audio-pulse { 50% { opacity:.55; } }
@media (max-width:620px) {
  body { gap:15px; padding-inline:10px; }
  .scene { height:230px; }
  .mascotte { width:min(260px,70vw); }
  .trail { width:55vw; height:72px; }
  .row { height:24px; }
  .debt { font-size:clamp(18px,7.5vw,26px); }
  .picker { width:86vw; }
  .audio-fab { top:10px; right:10px; width:36px; height:36px; }
}
@media (prefers-reduced-motion:reduce) { .stars i,.row,.row::after,.mascotte svg,.audio-fab,.picker { animation:none; transition:none; } }
