:root {
  font-family: "PingFang SC","Hiragino Sans GB","Noto Sans SC","Noto Sans CJK SC","Microsoft YaHei",sans-serif;
  color: #1c2a22;
  background: #eaf7ed;
  --paper: #eaf7ed;
  --ink: #1c2a22;
  --muted: #536057;
  --line: #e8e3d6;
  --yellow: #ffdc59;
  --green: #d8eea9;
  --blue: #d9edff;
  --coral: #ffd8cd;
  --forest: #264a35;
  --radius: 22px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  isolation: isolate;
  --bg-img: url("/assets/v5/themes/fairy-town.svg");
  --bg-img-m: url("/assets/v5/themes/fairy-town-m.svg");
  --accent: #286653;
  --panel: #fffbee;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--bg-img) center / cover no-repeat;
  pointer-events: none;
}
@media (max-aspect-ratio: 3/4) {
  body::before { background-image: var(--bg-img-m); }
}
[hidden] { display: none !important; }
button, input, select { font: inherit; }
button, .button, input, select { min-height: 46px; border-radius: 12px; }
button, .button {
  border: 1px solid #ccd9ca; border-bottom: 5px solid #b7c8b5; padding: 9px 16px; color: var(--ink); background: #fff;
  font-weight: 750; cursor: pointer; text-decoration: none; display: inline-flex;
  justify-content: center; align-items: center; gap: .4em; text-align: center;
}
button:hover:not(:disabled), .button:hover { filter: brightness(.96); }
button:active:not(:disabled), .button:active {
  transform: translateY(3px);
  border-bottom-width: 2px;
}
button:disabled { cursor: default; opacity: .62; }
:focus-visible { outline: 3px solid #276787; outline-offset: 3px; }
#app:focus, .quiz h2:focus { outline: none; }
a { color: var(--forest); text-underline-offset: .22em; }
input, select { width: 100%; min-width: 0; border: 1px solid #cbd3c3; background: #fff; color: var(--ink); padding: 9px 12px; }
label { display: grid; gap: 6px; font-size: .9rem; font-weight: 700; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(2rem, 4vw, 3.2rem); line-height: 1.16; }
h2 { font-size: 1.35rem; }
p, li { line-height: 1.65; }
ul, ol { margin-block: 0; padding-left: 1.5em; }
small, .muted { color: var(--muted); }
.wrap { width: min(1120px, calc(100% - max(20px, env(safe-area-inset-left)) - max(20px, env(safe-area-inset-right)))); margin-inline: auto; }
.top { border-bottom: 1px solid #fff9; background: #fffdf4; padding-top: env(safe-area-inset-top); }
.top-inner { min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 900; font-size: 1.18rem; white-space: nowrap; }
.brand-mark { width: 44px; height: 44px; object-fit: contain; }
#account { display: flex; align-items: center; gap: 8px; }
.pill { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 10px; font-size: .82rem; font-weight: 800; background: var(--green); width: fit-content; }
.pill.trial { background: #ffe894; }
#app, #admin { padding-block: 24px 32px; flex: 1; min-width: 0; }
.footer { background: #fffdf4; border: 1px solid #fff9; border-radius: 16px 16px 0 0; padding: 12px 16px max(12px, env(safe-area-inset-bottom)); display: flex; gap: 10px; justify-content: space-between; color: var(--muted); font-size: .84rem; }
.panel { padding: clamp(17px, 3vw, 29px); background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 32px #193e342e; min-width: 0; }
.stack { display: grid; gap: 15px; min-width: 0; }
.row, .section-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.section-head { justify-content: space-between; }
.narrow > .section-head, #dashboard > .section-head {
  padding: 10px 14px; border: 1px solid #fff9; border-radius: 18px; background: #fffdf4;
}
.narrow > .section-head { flex-wrap: nowrap; }
.narrow > .section-head h1 {
  min-width: 0; overflow-wrap: anywhere; text-wrap: balance;
  font-size: clamp(1.65rem, 3vw, 2rem);
}
.narrow > .section-head .button { flex: none; }
.primary { background: var(--yellow); border-color: #e0b632; border-bottom-color: #bc880e; color: #332809; }
.dark { background: var(--forest); border-color: var(--forest); border-bottom-color: #163225; color: #fff; }
.error { color: #922d20; font-weight: 700; }
.entry { display: grid; grid-template-columns: 1.34fr 1fr; gap: 22px; align-items: center; padding-block: 12px; }
.entry-hero { overflow: hidden; border: 1px solid #fff9; border-radius: 28px; background: #fffdf7; box-shadow: 0 14px 36px #193e3438; }
.hero-art, .hero-art img, .card-banner, .card-banner img { display: block; width: 100%; }
.hero-art img { height: clamp(245px, 32vw, 420px); object-fit: cover; object-position: center 54%; }
.hero-caption { position: relative; margin-top: -24px; padding: 18px 25px 23px; border-radius: 24px 24px 0 0; background: #fffdf7; }
.entry-hero h1 { font-size: clamp(2.35rem, 5vw, 4.5rem); letter-spacing: -.055em; }
.entry-hero p { margin-top: 4px; font-size: clamp(.9rem, 2vw, 1.12rem); font-weight: 700; }
.entry-form { padding: clamp(22px, 4vw, 42px); }
.entry-form h2 { font-size: 1.75rem; }
.entry-form form { gap: 12px; }
.entry-form button { width: 100%; }
.entry-form .muted { font-size: .87rem; border-top: 1px solid var(--line); padding-top: 12px; }
#trial { border-color: #bdd3bc; border-bottom-color: #a9c3a7; background: #f4faee; }
.lobby-head {
  background: #194c37; color: #fff; border: 1px solid #f2ffda75; border-radius: 26px;
  padding: 15px 22px; display: flex; justify-content: space-between; align-items: center;
  gap: 14px; flex-wrap: wrap; box-shadow: 0 8px 24px #163b3038;
}
.lobby-title { display: flex; align-items: center; gap: 12px; }
.lobby-title img { object-fit: contain; }
.lobby-title h1 { font-size: clamp(1.85rem, 3vw, 2.7rem); }
.lobby-head p { color: #e0efda; margin-top: 5px; }
.stats { display: flex; flex-wrap: wrap; gap: 7px; }
.stats span { background: #ffffff16; border: 1px solid #ffffff35; border-radius: 10px; padding: 8px 10px; font-weight: 750; white-space: nowrap; }
.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.card { display: grid; align-content: start; justify-content: stretch; justify-items: start; text-align: left; min-height: 130px; gap: 5px; padding: 16px; border-radius: 20px; background: #fff; color: var(--ink); text-decoration: none; border: 1px solid #fff9; border-bottom: 5px solid #b8c9ad; box-shadow: 0 7px 18px #1f49302b; }
.card:hover { filter: brightness(.97); }
.card strong { font-size: 1.25rem; }
.card small { font-weight: 600; }
.card .symbol { font-weight: 900; background: #ffffff9c; border-radius: 10px; min-width: 37px; min-height: 37px; display: grid; place-items: center; padding-inline: 4px; }
.cards .card { min-width: 0; }
.cards .illustrated { overflow: hidden; padding: 0; gap: 0; }
.card-banner img { height: 112px; object-fit: cover; }
.card-copy { display: grid; gap: 4px; }
.illustrated .card-copy { padding: 10px 14px 12px; }
.cards .card:not(.illustrated) {
  min-height: 72px; display: flex; justify-content: flex-start;
  align-items: center; gap: 12px;
}
.cards a.card:active { transform: translateY(3px); border-bottom-width: 2px; }
.card.yellow { background: linear-gradient(#fffbed, #fff2bd); border-bottom-color: #d4ad49; }
.card.green { background: linear-gradient(#fafff1, #e7f5cf); border-bottom-color: #9cb878; }
.card.blue { background: linear-gradient(#f7fcff, #dcefff); border-bottom-color: #85b1ce; }
.card.coral { background: linear-gradient(#fff8ee, #ffe6cf); border-bottom-color: #d39973; }
.card.lilac { background: linear-gradient(#fbf6ff, #efe5f8); border-bottom-color: #b8a6c9; }
.card.mint { background: linear-gradient(#f3fff8, #e0f3e9); border-bottom-color: #a0bfab; }
.narrow { width: min(760px, 100%); margin-inline: auto; }
.module-list, .options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.module-list button, .options button { min-height: 54px; overflow-wrap: anywhere; }
.options button { justify-content: start; text-align: left; }
.option-letter { background: #eef3e8; min-width: 28px; border-radius: 7px; text-align: center; padding: 3px; }
.options .chosen { outline: 2px solid #507354; opacity: 1; }
.options .correct-choice { background: #e0f2cb; opacity: 1; }
.options .wrong-choice { background: #ffded6; opacity: 1; }
.speed-levels { display: flex; flex-wrap: wrap; gap: 8px; }
.speed-levels button { flex: 1 0 76px; }
.quiz-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
#game .panel { background: #fffdf8; border-color: #fffb; }
.quiz h2 { font-size: clamp(1.3rem, 4vw, 2rem); overflow-wrap: anywhere; }
.quiz-form { display: flex; flex-wrap: wrap; gap: 9px; }
.quiz-form input { flex: 1 1 160px; }
.timer { display: block; width: 100%; height: 15px; border-radius: 10px; overflow: hidden; accent-color: #48794d; }
.timer::-webkit-progress-bar { background: #ebefe5; }
.timer::-webkit-progress-value { background: linear-gradient(90deg, #429e5c, #88c550); border-radius: 10px; }
.timer::-moz-progress-bar { background: linear-gradient(90deg, #429e5c, #88c550); border-radius: 10px; }
.feedback { border-radius: 14px; padding: 13px 15px; background: #e8f5d6; animation: rise .23s ease-out; }
.feedback p { white-space: pre-line; }
.feedback p, .feedback li { overflow-wrap: anywhere; }
.feedback ol { margin: 0; padding-inline-start: 1.35em; line-height: 1.55; }
.feedback li + li { margin-block-start: .45em; }
.feedback.missed { background: #fff0e9; }
.combo { padding: 4px 9px; border-radius: 999px; background: #fff0c6; color: #805309; font-weight: 900; }
@keyframes rise { from { transform: translateY(7px); opacity: .5; } to { transform: none; opacity: 1; } }
.match-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); gap: 8px; }
.tile { min-width: 0; min-height: 65px; padding: 5px; overflow-wrap: anywhere; background: #e6f2ff; }
.tile.open { background: #fff0ad; }
.tile.matched { background: #e1f2cd; }
dialog { border: 1px solid var(--line); border-radius: 22px; width: min(650px, calc(100% - 28px)); color: var(--ink); padding: 22px; max-height: 88dvh; }
dialog::backdrop { background: #1f332ba0; }
.report-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.report-grid > div { border-radius: 11px; background: #f3f6ed; padding: 10px; }
.badges { margin: 0; padding: 0; list-style: none; }
.badges li { padding: 4px 9px; border-radius: 8px; background: #fff0b9; font-size: .87rem; }
.admin h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); }
.admin-login { width: min(420px, 100%); margin: 25px auto; display: grid; gap: 20px; }
#dashboard { display: grid; gap: 16px; }
.admin-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.5fr) auto; gap: 10px; align-items: end; }
.table-scroll { min-width: 0; overflow-x: auto; }
.admin table { background: #fff; }
.admin tbody tr:nth-child(4n + 1) { background: #f8fbf5; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: .88rem; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line); }
th { background: #f2f5eb; white-space: nowrap; }
td code { white-space: nowrap; }
td button { font-size: .83rem; padding-inline: 9px; }
.device-list { padding: 8px; background: #f7f8f0; }
.device-list p { overflow-wrap: anywhere; }
.danger { color: #8a2f24; border-color: #e9bcb0; }
.toast { position: fixed; z-index: 2; bottom: 16px; left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 26px); padding: 10px 16px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: 0 8px 28px #1d33232e; }
@supports ((backdrop-filter: blur(16px)) or (-webkit-backdrop-filter: blur(16px))) {
  .panel, .top, .footer, .hero-caption, .narrow > .section-head, #dashboard > .section-head {
    background: rgba(255,252,247,.86);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
  }
  .lobby-head { background: #174632e0; -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
  #game .panel { background: #fffdf7f2; -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
}
@media (min-width: 701px) {
  .theme-lobby #app { padding-block: 18px; }
  .theme-lobby #app > .stack { gap: 12px; }
  .theme-lobby #app > .stack > .panel { padding-block: 14px; gap: 9px; }
  .cards .card:not(.illustrated) { padding-block: 10px; }
}
@media (max-width: 860px) {
  .admin-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .theme-entry {
    --scene: url("/assets/bg-entry-mobile.jpg?v=20261127a");
    --scene: image-set(url("/assets/bg-entry-mobile.webp?v=20261127a") type("image/webp"), url("/assets/bg-entry-mobile.jpg?v=20261127a") type("image/jpeg"));
  }
  .theme-lobby {
    --scene: url("/assets/bg-lobby-mobile.jpg");
    --scene: image-set(url("/assets/bg-lobby-mobile.webp") type("image/webp"), url("/assets/bg-lobby-mobile.jpg") type("image/jpeg"));
  }
  .wrap { width: calc(100% - max(12px, env(safe-area-inset-left)) - max(12px, env(safe-area-inset-right))); }
  #app, #admin { padding-top: 14px; }
  .top-inner { min-height: 58px; }
  .entry { grid-template-columns: minmax(0, 1fr); gap: 14px; padding-block: 0; }
  .entry-hero { border-radius: 22px; }
  .hero-art img { height: clamp(170px, 49vw, 270px); }
  .hero-caption { padding: 12px 17px 14px; border-radius: 19px 19px 0 0; }
  .entry-form { gap: 12px; }
  .lobby-head { padding: 12px 15px; gap: 9px; }
  .lobby-title img { width: 52px; height: 52px; }
  .stats span { padding: 5px 7px; font-size: .85rem; }
  .cards { grid-template-columns: minmax(0, 1fr); }
  .entry-form button, .quiz input, .quiz button { min-height: 52px; }
  input, select { font-size: 16px; }
  #submit-answer { width: 100%; }
}
@media (max-width: 440px) {
  .module-list, .options { grid-template-columns: minmax(0, 1fr); }
  .tile { font-size: .86rem; }
  .narrow > .section-head .button { padding-inline: 12px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; } }
@media print {
  body:has(dialog[open]) > :not(dialog), dialog button { display: none !important; }
  dialog[open] { position: static; width: 100%; max-height: none; max-width: none; border: 0; padding: 0; overflow: visible; }
  dialog::backdrop { background: transparent; }
}

/* Adventure, battle and collection */
#account { display: flex; gap: 8px; align-items: center; }
#mute { min-height: 36px; padding: 4px 10px; font-size: .85rem; }

.adventure-map { display: grid; gap: 11px; justify-items: center; padding: 12px 4px; position: relative; }
.adventure-map::before { content: ""; position: absolute; inset: 5% 50%; border-left: 4px dashed #c2c9ea; }
.adventure-map > button { position: relative; width: min(77%, 430px); z-index: 1; border-radius: 24px;
  text-align: left; background: #eef1ff; border: 2px solid #c2cdf8; box-shadow: 0 4px #c2cdf8; }
.adventure-map > button:nth-child(4n+1), .adventure-map > button:nth-child(4n+3) { transform: translateX(-10%); }
.adventure-map > button:nth-child(4n+2), .adventure-map > button:nth-child(4n) { transform: translateX(10%); background: #e6f7ee; }
.speed-levels.adventure-map { grid-template-columns: repeat(5, 1fr); align-items: center; }
.speed-levels.adventure-map::before { inset: 50% 7%; border-left: 0; border-top: 4px dashed #c2c9ea; }
.speed-levels.adventure-map > button { width: 100%; max-width: 78px; text-align: center; transform: translateY(-5px); }
.speed-levels.adventure-map > button:nth-child(even) { transform: translateY(5px); }
.locked-node { opacity: .78; }
.level-lock { display: block; font-size: .7rem; }

.battle-arena { display: grid; grid-template-columns: 1fr 1.25fr; align-items: end; min-height: 150px; gap: 12px;
  padding: 10px 14px; border-radius: 22px; color: #283965; overflow: hidden;
  background: radial-gradient(ellipse at 65% 18%, #fff9 0%, transparent 60%),
    linear-gradient(170deg, var(--battle-top, #e9efff), var(--battle-bottom, #b9d9f2)); }
.battle-player, .battle-enemy { display: grid; justify-items: center; gap: 1px; min-width: 0; text-align: center; }
.battle-player { padding-bottom: 4px; }
.battle-enemy { position: relative; }
.companion { display: inline-grid; place-items: center; position: relative; font-size: 2.45rem; line-height: 1.25; }
.monster { width: clamp(83px, 12vw, 115px); display: block; }
#boss-hp { width: min(185px, 100%); height: 13px; accent-color: #ee6386; }
#boss-hp::-webkit-progress-bar { background: #fff9; border-radius: 99px; }
#boss-hp::-webkit-progress-value { background: linear-gradient(90deg, #fa9a72, #e65487); border-radius: 99px; transition: width .25s ease; }
.battle-tools { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.quiz .battle-tools button { font-size: .86rem; min-height: 36px; padding: 4px; }
.question-visual { display: block; width: min(100%, 255px); height: auto; margin-inline: auto; color: #243b65;
  background: #f3f8ff; border: 1px solid #d4e0f1; border-radius: 14px; }
.question-visual text { fill: currentColor; }
.answer-choice[hidden] { display: none; }
.library-grid, .shop-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.library-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); gap: 8px; }
.library-filters label { display: grid; gap: 3px; min-width: 0; }
.library-filters input, .library-filters select { width: 100%; min-width: 0; }
.library-item small { font-weight: 500; }
.library-question { border-bottom: 1px solid #d4e0f1; padding-bottom: 10px; }
.library-question summary { cursor: pointer; padding: 8px 0; }
@media (max-width: 600px) {
  .library-filters, .shop-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .battle-arena { min-height: 124px; padding: 7px 9px; font-size: .88rem; }
  .speed-levels.adventure-map { gap: 5px; }
  .speed-levels.adventure-map > button { padding-inline: 3px; }
  #account { flex-wrap: wrap; justify-content: end; }
}
@media (prefers-reduced-motion: reduce) {
  #boss-hp::-webkit-progress-value { transition: none; }
}
#combo-meter { width: 55px; height: 12px; color: #db633e; }
#combo-meter::-webkit-meter-optimum-value { background: #e98246; }

.avatar { display: block; flex: none; }
.avatar img { display: block; width: 100%; height: auto; object-fit: cover; border-radius: inherit; }
#profile-avatar { min-height: 36px; width: 38px; padding: 2px; border: 1px solid #b7c8b5; border-radius: 50%; }
#profile-avatar .avatar { width: 100%; }
#profile-avatar .avatar, .lobby-title .avatar { border-radius: 50%; overflow: hidden; }
.lobby-title .avatar { width: 68px; border: 2px solid #fff9; }
.lobby-title .avatar img { width: 100%; height: auto; }
.subject-settings { display: flex; align-items: end; gap: 10px; padding: 10px 14px; }
.subject-settings label { flex: 0 1 145px; min-width: 0; gap: 3px; }
.subject-settings select { padding: 5px 7px; min-height: 39px; }
.subject-edition { padding: 9px 0; white-space: nowrap; }
.card-copy { width: 100%; text-align: left; }
.cards .card:not(.illustrated) strong { font-size: 1.03rem; }
.cards .illustrated .card-banner img { height: 142px; }

.library-grid { align-items: stretch; }
.library-item, .adventure-map:not(.speed-levels) > button, .module-list > [data-module] {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start;
  width: 100%; padding: 11px 14px; text-align: left; overflow-wrap: anywhere;
}
.library-item { height: 100%; min-height: 98px; }
.library-item :is(strong, small, span, p, .meta), .adventure-map:not(.speed-levels) > button > * { width: 100%; text-align: left; }
.library-item .meta { color: #586650; font-size: .76rem; }
.card-description, .card-copy small, .adventure-map:not(.speed-levels) > button > small {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
}
.adventure-map:not(.speed-levels) > button { max-width: 430px; }
.adventure-map:not(.speed-levels) > button:nth-child(n) { transform: none; }

/* The perch has its own strip above the footer, outside the scrolling content. */
body[data-companion] { height: 100dvh; }
[data-companion] #app { overflow: auto; scrollbar-width: thin; }
[data-companion] :is(.top, .footer) { flex-shrink: 0; }
[data-companion] .footer { --perch-gap: 53px; position: relative; margin-top: var(--perch-gap); }
#pet-perch {
  position: absolute; bottom: calc(100% + 5px); right: 0;
  z-index: 1; display: flex; align-items: center; gap: 6px;
}
.top { position: relative; z-index: 2; }
.pet-button, .pet-button:active:not(:disabled) {
  width: 48px; min-height: 44px; padding: 0; transform: none;
  border: 1px solid #e3c47f; border-radius: 50%; background: #fff5d6; box-shadow: 0 3px 0 #b18b54;
}
.pet-button .companion { font-size: 1.72rem; animation: pet-bob 2s ease-in-out infinite; }
.pet-bubble { color: #55345c; font-weight: 750; background: #fff8ff; border: 1px solid #e5c9ed; padding: 5px 10px; border-radius: 14px; }
.pet-bubble:empty { display: none; }
.pet-sparkles { position: absolute; top: 0; right: 46px; pointer-events: none; opacity: 0; }
.pet-play .pet-sparkles { opacity: 1; animation: pet-spark .7s ease-out both; }
.pet-play .companion { animation: pet-jump .56s ease-out; }
@keyframes pet-bob { 50% { transform: translateY(-3px) rotate(-4deg); } }
@keyframes pet-jump { 35% { transform: translateY(-10px) rotate(-12deg); } 70% { transform: rotate(9deg); } }
@keyframes pet-spark { from { transform: scale(.3); } to { transform: translate(-10px, -12px) scale(1.3); opacity: 0; } }

.battle-arena { position: relative; isolation: isolate; min-height: 163px; --flight: .23s; }
.battle-player .avatar { width: clamp(65px, 18vw, 100px); border: 3px solid #ffed9d; border-radius: 24px; box-shadow: 0 4px 0 #a16fb077; }
.battle-enemy { align-self: center; }
#damage { position: absolute; z-index: 3; top: 28%; left: 50%; transform: translateX(-50%);
  font-weight: 900; white-space: nowrap; pointer-events: none; font-size: clamp(1.4rem, 3.2vw, 2.05rem);
  line-height: 1; color: #922044; text-shadow: 0 2px #fff, 1px 0 #fff, -1px 0 #fff, 0 -1px #fff; }
.battle-critical #damage { color: #ad3a00; font-size: clamp(1.55rem, 3.8vw, 2.55rem); text-shadow: 0 2px 2px #ffed6b, 0 0 4px #fff; }
.battle-blocked #damage { color: #126970; }
.battle-projectile, .battle-burst, .defeat-burst {
  display: none; position: absolute; pointer-events: none; z-index: 2;
  left: var(--enemy-x); top: var(--enemy-y);
}
.battle-hit .battle-projectile { display: block; color: #fff483; font-size: 3rem; line-height: 1;
  text-shadow: 0 0 5px white, 0 0 15px #ff7700, -16px 3px 13px #ffc432;
  animation: projectile var(--flight) ease-in both; }
.battle-critical .battle-projectile { color: #fff; font-size: 3.8rem; text-shadow: 0 0 8px #ffed86, -19px 0 15px #ff4518; }
.battle-hit .battle-burst, .battle-blocked .battle-burst, .battle-defeat .defeat-burst { display: block; }
.battle-blocked .battle-burst { left: var(--hero-x); top: var(--hero-y); }
.battle-burst::before {
  content: ""; position: absolute; width: 85px; height: 85px; border-radius: 50%;
  background: radial-gradient(circle, white 12%, #fff8af 29%, #ff70a089 48%, transparent 70%);
  transform: translate(-50%, -50%); animation: impact .4s var(--flight) both;
}
.battle-blocked .battle-burst::before { background: radial-gradient(circle, white, #88fcf3bf 45%, transparent 70%); }
.battle-burst i, .defeat-burst i {
  position: absolute; color: var(--spark); font-size: 1.45rem; line-height: 1; font-style: normal;
  text-shadow: 0 0 4px #b53c46; animation: scatter .58s var(--flight) ease-out both;
}
.defeat-burst i { animation-delay: .49s; animation-duration: .65s; }
.battle-hit .monster { animation: knockback .42s var(--flight) both; }
.battle-defeat .monster { animation: poof .56s var(--flight) both; }
.battle-hit #damage { animation: damage-float .52s var(--flight) both; }
.battle-miss #damage { animation: damage-float .52s .09s both; }
.battle-miss .monster { animation: lunge .34s ease-out; }
.battle-hit:not(.ultimate-hit) .battle-player .avatar { animation: hero-lunge .42s var(--flight, .23s) both; }
.battle-miss:not(.battle-blocked, .battle-dodged, .ultimate-hit) .battle-player .avatar { animation: hero-recoil .4s .05s ease-out; }
.ultimate-hit .battle-player .avatar { animation: hero-ultimate .55s ease-out; }
.victory-banner:empty { display: none; }
.victory-banner {
  position: absolute; z-index: 4; top: 50%; left: 50%; width: max-content; max-width: 90%; text-align: center;
  padding: 9px 21px; border: 2px solid #f9d054; border-radius: 18px; color: #5f340d;
  background: #fff4c8; box-shadow: 0 5px 22px #67366655; transform: translate(-50%, -50%);
  animation: victory-pop .24s .64s both;
}
.victory-banner strong { display: block; font-size: 1.3rem; }
.victory-banner small { color: #704819; font-weight: 750; }
@keyframes projectile {
  from { left: var(--hero-x); top: var(--hero-y); transform: translate(-50%, -50%) scale(.6) rotate(-45deg); }
  78% { opacity: 1; }
  to { transform: translate(-50%, -50%) scale(1.12) rotate(50deg); opacity: 0; }
}
@keyframes impact { from { opacity: 0; scale: .55; } 24% { opacity: 1; scale: 1.11; } to { opacity: 0; scale: 1.3; } }
@keyframes scatter {
  from { opacity: 0; transform: translate(-50%, -50%) scale(.3); }
  24%, 57% { opacity: 1; }
  to { opacity: 0; transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) rotate(var(--spin)); }
}
@keyframes knockback { 20% { transform: translateX(15px) rotate(10deg); filter: brightness(2.3) saturate(1.6); }
  48% { transform: translateX(-4px) rotate(-5deg); } }
@keyframes poof { 16% { transform: translateX(13px) rotate(14deg); filter: brightness(2.5); }
  38% { transform: rotate(-22deg); } to { transform: rotate(235deg) scale(.18); opacity: 0; } }
@keyframes damage-float {
  from { transform: translate(-50%, 5px) scale(.75); opacity: 0; }
  25% { transform: translate(-50%, -9px) scale(1.18); opacity: 1; }
  to { transform: translate(-50%, -21px); opacity: 1; }
}
@keyframes lunge { 33% { transform: translateX(-27%) rotate(-12deg); filter: saturate(1.9) brightness(1.2); } }
@keyframes hero-lunge {
  0%, 100% { transform: none; }
  30% { transform: translate(16%, -8%) rotate(7deg) scale(1.07); filter: brightness(1.18) saturate(1.25); }
}
@keyframes hero-recoil {
  25% { transform: translateX(-12%) rotate(-8deg); filter: sepia(.45) saturate(1.8) brightness(1.1); box-shadow: 0 0 14px #f42d62; }
  50% { transform: translateX(6%) rotate(4deg); }
  75% { transform: translateX(-4%); }
}
@keyframes hero-ultimate {
  20% { transform: translateY(-10%) scale(1.12) rotate(-6deg); filter: brightness(1.3) saturate(1.3); box-shadow: 0 0 22px #ffe56a; }
  55% { transform: translate(18%, -6%) rotate(8deg) scale(1.08); }
  100% { transform: none; }
}
@keyframes tremble { 25%, 75% { transform: translateX(-4px); } 50% { transform: translateX(4px); } }
@keyframes victory-pop { from { transform: translate(-50%, -50%) scale(.82); opacity: 0; } }

@media (max-width: 700px) {
  .lobby-title .avatar { width: 54px; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .cards .illustrated .card-banner img { height: 86px; }
  .cards .card:not(.illustrated) { padding: 8px; gap: 7px; }
  .cards .card:not(.illustrated) small { display: none; }
  .illustrated .card-copy { padding: 8px; }
  .cards .illustrated strong { font-size: 1.02rem; }
  .cards .illustrated small { font-size: .75rem; }
  .subject-settings { gap: 6px; padding: 8px 10px; }
  .top .brand { gap: 5px; font-size: 1.05rem; }
  .top .brand-mark { width: 32px; }
}
@media (prefers-reduced-motion: reduce) {
  .battle-hit .battle-projectile { display: none; }
  .battle-defeat .monster { opacity: 0; }
  .battle-burst i, .defeat-burst i { transform: translate(calc(-50% + var(--x) * .55), calc(-50% + var(--y) * .55)); }
  .battle-burst::before { opacity: .65; }
}

/* Stage V4 */
.count-chooser, .report-tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.count-chooser > span { font-size: .86rem; font-weight: 700; margin-right: 4px; }
.count-chooser button, .report-tabs button { padding: 5px 11px; min-height: 36px; }
.count-chooser button[aria-pressed="true"], .report-tabs button[aria-pressed="true"] {
  background: #285e55; color: #fff; border-color: #285e55;
}
:is(.library-grid, .adventure-map) > .thumb-card { flex-direction: row; gap: 10px; align-items: flex-start; }
.adventure-map:not(.speed-levels) > .thumb-card > .card-art, .card-art {
  flex: 0 0 auto; width: 80px; height: 72px; display: block; border-radius: 14px;
}
.thumb-copy { display: grid; gap: 2px; min-width: 0; }
.thumb-copy strong { line-height: 1.2; }
.detail-art { display: flex; align-items: center; gap: 12px; }
.avatar-wrap { position: relative; display: inline-grid; justify-items: center; flex: 0 0 auto; --hat-size: 2rem; }
.avatar-wrap .avatar { display: block; }
.hero-hat {
  position: absolute; left: 50%; top: 1%; translate: -50% -14%; z-index: 1; display: grid; place-items: center;
  width: var(--hat-size); height: var(--hat-size); font-size: var(--hat-size); line-height: 1; pointer-events: none;
  filter: drop-shadow(0 2px 1px #49345555);
}
.hero-hat svg { width: 100%; height: auto; }
#profile-avatar .avatar-wrap { --hat-size: 1rem; width: 100%; }
.lobby-title .avatar-wrap { --hat-size: 1.7rem; }
.battle-player .avatar-wrap, .preview-hero .avatar-wrap { --hat-size: clamp(2.15rem, 4vw, 2.8rem); }
.battle-player { position: relative; }
#hero-hp {
  width: min(185px, 100%); height: 13px; border-radius: 99px; background: #fff9; overflow: hidden;
}
#hero-hp > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #32a88b, #69cd91); transition: width .25s ease; }
#hero-shield { position: absolute; right: 7%; top: 12%; font-size: 1.4rem; }
#heal-popup { position: absolute; top: 28%; right: 4%; color: #146f43; font-size: 1.5rem; font-weight: 900; text-shadow: 0 1px white; }
#damage.reflect-popup { color: #672a9a; }
.battle-miss:not(.battle-blocked) #hero-hp { animation: tremble .34s .08s ease-out; }

.hero-profile { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 18px; }
.hero-profile .avatar { width: clamp(74px, 17vw, 116px); border-radius: 20px; overflow: hidden; }
.hero-profile progress { width: 100%; accent-color: #347c6a; }
.hero-stats, .study-trend { list-style: none; margin: 0; padding: 0; }
.hero-stats li { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 12px; padding: 6px 0; border-bottom: 1px solid #dbe5df; }
.hero-stats small { display: block; color: #586650; }
.hero-stats button { min-height: 36px; padding: 4px 10px; }
.study-trend { display: grid; gap: 5px; font-variant-numeric: tabular-nums; }
.study-trend li { display: grid; grid-template-columns: 3rem 1fr 5.5rem; align-items: center; gap: 8px; }
.study-trend li > span { display: block; height: 9px; border-radius: 99px; background: #e7efe9; }
.study-trend i { display: block; height: 100%; border-radius: inherit; background: #468e7b; }
.wrong-day { border-top: 1px solid #dbe5df; padding-top: 10px; }
#report-detail .report-grid strong { display: block; }

@media (max-width: 600px) {
  .library-grid { grid-template-columns: 1fr; }
  .shop-preview { grid-template-columns: auto minmax(0, 1fr); gap: 10px; padding: 12px; }
  .preview-theme { grid-column: 1 / -1; justify-self: start; }
}
@media (prefers-reduced-motion: reduce) {
  .preview-pet .companion, .battle-miss:not(.battle-blocked) #hero-hp { animation: none; }
}

.cards .lobby-subject { display: flex; align-items: center; }
.cards .lobby-subject .card-art { width: 68px; height: auto; }
.cards .lobby-subject .card-copy { min-width: 0; }
@media (max-width: 600px) {
  .cards .lobby-subject .card-art { width: 42px; }
}
@media (min-width: 520px) {
  #report-detail .report-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Stage V4.1 */
body:has(> #app), body.admin { height: 100dvh; min-height: 0; }
body:has(> #app) > :is(.top, .footer), body.admin > .top { flex-shrink: 0; }
#app, #admin {
  min-height: 0;
  overflow: auto;
  scrollbar-width: none;
  padding-inline: 11px;
  padding-bottom: calc(56px + var(--perch-gap, 0px) + env(safe-area-inset-bottom));
  scroll-padding-block: 16px 40px;
}
[data-companion] { --perch-gap: 53px; }
[data-companion] #app { scrollbar-width: none; }
/* Leave space for the cue within the scrollport. */
.theme-lobby #app { padding-bottom: calc(56px + var(--perch-gap, 0px) + env(safe-area-inset-bottom)); }
dialog[open] {
  padding-bottom: calc(42px + env(safe-area-inset-bottom));
  overflow: auto;
  scrollbar-width: none;
  scroll-padding-block: 16px 40px;
}
:is(#app, #admin, dialog)::-webkit-scrollbar { display: none; }
.scroll-indicator {
  position: fixed;
  z-index: 5;
  width: 5px;
  border-radius: 99px;
  background: #d9e4db;
  box-shadow: 0 0 0 1px #fff9;
  pointer-events: none;
}
.scroll-thumb {
  display: block;
  border-radius: inherit;
  background: #35796a;
}
.scroll-cue {
  position: absolute;
  right: 10px;
  bottom: 0;
  border: 1px solid #adccba;
  border-radius: 99px;
  background: #f5fff4;
  color: #254f3b;
  padding: 3px 9px;
  font-size: .74rem;
  font-weight: 750;
  white-space: nowrap;
  box-shadow: 0 2px 8px #1d332322;
}
.gear-bonus { background: #e0f2eb; color: #245743; white-space: normal; }
.cards > .endless-card { grid-column: 1 / -1; background: #e4d7fa; }
.endless-selects { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.ranking-list { padding: 0; list-style: none; display: grid; gap: 8px; }
.ranking-list li {
  display: grid;
  grid-template-columns: 2rem auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  background: #f3f6ed;
  padding: 8px;
  border-radius: 12px;
  overflow-wrap: anywhere;
}
.ranking-list .avatar img { width: 36px; height: 36px; }
.ranking-list .avatar-wrap { --hat-size: .95rem; }
@media print {
  dialog[open] { padding: 0; overflow: visible; }
  .scroll-indicator { display: none; }
}

.hero-stats .stat-breakdown { display: block; font-weight: 650; color: #3b5f4e; }
.scroll-indicator { width: 6px; }

/* Stage V5 */
body { --forest: var(--accent); --line: color-mix(in srgb, var(--accent) 20%, #fff); }
body .panel, body .narrow > .section-head, body .footer, body .top, body #game .panel {
  background: color-mix(in srgb, var(--panel) 91%, transparent);
  backdrop-filter: blur(10px);
  border-color: #fff9;
}
body .top { position: relative; z-index: 6; }
.top-inner { min-height: 60px; }
#app { padding-top: 15px; }
.lobby-head { background: color-mix(in srgb, var(--accent) 88%, #161837); }
.lobby-title { gap: 12px; }
.v5-portrait .avatar { width: 56px; border-radius: 14px; background: radial-gradient(#fff, #f8e7c8); }
.v5-portrait .avatar img { aspect-ratio: 1; object-fit: cover; object-position: center top; }
.v5-portrait .hero-hat { top: 6%; object-fit: contain; }
#profile-avatar { width: auto; border-radius: 999px; padding: 3px 8px 3px 3px; min-width: 44px; }
#profile-avatar .avatar-wrap { width: 31px; --hat-size: 15px; }
#profile-avatar .avatar { width: 31px; border-radius: 50%; }
.account-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 10em; }
.pet-button .companion { width: 43px; height: 43px; object-fit: contain; }
.v5-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: stretch; }
.v5-card {
  display: flex; flex-direction: column; height: 100%; min-width: 0; overflow: hidden;
  background: color-mix(in srgb, var(--panel) 96%, white);
  border: 2px solid var(--rarity, #fff); border-radius: 20px;
  box-shadow: 0 5px 0 color-mix(in srgb, var(--rarity, var(--accent)) 30%, #fff), 0 9px 18px #2b234025;
  overflow-wrap: anywhere;
}
.v5-card-copy { display: flex; flex-direction: column; flex: 1; gap: 6px; padding: 10px; min-width: 0; }
.v5-card-copy .card-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: auto; }
.ultimate-desc { margin: 0; font-size: .78rem; line-height: 1.45; font-weight: 600; color: #3a3658; }
.ultimate-desc strong { display: block; font-size: .82rem; margin-bottom: 2px; color: #5a2f86; }
.v5-card :is(h2,h3) { font-size: clamp(1.02rem, 2.8vw, 1.32rem); line-height: 1.25; }
.v5-card button { padding-inline: 6px; }
.v5-card .pill { font-size: .72rem; padding: 3px 7px; }
.v5-card .row { gap: 4px; }
.hero-artwork, .collection-art {
  position: relative; display: grid; place-items: center;
  background: radial-gradient(ellipse at 50% 48%, #fff 2%, transparent 69%),
    linear-gradient(136deg, color-mix(in srgb, var(--rarity, var(--accent)) 26%, #fff), #fff2cd);
  overflow: hidden;
}
.hero-artwork { height: clamp(140px, 38vw, 240px); }
.hero-artwork img { display: block; height: 100%; max-width: 100%; object-fit: contain; }
.gender { position: absolute; top: 7px; right: 7px; background: #fff; }
.specialty { background: #e7dbff; }
.stat-meter { font-size: .72rem; gap: 1px; }
.stat-meter span { display: flex; justify-content: space-between; }
.stat-meter progress, .achievement progress { width: 100%; height: 9px; accent-color: var(--accent); }
.collection-art { height: clamp(92px, 29vw, 158px); }
.collection-art img { display: block; max-width: 100%; height: 100%; width: 100%; object-fit: contain; }
.theme-grid .collection-art img { object-fit: cover; }
.bonus-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.idle-art { animation: v5-bob 3.6s ease-in-out infinite; }
.hero-artwork img.idle-art, .theme-grid .idle-art { animation: none; }
@keyframes v5-bob { 50% { transform: translateY(-3px); } }
.legendary {
  border-color: transparent;
  background: linear-gradient(var(--panel), var(--panel)) padding-box,
    linear-gradient(110deg, #bf781c, #ffe372, #eb8acb, #88aaff, #55cdbb, #ffde61, #bf781c) border-box;
  background-size: 100% 100%, 260% 100%;
  animation: legendary-border 4s linear infinite alternate;
}
@keyframes legendary-border { to { background-position: 0 0, 100% 0; } }
.v5-tabs { gap: 6px; }
.v5-tabs button { padding: 5px 11px; min-height: 38px; font-size: .88rem; }
.v5-tabs button[aria-pressed=true] { background: var(--accent); color: white; border-color: var(--accent); }
.v5-preview {
  position: sticky; bottom: 5px; z-index: 4; padding: 10px 14px; border-radius: 17px; border: 2px solid #fff;
  box-shadow: 0 4px 22px #2b234044; background: var(--panel); display: flex; gap: 8px; flex-wrap: wrap;
  justify-content: space-between; align-items: center;
}
.loadout { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.stat-up { color: #21533e; background: #d9f4df; }
.stat-down { color: #922e44; background: #fae0e6; }
.detail-sheet .collection-art { height: 140px; }
.chest-sheet { min-width: min(280px, 69vw); }
.chest-stage { display: grid; place-items: center; position: relative; min-height: 190px; isolation: isolate; }
.chest-stage img { width: 175px; grid-area: 1 / 1; }
.chest-stage .chest-flash { width: min(100%, 250px); z-index: -1; animation: chest-flash .56s ease-out both; }
.chest-flash.epic { filter: hue-rotate(230deg); }
.chest-flash.rare { filter: hue-rotate(165deg); }
.chest-flash.legendary { filter: saturate(2); }
.chest-shake { animation: chest-shake .15s ease-in-out 3; }
.chest-burst { animation: chest-burst .55s ease-out both; }
.chest-trigger { gap: 10px; justify-self: start; }
.chest-trigger img { width: 33px; }
.chest-actions { margin-top: 12px; }
@keyframes chest-shake { 25% { rotate: 8deg; } 75% { rotate: -8deg; } }
@keyframes chest-burst { 0% { scale: .72; } 40% { scale: 1.15; } }
@keyframes chest-flash { from { scale: .2; opacity: 0; } 45% { opacity: 1; } to { scale: 1.25; opacity: .75; } }
.undiscovered img { filter: brightness(0) opacity(.28); }
.bestiary-card p { font-size: .84rem; }
.boss-badge { color: #763551; background: #ffdfeb; }
.achievement-grid { display: grid; gap: 9px; align-items: stretch; }
.achievement {
  display: grid; grid-template-columns: 50px minmax(0, 1fr); gap: 10px; align-items: center; height: 100%;
  border-radius: 13px; border: 1px solid #fff; padding: 8px; background: #ffffffb8;
}
.achievement h3 { font-size: 1rem; }
.achievement h3 small { color: #20634d; }
.achievement small { display: block; }
.badge-art { display: grid; place-items: center; font-size: 1.25rem; }
.badge-art :is(img,span) { grid-area: 1 / 1; }
.badge-art img { width: 100%; }
.rank-filters { gap: 9px; }
.period-tabs { border-top: 1px solid var(--line); padding-top: 8px; }
.ranking-list .rank-row { grid-template-columns: 27px 39px minmax(0, 1fr) auto; gap: 6px; }
.rank-row small { display: block; font-size: .73rem; }
.rank-medal {
  width: 27px; height: 27px; display: grid; place-items: center; border-radius: 50%;
  background: #e2eadf; font-weight: 900; line-height: 1;
}
.rank-score { text-align: right; }
.ranking-list .rank-1 { background: linear-gradient(110deg, #ffe29e, #fff4d4); }
.ranking-list .rank-2 { background: linear-gradient(110deg, #dde7f5, #f4f7ff); }
.ranking-list .rank-3 { background: linear-gradient(110deg, #f6d7c6, #fff3e9); }
.rank-1 .rank-medal { background: #ffca50; color: #593b00; }
.rank-2 .rank-medal { background: #b7c7e3; color: #2c3b58; }
.rank-3 .rank-medal { background: #eab693; color: #62351c; }
.rank-row .avatar { width: 36px; }
.my-ranking { position: sticky; bottom: 4px; padding: 8px 12px; z-index: 4; display: grid; gap: 4px; }
.period-results { display: grid; gap: 5px; }
.period-results p { padding: 6px 10px; border-radius: 9px; background: #fff9; }
.v5-toast { top: 66px; bottom: auto; z-index: 12; background: #fff9df; border-color: #edc96c; max-width: min(92vw, 430px); }
.v5-toast:has(~ .v5-toast) { display: none; }
.enemy-life { position: relative; display: flex; align-items: center; gap: 4px; width: min(100%, 250px); }
.enemy-life #boss-hp { min-width: 13px; flex: 1; }
.dr-badge { background: #ffedfa; color: #693052; border-radius: 99px; padding: 2px 5px; font-size: .66rem; white-space: nowrap; }
.boss-entrance, .ultimate-banner {
  z-index: 4; position: absolute; left: 50%; top: 7px; translate: -50% 0; text-align: center;
  width: max-content; max-width: calc(100% - 12px); padding: 4px 10px; border-radius: 99px; font-weight: 900;
  color: #6a2c46; border: 1px solid #fff; background: #ffe0e9; box-shadow: 0 3px 9px #602f6a38;
}
.boss-entrance { animation: boss-entrance 1.65s both; }
@keyframes boss-entrance { 0% { opacity: 0; scale: .85; } 18%, 72% { opacity: 1; scale: 1; } 100% { opacity: 0; } }
.ultimate-banner { color: #5f2e10; background: linear-gradient(100deg, #ffe47c, #ffddf8, #d2f9ff); }
.ultimate-hit .boss-entrance { visibility: hidden; }
.battle-vfx { inset: 0; position: absolute; display: grid; place-items: center; pointer-events: none; z-index: 2; }
.battle-vfx img { grid-area: 1 / 1; height: 100%; max-height: 240px; width: 100%; object-fit: contain; }
.attack-vfx { animation: weapon-vfx .95s ease-out both; }
.ultimate-vfx { animation: weapon-vfx 1.45s ease-out both; }
.ultimate-hit { animation: arena-shake .34s ease-in-out; }
@keyframes weapon-vfx { from { scale: .45; opacity: 0; } 23% { scale: 1.03; opacity: .94; } to { scale: 1.19; opacity: 0; } }
@keyframes arena-shake { 25%, 70% { transform: translateX(-3px); } 45%, 85% { transform: translateX(3px); } }
.charge b { color: #643d8b; letter-spacing: .05em; }
#hero-damage {
  position: absolute; left: 50%; top: 26%; color: #8b244f; font-weight: 900; font-size: 1.35rem;
  white-space: nowrap; text-shadow: 0 1px #fff, 1px 0 #fff; z-index: 3; transform: translateX(-50%);
}
.battle-miss #hero-damage { animation: damage-float .52s .09s both; }
.battle-enemy .monster { height: clamp(82px, 22vw, 135px); width: auto; max-width: 100%; object-fit: contain; }
.quiz .battle-tools button:disabled { opacity: .7; }
@media (min-width: 720px) {
  .v5-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; }
  .heroes-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .theme-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .achievement-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 530px) {
  .wrap { width: calc(100% - 20px); }
  .top-inner { gap: 5px; }
  .brand { font-size: 1rem; gap: 3px; }
  .brand-mark { width: 29px; height: 29px; }
  #account { flex-wrap: nowrap; gap: 3px; }
  #account .pill { padding: 3px 5px; font-size: .66rem; white-space: nowrap; }
  #mute { min-height: 32px; padding: 3px 4px; font-size: .66rem; white-space: nowrap; }
  #profile-avatar { min-width: 35px; padding-right: 4px; }
  .account-name { max-width: clamp(32px, 20vw, 76px); font-size: .75rem; }
  .panel { padding: 13px; }
  .rank-filters, .ranking-panel { padding: 10px; }
  .my-ranking { padding: 6px 9px; }
  #app:has(.quiz) { padding-top: 8px; }
  .narrow:has(.quiz), .narrow:has(.quiz) #stage, .quiz { gap: 8px; }
  .narrow:has(.quiz) > .section-head { padding-block: 5px; }
  .narrow:has(.quiz) :is(#leave-game, .section-head .button) { min-height: 34px; padding-block: 3px; }
  .quiz .feedback { padding: 8px 10px; gap: 5px; }
  .quiz .battle-tools button { font-size: .72rem; }
}
@media (prefers-reduced-motion: reduce) {
  .idle-art, .legendary, .ultimate-hit, .boss-entrance { animation: none; }
  .battle-vfx img { animation: reduced-flash .7s ease-out both; }
}
@keyframes reduced-flash { from { opacity: .55; } to { opacity: 0; } }

/* Constrain the artwork within the art well, including on two-column mobile grids. */
.hero-artwork img, .collection-art img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
}
.hero-artwork img, .collection-art:not(.theme-grid .collection-art) img { padding: 5px; }
.gender { z-index: 1; }
.chest-sheet .collection-art { height: 140px; }
.v5-portrait { --hat-size: 1.35rem; }
.v5-portrait .hero-hat { top: 2%; translate: -50% -28%; }
.lobby-title .v5-portrait { --hat-size: 1.45rem; }
.battle-player .v5-portrait { --hat-size: 1.8rem; }
.hero-profile .v5-portrait { --hat-size: 2.15rem; }
.achievement-check { color: #20634d; margin-inline-start: 3px; }
.rank-filters .v5-tabs button { padding-inline: 9px; }
#app:has(.my-ranking) { padding-bottom: 21px; }
.question-review { color: var(--muted); font-size: .82rem; }
.question-review summary { cursor: pointer; padding: 3px 0; }
.question-review[open] .question-work { margin-top: 7px; }
@media (min-width: 1050px) {
  .narrow:has(.heroes-grid) { width: min(960px, 100%); }
  .hero-intro { padding-block: 13px; }
  .hero-artwork { height: 165px; }
}
@media (max-width: 530px) {
  .rank-filters .v5-tabs { gap: 4px; }
  .rank-filters .v5-tabs button { padding-inline: 7px; font-size: .82rem; }
  .lobby-title .hero-hat { width: var(--hat-size); height: var(--hat-size); }
  .endless-quiz #next { min-height: 42px; padding-block: 5px; }
}
@media (max-width: 530px) {
  .loadout-panel { gap: 7px; }
  .loadout-panel .avatar { width: 43px; }
  .loadout-panel .bonus-tags .pill { padding: 2px 6px; font-size: .7rem; }
  .narrow:has(.loadout-panel) #stage { gap: 9px; }
  .narrow:has(.loadout-panel) .collection-art { height: 96px; }
}
.ranking-play { margin-inline-start: auto; font-weight: 800; font-size: .85rem; }
#damage { top: 36%; }
.battle-dodged .battle-player .avatar, .battle-dodged #hero-hp { animation: none !important; }
.shop-fitting { padding: 8px; border-radius: 12px; background: #fff9; }
.shop-fitting .companion { width: 52px; }
@media (max-width: 530px) {
  .cards .lobby-subject strong { font-size: .91rem; }
  body[data-companion] > .scroll-indicator .scroll-cue { bottom: -29px; right: 54px; }
}

.hero-card-selected { outline: 3px solid #4178bd; outline-offset: -3px; }
.hero-lock-badge { background: #e3efff; color: #174678; }
.onboarding-name { max-width: 30rem; }
.onboarding-actions { justify-content: space-between; }
.loadout.hero-loadout { grid-template-columns: repeat(2, minmax(0, 9rem)); }
.loadout .equipped-slot {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 3px;
  padding: 6px 4px;
  text-align: center;
  border: 1px solid var(--slot-color);
  box-shadow: inset 0 0 10px var(--slot-glow);
  border-radius: 12px;
  background: var(--panel, #fff);
  overflow-wrap: anywhere;
  min-width: 0;
}
.equipped-slot .slot-icon { width: 48px; height: 48px; object-fit: contain; }
.loadout .empty-slot { border-style: dashed; box-shadow: none; }
.empty-slot .slot-icon { opacity: .28; filter: grayscale(1); }
@media (max-width: 600px) {
  .loadout { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* v5.3 aligned battle stage: equal sprite row, name row, HP-bar row and HP-text row */
.battle-arena { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; --stage: 100px; --sprite: 94px; --boss-sprite: 114px; }
.battle-arena.boss-stage { --stage: 118px; }
.battle-player, .battle-enemy {
  display: grid; grid-template-rows: var(--stage) 22px 16px auto auto; align-self: start; align-content: start;
  justify-items: center; row-gap: 3px; padding: 0; min-width: 0;
}
.sprite-stage { height: var(--stage); width: 100%; display: flex; align-items: flex-end; justify-content: center; position: relative; }
.sprite-stage::after { content: ""; position: absolute; bottom: 1px; left: 50%; width: 62%; height: 8px; translate: -50% 0;
  border-radius: 50%; background: radial-gradient(#3a2d5a40, transparent 70%); z-index: -1; }
.battle-player .sprite-stage .avatar-wrap { height: var(--sprite); }
.battle-player .avatar {
  width: auto; height: var(--sprite); border: 0; border-radius: 0; box-shadow: none; background: none; overflow: visible;
}
.battle-player .avatar img { height: var(--sprite); width: auto; aspect-ratio: 240 / 280; object-fit: contain; object-position: center bottom; border-radius: 0; }
.battle-player .v5-portrait .hero-hat { top: 0; }
.battle-enemy .monster { height: var(--sprite); width: auto; max-width: 100%; object-fit: contain; object-position: center bottom; }
.boss-stage .battle-enemy .monster { height: var(--boss-sprite); }
.battle-name { height: 22px; line-height: 22px; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; display: flex; gap: 4px; align-items: center; }
.boss-tag { font-size: .66rem; padding: 1px 6px; border-radius: 99px; background: #e65487; color: #fff; line-height: 1.4; }
.hp-row { height: 16px; width: min(185px, 100%); display: flex; align-items: center; gap: 4px; position: relative; }
.hp-row #hero-hp, .hp-row #boss-hp { flex: 1; min-width: 13px; width: auto; height: 13px; margin: 0; display: block; }
.hp-row #hero-shield { position: absolute; right: -2px; top: -16px; font-size: .95rem; line-height: 1; }
.hp-text { line-height: 1.2; }
.enemy-life { width: min(185px, 100%); }
@media (max-width: 600px) {
  .battle-arena { --stage: 92px; --sprite: 86px; --boss-sprite: 104px; }
  .battle-arena.boss-stage { --stage: 108px; }
}

.pet-grid { grid-auto-rows: 1fr; }
.pet-card .card-actions { display: grid; align-items: stretch; }
.pet-upgrade-preview { display: grid; gap: 2px; font-size: .78rem; }
.pet-upgrade-preview small { font-size: inherit; }
.pet-shortage { color: #972b37; }
