@font-face { font-family: 'Gowun Batang'; src: url(assets/fonts/GowunBatang-Bold.woff2) format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Nanum Brush'; src: url(assets/fonts/NanumBrushScript.woff2) format('woff2'); font-display: swap; }
/* English headings: a Latin-only brush subset (OFL), with the Korean brush behind it for anything else */
@font-face { font-family: 'Caveat Brush'; src: url(assets/fonts/CaveatBrush-Latin.woff2) format('woff2'); font-display: swap; }

:root {
  --ink: #2c1c12;
  --ink2: #5a3e28;
  --paper: #f3e6c8;
  --paper2: #e7d4ab;
  --gold: #ffd77a;
  --red: #b8402c;
  --wood: #6b4527;
  --u: clamp(9px, 1.6vmin + 0.35vmax, 15px); /* one ui unit: phone ≈ 10px, desktop ≈ 15px */
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --brush: 'Nanum Brush', serif;
}
html:lang(en) { --brush: 'Caveat Brush', 'Nanum Brush', serif; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1d130c; color: var(--ink); font: 700 var(--u)/1.4 'Gowun Batang', serif; user-select: none; -webkit-user-select: none; touch-action: none; overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; touch-action: manipulation; }
img { -webkit-user-drag: none; user-select: none; }
.hidden { display: none !important; }
#game, #overlay { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; touch-action: none; }
#game { background: #1b120b; cursor: grab; }
#overlay { pointer-events: none; z-index: 1; }

/* ---------------------------------------------------------------- materials */
.paper {
  background:
    url(assets/ui/grain.svg),
    radial-gradient(120% 90% at 30% 20%, #fbf2dc 0%, var(--paper) 55%, var(--paper2) 100%);
  border-radius: calc(var(--u) * 0.5);
  box-shadow: 0 0 0 2px #8a6440, 0 0 0 4px #3a2414, 0 calc(var(--u) * 0.6) calc(var(--u) * 1.4) rgba(0, 0, 0, 0.45), inset 0 0 calc(var(--u) * 2) rgba(120, 80, 30, 0.25);
}
.seal-btn {
  position: relative; padding: calc(var(--u) * 0.8) calc(var(--u) * 2.2); border-radius: 999px;
  background: radial-gradient(circle at 35% 30%, #e0624a, #a8321f 60%, #7c2010);
  color: #fff3dc; font-size: calc(var(--u) * 1.3); letter-spacing: 0.06em;
  box-shadow: 0 0 0 2px #5a1a0c, inset 0 2px 0 rgba(255, 220, 190, 0.45), inset 0 -3px 0 rgba(60, 10, 0, 0.4), 0 4px 10px rgba(0, 0, 0, 0.4);
  text-shadow: 0 1px 0 #5a1a0c; transition: transform 0.12s, filter 0.12s;
}
.seal-btn:hover { filter: brightness(1.08); }
.seal-btn:active { transform: scale(0.96); }
.seal-btn:disabled { filter: grayscale(0.8) brightness(0.8); cursor: default; }
.line-btn {
  padding: calc(var(--u) * 0.6) calc(var(--u) * 1.4); border-radius: 999px; color: var(--ink2);
  box-shadow: inset 0 0 0 2px var(--ink2); background: rgba(255, 250, 235, 0.5);
}
.line-btn:active { transform: scale(0.96); }
.chip-btn { padding: 0.3em 0.9em; border-radius: 999px; background: rgba(255, 240, 210, 0.15); color: #f6e3bd; box-shadow: inset 0 0 0 1px rgba(255, 230, 190, 0.4); }

/* ---------------------------------------------------------------- screens */
.screen { position: fixed; inset: 0; z-index: 10; }
#shelfScreen {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(var(--u) * 1.4);
  background:
    radial-gradient(70% 60% at 50% 45%, rgba(255, 190, 110, 0.25), rgba(0, 0, 0, 0) 70%),
    url(assets/ui/wood.svg), linear-gradient(#3a2416, #1a0f08);
  background-size: auto, 220px, auto;
  padding: calc(var(--u) * 1.5) calc(var(--u) * 2 + var(--safe-r)) calc(var(--u) * 1.5 + var(--safe-b)) calc(var(--u) * 2 + var(--safe-l));
}
.logo { text-align: center; color: #fbeccc; }
.logo h1 { margin: 0; font: 400 calc(var(--u) * 5) var(--brush); line-height: 1; text-shadow: 0 3px 0 #3a1a08, 0 0 30px rgba(255, 190, 110, 0.5); }
.logo p { margin: calc(var(--u) * 0.4) 0 0; font-size: calc(var(--u) * 1); color: #e6cfa4; opacity: 0.9; }
.shelf {
  position: relative; width: min(100%, calc(var(--u) * 70)); aspect-ratio: 1112 / 600; max-height: 62vh;
  background: url(assets/ui/shelf.webp) center / 100% 100% no-repeat;
  display: flex; align-items: flex-end; justify-content: center; padding: 0 9% 10.5%;
}
@media (max-aspect-ratio: 1/1) { .shelf { aspect-ratio: auto; height: 52vh; background-size: 100% 100%; } }
#spines { display: flex; align-items: flex-end; justify-content: center; gap: 3.2%; width: 100%; height: 84%; }
.spine {
  position: relative; height: 100%; aspect-ratio: 124 / 440; container-type: size; transition: transform 0.25s cubic-bezier(.3,1.6,.5,1);
  background: center / 100% 100% no-repeat; filter: drop-shadow(3px 4px 3px rgba(0, 0, 0, 0.55));
}
.spine:hover, .spine:focus-visible { transform: translateY(-6%) rotate(-2deg); }
.spine:active { transform: translateY(-4%) scale(0.98); }
.spine .label {
  position: absolute; left: 18%; right: 18%; top: 19%; height: 31%;
  display: flex; align-items: center; justify-content: center; text-align: center; white-space: nowrap;
  font-size: min(4.6cqh, calc(26cqh / var(--n, 4))); line-height: 1; color: var(--ink); writing-mode: vertical-rl; letter-spacing: 0;
}
.spine .no { position: absolute; left: 0; right: 0; bottom: 8%; text-align: center; color: #f8e6c4; font-size: calc(var(--u) * 0.8); text-shadow: 0 1px 0 #000; }
.spine .stars { position: absolute; left: -30%; right: -30%; bottom: -9%; display: flex; justify-content: center; gap: 2px; font-size: calc(var(--u) * 1.05); color: #5a3e28; text-shadow: 0 1px 0 rgba(255, 230, 190, 0.3); }
.spine .stars .on { color: var(--gold); text-shadow: 0 0 6px rgba(255, 200, 100, 0.8), 0 1px 0 #000; }
.spine.locked { filter: grayscale(0.85) brightness(0.55) drop-shadow(3px 4px 3px rgba(0, 0, 0, 0.55)); cursor: not-allowed; }
.spine.locked::after { content: ''; position: absolute; left: 18%; right: 18%; top: 53%; aspect-ratio: 118 / 153; background: url(assets/ui/lock.webp) center / contain no-repeat; filter: none; }
.spine.next::before { content: ''; position: absolute; left: 74%; width: 26%; top: 2%; aspect-ratio: 76/220; background: url(assets/ui/mark_ribbon.webp) center / contain no-repeat; z-index: -1; transform: translateY(-50%); animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-58%); } }
@media (max-height: 520px) {
  #shelfScreen { gap: calc(var(--u) * 0.4); padding-top: calc(var(--u) * 0.6); padding-bottom: calc(var(--u) * 0.6 + var(--safe-b)); }
  .logo h1 { font-size: calc(var(--u) * 3.6); }
  .logo p { display: none; }
  .shelf { max-height: 76vh; }
}
.shelf-foot { display: flex; flex-wrap: wrap; justify-content: center; gap: calc(var(--u)); align-items: center; color: #d8bf92; font-size: calc(var(--u) * 0.95); }

/* briefing */
#briefScreen { background: url(assets/ui/wood.svg), linear-gradient(#2e1d12, #170d07); background-size: 220px, auto; overflow: auto; touch-action: pan-y; }
.brief {
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: calc(var(--u) * 1.2);
  min-height: 100%; padding: calc(var(--u) * 1.2) calc(var(--u) * 1.4 + var(--safe-r)) calc(var(--u) * 1.2 + var(--safe-b)) calc(var(--u) * 1.4 + var(--safe-l));
  align-content: stretch; /* the columns fill the screen: the picture grows into the left one, the cards take the free height on the right */
}
@media (max-aspect-ratio: 1/1) { .brief { grid-template-columns: 1fr; grid-template-rows: auto 1fr; } }
.brief-map { position: relative; display: flex; flex-direction: column; gap: calc(var(--u) * 0.8); min-width: 0; }
.back { align-self: flex-start; color: #f1dcb4; font-size: calc(var(--u) * 1.05); padding: 0.2em 0.6em; border-radius: 999px; background: rgba(0, 0, 0, 0.25); }
.map-thumb {
  position: relative; border-radius: calc(var(--u) * 0.6); overflow: hidden; box-shadow: 0 0 0 3px #8a6440, 0 0 0 6px #2a170b, 0 8px 18px rgba(0, 0, 0, 0.5); aspect-ratio: 1536 / 1024; max-height: 44vh;
  background: radial-gradient(ellipse at 50% 120%, #f3e3c2 0 45%, #6b4a2c 46%, #2a170b 100%);
}
.map-thumb img { width: 100%; height: 100%; object-fit: contain; object-position: bottom; display: block; }
@media (min-aspect-ratio: 1/1) {
  .brief-map .map-thumb { flex: 1 1 0; min-height: calc(var(--u) * 14); max-height: none; aspect-ratio: auto; }
  .brief-map .map-thumb img { position: absolute; inset: 0; object-fit: cover; object-position: 50% 100%; }
}
.brief-text { padding: calc(var(--u) * 0.9) calc(var(--u) * 1.2); }
.brief-text small { color: var(--red); }
.brief-text h2 { margin: 0.05em 0 0.2em; font: 400 calc(var(--u) * 2.4) var(--brush); line-height: 1; }
.brief-text p { margin: 0 0 0.4em; color: var(--ink2); }
.brief-text ul { margin: 0; padding-left: 1.1em; font-size: calc(var(--u) * 0.92); }
.brief-text li::marker { content: '✦ '; color: var(--red); }
.brief-side { display: flex; flex-direction: column; gap: calc(var(--u) * 0.9); min-width: 0; }
.block { padding: calc(var(--u) * 0.7) calc(var(--u) * 0.9); }
.block h3 { margin: 0 0 0.4em; font-size: calc(var(--u) * 1.05); display: flex; justify-content: space-between; }
.brief-side > .block:nth-child(2) { flex: 1 1 auto; display: flex; flex-direction: column; }
#roster { display: flex; flex-wrap: wrap; gap: calc(var(--u) * 0.25); }
.foe { position: relative; width: calc(var(--u) * 3.9); text-align: center; font-size: calc(var(--u) * 0.66); line-height: 1.1; color: var(--ink2); word-break: keep-all; }
.foe img { width: calc(var(--u) * 3.4); height: calc(var(--u) * 3.4); border-radius: 50%; background: radial-gradient(#fff6e2, #d9c29a); box-shadow: 0 0 0 2px #7a5636; display: block; margin: 0 auto 2px; object-fit: cover; }
.foe.boss img { box-shadow: 0 0 0 2px #7a5636, 0 0 0 4px var(--red); }
.foe .tr { position: absolute; top: 0; right: -2px; display: flex; flex-direction: column; gap: 1px; }
.tag { display: inline-block; min-width: 1.5em; padding: 0 0.3em; border-radius: 999px; font-size: calc(var(--u) * 0.66); line-height: 1.5; color: #fff6e0; background: #6d5038; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3); }
.tag.fly { background: #4c7aa8; } .tag.armor { background: #8a6a3a; } .tag.ward { background: #7a58b0; } .tag.stealth { background: #3d4a55; } .tag.boss { background: var(--red); }
.tag.heal { background: #4f8a45; } .tag.split { background: #b07a3a; } .tag.burrow { background: #5a4a3a; } .tag.thief { background: #b08a2a; }
#picks { flex: 1 1 auto; display: grid; grid-template-columns: repeat(auto-fit, minmax(calc(var(--u) * 4.4), 1fr)); align-content: center; gap: calc(var(--u) * 0.45); }
.pick {
  position: relative; aspect-ratio: 3 / 4.2; max-height: calc(var(--u) * 11.5); border-radius: calc(var(--u) * 0.4); overflow: hidden;
  background: linear-gradient(#fff7e4, #e6d0a4); box-shadow: 0 0 0 2px #9a7650; transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
}
.pick img { position: absolute; inset: 4% 4% 26%; width: 92%; height: 70%; object-fit: contain; object-position: bottom; }
.pick .nm { position: absolute; left: 0; right: 0; bottom: 3%; text-align: center; font-size: calc(var(--u) * 0.7); line-height: 1.1; }
.pick .rl { position: absolute; left: 4px; top: 4px; font-size: calc(var(--u) * 0.6); color: #fff; background: rgba(60, 36, 20, 0.75); padding: 0 0.35em; border-radius: 999px; }
.pick .st { position: absolute; right: 4px; top: 4px; width: calc(var(--u) * 0.8); height: calc(var(--u) * 0.8); border-radius: 50%; box-shadow: 0 0 0 1px rgba(0,0,0,.4); }
.pick:not(.on) { filter: grayscale(0.7) brightness(0.85); }
.pick.new { box-shadow: 0 0 0 3px var(--red), 0 0 12px rgba(184, 64, 44, 0.6); }
.pick.new::after { content: '새 인물'; position: absolute; left: 50%; bottom: 17%; transform: translateX(-50%) rotate(-4deg); font-size: calc(var(--u) * 0.62); color: #fff; background: var(--red); padding: 0.05em 0.5em; border-radius: 4px; white-space: nowrap; }
.st-red { background: #c8402c; } .st-cinder { background: #7aa6d6; } .st-band { background: #d6a23c; } .st-kids { background: #5d9a4a; }
.link-hint { margin: auto 0 0; padding-top: 0.6em; font-size: calc(var(--u) * 0.78); color: var(--ink2); }
.link-hint i { display: inline-block; width: 0.75em; height: 0.75em; border-radius: 50%; margin: 0 0.3em 0 0; vertical-align: -0.05em; }
.brief-go { display: flex; align-items: center; justify-content: space-between; column-gap: calc(var(--u) * 0.6); row-gap: calc(var(--u) * 0.4); margin-top: auto; flex-wrap: wrap; }
#goBtn { margin-left: auto; }
.hard { color: #f1dcb4; display: flex; align-items: center; gap: 0.4em; }
.hard small { opacity: 0.7; font-size: 0.8em; }
.hard input { width: 1.2em; height: 1.2em; accent-color: var(--red); }

/* ---------------------------------------------------------------- battle hud */
#hud { position: fixed; inset: 0; z-index: 5; pointer-events: none; }
#hud > * { position: absolute; }
#hud button { pointer-events: auto; }
/* the book plate: one paper label glued under the top edge, stamp-cut at the bottom */
.top-left {
  left: calc(var(--u) * 0.8 + var(--safe-l)); top: 0; display: flex; align-items: center;
  padding: calc(var(--u) * 0.55) calc(var(--u) * 0.6) calc(var(--u) * 0.85);
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.5));
}
.top-left::before {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(#a8321f, #a8321f) top / 100% calc(var(--u) * 0.32) no-repeat, url(assets/ui/grain.svg), linear-gradient(#fbf1d8, #e6d0a3);
  -webkit-mask: radial-gradient(circle calc(var(--u) * 0.32) at 50% 100%, transparent 96%, #000) bottom / calc(var(--u) * 0.9) 100% repeat-x;
  mask: radial-gradient(circle calc(var(--u) * 0.32) at 50% 100%, transparent 96%, #000) bottom / calc(var(--u) * 0.9) 100% repeat-x;
}
.res {
  position: relative; display: flex; align-items: center; gap: 0.25em; height: calc(var(--u) * 2.3); padding: 0 calc(var(--u) * 0.6);
  font-size: calc(var(--u) * 1.3); color: var(--ink);
}
.res + .res { border-left: 2px dotted rgba(90, 62, 40, 0.45); }
.res img { height: 115%; margin: -10% 0; filter: drop-shadow(0 2px 1px rgba(0, 0, 0, 0.3)); }
.res span { font-size: 0.7em; color: var(--ink2); }
.res.bump { animation: bump 0.35s; }
.res.hurt { animation: hurt 0.45s; }
@keyframes bump { 40% { transform: scale(1.12); } }
@keyframes hurt { 20%, 60% { transform: translateX(-4px); background: #f2b3a0; } 40%, 80% { transform: translateX(4px); } }
/* cloth index tabs hanging from the top edge of the book */
.top-right { right: calc(var(--u) * 0.8 + var(--safe-r)); top: 0; display: flex; gap: calc(var(--u) * 0.3); filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.5)); }
.round {
  width: calc(var(--u) * 3); height: calc(var(--u) * 3.6); padding-top: calc(var(--u) * 0.4); border-radius: 0 0 calc(var(--u) * 0.6) calc(var(--u) * 0.6);
  font-size: calc(var(--u) * 1.1); color: #fff3dc; text-shadow: 0 1px 0 rgba(40, 10, 0, 0.6);
  background: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.07) 0 2px, transparent 2px 4px), linear-gradient(#c24a33, #8c2a18);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.22), inset 0 0 0 1px rgba(255, 220, 180, 0.25), inset 0 calc(var(--u) * -0.55) 0 -1px rgba(255, 230, 190, 0.0);
  outline: 1px dashed rgba(255, 225, 185, 0.45); outline-offset: calc(var(--u) * -0.3);
  transform-origin: top; transition: transform 0.15s;
}
#pauseBtn { background: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.07) 0 2px, transparent 2px 4px), linear-gradient(#5b8a55, #36593a); }
.round:hover { transform: scaleY(1.08); }
.round:active { transform: scaleY(0.92); }
#bossBar { left: 50%; top: calc(var(--u) * 0.6); transform: translateX(-50%); display: flex; align-items: center; gap: calc(var(--u) * 0.5); width: min(40vw, calc(var(--u) * 30)); }
#bossBar img { width: calc(var(--u) * 3.4); height: calc(var(--u) * 3.4); border-radius: 50%; object-fit: cover; background: #2a1a12; box-shadow: 0 0 0 2px #d9b070, 0 0 0 4px #3a1a0c; }
#bossBar > div { flex: 1; color: #fff1d6; text-shadow: 0 1px 2px #000; font-size: calc(var(--u) * 0.95); }
#bossBar .bar { height: calc(var(--u) * 0.85); background: rgba(30, 10, 6, 0.8); border-radius: 999px; box-shadow: 0 0 0 2px #3a1a0c, inset 0 1px 2px #000; overflow: hidden; margin-top: 2px; }
#bossBar .bar i { display: block; height: 100%; width: 100%; background: linear-gradient(#ff8a6a, #b8291a); transition: width 0.2s; }

.bottom-left { left: calc(var(--u) * 0.8 + var(--safe-l)); bottom: calc(var(--u) * 0.7 + var(--safe-b)); display: flex; align-items: flex-end; gap: calc(var(--u) * 0.4); }
#heroCard {
  position: relative; width: calc(var(--u) * 5.4); height: calc(var(--u) * 5.4); border-radius: 50%;
  background: url(assets/ui/rim.webp) center / 100% 100% no-repeat; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.5)); transition: transform 0.15s;
}
#heroCard img { position: absolute; inset: 13%; width: 74%; height: 74%; border-radius: 50%; object-fit: cover; object-position: 30% 10%; }
#heroCard.sel { transform: scale(1.06); filter: drop-shadow(0 0 10px rgba(255, 220, 140, 0.95)); }
#heroCard .lvl { position: absolute; right: -2%; top: -4%; width: 36%; height: 36%; border-radius: 50%; background: radial-gradient(circle at 40% 30%, #ffe9a8, #d29a32); box-shadow: 0 0 0 2px #5a3410; display: grid; place-items: center; font-size: calc(var(--u) * 1); }
#heroCard .dead { position: absolute; inset: 13%; border-radius: 50%; background: rgba(20, 10, 6, 0.7); color: #fff; display: grid; place-items: center; font-size: calc(var(--u) * 1.6); }
#heroCard .dead:empty { display: none; }
#heroCard .hp { position: absolute; left: 14%; right: 14%; bottom: -6%; height: calc(var(--u) * 0.55); border-radius: 999px; background: #2a1a10; box-shadow: 0 0 0 1.5px #2a1a10; overflow: hidden; }
#heroCard .hp i { display: block; height: 100%; background: linear-gradient(#a6ef8a, #4f9d3c); }
/* the skill is a cloth bookmark sticking out of the bottom of the book */
#heroSkill {
  position: relative; width: calc(var(--u) * 3.5); height: calc(var(--u) * 6.6); overflow: hidden;
  display: flex; justify-content: center; padding-top: calc(var(--u) * 0.6); color: #fff3dc; text-shadow: 0 1px 0 rgba(40, 10, 0, 0.6);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 85%, 0 100%);
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.07) 0 1px, transparent 1px 3px), linear-gradient(90deg, #8c2416, #cc4630 45%, #a8321f);
  box-shadow: inset 2px 0 0 rgba(0, 0, 0, 0.2), inset -2px 0 0 rgba(0, 0, 0, 0.2);
  transform-origin: bottom; transition: transform 0.15s;
}
#heroSkill:active { transform: scaleY(0.94); }
#heroSkill em { position: relative; z-index: 1; font-style: normal; font-size: calc(var(--u) * 0.9); line-height: 1.15; writing-mode: vertical-rl; letter-spacing: 0.08em; }
#heroSkill .cd { position: absolute; inset: 0; background: linear-gradient(rgba(25, 12, 6, 0.62) var(--p, 0%), transparent 0); }
#heroSkill.ready::after { content: ''; position: absolute; inset: 0; background: linear-gradient(170deg, transparent 35%, rgba(255, 232, 170, 0.6) 48%, transparent 60%) 0 0 / 100% 300%; animation: sheen 1.8s linear infinite; }
@keyframes sheen { from { background-position: 0 100%; } to { background-position: 0 -200%; } }

.bottom-right { right: 0; bottom: 0; display: flex; align-items: flex-end; filter: drop-shadow(-3px -3px 5px rgba(0, 0, 0, 0.45)); }
/* who comes next: a paper slip tucked under the turning corner */
#preview {
  display: flex; gap: calc(var(--u) * 0.3); align-items: flex-end; margin: 0 calc(var(--u) * -0.4) calc(var(--u) * 0.7 + var(--safe-b)) 0;
  padding: calc(var(--u) * 0.4) calc(var(--u) * 1) calc(var(--u) * 0.4) calc(var(--u) * 0.5); border-radius: 3px; transform: rotate(-1.5deg);
  background: url(assets/ui/grain.svg), linear-gradient(#fbf1d8, #e6d0a3); box-shadow: 0 0 0 1.5px #8a6440, 0 4px 8px rgba(0, 0, 0, 0.45); pointer-events: auto;
}
#preview:empty { display: none; }
#preview .pv { position: relative; cursor: pointer; width: calc(var(--u) * 2.7); text-align: center; color: var(--ink); font-size: calc(var(--u) * 0.72); line-height: 1; }
#preview .pv img { width: calc(var(--u) * 2.5); height: calc(var(--u) * 2.5); border-radius: 50%; background: radial-gradient(#fff6e2, #cdb38a); box-shadow: 0 0 0 1.5px #8a6440; display: block; margin: 0 auto 2px; object-fit: cover; }
#preview .pv b { position: absolute; right: 0; top: calc(var(--u) * 1.6); color: #fff3dc; background: var(--red); border-radius: 999px; padding: 0 0.3em; }
#preview .pv .tags { display: flex; justify-content: center; gap: 1px; margin-top: 1px; }
#preview .pv .tag { font-size: calc(var(--u) * 0.56); min-width: 0; }
#preview .lbl { writing-mode: vertical-rl; color: var(--red); font-size: calc(var(--u) * 0.7); align-self: center; }
/* the next chapter: the dog-eared corner of the page, pulled to turn it */
#waveBtn {
  --s: calc(var(--u) * 11.5);
  position: relative; width: var(--s); height: var(--s); color: var(--ink);
  /* cut the button itself to the corner so taps on the see-through half reach the board below */
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
  transition: width 0.3s cubic-bezier(.3,1.5,.5,1), height 0.3s cubic-bezier(.3,1.5,.5,1), filter 0.2s;
}
#waveBtn::before {
  content: ''; position: absolute; inset: 0; clip-path: polygon(100% 0, 100% 100%, 0 100%);
  background:
    linear-gradient(to bottom right, transparent 50%, rgba(60, 30, 10, 0.55) 50.3%, rgba(150, 110, 60, 0.4) 53%, transparent 62%),
    url(assets/ui/grain.svg),
    linear-gradient(to bottom right, #d5b98a 50%, #efdfba 64%, #fff8e6 100%);
}
#waveBtn .lab {
  position: absolute; left: 33%; top: calc(66.7% - 1.25em); width: 66%; transform: rotate(-45deg);
  display: flex; flex-direction: column; align-items: center; line-height: 1.05;
}
#waveBtn b { font: 400 calc(var(--u) * 1.9) var(--brush); line-height: 1; color: var(--red); }
#waveBtn small { font-size: calc(var(--u) * 0.72); color: var(--ink2); }
#waveBtn:hover:not(:disabled), #waveBtn.early { --s: calc(var(--u) * 12.5); }
#waveBtn.idle { animation: curl 1.6s ease-in-out infinite; }
#waveBtn:disabled { --s: calc(var(--u) * 8); cursor: default; filter: saturate(0.6); }
#waveBtn:disabled b { font-size: calc(var(--u) * 1.4); color: var(--ink2); }
#waveBtn:active:not(:disabled) { --s: calc(var(--u) * 12); }
@keyframes curl { 50% { width: calc(var(--u) * 13); height: calc(var(--u) * 13); } }
#heroHint { left: 50%; bottom: calc(var(--u) * 7 + var(--safe-b)); transform: translateX(-50%); padding: 0.4em 1.1em; border-radius: 3px; background: url(assets/ui/grain.svg), linear-gradient(#fbf1d8, #e6d0a3); color: var(--ink); box-shadow: 0 0 0 1.5px #8a6440, 0 4px 8px rgba(0, 0, 0, 0.45); white-space: nowrap; }
/* first-play guide: a torn paper note pinned under the top edge; the note lets taps through, its buttons don't */
#guide {
  left: 50%; bottom: calc(var(--u) * 0.8 + var(--safe-b)); transform: translateX(-50%) rotate(-0.8deg); z-index: 1;
  width: min(36vw, calc(var(--u) * 30)); padding: calc(var(--u) * 0.55) calc(var(--u) * 0.9) calc(var(--u) * 0.5);
  border-radius: 3px; pointer-events: none; color: var(--ink); font-size: calc(var(--u) * 0.9); line-height: 1.4;
  background: linear-gradient(#a8321f, #a8321f) top / 100% calc(var(--u) * 0.25) no-repeat, url(assets/ui/grain.svg), linear-gradient(#fbf1d8, #e6d0a3);
  box-shadow: 0 0 0 1.5px #8a6440, 0 4px 8px rgba(0, 0, 0, 0.45); animation: noteIn 0.35s cubic-bezier(.2,1.3,.4,1);
}
#guide small { display: block; color: var(--red); font-size: calc(var(--u) * 0.72); }
#guide p { margin: 0.1em 0 0.3em; word-break: keep-all; }
#guide.ok p { color: #2f7a3a; font-size: calc(var(--u) * 1.15); }
#guide.ok .g-row { visibility: hidden; }
#guide .g-row { display: flex; justify-content: flex-end; gap: 0.5em; }
#guide .g-row button { font-size: calc(var(--u) * 0.78); padding: 0.15em 0.7em; border-radius: 999px; color: var(--ink2); box-shadow: inset 0 0 0 1.5px rgba(90, 62, 40, 0.6); background: rgba(255, 250, 235, 0.6); }
@keyframes noteIn { from { opacity: 0; transform: translate(-50%, 10px) rotate(-3deg); } }
.nudge { animation: nudge 1.1s ease-in-out infinite !important; }
@keyframes nudge { 50% { transform: translateY(calc(var(--u) * -0.5)) scale(1.06); } }
@media (max-aspect-ratio: 1/1) {
  #guide { bottom: auto; top: calc(var(--u) * 7.6); width: min(92vw, calc(var(--u) * 34)); }
}

/* star rules and the endless challenge on the briefing / result card */
/* both difficulties' stars by the title */
.goals h3 { gap: 0.5em; align-items: baseline; }
.goals h3 small { display: flex; flex-wrap: wrap; justify-content: flex-end; column-gap: 0.7em; font-size: calc(var(--u) * 0.78); color: var(--red); }
.star-goals { list-style: none; margin: 0; padding: 0; font-size: calc(var(--u) * 0.85); color: var(--ink2); text-align: left; }
.star-goals li { display: flex; gap: 0.5em; align-items: baseline; }
.star-goals li i { flex: none; width: 3.4em; font-style: normal; color: #c7b494; letter-spacing: -1px; }
.star-goals li.on { color: var(--ink); }
.star-goals li.on i { color: #e09a1c; text-shadow: 0 0 4px rgba(255, 180, 60, 0.6); }
.star-goals li.note { font-size: 0.85em; opacity: 0.8; padding-left: 3.9em; }
#resGoals { display: inline-block; margin: 0.2em 0 0.3em; }
#resGoals:empty { display: none; }
.challenge { display: flex; gap: calc(var(--u) * 0.8); align-items: center; justify-content: space-between; margin-top: calc(var(--u) * 0.6); padding-top: calc(var(--u) * 0.5); border-top: 2px dotted rgba(90, 62, 40, 0.4); }
.challenge b { color: var(--red); }
.challenge p { margin: 0.1em 0; font-size: calc(var(--u) * 0.78); color: var(--ink2); }
.challenge small { color: var(--ink); }
.challenge button { flex: none; }
.challenge button:disabled { opacity: 0.45; cursor: default; }
.challenge.locked b { color: var(--ink2); }
.spine .best { position: absolute; left: -20%; right: -20%; top: -8%; text-align: center; font-size: calc(var(--u) * 0.72); color: #fff3dc; white-space: nowrap; text-shadow: 0 1px 0 #000; }
#resStars .pages { font: 400 calc(var(--u) * 3.6) var(--brush); color: var(--red); }

/* ---------------------------------------------------------------- side page */
#panel {
  position: fixed; z-index: 8; top: calc(var(--u) * 4.2); max-height: calc(100vh - var(--u) * 11.2 - var(--safe-b)); max-height: calc(100dvh - var(--u) * 11.2 - var(--safe-b)); width: min(42vw, calc(var(--u) * 25));
  display: flex; flex-direction: column; overflow: hidden;
  background: url(assets/ui/grain.svg), linear-gradient(100deg, #e5d0a5 0%, #f6ebd1 8%, #f3e6c8 70%, #e9d6af 100%);
  border-radius: calc(var(--u) * 0.7); box-shadow: 0 0 0 2px #8a6440, 0 0 0 4px #2a170b, 0 10px 30px rgba(0, 0, 0, 0.55);
  animation: panelIn 0.22s cubic-bezier(.2,1.3,.4,1);
}
#panel::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: calc(var(--u) * 0.32); background: #a8321f; z-index: 1; }
#panel.right { right: calc(var(--u) * 0.8 + var(--safe-r)); }
#panel.left { left: calc(var(--u) * 0.8 + var(--safe-l)); }
@keyframes panelIn { from { opacity: 0; transform: translateY(10px) scale(0.97); } }
@media (max-aspect-ratio: 1/1) {
  #panel { left: calc(var(--u) * 0.6) !important; right: calc(var(--u) * 0.6) !important; width: auto; top: auto; bottom: calc(var(--u) * 0.6 + var(--safe-b)); max-height: 48vh; }
}
#panel .close { position: absolute; right: calc(var(--u) * 0.5); top: calc(var(--u) * 0.4); width: calc(var(--u) * 2.2); height: calc(var(--u) * 2.2); border-radius: 50%; color: var(--ink2); z-index: 2; }
#panelBody { overflow-y: auto; touch-action: pan-y; padding: calc(var(--u) * 0.9); flex: 1; }
.p-head { display: flex; gap: calc(var(--u) * 0.7); align-items: flex-end; padding-right: calc(var(--u) * 2); }
.p-head .art { width: calc(var(--u) * 5); height: calc(var(--u) * 6.6); flex: none; object-fit: contain; object-position: bottom; background: radial-gradient(60% 40% at 50% 92%, rgba(90, 60, 30, 0.25), transparent); }
.p-head h3 { margin: 0; font: 400 calc(var(--u) * 2) var(--brush); line-height: 1; }
.p-head .sub { color: var(--ink2); font-size: calc(var(--u) * 0.8); }
.lvstars { color: rgba(90, 62, 40, 0.25); letter-spacing: 1px; } .lvstars .on { color: #e09a1c; text-shadow: 0 0 4px rgba(255, 180, 60, 0.6); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 0.4em 0; }
.stats div { background: rgba(120, 80, 40, 0.12); border-radius: 6px; padding: 0.2em 0.4em; font-size: calc(var(--u) * 0.72); color: var(--ink2); }
.stats b { display: block; font-size: calc(var(--u) * 1.05); color: var(--ink); }
.stats b em { font-style: normal; color: #2f8a3a; font-size: 0.8em; }
.linkline { margin: 0.3em 0; padding: 0.35em 0.6em; border-radius: 8px; font-size: calc(var(--u) * 0.78); background: rgba(255, 210, 120, 0.3); box-shadow: inset 0 0 0 1px rgba(160, 110, 40, 0.4); }
.linkline.off { background: transparent; color: #8a7058; box-shadow: inset 0 0 0 1px rgba(140, 110, 80, 0.3); }
.act { display: flex; align-items: center; justify-content: space-between; gap: 0.6em; width: 100%; margin-top: 0.45em; padding: 0.55em 0.8em; border-radius: 10px; text-align: left; background: linear-gradient(#fff8e6, #ecd8b0); box-shadow: 0 0 0 1.5px #9a7650, 0 2px 0 #7a5636; }
.act:active { transform: translateY(1px); box-shadow: 0 0 0 1.5px #9a7650; }
.act .cost { display: flex; align-items: center; gap: 0.15em; white-space: nowrap; font-size: calc(var(--u) * 1.05); }
.act .cost img { width: 1.3em; }
.act small { display: block; color: var(--ink2); font-size: calc(var(--u) * 0.74); }
.act.poor { filter: grayscale(0.5); opacity: 0.6; }
.act.poor .cost { color: var(--red); }
.act.gold { background: linear-gradient(#fff2c8, #f0cf7c); box-shadow: 0 0 0 1.5px #b8862c, 0 2px 0 #8a5a14; }
.act.skill { background: linear-gradient(#ffe9d6, #f2c6a0); }
.act.skill.cooling { filter: grayscale(0.6); opacity: 0.7; }
.act.sell { background: transparent; box-shadow: inset 0 0 0 1.5px rgba(140, 100, 60, 0.6); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.45em; }
.row2 .act { margin-top: 0; }
.specs h4, .p-sec { margin: 0.8em 0 0.2em; font-size: calc(var(--u) * 0.85); color: var(--red); }
.specs .act { flex-direction: column; align-items: stretch; }
.specs .act .top { display: flex; justify-content: space-between; }
.chosen { margin-top: 0.4em; padding: 0.4em 0.6em; border-radius: 10px; background: linear-gradient(#fff2c8, #f0cf7c); box-shadow: 0 0 0 1.5px #b8862c; font-size: calc(var(--u) * 0.8); }
.chosen b { display: block; font-size: calc(var(--u) * 1); }

/* build grid */
.b-title { margin: 0 0 0.4em; padding-right: calc(var(--u) * 2); font-size: calc(var(--u) * 1); }
.bgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(calc(var(--u) * 6.4), 1fr)); gap: calc(var(--u) * 0.45); }
.bcard { position: relative; aspect-ratio: 3 / 4; border-radius: 10px; overflow: hidden; background: linear-gradient(#fff8e8, #e9d3a8); box-shadow: 0 0 0 1.5px #9a7650, 0 2px 0 #7a5636; }
.bcard img { position: absolute; left: 6%; right: 6%; top: 4%; bottom: 26%; width: 88%; height: 70%; object-fit: contain; object-position: bottom; }
.bcard .nm { position: absolute; left: 0; right: 0; bottom: 14%; text-align: center; font-size: calc(var(--u) * 0.66); line-height: 1.1; }
.bcard .cost { position: absolute; left: 0; right: 0; bottom: 1%; display: flex; justify-content: center; align-items: center; gap: 2px; font-size: calc(var(--u) * 0.86); }
.bcard .cost img { position: static; width: 1.2em; height: auto; }
.bcard .rl { position: absolute; left: 4px; top: 4px; font-size: calc(var(--u) * 0.58); color: #fff; background: rgba(60, 36, 20, 0.75); padding: 0 0.35em; border-radius: 999px; }
.bcard.poor { filter: grayscale(0.9); opacity: 0.55; }
.bcard.poor .cost { color: var(--red); }
.bcard.on { box-shadow: 0 0 0 3px var(--red), 0 0 14px rgba(184, 64, 44, 0.6); }
.bcard.link::after { content: '이음'; position: absolute; right: 4px; top: 4px; font-size: calc(var(--u) * 0.58); background: #e0a63a; color: #3a1a08; padding: 0 0.35em; border-radius: 999px; }
.bdesc { margin-top: 0.6em; padding: 0.5em 0.7em; border-radius: 10px; background: rgba(120, 80, 40, 0.1); font-size: calc(var(--u) * 0.8); color: var(--ink2); }
.bdesc b { color: var(--ink); font-size: calc(var(--u) * 0.95); }
.bdesc .go { margin-top: 0.4em; }

/* ---------------------------------------------------------------- moments */
#banner { position: fixed; z-index: 9; left: 50%; top: 24%; transform: translateX(-50%); text-align: center; pointer-events: none; color: #fff2d6; text-shadow: 0 2px 0 #3a1a08, 0 0 20px rgba(0, 0, 0, 0.6); animation: banner 2.2s forwards; }
#banner b { display: block; font: 400 calc(var(--u) * 4.4) var(--brush); line-height: 1; }
#banner small { display: block; font-size: calc(var(--u) * 1); color: var(--gold); }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, 12px) scale(0.9); letter-spacing: 0.3em; } 15% { opacity: 1; transform: translate(-50%, 0) scale(1); letter-spacing: 0.05em; } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -10px); } }
#cutin { position: fixed; z-index: 9; left: 0; right: 0; top: 30%; pointer-events: none; }
#cutin .band { display: flex; align-items: center; gap: calc(var(--u) * 1); height: calc(var(--u) * 6); padding-left: 12vw; background: linear-gradient(90deg, rgba(40, 20, 10, 0), rgba(40, 20, 10, 0.85) 20%, rgba(40, 20, 10, 0.85) 70%, rgba(40, 20, 10, 0)); animation: cutin 1.3s cubic-bezier(.2,.9,.3,1) forwards; }
#cutin img { height: calc(var(--u) * 8.5); margin-bottom: calc(var(--u) * 2.4); filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.6)); }
#cutin small { display: block; color: var(--gold); font-size: calc(var(--u) * 0.9); }
#cutin b { color: #fff2d6; font: 400 calc(var(--u) * 3) var(--brush); line-height: 1; }
@keyframes cutin { 0% { transform: translateX(-30vw); opacity: 0; } 18% { transform: translateX(0); opacity: 1; } 72% { transform: translateX(3vw); opacity: 1; } 100% { transform: translateX(30vw); opacity: 0; } }
#bossIntro { position: fixed; z-index: 9; inset: 0; display: flex; align-items: center; justify-content: center; gap: calc(var(--u) * 1.5); pointer-events: none; background: radial-gradient(closest-side, rgba(60, 10, 0, 0.6), rgba(0, 0, 0, 0) 100%); animation: bossin 3s forwards; }
#bossIntro img { width: calc(var(--u) * 11); height: calc(var(--u) * 11); border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 4px #d9b070, 0 0 0 8px #3a1a0c, 0 0 40px rgba(255, 90, 40, 0.6); animation: bossimg 3s; }
#bossIntro small { color: var(--gold); font-size: calc(var(--u) * 1); }
#bossIntro b { display: block; color: #fff2d6; font: 400 calc(var(--u) * 4.4) var(--brush); line-height: 1; text-shadow: 0 3px 0 #3a1a08; }
#bossIntro p { margin: 0.3em 0 0; color: #f1d8b0; max-width: 22em; }
@keyframes bossin { 0% { opacity: 0; } 10% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; } }
@keyframes bossimg { 0% { transform: scale(1.6) rotate(-8deg); } 14% { transform: scale(1) rotate(0); } }
#toast { position: fixed; z-index: 9; left: 50%; top: calc(var(--u) * 4.4); transform: translateX(-50%); max-width: 80vw; padding: 0.45em 1.1em; border-radius: 3px; background: url(assets/ui/grain.svg), linear-gradient(#fbf1d8, #e6d0a3); color: var(--ink); box-shadow: 0 0 0 1.5px #8a6440, 0 4px 10px rgba(0, 0, 0, 0.5); pointer-events: none; text-align: center; animation: toast 2.6s forwards; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, -8px); } 10%, 85% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }

/* overlays */
.overlay { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(15, 8, 4, 0.6); backdrop-filter: blur(3px); }
.overlay .card { padding: calc(var(--u) * 1.4) calc(var(--u) * 2.2); text-align: center; min-width: min(80vw, calc(var(--u) * 24)); max-width: 90vw; animation: panelIn 0.3s; }
.overlay h2 { margin: 0 0 0.4em; font: 400 calc(var(--u) * 2.8) var(--brush); line-height: 1; }
.overlay .col { display: flex; flex-direction: column; gap: 0.6em; align-items: center; }
.overlay .row { display: flex; gap: 0.6em; justify-content: center; flex-wrap: wrap; margin-top: 0.8em; }
#resBook { color: var(--red); }
#resStars { display: flex; justify-content: center; gap: 0.3em; font-size: calc(var(--u) * 3); line-height: 1; margin: 0.1em 0 0.2em; }
#resStars span { color: #c7b494; text-shadow: 0 2px 0 #6a5440; }
#resStars span.on { color: #ffcf5a; text-shadow: 0 2px 0 #8a5a14, 0 0 18px rgba(255, 200, 90, 0.8); animation: starpop 0.5s backwards; }
#resStars span:nth-child(2) { animation-delay: 0.25s; } #resStars span:nth-child(3) { animation-delay: 0.5s; }
@keyframes starpop { 0% { transform: scale(2.4) rotate(-30deg); opacity: 0; } 70% { transform: scale(0.9); } }
#resText { margin: 0.2em 0; color: var(--ink2); }
#resStats { display: grid; grid-template-columns: repeat(3, auto); justify-content: center; gap: 0 1.4em; margin: 0.4em 0 0; }
#resStats dt { font-size: 0.75em; color: var(--ink2); grid-row: 1; }
#resStats dd { margin: 0; font-size: 1.3em; grid-row: 2; }
.bar { height: calc(var(--u) * 0.8); border-radius: 999px; background: rgba(60, 40, 20, 0.25); overflow: hidden; margin-top: 0.6em; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #c8402c, #e9925a); transition: width 0.15s; }

/* ---------------------------------------------------------------- the settings card */
.set-card { width: min(92vw, calc(var(--u) * 30)); max-height: 92vh; max-height: 92dvh; overflow-y: auto; touch-action: pan-y; }
.set-rows { display: flex; flex-direction: column; gap: calc(var(--u) * 0.7); text-align: left; }
.set-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: calc(var(--u) * 0.8); padding-bottom: calc(var(--u) * 0.6); border-bottom: 2px dotted rgba(90, 62, 40, 0.35); }
.set-row:has(input[type=range]) { grid-template-columns: calc(var(--u) * 6.5) minmax(0, 1fr) calc(var(--u) * 2); }
.set-row small { display: block; font-size: calc(var(--u) * 0.75); color: var(--ink2); }
.set-row output { text-align: right; color: var(--ink2); font-size: calc(var(--u) * 0.85); }
.set-row input[type=range] { width: 100%; accent-color: var(--red); }
.set-row input[type=checkbox] { width: 1.4em; height: 1.4em; accent-color: var(--red); }
.set-row.check { cursor: pointer; }
.seg { display: flex; border-radius: 999px; box-shadow: inset 0 0 0 2px var(--ink2); overflow: hidden; }
.seg button { padding: 0.35em 0.9em; color: var(--ink2); }
.seg button.on { background: var(--red); color: #fff3dc; }
.set-row.reset .line-btn { color: var(--red); box-shadow: inset 0 0 0 2px var(--red); padding: 0.4em 1em; }
.set-confirm { display: flex; flex-direction: column; align-items: center; gap: 0.5em; padding: 0.6em; border-radius: 10px; background: rgba(184, 64, 44, 0.12); }
.set-confirm > div { display: flex; gap: 0.6em; }
.set-confirm .seal-btn { font-size: calc(var(--u) * 1); padding: calc(var(--u) * 0.5) calc(var(--u) * 1.4); }
#settings { z-index: 25; }

/* ---------------------------------------------------------------- English: longer words, Latin line breaking */
html:lang(en) .spine .label { text-orientation: sideways; }
html:lang(en) .pick.new::after { content: 'New'; }
html:lang(en) .bcard.link::after { content: 'Link'; }
html:lang(en) .foe, html:lang(en) #guide p { word-break: normal; overflow-wrap: break-word; }
html:lang(en) .pick .nm, html:lang(en) .bcard .nm { padding: 0 2px; }
html:lang(en) #heroSkill em { letter-spacing: 0.02em; }
html:lang(en) #heroHint { white-space: normal; max-width: 80vw; text-align: center; }
/* a phone cannot fit the page (sideways, or upright with the longer English text): the start row rides along the bottom edge while it scrolls */
@media (min-aspect-ratio: 1/1) and (max-height: 520px), (max-width: 600px) {
  .brief-go { position: sticky; bottom: 0; z-index: 2; margin: 0 calc(var(--u) * -0.4); padding: calc(var(--u) * 0.5) calc(var(--u) * 0.4) calc(var(--u) * 0.3 + var(--safe-b)); background: linear-gradient(rgba(30, 18, 10, 0), rgba(30, 18, 10, 0.92) 35%); }
}

/* ================================================================ player info: guardian numbers (DPS, before → after) */
#panelBody .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.act small.delta { margin-top: 0.15em; color: #3c5a2a; line-height: 1.35; }
.act small.delta span { white-space: nowrap; margin-right: 0.5em; }
.act small.delta b { color: #2f7a3a; }
.specs .act small.delta { border-top: 1px dotted rgba(90, 62, 40, 0.35); padding-top: 0.15em; }

/* ================================================================ player info: first-meeting cards */
#tipCard { position: fixed; inset: 0; z-index: 15; display: grid; place-items: center; background: rgba(15, 8, 4, 0.35); cursor: pointer; }
#tipCard .tc {
  width: min(88vw, max(calc(var(--u) * 26), 320px)); max-height: 86vh; max-height: 86dvh; overflow-y: auto; touch-action: pan-y;
  padding: calc(var(--u) * 0.9) calc(var(--u) * 1.2); text-align: left; transform: rotate(-1deg); animation: noteCardIn 0.3s cubic-bezier(.2,1.3,.4,1);
}
@keyframes noteCardIn { from { opacity: 0; transform: translateY(12px) rotate(-4deg) scale(0.94); } }
#tcKind { display: block; color: var(--red); }
.tc-head { display: flex; gap: calc(var(--u) * 0.8); align-items: center; margin: 0.2em 0 0.3em; }
.tc-head img { flex: none; width: calc(var(--u) * 5); height: calc(var(--u) * 5.6); object-fit: contain; object-position: bottom; }
.tc.villain .tc-head img { height: calc(var(--u) * 5); border-radius: 50%; object-fit: cover; background: radial-gradient(#fff6e2, #cdb38a); box-shadow: 0 0 0 2px #8a6440; }
#tcName { display: block; font: 400 calc(var(--u) * 2.2) var(--brush); line-height: 1.05; }
#tcTags { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 0.2em; }
#tcText { margin: 0.2em 0; white-space: pre-line; font-size: max(calc(var(--u) * 0.85), 11px); color: var(--ink2); word-break: keep-all; }
#tcText:empty { display: none; }
#tcTip { margin: 0.3em 0; padding: 0.35em 0.6em; border-radius: 8px; font-size: max(calc(var(--u) * 0.88), 12px); background: rgba(255, 210, 120, 0.32); box-shadow: inset 0 0 0 1px rgba(160, 110, 40, 0.4); word-break: keep-all; }
#tcTap { display: block; margin-top: 0.4em; text-align: center; color: var(--red); font-size: max(calc(var(--u) * 0.74), 10px); }
#tcKind, #tcTags .tag { font-size: max(calc(var(--u) * 0.74), 10px); }
html:lang(en) #tcText, html:lang(en) #tcTip { word-break: normal; overflow-wrap: break-word; }

/* ================================================================ player info: the villain sheet */
#foeSheet {
  position: fixed; z-index: 8; left: calc(var(--u) * 0.8 + var(--safe-l)); top: calc(var(--u) * 4.6);
  width: min(62vw, calc(var(--u) * 21)); max-height: calc(100vh - var(--u) * 12 - var(--safe-b)); max-height: calc(100dvh - var(--u) * 12 - var(--safe-b));
  overflow-y: auto; touch-action: pan-y; padding: calc(var(--u) * 0.8) calc(var(--u) * 0.9);
  background: url(assets/ui/grain.svg), linear-gradient(100deg, #e5d0a5 0%, #f6ebd1 8%, #f3e6c8 70%, #e9d6af 100%);
  border-radius: calc(var(--u) * 0.7); box-shadow: 0 0 0 2px #8a6440, 0 0 0 4px #2a170b, 0 10px 30px rgba(0, 0, 0, 0.55);
  animation: panelIn 0.22s cubic-bezier(.2,1.3,.4,1);
}
#foeSheet .close { position: absolute; right: calc(var(--u) * 0.4); top: calc(var(--u) * 0.3); width: calc(var(--u) * 2.2); height: calc(var(--u) * 2.2); border-radius: 50%; color: var(--ink2); }
.fs-head { display: flex; gap: calc(var(--u) * 0.6); align-items: center; padding-right: calc(var(--u) * 2); }
.fs-head img { flex: none; width: calc(var(--u) * 3.6); height: calc(var(--u) * 3.6); border-radius: 50%; object-fit: cover; background: radial-gradient(#fff6e2, #cdb38a); box-shadow: 0 0 0 2px #8a6440; }
.fs-head > div { flex: 1; min-width: 0; }
#fsName { display: block; font: 400 calc(var(--u) * 1.7) var(--brush); line-height: 1.05; }
.fs-head .bar { margin-top: 0.2em; height: calc(var(--u) * 0.6); }
.fs-head .bar i { width: 100%; background: linear-gradient(#ff8a6a, #b8291a); transition: none; }
#fsHpTxt { display: block; font-size: calc(var(--u) * 0.72); color: var(--ink2); }
#fsStats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#fsTraits, #fsTip { list-style: none; margin: 0.2em 0; padding: 0; font-size: max(calc(var(--u) * 0.78), 10.5px); color: var(--ink2); }
#fsTraits li + li, #fsTip li + li { margin-top: 0.2em; }
#fsTraits:empty { display: none; }
#foeSheet h4 { margin: 0.5em 0 0.1em; font-size: calc(var(--u) * 0.85); color: var(--red); }
#fsTip li { padding: 0.25em 0.5em; border-radius: 8px; color: var(--ink); background: rgba(255, 210, 120, 0.3); box-shadow: inset 0 0 0 1px rgba(160, 110, 40, 0.4); }
#foeSheet, #fsTip li { word-break: keep-all; }
html:lang(en) #foeSheet, html:lang(en) #fsTip li { word-break: normal; overflow-wrap: break-word; }
@media (max-aspect-ratio: 1/1) {
  #foeSheet { width: min(72vw, max(calc(var(--u) * 24), 260px)); }
}

/* ================================================================ a book that would not load: the reason and a retry on the loading card */
#loadFail { margin-top: 0.7em; text-align: center; }
#loadFail p { margin: 0 0 0.6em; font-size: calc(var(--u) * 0.9); color: var(--ink2); word-break: keep-all; }
/* back to the whole book (shown once the reader has zoomed or panned) */
#fitBtn { font-size: calc(var(--u) * 1.4); background: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.07) 0 2px, transparent 2px 4px), linear-gradient(#4f6f9a, #2f4a6e); }

/* ================================================================ replay challenges: Hard stars, Iron pages, Page of the Day, the guardians' tally */
/* the spine: Hard stars in red ink under the gold ones; the Iron seal stamped below the title */
.spine .hstars { position: absolute; left: 50%; bottom: 15%; transform: translateX(-50%); display: flex; gap: 1px; padding: 0.15em 0.35em; border-radius: 999px; background: rgba(30, 18, 10, 0.72); font-size: min(17cqw, calc(var(--u) * 0.8)); line-height: 1; color: #6a5440; }
.spine .hstars .on { color: #ff7a5c; text-shadow: 0 0 5px rgba(255, 110, 70, 0.7), 0 1px 0 #000; }
.iron-seal {
  display: inline-grid; place-items: center; border-radius: 50%; font-style: normal; line-height: 1; white-space: nowrap;
  color: #f4ece0; background: radial-gradient(circle at 35% 30%, #6d7a86, #3d4a55 70%); box-shadow: 0 0 0 1.5px #20262c, inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.spine .iron-seal { position: absolute; right: 2%; top: 44%; transform: rotate(-10deg); width: 42cqw; aspect-ratio: 1; font-size: min(20cqw, calc(var(--u) * 0.8)); }
html:lang(en) .spine .iron-seal { font-size: min(13cqw, calc(var(--u) * 0.6)); }
#resStars .iron-seal.big { width: calc(var(--u) * 4.4); height: calc(var(--u) * 4.4); font-size: calc(var(--u) * 1.3); transform: rotate(-8deg); filter: grayscale(1) opacity(0.5); }
#resStars .iron-seal.big.on { filter: none; animation: starpop 0.5s backwards; }
/* the briefing: the star rows by the title, and the Iron page row under the endless one */
.star-row { white-space: nowrap; color: var(--ink2); }
.star-row i { font-style: normal; color: #c7b494; }
.star-row i.on { color: #e09a1c; }
.star-row + .star-row i.on { color: #d2452c; }
.challenge.iron b { color: #3d4a55; }
.challenge.iron.locked b { color: var(--ink2); }
/* the shelf's Page of the Day chip */
.daily-chip.fresh { background: linear-gradient(#c8492f, #93301c); color: #fff3dc; box-shadow: 0 0 0 1px #5a1a0c, 0 0 10px rgba(255, 150, 90, 0.45); }
.daily-chip.locked { opacity: 0.6; }
/* the Page of the Day card */
.daily-card { width: min(92vw, calc(var(--u) * 28)); max-height: 94vh; max-height: 94dvh; overflow-y: auto; touch-action: pan-y; }
#dailyDate { color: var(--red); }
#dailyBook { margin: 0 0 0.4em; color: var(--ink2); font-size: calc(var(--u) * 0.85); }
.daily-mod { margin: 0.3em 0; padding: 0.5em 0.8em; border-radius: 10px; text-align: left; background: rgba(61, 74, 85, 0.12); box-shadow: inset 0 0 0 1px rgba(61, 74, 85, 0.35); font-size: calc(var(--u) * 0.85); color: var(--ink2); }
.daily-mod b { display: block; color: #3d4a55; font-size: calc(var(--u) * 1.05); }
.daily-budget { margin: 0.4em 0; }
.daily-rec { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.15em 0.8em; margin: 0.3em auto; width: fit-content; max-width: 100%; text-align: left; font-size: calc(var(--u) * 0.85); }
.daily-rec dt { color: var(--ink2); }
.daily-rec dd { margin: 0; }
.daily-note { margin: 0.4em 0 0; font-size: calc(var(--u) * 0.75); color: var(--ink2); }
.daily-card, .daily-mod { word-break: keep-all; }
html:lang(en) .daily-card, html:lang(en) .daily-mod { word-break: normal; overflow-wrap: break-word; }
/* the result card: the modifier played, and the three guardians who did the most */
#result .card { max-height: 96vh; max-height: 96dvh; overflow-y: auto; touch-action: pan-y; }
.star-goals li.mod { display: block; max-width: 30em; text-align: center; }
.star-goals li.mod b { color: #3d4a55; }
#resCast:empty, #resStars:empty { display: none; }
#resCast h3 { margin: 0.6em 0 0.3em; font-size: calc(var(--u) * 0.85); color: var(--red); }
#resCast ol { list-style: none; margin: 0 auto; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, calc(var(--u) * 9))); justify-content: center; gap: calc(var(--u) * 0.5); }
#resCast li { display: flex; flex-direction: column; align-items: center; min-width: 0; padding: 0.3em 0.4em 0.35em; border-radius: 8px; background: rgba(120, 80, 40, 0.1); box-shadow: inset 0 0 0 1px rgba(140, 110, 80, 0.3); }
#resCast li:first-child { background: rgba(255, 210, 120, 0.3); box-shadow: inset 0 0 0 1px rgba(160, 110, 40, 0.5); }
#resCast img { width: calc(var(--u) * 3.4); height: calc(var(--u) * 4); object-fit: contain; object-position: bottom; }
#resCast b { font-size: calc(var(--u) * 0.78); line-height: 1.15; max-width: 100%; overflow-wrap: anywhere; }
#resCast small { font-size: calc(var(--u) * 0.66); color: var(--ink2); line-height: 1.2; }
#resCast dl { width: 100%; margin: 0.2em 0 0; display: grid; grid-template-columns: auto auto; justify-content: space-between; gap: 0 0.3em; font-size: calc(var(--u) * 0.68); line-height: 1.3; }
#resCast dt { color: var(--ink2); text-align: left; }
#resCast dd { margin: 0; text-align: right; }
/* a short landscape screen: the portraits sit beside their names */
@media (min-aspect-ratio: 1/1) and (max-height: 520px) {
  #resCast h3 { margin-top: 0.3em; }
  #resCast ol { grid-template-columns: repeat(3, minmax(0, calc(var(--u) * 13))); }
  #resCast li { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 0.4em; align-items: center; text-align: left; }
  #resCast img { grid-row: 1 / 4; height: calc(var(--u) * 4.4); }
  #resCast b, #resCast small { justify-self: start; }
}
/* ================================================================ v6: reading the board, the cast notebook */
/* a story branch's mark, as on the guardian's stand: an ink tab with a disc (first branch) or a diamond (second) cut out */
.rk { position: relative; display: inline-block; width: 1.55em; height: 1em; margin-right: 0.35em; vertical-align: -0.15em; border-radius: 2px; background: #3a2a20; box-shadow: 0 0 0 2px #fbf4e2, 0 0 0 3px rgba(90, 62, 40, 0.7); }
.rk::after { content: ''; position: absolute; left: 50%; top: 50%; width: 0.52em; height: 0.52em; transform: translate(-50%, -50%); background: #f1e2c0; border-radius: 50%; }
.rk.rk-1::after { width: 0.5em; height: 0.62em; border-radius: 0; clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.p-head .sub .rk { font-size: 0.95em; }
/* the guardian page's running tally */
.tally { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 0.9em; row-gap: 0.1em; margin: 0.1em 0 0.35em; padding: 0.25em 0.5em; border-radius: 6px; border: 1.5px dashed rgba(90, 62, 40, 0.35); font-size: calc(var(--u) * 0.74); color: var(--ink2); }
.tally small { flex-basis: 100%; font-size: 0.9em; color: var(--red); }
.tally b { font-size: calc(var(--u) * 1); color: var(--ink); font-variant-numeric: tabular-nums; }
/* an upright phone: the battle's controls a size up, for thumbs (the board has the height to spare) */
@media (max-aspect-ratio: 3/4) {
  #hud, #panel, #foeSheet, #tipCard { --u: clamp(10px, 2.9vmin, 13px); }
}
/* the shelf's notebook */
.notebook-chip { background: rgba(255, 240, 210, 0.22); }
#notebook .nb-card { text-align: left; }
.nb-card { position: relative; display: flex; flex-direction: column; width: min(94vw, calc(var(--u) * 62)); height: min(90vh, calc(var(--u) * 46)); height: min(90dvh, calc(var(--u) * 46)); padding: calc(var(--u) * 1) calc(var(--u) * 1.2); text-align: left; }
.nb-card h2 { margin: 0 0 0.25em; padding-right: calc(var(--u) * 2.4); }
.nb-card .close { position: absolute; right: calc(var(--u) * 0.6); top: calc(var(--u) * 0.5); width: calc(var(--u) * 2.6); height: calc(var(--u) * 2.6); border-radius: 50%; color: var(--ink2); font-size: calc(var(--u) * 1.2); }
.nb-tabs { display: flex; gap: 0.5em; margin-bottom: 0.5em; border-bottom: 2px dotted rgba(90, 62, 40, 0.4); }
.nb-tabs button { padding: 0.35em 1em 0.3em; border-radius: 8px 8px 0 0; color: var(--ink2); background: rgba(120, 80, 40, 0.1); }
.nb-tabs button small { font-size: 0.78em; opacity: 0.85; }
.nb-tabs button.on { color: #fff3dc; background: var(--red); }
.nb-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: calc(var(--u) * 0.9); }
.nb-grid { overflow-y: auto; touch-action: pan-y; display: grid; grid-template-columns: repeat(auto-fill, minmax(calc(var(--u) * 5.4), 1fr)); align-content: start; gap: calc(var(--u) * 0.4); padding: 3px; }
.nb-tile { display: flex; flex-direction: column; align-items: center; padding: 0.25em 0.15em 0.2em; border-radius: 8px; background: rgba(255, 250, 235, 0.55); box-shadow: 0 0 0 1.5px rgba(140, 100, 60, 0.45); color: var(--ink); font-size: calc(var(--u) * 0.66); line-height: 1.15; text-align: center; word-break: keep-all; }
.nb-tile.on { background: #fff2c8; box-shadow: 0 0 0 2.5px var(--red); }
.nb-tile.unmet { background: rgba(120, 80, 40, 0.08); color: var(--ink2); }
.nb-tile .pic { display: grid; place-items: end center; width: 100%; height: calc(var(--u) * 4.6); border-radius: 6px 6px 0 0; }
.nb-tile .nm { margin-top: 0.15em; min-height: 2.3em; display: flex; align-items: center; }
.nb-card .pic { position: relative; overflow: hidden; }
.nb-card .pic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; object-position: 50% 100%; }
.nb-tile.unmet .pic img, .nb-head .pic.unmet img { filter: brightness(0) sepia(1) opacity(0.62); }
.nb-page { overflow-y: auto; touch-action: pan-y; padding: 0.4em 0.7em 0.6em; border-radius: 8px; background: rgba(255, 250, 235, 0.5); box-shadow: inset 0 0 0 1px rgba(140, 110, 80, 0.3); font-size: max(calc(var(--u) * 0.8), 11px); color: var(--ink2); word-break: keep-all; }
.nb-head { display: flex; gap: calc(var(--u) * 0.8); align-items: flex-end; }
.nb-head .pic { flex: none; display: grid; place-items: end center; width: calc(var(--u) * 6.4); height: calc(var(--u) * 7.4); }
.nb-name { display: block; font: 400 calc(var(--u) * 2) var(--brush); line-height: 1.05; color: var(--ink); }
.nb-head small { display: block; color: var(--red); }
.nb-tags { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 0.25em; }
.nb-page h4 { margin: 0.7em 0 0.15em; font-size: calc(var(--u) * 0.85); color: var(--red); }
.nb-desc { margin: 0.3em 0; }
.nb-desc b, .nb-list b { color: var(--ink); }
.nb-good { margin: 0.3em 0; padding: 0.3em 0.5em; border-radius: 8px; background: rgba(255, 210, 120, 0.3); box-shadow: inset 0 0 0 1px rgba(160, 110, 40, 0.4); color: var(--ink); }
.nb-list, .nb-tips { list-style: none; margin: 0; padding: 0; }
.nb-list li + li, .nb-tips li + li { margin-top: 0.3em; }
.nb-tips li { padding: 0.25em 0.5em; border-radius: 8px; color: var(--ink); background: rgba(255, 210, 120, 0.3); box-shadow: inset 0 0 0 1px rgba(160, 110, 40, 0.4); }
.nb-branches li { padding-left: 0.1em; }
.nb-branches b { margin-right: 0.3em; }
.nb-story { display: inline-block; width: 0.75em; height: 0.75em; border-radius: 50%; margin-right: 0.35em; vertical-align: -0.05em; }
html:lang(en) .nb-page, html:lang(en) .nb-tile { word-break: normal; overflow-wrap: break-word; }
@media (max-aspect-ratio: 1/1) {
  .nb-card { height: 92vh; height: 92dvh; padding: calc(var(--u) * 0.8); }
  .nb-body { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .nb-page { order: -1; max-height: 50vh; max-height: 50dvh; }
}
/* ---------------------------------------------------------------- v6: undo, the chapter to come back to, Easy */
.act.sell.undo { background: linear-gradient(#f4f0dc, #e2dcb8); box-shadow: inset 0 0 0 1.5px #6f8a4a; }
.act.sell.undo .cost { color: #4f6b2a; }
.resume-chip { background: linear-gradient(#5f7d44, #3f5a2c); color: #fff3dc; box-shadow: 0 0 0 1px #233515, 0 0 10px rgba(170, 220, 120, 0.35); max-width: 100%; white-space: normal; text-align: center; }
.hard.easy input { accent-color: #5f7d44; }
.spine .easy-mark { position: absolute; left: 50%; top: 56%; transform: translateX(-50%) rotate(-6deg); padding: 0.1em 0.4em; border-radius: 4px; background: #e9f0d6; color: #3f5a2c; box-shadow: 0 0 0 1px #3f5a2c; font-size: min(20cqw, calc(var(--u) * 0.7)); line-height: 1.1; white-space: nowrap; }
#resStars span.off { opacity: 0.35; text-decoration: line-through; }
