:root {
  --gold: #e6c47c;
  --gold2: #b98d3f;
  --crimson: #7d1f1c;
  --ink: #120b08;
  --parch: #f3e6c8;
  --muted: #c9b48c;
  --font: Georgia, "Times New Roman", serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #000; overflow: hidden; }
html { font-size: calc(min(100vw, 56.25vh) / 25); }
body { font-family: var(--font); color: var(--parch); user-select: none; -webkit-user-select: none; }
/* clip: nothing (not even scrollIntoView) can scroll the game's frame sideways */
#app { position: fixed; inset: 0; overflow: hidden; overflow: clip; background: var(--ink); }

.screen { position: absolute; inset: 0; display: flex; flex-direction: column; opacity: 0; pointer-events: none; transition: opacity .35s ease, transform .35s ease; transform: scale(1.02); overflow: hidden; overflow: clip; }
.screen.active { opacity: 1; pointer-events: auto; transform: none; }
/* the intro replayed from the pause menu: over everything, without leaving the current screen */
.screen.overlay { opacity: 1; pointer-events: auto; transform: none; z-index: 60; }
.art { position: absolute; inset: 0; background-size: cover; background-position: center; z-index: 0; }
.art.dim::after, .art.dim2::after { content: ""; position: absolute; inset: 0; }
.art.dim::after { background: linear-gradient(180deg, rgba(10,6,4,.25) 0%, rgba(10,6,4,.55) 45%, rgba(10,6,4,.85) 100%); }
.art.dim2::after { background: linear-gradient(180deg, rgba(10,6,4,.72) 0%, rgba(10,6,4,.82) 50%, rgba(10,6,4,.93) 100%); }
/* zero specificity: every element's own position rule wins */
:where(.screen) > :where(:not(.art)) { position: relative; z-index: 1; }

/* text style */
.outl { text-shadow: 0 2px 0 #000, 0 0 6px rgba(0,0,0,.9); }
h2, h3, b { font-weight: 800; }

/* portraits: a missing one falls back to the category medal */
img.medal { object-fit: contain !important; border-radius: 0 !important; border-color: transparent !important; box-shadow: none !important; background: none !important; }

/* buttons */
.btn { display: flex; align-items: center; justify-content: center; text-align: center; cursor: pointer; min-height: 3rem; padding: .55rem 1.2rem;
  color: #fff3d6; font-weight: 800; font-size: 1.05rem; letter-spacing: .03em; text-shadow: 0 2px 0 #2a0806, 0 0 4px #000;
  background: linear-gradient(180deg, #a3302a 0%, #7d1f1c 55%, #5a1311 100%);
  border: 2px solid var(--gold); border-radius: .7rem;
  box-shadow: inset 0 1px 0 rgba(255,230,180,.45), inset 0 -3px 0 rgba(0,0,0,.35), 0 4px 10px rgba(0,0,0,.6), 0 0 0 1px #3a1a08;
  transition: transform .12s cubic-bezier(.3,1.6,.5,1), filter .15s, opacity .2s; }
.btn.alt { background: linear-gradient(180deg, #3d2c1c 0%, #261a10 100%); }
.btn.small { min-height: 3rem; font-size: .95rem; padding: .4rem 1rem; }
.btn:active, .pressed { transform: scale(.94) !important; }
.focus { outline: 3px solid #fff2b8 !important; outline-offset: 3px; filter: brightness(1.18); transform: scale(1.03); }
.btn.back { position: absolute; left: .7rem; top: calc(.6rem + env(safe-area-inset-top)); width: 2.9rem; height: 2.9rem; min-height: 0; padding: 0; font-size: 1.9rem; line-height: 1; border-radius: 50%; }

/* panel (9-slice of ui-panel.webp; the picture's transparent margins are pushed outside with the outset) */
.panel {
  border: 1.4rem solid transparent;
  border-image-source: url(assets/ui-panel.webp);
  border-image-slice: 146 80 167 83 fill;
  border-image-width: 2.77rem 1.52rem 3.17rem 1.58rem;
  border-image-outset: 1.35rem .1rem 1.75rem .15rem;
  border-image-repeat: stretch;
}

/* title */
#s-title .art { animation: slowzoom 30s ease-in-out infinite alternate; }
.title-vignette { position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 40%, transparent 40%, rgba(0,0,0,.65) 100%); }
#logo { position: absolute; left: 50%; top: 7%; width: 84%; max-height: 30%; object-fit: contain; transform: translateX(-50%); filter: drop-shadow(0 6px 14px rgba(0,0,0,.85)); }
#s-title.active #logo { animation: logoIn .8s cubic-bezier(.2,1.4,.4,1) both, floaty 5s ease-in-out .8s infinite; }
.title-prompt { position: absolute; left: 0; right: 0; bottom: 8%; text-align: center; display: flex; flex-direction: column; gap: .5rem; align-items: center; }
#t-prompt { font-size: 1.45rem; font-weight: 800; color: #fff0c8; padding: .45rem 1.6rem; border-radius: 2rem; background: radial-gradient(ellipse, rgba(20,10,4,.75) 0%, rgba(20,10,4,.45) 60%, transparent 100%);
  text-shadow: 0 2px 0 #000, 0 0 12px rgba(230,196,124,.8); animation: pulse 2s ease-in-out infinite; letter-spacing: .1em; }
#t-keyhint { font-size: .9rem; color: var(--muted); text-shadow: 0 1px 0 #000, 0 0 6px #000; }
#t-keyhint.hide { display: none; }
@keyframes logoIn { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.7); } 100% { opacity: 1; transform: translate(-50%, 0) scale(1); } }
@keyframes floaty { 0%,100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, -6px); } }
@keyframes pulse { 0%,100% { opacity: .6; } 50% { opacity: 1; } }
@keyframes slowzoom { from { transform: scale(1); } to { transform: scale(1.08); } }

/* video */
#vid { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1; background: transparent; }
.skip { position: absolute !important; right: .8rem; top: calc(.8rem + env(safe-area-inset-top)); z-index: 3 !important; min-width: 4.6rem; }
.subtitle { position: absolute; left: 6%; right: 6%; bottom: 10%; z-index: 3 !important; text-align: center; font-size: 1.1rem; font-weight: 700; color: #fff4d8; text-shadow: 0 2px 0 #000, 0 0 8px #000; opacity: 0; transition: opacity .4s; pointer-events: none; }
.subtitle.on { opacity: 1; }
.subtitle.top { top: 10.2rem; bottom: auto; font-size: .95rem; line-height: 1.45; background: rgba(0,0,0,.66); padding: .4rem .7rem; border-radius: .6rem; border: 1px solid rgba(230,196,124,.35); }
.subtitle .who { display: block; font-size: .78rem; color: var(--gold); letter-spacing: .08em; margin-bottom: .1rem; }

/* hub */
#hub-logo { position: absolute; left: 50%; top: 4.5%; width: 66%; max-height: 20%; object-fit: contain; transform: translateX(-50%); filter: drop-shadow(0 6px 12px rgba(0,0,0,.9)); }
.hub-menu { position: absolute; left: 7%; right: 7%; top: 29%; display: flex; flex-direction: column; gap: .85rem; }
.menu-card { display: flex; align-items: center; gap: .9rem; padding: .75rem 1rem; min-height: 4.6rem; cursor: pointer;
  background: linear-gradient(90deg, rgba(90,22,18,.92), rgba(40,18,10,.92)); border: 2px solid var(--gold); border-radius: .9rem;
  box-shadow: inset 0 1px 0 rgba(255,230,180,.35), 0 6px 14px rgba(0,0,0,.6); transition: transform .12s cubic-bezier(.3,1.6,.5,1), filter .15s; }
.menu-card img { width: 3.2rem; height: 3.2rem; object-fit: contain; filter: drop-shadow(0 2px 4px #000); }
.menu-card b { display: block; font-size: 1.3rem; color: #fff0cc; text-shadow: 0 2px 0 #2a0806; }
.menu-card small { display: block; font-size: .85rem; color: var(--muted); margin-top: .15rem; }
.menu-card:active { transform: scale(.96); }
#s-hub.active .menu-card { animation: popIn .45s cubic-bezier(.2,1.5,.4,1) both; }
#s-hub.active .menu-card:nth-child(2) { animation-delay: .08s; }
#s-hub.active .menu-card:nth-child(3) { animation-delay: .16s; }
@keyframes popIn { from { opacity: 0; transform: translateY(18px) scale(.92); } to { opacity: 1; transform: none; } }
.hub-bottom { position: absolute; left: 0; right: 0; bottom: 0; height: 30%; display: flex; align-items: flex-end; padding: 0 5% 3% 2%; }
.hub-bottom .chron { height: 100%; width: auto; aspect-ratio: 2/3; flex: none; }
.bubble { flex: 1; margin-bottom: 18%; margin-left: .3rem; padding: .7rem .9rem; background: rgba(243,230,200,.94); color: #2a1a0e; border-radius: .9rem; position: relative; box-shadow: 0 4px 12px rgba(0,0,0,.6); border: 2px solid var(--gold2); }
.bubble::before { content: ""; position: absolute; left: -.6rem; bottom: 1rem; border: .5rem solid transparent; border-right-color: rgba(243,230,200,.94); border-left: 0; }
.bubble p { margin: 0; font-size: .95rem; line-height: 1.45; font-weight: 600; }
.bubble small { display: block; margin-top: .4rem; font-size: .75rem; color: #6b4a26; }

/* bars & lists */
.bar { height: calc(4.2rem + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 4.3rem 0; display: flex; align-items: center; justify-content: center; flex: none; }
.bar h2 { margin: 0; font-size: 1.35rem; padding: 0; text-align: center; color: #fff0cc; text-shadow: 0 2px 0 #000, 0 0 10px rgba(230,196,124,.5); line-height: 1.2; }
.sub-head { text-align: center; color: var(--gold); font-weight: 700; font-size: .95rem; margin-bottom: .4rem; text-shadow: 0 1px 0 #000; flex: none; }
.scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: .3rem 1rem 1.6rem; scrollbar-width: none; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  -webkit-mask-image: linear-gradient(180deg, #000 calc(100% - 2.2rem), transparent 100%); mask-image: linear-gradient(180deg, #000 calc(100% - 2.2rem), transparent 100%); }
.scroll::-webkit-scrollbar { display: none; }

/* era tabs: a row that scrolls sideways (finger, mouse drag, wheel), with arrows at both ends */
.tabs-wrap { display: flex; align-items: center; gap: .35rem; padding: .1rem .6rem .7rem; flex: none; }
.tab-arrow { flex: none; width: 2.85rem; height: 2.85rem; min-height: 0; padding: 0 0 .15rem; border-radius: 50%; font-size: 1.7rem; line-height: 1; }
.tab-arrow.dis { opacity: .35; filter: grayscale(.6); }
.tabs { position: relative; flex: 1; min-width: 0; display: flex; gap: .45rem; overflow-x: auto; overflow-y: hidden; padding: .2rem .9rem; scrollbar-width: none; cursor: grab; overscroll-behavior-x: contain; touch-action: pan-x;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 1rem, #000 calc(100% - 1rem), transparent 100%); mask-image: linear-gradient(90deg, transparent 0, #000 1rem, #000 calc(100% - 1rem), transparent 100%); }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; padding: .55rem .9rem; min-height: 2.95rem; display: flex; align-items: center; border-radius: 2rem; font-size: .9rem; font-weight: 700; cursor: pointer; color: var(--muted); background: rgba(30,18,10,.85); border: 1.5px solid #5a4325; transition: transform .12s, background .2s, color .2s; white-space: nowrap; }
.tab.on { color: #2a1406; background: linear-gradient(180deg, #f3d792, #c99a48); border-color: #fff0c0; box-shadow: 0 0 12px rgba(230,196,124,.45); }
#tl-list { touch-action: pan-y; }
#tl-list.from-r .ev-card { animation-name: fromR; }
#tl-list.from-l .ev-card { animation-name: fromL; }
@keyframes fromR { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }
@keyframes fromL { from { opacity: 0; transform: translateX(-40px); } to { opacity: 1; transform: none; } }

.ev-card { position: relative; display: block; margin-bottom: .8rem; min-height: 6.4rem; border-radius: .9rem; overflow: hidden; cursor: pointer; border: 2px solid #8b6a35; background-size: cover; background-position: center; box-shadow: 0 5px 12px rgba(0,0,0,.6); transition: transform .12s cubic-bezier(.3,1.6,.5,1); }
.ev-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 38%; z-index: 0; }
.ev-card::before { content: ""; position: absolute; inset: 0; z-index: 1; background: linear-gradient(90deg, rgba(12,7,4,.94) 0%, rgba(12,7,4,.78) 52%, rgba(12,7,4,.2) 100%); }
.ev-card > .ev-in { position: relative; z-index: 2; }
.ev-in { padding: .7rem .9rem; }
.ev-year { font-size: 1.5rem; font-weight: 900; color: var(--gold); text-shadow: 0 2px 0 #000; line-height: 1.1; }
.ev-title { font-size: 1.1rem; font-weight: 800; margin-top: .15rem; color: #fff3da; text-shadow: 0 2px 0 #000; }
.ev-meta { display: flex; gap: .8rem; margin-top: .35rem; font-size: .8rem; color: var(--muted); }
.ev-names { font-size: .8rem; color: #e8d6ae; margin-top: .25rem; opacity: .9; }
.prog { height: .35rem; border-radius: .2rem; background: rgba(255,255,255,.12); overflow: hidden; margin-top: .4rem; }
.prog i { display: block; height: 100%; background: linear-gradient(90deg, #c99a48, #f6dc9a); }
.ev-card:active, .ch-card:active, .ga-row:active { transform: scale(.97); }
.anim-in { animation: popIn .35s cubic-bezier(.2,1.4,.4,1) both; }

/* character select */
.ch-hero { border-radius: .9rem; overflow: hidden; margin-bottom: .9rem; border: 2px solid #8b6a35; background: rgba(15,9,5,.8); }
.ch-hero .img { height: 10rem; background-size: cover, cover; background-position: center 35%, center; position: relative; }
.ch-hero .img::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 35%, rgba(15,9,5,.95)); }
.ch-hero .yr { position: absolute; left: .9rem; bottom: .4rem; z-index: 1; font-size: 1.6rem; font-weight: 900; color: var(--gold); text-shadow: 0 2px 0 #000; }
.ch-hero p { margin: 0; padding: .3rem .9rem .9rem; font-size: .95rem; line-height: 1.6; color: #eadbb8; }
.sec-title { font-size: 1rem; font-weight: 800; color: var(--gold); margin: .3rem 0 .6rem; text-shadow: 0 1px 0 #000; }
.ch-card { display: flex; gap: .85rem; align-items: center; padding: .75rem .9rem; margin-bottom: .75rem; border-radius: .9rem; cursor: pointer;
  background: linear-gradient(90deg, rgba(70,20,16,.95), rgba(30,16,10,.95)); border: 2px solid var(--gold2); box-shadow: 0 5px 12px rgba(0,0,0,.55); transition: transform .12s cubic-bezier(.3,1.6,.5,1); }
.ch-pt { position: relative; flex: none; width: 4.4rem; height: 4.4rem; }
.ch-pt img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; object-position: 50% 18%; border: .18rem solid var(--gold); box-shadow: 0 0 0 .14rem #2a1206, 0 4px 10px rgba(0,0,0,.7); background: #1a0f08; }
.ch-pt .vo { position: absolute; right: -.2rem; bottom: -.1rem; width: 1.55rem; height: 1.55rem; border-radius: 50%; background: linear-gradient(180deg, #a3302a, #5a1311); border: 1.5px solid var(--gold); display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 4px #000; }
.ch-pt .vo svg { width: .95rem; height: .95rem; fill: #fff0cc; }
.ch-card .nm { font-size: 1.2rem; font-weight: 900; color: #fff0cc; text-shadow: 0 2px 0 #000; }
.ch-card .ct { font-size: .75rem; color: var(--gold); font-weight: 700; }
.ch-card .rl { font-size: .85rem; color: #e2d0aa; margin-top: .15rem; line-height: 1.35; }
.ch-card .info { flex: 1; min-width: 0; }

/* story */
.kenburns { animation: kb 40s ease-in-out infinite alternate; background-size: cover, cover; background-position: center 30%, center; }
@keyframes kb { from { transform: scale(1.05) translate(0,0); } to { transform: scale(1.18) translate(-2%, -2%); } }
.story-shade { position: absolute; inset: 0; z-index: 0 !important; pointer-events: none; background: linear-gradient(180deg, rgba(8,5,3,.82) 0%, rgba(8,5,3,.25) 26%, rgba(8,5,3,.4) 50%, rgba(8,5,3,.92) 100%); }
#amb { position: absolute !important; inset: 0; width: 100%; height: 100%; z-index: 0 !important; pointer-events: none; }
.st-top { display: flex; align-items: center; gap: .6rem; padding: calc(.6rem + env(safe-area-inset-top)) 4.4rem 0 .9rem; height: calc(4rem + env(safe-area-inset-top)); flex: none; }
.st-top img { width: 2.9rem; height: 2.9rem; flex: none; border-radius: 50%; object-fit: cover; object-position: 50% 18%; border: .14rem solid var(--gold); box-shadow: 0 2px 6px #000; background: #1a0f08; }
.st-top b { display: block; font-size: 1.15rem; color: #fff0cc; text-shadow: 0 2px 0 #000; line-height: 1.2; }
.st-top small { display: block; font-size: .8rem; color: var(--gold); text-shadow: 0 1px 0 #000; }
/* six stats in a 3 x 2 grid: icon and name on the left, the number on the right, a bar under them */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .32rem .4rem; padding: .3rem .9rem; flex: none; }
.stat { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: .25rem; background: rgba(15,9,5,.82); border: 1.5px solid #7a5a2c; border-radius: .6rem; padding: .26rem .5rem .34rem; }
.stat .ic { display: flex; align-items: center; gap: .25rem; min-width: 0; font-size: .8rem; font-weight: 800; color: var(--parch); white-space: nowrap; overflow: hidden; text-shadow: 0 1px 0 #000; }
.stat .ic span { overflow: hidden; text-overflow: ellipsis; }
.stat svg { width: 1rem; height: 1rem; fill: var(--gold); flex: none; }
.stat .v { font-size: 1.15rem; font-weight: 900; color: #fff; text-shadow: 0 2px 0 #000; line-height: 1.1; }
.stat .bar2 { grid-column: 1 / -1; height: .3rem; border-radius: .2rem; background: rgba(255,255,255,.12); overflow: hidden; margin-top: .18rem; }
.stat .bar2 i { display: block; height: 100%; background: linear-gradient(90deg, #a87c34, #f6dc9a); transition: width .5s cubic-bezier(.3,1.4,.5,1); }
.stat.top { border-color: var(--gold); box-shadow: 0 0 10px rgba(230,196,124,.5); }
.delta { position: absolute; left: 50%; top: -.4rem; transform: translateX(-50%); font-weight: 900; font-size: 1.1rem; text-shadow: 0 2px 0 #000; animation: deltaUp 1.1s ease-out forwards; pointer-events: none; }
.delta.up { color: #9bf08a; } .delta.dn { color: #ff8a7a; }
@keyframes deltaUp { 0% { opacity: 0; transform: translate(-50%, 6px) scale(.6); } 20% { opacity: 1; transform: translate(-50%, -4px) scale(1.25); } 100% { opacity: 0; transform: translate(-50%, -22px) scale(1); } }
.st-main { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; padding: 0 .9rem calc(1.1rem + env(safe-area-inset-bottom)); min-height: 0; position: relative; }
.st-tagrow { position: relative; display: flex; justify-content: space-between; align-items: center; margin-bottom: .9rem; }
.tag { padding: .25rem .7rem; border-radius: 1rem; font-size: .8rem; font-weight: 800; color: #2a1406; background: linear-gradient(180deg, #f3d792, #c99a48); box-shadow: 0 2px 6px rgba(0,0,0,.5); }
.tag.era { color: #f6e2b0; background: linear-gradient(180deg, #4b5b52, #26332c); border: 1px solid #b9c9a0; }
.tag.dilemma { color: #f6e2b0; background: linear-gradient(180deg, #5d3f6e, #2f1e3a); border: 1px solid #c8a8d8; }
.tag.eve { color: #ffe9b8; background: linear-gradient(180deg, #2c3a66, #151c38); border: 1px solid var(--gold); }
.tag.final { background: linear-gradient(180deg, #ff9b7a, #b8332a); color: #fff; }
#st-act { font-size: .8rem; color: var(--muted); text-shadow: 0 1px 0 #000; }
.st-chron { position: absolute; right: 3.2rem; bottom: .1rem; height: 10.5rem; width: auto; aspect-ratio: 2/3; display: none; pointer-events: none; }
.st-chron.on { display: block; }
/* the figure's portrait on the role and eve steps */
.st-portrait { position: absolute; left: 50%; bottom: calc(100% + .7rem); width: 7.6rem; aspect-ratio: 4/5; display: none; pointer-events: none; transform: translateX(-50%);
  border-radius: 50%; overflow: hidden; border: .22rem solid var(--gold); background: #1a0f08;
  box-shadow: 0 0 0 .2rem #2a1206, 0 0 0 .32rem rgba(230,196,124,.55), 0 12px 26px rgba(0,0,0,.85), 0 0 38px rgba(230,196,124,.35); }
.st-portrait.on { display: block; animation: ptIn .7s cubic-bezier(.2,1.4,.4,1) both, ptGlow 3.2s ease-in-out .7s infinite; }
.st-portrait img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 22%; display: block; }
@keyframes ptIn { from { opacity: 0; transform: translateX(-50%) translateY(16px) scale(.75); } to { opacity: 1; transform: translateX(-50%); } }
@keyframes ptGlow { 0%,100% { filter: brightness(1); } 50% { filter: brightness(1.12); } }
.st-card { min-height: 9rem; max-height: 44vh; overflow-y: auto; scrollbar-width: none; }
.st-card h3 { margin: 0 0 .35rem; font-size: 1.15rem; color: var(--gold); text-shadow: 0 2px 0 #000; }
.st-card p { margin: 0; font-size: 1.08rem; line-height: 1.7; color: #f6ead0; text-shadow: 0 1px 0 #000; min-height: 4.5em; white-space: pre-line; }
.st-card.turn { animation: pageTurn .45s ease both; }
@keyframes pageTurn { 0% { opacity: 0; transform: translateX(26px) rotateY(-12deg); } 100% { opacity: 1; transform: none; } }
.choices { display: flex; flex-direction: column; gap: .6rem; margin-top: 1.1rem; }
.choice { justify-content: flex-start; text-align: left; padding: .6rem 1rem; min-height: 3.3rem; }
.choice .lbl { flex: 1; font-size: 1.02rem; line-height: 1.3; }
.choice .fx { display: flex; gap: .3rem; flex-wrap: wrap; justify-content: flex-end; max-width: 48%; }
.choice .fx span { font-size: .72rem; padding: .1rem .35rem; border-radius: .4rem; background: rgba(0,0,0,.45); font-weight: 800; white-space: nowrap; text-shadow: none; }
.choice .fx .u { color: #b6f5a6; } .choice .fx .d { color: #ffb0a4; }
.choice .ht { font-size: .7rem; padding: .1rem .4rem; border-radius: .4rem; background: var(--gold); color: #2a1406; margin-left: .4rem; text-shadow: none; }
.choices.in .btn { animation: popIn .35s cubic-bezier(.2,1.4,.4,1) both; }
.choices.in .btn:nth-child(2) { animation-delay: .06s; } .choices.in .btn:nth-child(3) { animation-delay: .12s; }
.choices.locked { pointer-events: none; }

/* ending */
#en-body { padding-top: calc(1.2rem + env(safe-area-inset-top)); padding-bottom: 2rem; }
.en-head { text-align: center; position: relative; }
.en-ptwrap { position: relative; width: 7.4rem; height: 7.4rem; margin: .2rem auto 0; }
.en-pt { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; object-position: 50% 20%; border: .25rem solid var(--gold); background: #1a0f08;
  box-shadow: 0 0 0 .2rem #3a1a08, 0 8px 20px #000, 0 0 30px rgba(230,196,124,.35); }
#s-ending.active .en-pt { animation: popIn .5s cubic-bezier(.2,1.5,.4,1) both; }
.en-seal { position: absolute; right: -1.7rem; bottom: -.7rem; width: 4rem; height: 4rem; object-fit: contain; filter: drop-shadow(0 4px 6px #000); }
#s-ending.active .en-seal { animation: stamp .6s cubic-bezier(.2,1.6,.4,1) .35s both; }
@keyframes stamp { 0% { opacity: 0; transform: scale(2.6) rotate(-25deg); } 100% { opacity: 1; transform: scale(1) rotate(-8deg); } }
.en-no { font-size: .85rem; color: var(--gold); font-weight: 700; letter-spacing: .1em; margin-top: .6rem; text-shadow: 0 1px 0 #000; }
.en-title { font-size: 1.6rem; font-weight: 900; color: #fff0cc; margin: .3rem 0 .2rem; line-height: 1.3; text-shadow: 0 3px 0 #000, 0 0 16px rgba(230,196,124,.55); }
#s-ending.active .en-title { animation: popIn .5s cubic-bezier(.2,1.5,.4,1) .45s both; }
.en-who { font-size: .9rem; color: var(--muted); }
.en-new { display: inline-block; margin-top: .35rem; padding: .15rem .6rem; border-radius: 1rem; background: linear-gradient(180deg, #ffe08a, #d8a13c); color: #3a1c06; font-weight: 900; font-size: .8rem; animation: pulse 1.4s infinite; }

/* the verdict: a big rank seal, its title, why, and how far to the next rank */
.verdict { position: relative; margin-top: 1.1rem; display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 1rem; align-items: center; padding: .95rem 1rem .85rem; border-radius: 1rem;
  background: linear-gradient(135deg, rgba(70,20,16,.95), rgba(24,12,7,.95)); border: 2px solid var(--gold2);
  box-shadow: inset 0 1px 0 rgba(255,230,180,.25), 0 6px 16px rgba(0,0,0,.6); }
#s-ending.active .verdict { animation: popIn .45s cubic-bezier(.2,1.5,.4,1) .6s both; }
.v-seal { position: relative; width: 5.4rem; height: 5.4rem; border-radius: 50%; display: flex; align-items: center; justify-content: center; transform: rotate(-8deg);
  background: radial-gradient(circle at 38% 32%, #d0463a, #8d2420 58%, #4a0f0c); border: .24rem solid var(--gold);
  box-shadow: 0 0 0 .18rem #2a1206, 0 0 0 .34rem rgba(230,196,124,.4), 0 6px 14px #000; }
.v-seal b { font-size: 3.4rem; line-height: 1; font-weight: 900; color: #ffe7a6; text-shadow: 0 3px 0 #2a0806, 0 0 14px rgba(255,220,140,.55); font-family: Georgia, "Times New Roman", serif; }
#s-ending.active .v-seal { animation: vStamp .55s cubic-bezier(.2,1.6,.4,1) .95s both; }
@keyframes vStamp { 0% { opacity: 0; transform: scale(2.8) rotate(-32deg); } 100% { opacity: 1; transform: scale(1) rotate(-8deg); } }
.r-S .v-seal { background: radial-gradient(circle at 38% 30%, #fff4c4, #e8b955 52%, #9a6a1c); border-color: #fff4cc; box-shadow: 0 0 0 .18rem #4a2e08, 0 0 0 .34rem rgba(255,226,150,.55), 0 0 30px rgba(255,214,120,.8), 0 6px 14px #000; }
.r-S .v-seal b { color: #6a3404; text-shadow: 0 2px 0 #fff3c8, 0 0 12px rgba(255,255,255,.7); }
.r-S .v-seal::after { content: ""; position: absolute; inset: -.55rem; border-radius: 50%; border: 2px solid rgba(255,230,160,.7); animation: vRing 2.2s ease-out 1.6s infinite; }
@keyframes vRing { 0% { transform: scale(.92); opacity: .9; } 100% { transform: scale(1.4); opacity: 0; } }
.r-B .v-seal { background: radial-gradient(circle at 38% 32%, #9a7a52, #66482a 58%, #33240f); border-color: #d8b878; }
.r-C .v-seal { background: radial-gradient(circle at 38% 32%, #77736c, #46423d 58%, #22201d); border-color: #a89c86; box-shadow: 0 0 0 .18rem #1a1814, 0 6px 14px #000; }
.r-C .v-seal b { color: #ece2cf; text-shadow: 0 3px 0 #111; }
.r-S { border-color: #f6dc9a; box-shadow: inset 0 1px 0 rgba(255,240,200,.35), 0 0 22px rgba(230,196,124,.35), 0 6px 16px rgba(0,0,0,.6); }
.v-info small { display: block; font-size: .8rem; color: var(--gold); letter-spacing: .2em; font-weight: 800; text-shadow: 0 1px 0 #000; }
.v-name { display: block; font-size: 1.5rem; color: #fff0cc; line-height: 1.25; margin: .1rem 0 .2rem; text-shadow: 0 2px 0 #000, 0 0 12px rgba(230,196,124,.4); }
.v-why, .v-top { display: block; font-size: .82rem; color: #dcc8a0; line-height: 1.45; }
.v-desc { grid-column: 1 / -1; margin: .75rem 0 0; font-size: .95rem; line-height: 1.6; color: #f0e2c0; }
.v-next { grid-column: 1 / -1; margin-top: .5rem; padding-top: .45rem; border-top: 1px dashed rgba(230,196,124,.35); font-size: .82rem; font-weight: 800; color: var(--gold); }
.en-sec { margin-top: 1.2rem; text-align: center; }
.en-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .35rem .4rem; }
.en-buttons { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .5rem; padding: .6rem .9rem calc(1rem + env(safe-area-inset-bottom)); flex: none; background: linear-gradient(180deg, transparent, rgba(0,0,0,.7) 30%); }
.en-buttons .btn { font-size: .9rem; padding: .4rem .3rem; min-height: 3.1rem; line-height: 1.2; }

/* the chronicle of this run: a vertical timeline from the prologue to the epilogue */
.sl-title { margin-top: 1.7rem; margin-bottom: .25rem; font-size: 1.2rem; text-align: center; letter-spacing: .08em; }
.sl-sub { text-align: center; font-size: .82rem; color: var(--muted); margin-bottom: 1rem; }
.story-line { position: relative; padding-left: 1.55rem; }
.story-line::before { content: ""; position: absolute; left: .58rem; top: .5rem; bottom: .8rem; width: 2px; background: linear-gradient(180deg, var(--gold), rgba(185,141,63,.25)); }
.sl-node { position: relative; margin-bottom: .8rem; }
.sl-dot { position: absolute; left: -1.37rem; top: .62rem; width: .9rem; height: .9rem; border-radius: 50%; background: #c99a48; border: 2px solid #fff0c0; box-shadow: 0 0 8px rgba(230,196,124,.6); }
.sl-body { padding: .6rem .85rem .7rem; border-radius: .75rem; background: rgba(20,11,6,.88); border: 1.5px solid #5d4423; box-shadow: 0 4px 10px rgba(0,0,0,.45); }
.sl-tag { font-size: .78rem; font-weight: 800; color: var(--gold); letter-spacing: .05em; margin-bottom: .2rem; text-shadow: 0 1px 0 #000; }
.sl-body p { margin: .25rem 0 0; font-size: .93rem; line-height: 1.6; color: #eadbb8; }
.sl-body p.sl-sit { color: #d2c098; }
.sl-body p.sl-pick { font-weight: 800; color: #fff0cc; }
.sl-body p.sl-cq { font-style: italic; color: #f3e1b5; }
.sl-chips { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .35rem; }
.sl-chips span { font-size: .76rem; padding: .08rem .42rem; border-radius: .4rem; background: rgba(0,0,0,.5); font-weight: 800; white-space: nowrap; }
.sl-chips .u { color: #b6f5a6; } .sl-chips .d { color: #ffb0a4; }
.sl-node.era .sl-dot { background: #4b5b52; border-color: #b9c9a0; box-shadow: 0 0 8px rgba(185,201,160,.5); }
.sl-node.era .sl-tag { color: #c9dbb0; }
.sl-node.dilemma .sl-dot { background: #5d3f6e; border-color: #c8a8d8; box-shadow: 0 0 8px rgba(200,168,216,.5); }
.sl-node.dilemma .sl-tag { color: #dcc2ea; }
.sl-node.eve .sl-dot { background: #2c3a66; border-color: var(--gold); }
.sl-node.eve .sl-tag { color: #c6d0f2; }
.sl-node.final .sl-dot { left: -1.47rem; top: .55rem; width: 1.1rem; height: 1.1rem; background: #b8332a; border-color: #ffd0b8; box-shadow: 0 0 12px rgba(255,120,90,.7); }
.sl-node.final .sl-body { border-color: #c0503e; background: linear-gradient(135deg, rgba(86,20,15,.94), rgba(26,10,6,.94)); }
.sl-node.final .sl-tag { color: #ffb19a; }
.sl-node.hist .sl-body { border-style: dashed; border-color: #8b6a35; background: rgba(0,0,0,.55); }
.sl-node.hist.rw .sl-dot { background: #e0604a; border-color: #ffd0b8; }
.sl-body p.sl-h1 { font-weight: 900; color: var(--gold); }
.sl-body p.sl-h1.rw { color: #ff9f86; }
.sl-node.epi .sl-body { border-color: var(--gold); background: linear-gradient(135deg, rgba(60,40,14,.92), rgba(22,12,6,.92)); }
.sl-node.epi .sl-dot { background: #f3d792; border-color: #fff; }
.sl-body p.sl-end { font-weight: 900; font-size: 1.02rem; color: #fff0cc; }
.sl-body p.epi { color: #e6cf9a; font-style: italic; }

/* gallery */
.ga-ev { font-size: .85rem; color: var(--gold); font-weight: 800; margin: .9rem 0 .4rem; text-shadow: 0 1px 0 #000; }
.ga-row { display: flex; align-items: center; gap: .7rem; padding: .5rem .8rem; min-height: 3.4rem; border-radius: .7rem; margin-bottom: .45rem; cursor: pointer; background: rgba(40,22,12,.9); border: 1.5px solid #6d5129; transition: transform .12s; }
.ga-row img { width: 2.6rem; height: 2.6rem; flex: none; border-radius: 50%; object-fit: cover; object-position: 50% 18%; border: .12rem solid var(--gold2); background: #1a0f08; }
.ga-row .nm { flex: 1; font-weight: 800; font-size: 1rem; }
.ga-row .ct { font-size: .85rem; color: var(--gold); font-weight: 800; min-width: 3rem; text-align: right; }
.ga-row .prog { width: 4.5rem; margin: 0; }
.ga-row.done { border-color: var(--gold); }
.ga-row.done img { border-color: var(--gold); }
#modal { position: absolute; inset: 0; z-index: 30; background: rgba(0,0,0,.72); display: flex; align-items: center; justify-content: center; padding: 2.2rem 1rem; }
#modal.hidden { display: none; }
.modal-box { width: 100%; max-height: 88%; overflow-y: auto; scrollbar-width: none; animation: popIn .3s cubic-bezier(.2,1.5,.4,1) both; }
.modal-box h3 { margin: 0 0 .6rem; text-align: center; color: #fff0cc; font-size: 1.2rem; text-shadow: 0 2px 0 #000; }
.mh { display: flex; align-items: center; gap: .8rem; margin-bottom: .7rem; }
.mh h3 { margin: 0; text-align: left; }
.mh small { display: block; font-size: .8rem; color: var(--muted); margin-top: .15rem; line-height: 1.35; }
.mh-pt { width: 4.2rem; height: 4.2rem; flex: none; border-radius: 50%; object-fit: cover; object-position: 50% 18%; border: .18rem solid var(--gold); box-shadow: 0 0 0 .14rem #2a1206, 0 4px 10px #000; background: #1a0f08; }
/* six stat columns; each final option is a full-width label over its six tiles */
.grid12 { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .35rem; align-items: center; justify-items: center; }
.grid12 .rh { grid-column: 1 / -1; justify-self: stretch; margin-top: .45rem; font-size: .86rem; font-weight: 800; color: #f0dfb8; line-height: 1.3; text-shadow: 0 1px 0 #000; }
.grid12 .chd { display: flex; flex-direction: column; align-items: center; gap: .1rem; min-width: 0; }
.grid12 .chd svg { width: 1.2rem; height: 1.2rem; fill: var(--gold); }
.grid12 .chd span { font-size: .74rem; font-weight: 700; color: var(--muted); white-space: nowrap; }
.tile { position: relative; width: 100%; max-width: 3rem; aspect-ratio: 1; border-radius: .5rem; display: flex; align-items: center; justify-content: center; cursor: pointer; font-weight: 900; color: #6d5a3c; background: rgba(0,0,0,.5); border: 1.5px solid #4d3a20; }
.tile.on { background: radial-gradient(circle, #9b2a24, #4a0f0c); border-color: var(--gold); }
.tile.on img { width: 78%; height: 78%; object-fit: contain; }
.tile .tr { position: absolute; right: -.25rem; bottom: -.3rem; min-width: 1.15rem; height: 1.15rem; padding: 0 .15rem; border-radius: .6rem; font-style: normal; font-size: .72rem; line-height: 1.15rem; text-align: center; color: #2a1406; background: #e6c47c; border: 1px solid #2a1406; font-family: Georgia, serif; }
.tile .tr.r-S { background: linear-gradient(180deg, #fff1b8, #e3b450); }
.tile .tr.r-B { background: #b89a6a; }
.tile .tr.r-C { background: #9a948a; }
.detail { margin-top: .8rem; padding: .7rem; border-radius: .6rem; background: rgba(0,0,0,.4); min-height: 4rem; }
.detail h4 { margin: 0 0 .3rem; color: var(--gold); font-size: 1rem; }
.detail p { margin: .2rem 0; font-size: .9rem; line-height: 1.55; color: #eadbb8; }
.detail .best { display: inline-block; margin: .1rem 0 .3rem; padding: .1rem .55rem; border-radius: 1rem; font-size: .8rem; font-weight: 800; color: #2a1406; background: #e6c47c; }
.detail .best.r-S { background: linear-gradient(180deg, #fff1b8, #e3b450); }
.detail .best.r-B { background: #b89a6a; }
.detail .best.r-C { background: #9a948a; }
.modal-close { margin: .9rem auto 0; width: 60%; }

/* achievements */
.ac-card { display: flex; gap: .8rem; align-items: center; padding: .6rem .8rem; margin-bottom: .55rem; border-radius: .8rem; background: rgba(40,22,12,.9); border: 1.5px solid #5d4423; }
.ac-card img { width: 3rem; height: 3rem; object-fit: contain; flex: none; }
.ac-card.off img { filter: grayscale(1) brightness(.45); }
.ac-card.off { opacity: .75; }
.ac-card.on { border-color: var(--gold); background: linear-gradient(90deg, rgba(90,30,20,.95), rgba(40,22,12,.95)); }
.ac-card b { display: block; font-size: 1rem; color: #fff0cc; }
.ac-card small { display: block; font-size: .8rem; color: var(--muted); margin-top: .1rem; }

/* final cutscene: how history moved */
#cine { position: absolute; inset: 0; z-index: 45; overflow: hidden; background: #000; opacity: 0; transition: opacity .45s ease; pointer-events: none; }
#cine.hidden { display: none; }
#cine.on { opacity: 1; pointer-events: auto; cursor: pointer; }
.cine-art { position: absolute; inset: -6%; background-size: cover, cover; background-position: center 35%, center; transform: scale(1.45); filter: brightness(.45); }
#cine.on .cine-art { animation: cinePan 8.5s cubic-bezier(.3,.1,.25,1) both; }
@keyframes cinePan {
  0% { transform: scale(1.5) translate(var(--px, 4%), var(--py, 3%)); filter: brightness(.35) saturate(.7) sepia(.35); }
  35% { filter: brightness(.8) saturate(.9) sepia(.2); }
  100% { transform: scale(1.04) translate(0, 0); filter: brightness(.95) saturate(1.05) sepia(.05); }
}
#cine-amb { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
.cine-shade { position: absolute; inset: 0; z-index: 1; pointer-events: none; background: radial-gradient(ellipse at 50% 42%, transparent 35%, rgba(0,0,0,.55) 100%), linear-gradient(180deg, transparent 45%, rgba(0,0,0,.85) 78%, rgba(0,0,0,.95) 100%); }
.cine-bar { position: absolute; left: 0; right: 0; height: 11%; background: #000; z-index: 3; transition: transform .8s cubic-bezier(.2,.9,.3,1); }
.cine-bar.top { top: 0; transform: translateY(-100%); }
.cine-bar.bot { bottom: 0; transform: translateY(100%); }
#cine.on .cine-bar { transform: none; }
#cine-year { position: absolute; left: 1rem; right: 7rem; bottom: .55rem; font-size: .85rem; letter-spacing: .12em; color: var(--gold); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0; transition: opacity .6s .5s; }
#cine.on #cine-year { opacity: .9; }
.cine-title { position: absolute; left: 6%; right: 6%; top: 40%; z-index: 4; text-align: center; font-size: 1.75rem; font-weight: 900; letter-spacing: .25em; color: #fff0cc; text-shadow: 0 3px 0 #000, 0 0 24px rgba(230,196,124,.75); opacity: 0; pointer-events: none; }
#cine.on .cine-title { animation: cineTitle 2.2s ease .25s both; }
@keyframes cineTitle { 0% { opacity: 0; transform: scale(1.12); filter: blur(6px); letter-spacing: .5em; } 30% { opacity: 1; transform: none; filter: blur(0); letter-spacing: .25em; } 75% { opacity: 1; } 100% { opacity: 0; transform: scale(.96); } }
.cine-stamp { position: absolute; left: 50%; top: 31%; z-index: 4; padding: .35rem 1.1rem .45rem; font-size: 2.3rem; font-weight: 900; letter-spacing: .14em; white-space: nowrap; pointer-events: none;
  color: #ff5a46; border: .28rem double #ff5a46; border-radius: .5rem; background: rgba(40,4,2,.35); text-shadow: 0 0 14px rgba(255,90,70,.6), 0 3px 0 #000; box-shadow: 0 0 24px rgba(255,80,60,.35), inset 0 0 18px rgba(255,80,60,.25);
  opacity: 0; transform: translate(-50%, -50%) rotate(-8deg) scale(3); }
.cine-stamp.same { color: #f3d792; border-color: #f3d792; background: rgba(30,18,4,.4); text-shadow: 0 0 14px rgba(243,215,146,.6), 0 3px 0 #000; box-shadow: 0 0 24px rgba(243,215,146,.3), inset 0 0 18px rgba(243,215,146,.2); }
.cine-stamp.show { animation: cineStamp .55s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes cineStamp { 0% { opacity: 0; transform: translate(-50%, -50%) rotate(-20deg) scale(3); } 100% { opacity: 1; transform: translate(-50%, -50%) rotate(-8deg) scale(1); } }
.cine-cap { position: absolute; left: 5.5%; right: 5.5%; bottom: calc(11% + 1.1rem); z-index: 4; opacity: 0; transform: translateY(24px); transition: opacity .6s ease, transform .6s cubic-bezier(.2,1.2,.4,1); pointer-events: none; }
.cine-cap.show { opacity: 1; transform: none; }
.cine-head { display: flex; align-items: center; gap: .75rem; margin-bottom: .6rem; }
.cine-head img { width: 4.2rem; height: 4.2rem; flex: none; border-radius: 50%; object-fit: cover; object-position: 50% 18%; border: .2rem solid var(--gold); box-shadow: 0 0 0 .15rem #2a1206, 0 6px 14px #000; background: #1a0f08; }
.cine-head small { display: block; font-size: .8rem; color: var(--muted); letter-spacing: .08em; text-shadow: 0 1px 0 #000; }
.cine-head b { display: block; font-size: 1.25rem; color: var(--gold); line-height: 1.3; text-shadow: 0 2px 0 #000, 0 0 12px rgba(230,196,124,.5); }
#cine-res { margin: 0; min-height: 5.2em; font-size: 1.05rem; line-height: 1.7; color: #fbf0d8; text-shadow: 0 2px 0 #000, 0 0 10px #000; }
.cine-flash { position: absolute; inset: 0; z-index: 5; background: #fff4d8; opacity: 0; pointer-events: none; }
.cine-flash.go { animation: flash .9s ease-out; }
.cine-skip { position: absolute !important; right: .8rem; top: calc(.8rem + env(safe-area-inset-top)); z-index: 6; min-width: 4.6rem; opacity: 0; transition: opacity .4s .6s; }
#cine.on .cine-skip { opacity: 1; }

/* toast, flash, fx */
#toast { position: absolute; left: 50%; top: calc(5.4rem + env(safe-area-inset-top)); z-index: 40; transform: translate(-50%, -260%); width: 80%; display: flex; align-items: center; gap: .6rem; transition: transform .45s cubic-bezier(.2,1.4,.4,1); pointer-events: none; padding: .1rem; }
#toast.show { transform: translate(-50%, 0); }
#toast img { width: 2.6rem; height: 2.6rem; object-fit: contain; }
#toast b { display: block; font-size: .8rem; color: var(--gold); }
#toast span { display: block; font-size: 1rem; font-weight: 800; color: #fff0cc; }
#flash { position: absolute; inset: 0; z-index: 35; background: #fff4d8; opacity: 0; pointer-events: none; }
#flash.go { animation: flash .9s ease-out; }
@keyframes flash { 0% { opacity: 0; } 15% { opacity: .85; } 100% { opacity: 0; } }
#fx { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 50; pointer-events: none; }
.shake { animation: shake .45s ease; }
@keyframes shake { 0%,100% { transform: none; } 20% { transform: translate(-6px, 3px); } 40% { transform: translate(5px, -4px); } 60% { transform: translate(-4px, 2px); } 80% { transform: translate(3px, -1px); } }
