@font-face {
  font-family: StarlightRound;
  src: url("assets/fonts/zcool-kuaile-subset.woff2") format("woff2");
  font-display: swap;
}

:root {
  --ink: #382441;
  --muted: #725d72;
  --cream: #fffaf0;
  --berry: #be366b;
  --pink: #f8b9d3;
  --mint: #c0efdc;
  --gold: #8c550c;
  --red: #a63258;
  --edge: #dec7ce;
  --shadow: 0 5px 0 #cbb1bf, 0 12px 24px #674b6321;
  --top: max(12px, env(safe-area-inset-top));
  --left: max(12px, env(safe-area-inset-left));
  --right: max(12px, env(safe-area-inset-right));
  --bottom: max(12px, env(safe-area-inset-bottom));
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; overflow: hidden; height: 100%; overscroll-behavior: none; }
body {
  color: var(--ink);
  background: var(--cream);
  font: 600 15px/1.5 "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
#game { position: fixed; inset: 0; display: block; touch-action: none; }
button { cursor: pointer; color: inherit; font: inherit; touch-action: manipulation; }
button:disabled { cursor: default; }
button:focus-visible { outline: 3px solid #187b72; outline-offset: 4px; }
html.touch-input button:focus { outline: none; }
button:not(:disabled) { transition: transform .16s, box-shadow .16s, background .16s; }
button:not(:disabled):active { transform: translateY(3px); box-shadow: none; }
.hidden, .done { display: none !important; }
h1, h2, p, figure { margin: 0; }
h1, h2 { font-family: StarlightRound, "PingFang SC", system-ui, sans-serif; font-weight: 400; line-height: 1.05; }
h2 { font-size: clamp(29px, 5vw, 52px); }
svg { display: block; }
.btn, .icon-btn, .hud-pause, .settings-close {
  min-height: 44px;
  padding: 9px 23px;
  border: 1px solid #9e2f58;
  border-radius: 15px;
  background: linear-gradient(#df6192, #bc366b);
  color: white;
  box-shadow: 0 4px 0 #902850, 0 8px 16px #a62c6240;
  font-weight: 800;
}
.ghost, .icon-btn, .hud-pause, .settings-close {
  border-color: var(--edge);
  background: var(--cream);
  color: var(--ink);
  box-shadow: 0 3px 0 #cfbac7;
}
.icon-btn, .hud-pause, .settings-close { display: grid; place-items: center; width: 44px; padding: 0; }
#settingsBtn { position: fixed; z-index: 9; top: var(--top); left: var(--left); }
.icon-btn img { width: 26px; }
.hud-pause svg, .settings-close svg { width: 20px; fill: currentColor; }
.settings-close svg { fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; }

.screen, #loading {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: safe center; gap: 14px; padding: max(64px, var(--top)) var(--right) max(18px, var(--bottom)) var(--left);
  overflow: auto; z-index: 7; text-align: center; background: #fff5eb;
}
.screen, #loading, .settings-overlay { touch-action: pan-y; overscroll-behavior: contain; }
#loading {
  z-index: 20;
  isolation: isolate;
  display: grid;
  grid-template: "title" 24% "." 1fr "entry" auto / minmax(0, 1fr);
  justify-items: center;
  align-items: center;
  gap: 0;
  padding: max(18px, var(--top)) max(24px, var(--right)) max(5svh, var(--bottom)) max(24px, var(--left));
  background: #19163d;
}
.load-art {
  position: absolute; z-index: -1; inset: 0;
  width: 100%; height: 100%; object-fit: cover; object-position: center;
}
.load-title {
  grid-area: title;
  align-self: end;
  font-size: clamp(39px, min(13vw, 8svh), 86px);
  line-height: .98;
  color: #fff2d3;
  text-shadow: 0 3px 0 #623f74, 0 6px 18px #151034;
}
.load-title span { display: table; position: relative; margin: 0 auto; font-size: .75em; color: #ffd487; }
.load-title img { position: absolute; width: .58em; inset: -.08em auto auto calc(100% + .14em); transform: rotate(11deg); }
.load-slot { grid-area: entry; width: min(100%, 330px); min-height: 80px; display: grid; place-items: center; }
.load-slot > * { grid-area: 1 / 1; }
.load-meter { width: 100%; display: grid; gap: 8px; }
#loading.ready .load-meter { visibility: hidden; }
#loadStart {
  width: min(100%, 240px);
  min-height: 52px;
  background: linear-gradient(#fff0ab, #ffc55f);
  color: #552b48;
  border-color: #ffe6a4;
  border-radius: 999px;
  box-shadow: 0 5px 14px #35162b70;
  font-size: 17px;
}
#loadStart:focus-visible { outline-color: #fff7df; }
#loading.ready #loadStart { animation: load-unseal .26s cubic-bezier(.18,.8,.25,1) both; }
@keyframes load-unseal { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.load-track { height: 14px; border: 1px solid #ffd9a0; background: #3f2548; border-radius: 999px; overflow: hidden; }
.load-track i { display: block; height: 100%; background: linear-gradient(90deg, #f9ab56, #ffe497); border-radius: inherit; transition: transform .2s ease; }
.load-track i, .hbar-track i { transform: scaleX(var(--progress, 0)); transform-origin: left center; }
.load-status, .load-tip { color: #fff7e9; font-size: 13px; text-shadow: 0 1px 4px #28182e; }
.load-status { display: flex; justify-content: space-between; gap: 8px; font-variant-numeric: tabular-nums; }
.load-tip { color: #ffe3d5; }
@media (orientation: landscape) {
  #loading {
    grid-template: "title ." 1fr "entry ." 1fr / minmax(0, 44%) 1fr;
    padding-inline: clamp(20px, 6vw, 100px);
    background: linear-gradient(90deg, #19163d 35%, #19163d00 80%);
  }
  .load-art { z-index: -2; left: auto; width: 65%; object-position: 50% 47%; }
  #loading::before { content: ""; position: absolute; z-index: -1; inset: 0; background: linear-gradient(90deg, #19163d 34%, #19163d00 62%); }
  .load-title { font-size: clamp(38px, min(8vw, 14svh), 96px); }
  .load-slot { align-self: center; }
}
#sceneTransition {
  position: fixed; inset: 0; z-index: 25; overflow: hidden; pointer-events: all;
}
.scene-wrap {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse farthest-corner at var(--scene-x,50%) var(--scene-y,50%),
    #fff6dc 0%, #f7e4d7 52%, #e9cfd8 100%);
}
.scene-spark {
  position: absolute; left: var(--scene-x,50%); top: var(--scene-y,50%);
  width: clamp(32px, 4vw, 46px); transform: translate(-50%,-50%);
}
@media (prefers-reduced-motion: no-preference) {
  #sceneTransition:not(.hidden) .scene-spark { animation: scene-glimmer .76s ease-out both; }
}
@keyframes scene-glimmer {
  from { transform: translate(-50%,-50%) rotate(-12deg) scale(.78); }
  to { transform: translate(-50%,-50%) rotate(4deg) scale(1.06); }
}

#menu {
  padding: max(48px, var(--top)) var(--right) max(14px, var(--bottom)) var(--left);
  background: linear-gradient(180deg, #19163d22 18%, transparent 48%, #14162cd9 100%),
    #19163d url("assets/entry/lobby-valley.webp") 50% 58% / cover no-repeat;
}
.home-shell {
  width: min(980px, 100%);
  min-height: min(76svh, 720px);
  display: grid;
  grid-template: "title hero" 1fr "actions hero" 1fr / 1fr 1.1fr;
  align-items: center;
  gap: clamp(10px, 3vw, 44px);
}
.home-copy { grid-area: title; align-self: end; text-align: left; }
#gameTitle {
  font-size: clamp(44px, 7.5vw, 98px);
  line-height: 1.04;
  color: #ffd68d;
  text-shadow: 0 3px #6a407a, 0 10px 28px #171233;
}
#gameTitle span { display: block; color: #fff1d4; }
.home-actions { grid-area: actions; align-self: start; justify-self: start; display: grid; gap: 11px; width: min(100%, 290px); }
.home-play {
  display: flex; align-items: center; gap: 13px; width: 100%; min-height: 54px; padding: 8px 14px;
  color: #281d47; background: linear-gradient(180deg, #fff0b5, #efba70); border-color: #ffe4ab;
  box-shadow: 0 4px #885c72, 0 9px 22px #14102d99;
}
.home-play img { width: 34px; }
.play-copy { flex: 1; text-align: left; font-size: 19px; }
#menuProgress { font-size: 12px; font-weight: 700; color: #fff0da; text-shadow: 0 1px 6px #14162c; }
.hero-area { grid-area: hero; position: relative; min-width: 0; display: grid; place-items: center; isolation: isolate; }
.hero-area::after {
  content: ""; position: absolute; z-index: -1; bottom: 3%;
  width: 48%; height: 10%; border-radius: 50%;
  background: radial-gradient(ellipse, #1f172984 12%, transparent 72%);
}
.hero-character { display: block; width: min(100%, 400px, 66svh); }
.hero-character img { display: block; width: 100%; height: auto; filter: drop-shadow(0 0 14px #ebc3ff55); }

#levels { background: linear-gradient(#fff9e8ad, #fff7ec59), #ffe9d6 url("assets/starlight-island.webp") center bottom / cover; }
.sub, .hint { color: var(--muted); }
#levelGrid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; width: min(100%, 495px); }
.lv {
  position: relative; display: grid; place-items: center; min-width: 0; min-height: 48px; aspect-ratio: 1.36;
  border: 1px solid #cda7bd; border-radius: 14px; background: var(--act); box-shadow: 0 3px 0 #b892a7;
}
.act1 { --act: #e1f4c9; } .act2 { --act: #ffdbeb; } .act3 { --act: #d7f1fe; } .act4 { --act: #e8ddff; }
.lv .n { font-weight: 900; font-size: 19px; }
.lv.boss { border: 2px solid #b67522; }
.lv.locked { background: color-mix(in srgb, var(--act) 48%, #efeaeb); color: var(--muted); box-shadow: none; }

#hud {
  --hud-top: max(7px, env(safe-area-inset-top));
  --hud-gold: #b58549;
  --hud-rim: #6d4b42;
  --hud-candy: linear-gradient(#fff8e0, #f9e1b2);
  --hud-shadow: 0 2px 0 #72534295, 0 3px 5px #3c482f29;
  position: fixed; z-index: 5;
  inset: var(--hud-top) max(7px, env(safe-area-inset-right)) auto max(7px, env(safe-area-inset-left));
  display: none; flex-direction: column; gap: 7px; max-width: 660px; margin-inline: auto;
  pointer-events: none;
}
.hud-top {
  display: grid; grid-template-columns: clamp(51px, 16.5vw, 75px) minmax(0, 1fr) clamp(44px, 11.5vw, 56px);
  align-items: center; gap: clamp(5px, 2.3vw, 15px);
}
.hud-avatar {
  position: relative; isolation: isolate; aspect-ratio: 1.13;
  margin: 3px 4px 3px 1px;
  border: 1.5px solid var(--hud-rim); border-radius: 38% 38% 31% 31%;
  background: var(--hud-candy); box-shadow: var(--hud-shadow), inset 0 0 0 2px #fff8e9;
}
.hud-portrait { position: absolute; inset: 2px; border-radius: inherit; overflow: hidden; background: radial-gradient(#fffcf2, #e9cdf6); }
.hud-portrait img { position: absolute; width: 100%; height: 100%; object-fit: cover; inset: 0; }
.hud-lv {
  position: absolute; bottom: -2px; right: -6px; display: grid; grid-auto-flow: column; place-content: center;
  min-width: 25px; aspect-ratio: 1; padding: 0 3px;
  border: 2px solid #f5e5fb; border-radius: 50%; background: linear-gradient(#b176d6, #613685);
  box-shadow: 0 0 0 1px #4e315e, 0 2px 0 #513d50;
  color: #fff9ff; font-size: clamp(10px, 2.7vw, 15px); font-weight: 950; line-height: 1;
}
.hud-bars { min-width: 0; display: grid; gap: clamp(3px, 1.15vw, 6px); }
.hbar { display: flex; align-items: center; gap: clamp(3px, 1.1vw, 7px); }
.hbar-ico { width: clamp(17px, 5.5vw, 25px); flex: none; filter: drop-shadow(0 1px 0 #513d4e65); }
.hbar-ico svg { width: 100%; fill: #fa647e; stroke: #6a383b; stroke-width: 1.5; stroke-linejoin: round; }
.xp .hbar-ico svg { fill: #ffcf51; stroke: #9f621f; }
.hbar-ico .shine { fill: #fff4e9; stroke: none; }
.hbar-track, .bar { position: relative; border-radius: 99px; overflow: hidden; }
.hbar-track {
  flex: 1; min-width: 0; height: clamp(18px, 5.25vw, 27px);
  border: 2px solid #fff4dc; outline: 1px solid var(--hud-rim);
  background: linear-gradient(#8c6a52, #e6c497 40%, #f8e2b4 78%, #a67c61);
  box-shadow: var(--hud-shadow);
}
.hbar-track i, .bar i { position: absolute; inset: 0; border-radius: inherit; }
.hbar-track i {
  background: linear-gradient(136deg, transparent 24%, #fff3 24% 29%, transparent 29% 69%, #fff2 69% 74%, transparent 74%), linear-gradient(#ffbdc2, #fa6588 54%, #e44770);
  box-shadow: inset 0 1px 0 #fff8, inset 0 -2px 1px #a72e5960;
  transition: transform .19s ease-out;
}
.hp.low .hbar-track i { background: linear-gradient(#ff9f92, #cc3054 80%); }
.xp .hbar-track { height: clamp(12px, 3.75vw, 19px); background: linear-gradient(#655948, #aba385 50%, #776f58); }
.xp .hbar-track i {
  background: linear-gradient(130deg, #ffcb8c, #f1a1fa 27%, #bc76f2 70%, #9f5cde);
  box-shadow: inset 0 1px 1px #ffefff, inset 0 -2px 2px #6c29965c;
}
.xp .hbar-text { font-size: clamp(9px, 2.5vw, 12px); -webkit-text-stroke-width: 2px; white-space: nowrap; }
.hbar-text {
  position: absolute; inset: 0; display: grid; place-content: center;
  color: #fffaf4; font-size: clamp(11px, 3.5vw, 19px); font-weight: 950; line-height: 1;
  font-variant-numeric: tabular-nums; paint-order: stroke fill; -webkit-text-stroke: 2.6px #492b3a;
}
#hud .hud-pause, .hud-stage, .wicon {
  border: 1px solid var(--hud-gold);
  background: var(--hud-candy);
  box-shadow: var(--hud-shadow), inset 0 0 0 2px #fff7df;
}
#hud .hud-pause {
  pointer-events: auto; width: 100%; aspect-ratio: 1; min-height: 44px; border-radius: 14px;
  background: linear-gradient(#fff4cf, #ffd895);
}
#hud .hud-pause svg { width: 56%; fill: #fff9e8; stroke: #df405e; stroke-width: 1.75; }
.hud-stage {
  min-height: clamp(37px, 9vw, 46px); border-radius: clamp(12px, 3vw, 17px);
  display: flex; align-items: center; justify-content: space-between;
  gap: 5px; padding: 3px clamp(5px, 1.7vw, 10px);
}
.hud-act { display: flex; align-items: center; gap: clamp(3px, 1.45vw, 8px); min-width: 0; color: #983d31;
  font-size: clamp(12px, 3.4vw, 19px); font-weight: 900; line-height: 1.12; }
.hud-act-icon { flex: none; display: grid; place-items: center; width: clamp(23px, 8.2vw, 38px); aspect-ratio: 1;
  background: #f4d9a6; border-radius: 50%; font-size: clamp(15px, 5.6vw, 28px); line-height: 1; }
.hud-stats { flex: none; display: flex; gap: clamp(3px, 1.15vw, 7px); padding-left: clamp(4px, 1.6vw, 11px); border-left: 1px solid #dfba8580; }
.hud-stat {
  display: flex; align-items: center; gap: 3px; justify-content: center;
  border-radius: 99px; padding: 2px clamp(4px, 1.4vw, 11px);
  background: linear-gradient(#8a6d79, #755c67); color: #fffbf7;
  font-size: clamp(10px, 3.1vw, 17px); font-weight: 950; line-height: 1.35;
  font-variant-numeric: tabular-nums; white-space: nowrap; text-shadow: 0 1px #432634;
}
.hud-stat svg { width: clamp(12px, 4.1vw, 21px); fill: #f0d3ed; stroke: #553746; stroke-width: 1.7; stroke-linecap: round; }
.hud-stat .hole { fill: #553746; stroke: none; }
#wpanel { display: flex; gap: 5px; flex-wrap: wrap; padding-inline: 5px; }
.wicon {
  position: relative; width: clamp(36px, 10.4vw, 52px); aspect-ratio: 1; border-radius: 12px;
  display: grid; place-items: start center; padding: 2px;
}
.wicon .item-glyph { width: 73%; height: 73%; }
.wicon small { position: absolute; bottom: 1px; color: #963f2f; font-size: clamp(9px, 2.4vw, 12px); font-weight: 950; line-height: 1.05; }
#bossbar { display: none; pointer-events: none; position: fixed; z-index: 6; bottom: max(25px, var(--bottom)); left: 50%; transform: translateX(-50%); width: min(77%, 450px); border: 1px solid var(--edge); border-radius: 15px; background: var(--cream); padding: 6px 10px; text-align: center; }
.bar.boss { height: 14px; background: #e7d7e7; }
.bar.boss i { width: 100%; background: #c55285; }
#toast { position: absolute; pointer-events: none; top: calc(100% + 7px); left: 50%; width: max-content; max-width: 90%; text-align: center; transform: translate(-50%, -6px); opacity: 0; padding: 6px 13px; border-radius: 12px; background: #513445; color: #fff8ee; font-size: 12px; transition: opacity .15s, transform .15s; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

#result { background: #fbededec; }
#levelup {
  justify-content: safe center;
  padding: max(100px, var(--top)) var(--right) max(74px, var(--bottom)) var(--left);
  background: transparent;
}
#rewardVeil {
  position: fixed; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, #20162b4d 0%, #24172bc9 56%, #281935e8 100%);
  transition: opacity 175ms ease-out;
}
body:has(#levelup:not(.hidden)) #hud { z-index: 8; }
body:has(#levelup:not(.hidden)) #hud .hud-pause { pointer-events: none; }
body:has(#levelup:not(.hidden):not(.is-peeking)) #toast { visibility: hidden; }
.reward-drawer {
  position: relative; width: min(100%, 648px);
  outline: none;
}
#rewardContent {
  display: grid; justify-items: center; gap: clamp(13px, 3.4vw, 20px);
  transition: opacity 165ms ease-out, transform 165ms ease-out;
}
.reward-head {
  display: grid; justify-items: center; gap: 5px;
  color: #fff2d4; text-shadow: 0 2px 9px #1e112c, 0 1px 2px #1e112c;
}
.reward-head h2 {
  display: flex; align-items: center; justify-content: center; gap: 11px;
  font-size: clamp(28px, 6vw, 42px); line-height: 1.15;
}
.reward-head h2::before, .reward-head h2::after {
  content: ""; width: 14px; height: 14px; flex: none; background: #ffdc8f;
  clip-path: polygon(50% 0, 62% 39%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 39%);
}
#upHint { line-height: 1.25; font-size: 12px; color: #ffead7; }
#upHint:empty { display: none; }
#cards {
  width: 100%; display: flex; justify-content: center; align-items: stretch;
  gap: clamp(6px, 2vw, 15px);
}
.card {
  --card-light: #e1cff5; --card-ink: #563572; --card-rim: #9a77b4;
  flex: 1 1 0; max-width: min(206px, 35%); min-width: 0; min-height: 222px;
  position: relative; border: 0; padding: 0; background: transparent; border-radius: 13px;
  perspective: 760px; color: #302044; text-align: center;
}
.card-bolt, .card-speed, .card-armor, .card-wave, .card-beam, .card-xp {
  --card-light: #d0e8fb; --card-ink: #284e74; --card-rim: #739abb;
}
.card-orbit, .card-firerate, .card-boomer, .card-chrono, .card-area {
  --card-light: #dfd0f7; --card-ink: #573383; --card-rim: #9879c4;
}
.card-nova, .card-damage, .card-maxhp, .card-sprite, .card-revive, .card-critdmg {
  --card-light: #f6cfe6; --card-ink: #843758; --card-rim: #bc7198;
}
.card-aura, .card-crit, .card-regen {
  --card-light: #ccecdf; --card-ink: #285b51; --card-rim: #6c9d88;
}
.card-lightning, .card-cooldown, .card-pickup, .card-chain, .card-mine, .card-duration {
  --card-light: #f7deb6; --card-ink: #73411f; --card-rim: #ab7b4c;
}
.card-back, .card-front { backface-visibility: hidden; border-radius: inherit; }
.card-back {
  position: absolute; inset: 0; opacity: 0; pointer-events: none;
  background: #352449 url("assets/reward-card-back.svg") center / 100% 100% no-repeat;
  box-shadow: 0 8px 18px #160d2588;
}
.card-front {
  min-height: 100%; height: 100%; position: relative; isolation: isolate;
  display: grid; align-content: start; justify-items: center;
  grid-template-rows: auto auto auto 1fr auto;
  gap: clamp(6px, 1.7vw, 9px); padding: 13px clamp(6px, 1.5vw, 16px) 10px;
  border: 1px solid var(--card-rim);
  background: linear-gradient(154deg, var(--card-light), #f4eafb 43%, #fbf7ff 92%);
  box-shadow: inset 0 0 0 2px #fff9ed, 0 6px 14px #170f2866;
}
.card-front::before {
  content: ""; position: absolute; inset: 5px; z-index: -1; border: 1px solid var(--card-rim);
  border-radius: 8px; opacity: .7; pointer-events: none;
  background: linear-gradient(90deg, #fff2bb 0 8px, transparent 8px calc(100% - 8px), #fff2bb calc(100% - 8px)) top / 100% 1px no-repeat,
              linear-gradient(90deg, #fff2bb 0 8px, transparent 8px calc(100% - 8px), #fff2bb calc(100% - 8px)) bottom / 100% 1px no-repeat;
}
.card-front::after {
  content: ""; position: absolute; inset: 4px; pointer-events: none;
  background:
    radial-gradient(circle, var(--card-ink) 1px, transparent 1.5px) top left / 5px 5px no-repeat,
    radial-gradient(circle, var(--card-ink) 1px, transparent 1.5px) top right / 5px 5px no-repeat,
    radial-gradient(circle, var(--card-ink) 1px, transparent 1.5px) bottom left / 5px 5px no-repeat,
    radial-gradient(circle, var(--card-ink) 1px, transparent 1.5px) bottom right / 5px 5px no-repeat;
}
:where(html:not(.touch-input)) .card:focus-visible .card-front,
.card.is-selected .card-front { border-color: #e7b868; box-shadow: inset 0 0 0 2px #ffefbd, 0 6px 14px #170f2866; }
.card:focus-visible { outline: 2px solid #fff0bf; outline-offset: 3px; }
.card .cn {
  width: 100%; display: block; padding: 3px 0 5px; border-bottom: 1px solid var(--card-rim);
  font: 400 clamp(14px, 2.3vw, 22px)/1.18 StarlightRound, "PingFang SC", system-ui, sans-serif;
  color: var(--card-ink); overflow-wrap: anywhere;
}
.card .ci {
  width: clamp(48px, 15vw, 74px); aspect-ratio: 1; display: grid; place-items: center;
  background: radial-gradient(circle closest-side, #fff8e5 68%, var(--card-rim) 70% 71%, transparent 73%);
}
.card .ci .item-glyph { width: 87%; height: 87%; filter: drop-shadow(0 2px 2px #24133542); }
.card .cl {
  max-width: 100%; padding: 2px 5px; border-radius: 4px; background: var(--card-light);
  color: var(--card-ink); font-size: clamp(10px, 1.6vw, 13px); font-weight: 800;
  line-height: 1.2; font-variant-numeric: tabular-nums;
}
.card .cd {
  color: #443350; font-weight: 650; font-size: clamp(11px, 1.7vw, 14px);
  line-height: 1.46; text-wrap: pretty; overflow-wrap: anywhere;
}
.card .ck {
  align-self: end; min-width: 18px; border-radius: 4px; border: 1px solid var(--card-rim);
  padding: 0 4px; color: var(--card-ink); font: 700 11px/1.45 system-ui, sans-serif;
}
#skipCardBtn, #rewardPeekBtn {
  min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid #d5a969; border-radius: 12px;
  background: #39264a; color: #fff2d7;
}
#skipCardBtn { padding: 0 15px; font-size: 13px; background: #2c1e3a; }
#rewardPeekBtn {
  position: fixed; z-index: 1; bottom: var(--bottom); right: var(--right);
  padding: 0 10px; font-size: 12px;
}
#rewardPeekBtn svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.65; }
#skipCardBtn:focus-visible, #rewardPeekBtn:focus-visible { outline-color: #ffe4a5; }
#rewardPeekStatus {
  position: fixed; bottom: calc(var(--bottom) + 6px); left: var(--left);
  padding: 5px 10px; color: #fff4da; background: #302041eb; border-radius: 8px; font-size: 12px;
}
#rewardPeekStatus:empty { display: none; }
#levelup.is-peeking #rewardVeil { opacity: 0; }
#levelup.is-peeking #rewardContent { opacity: 0; transform: translateY(10px); pointer-events: none; }
.stats, .result-btns { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.stats > div, .result-build { display: grid; gap: 4px; min-width: 85px; border: 1px solid var(--edge); background: var(--cream); border-radius: 13px; padding: 8px 12px; }
.stats b { font-size: 21px; }
.result-build { width: min(100%, 370px); }

.settings-overlay { position: fixed; z-index: 12; inset: 0; display: grid; place-items: safe center; overflow: auto; padding: var(--top) var(--right) var(--bottom) var(--left); }
.settings-overlay#settingsOverlay { z-index: 13; }
.settings-backdrop { position: fixed; inset: 0; background: #3d23496e; }
.settings-panel { position: relative; width: min(100%, 465px); background: var(--cream); border: 2px solid #e8bfd0; border-radius: 24px; padding: clamp(10px, 3vw, 21px); box-shadow: var(--shadow); }
.settings-head { display: flex; align-items: center; gap: 8px; }
.settings-head h2 { flex: 1; font-size: 31px; }
.settings-head-gear { width: 29px; fill: var(--berry); }
.settings-body { margin-block: 12px; display: grid; gap: 5px; }
.setting-row { min-width: 0; display: flex; gap: 7px; align-items: center; border-radius: 10px; background: #f7ebee; padding: 5px; }
.setting-icon { width: 24px; flex: none; }
.setting-icon svg { width: 100%; stroke: #91476e; stroke-width: 1.7; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.setting-text { flex: 1; display: grid; min-width: 0; line-height: 1.25; }
.setting-text small, .settings-note, .pause-sub { color: var(--muted); font-size: 12px; }
.switch, .seg button { min-height: 44px; border: 1px solid var(--edge); background: var(--cream); border-radius: 9px; padding: 0 6px; font-size: 12px; }
.switch { width: 52px; display: flex; align-items: center; background: #e2d5e1; }
.switch i { width: 18px; height: 18px; border-radius: 50%; background: white; box-shadow: 0 1px 4px #72576c56; transition: transform .18s; }
.switch.on, .seg .active { background: #bee9d7; border-color: #6daa98; }
.switch.on i { transform: translateX(19px); }
.seg { display: flex; gap: 2px; }
.pause-actions { display: grid; gap: 9px; margin-top: 13px; }

@media (hover: hover) {
  button:not(:disabled):hover { filter: brightness(1.04); }
  .card:hover { transform: translateY(-4px); border-color: var(--card-ink); }
}
@media (pointer: coarse) { .card .ck { display: none; } }
@media (orientation: portrait) {
  .home-shell {
    width: min(100%, 470px);
    min-height: min(82svh, 800px);
    grid-template: "title" auto "hero" 1fr "actions" auto / minmax(0, 1fr);
    justify-items: center;
    gap: clamp(8px, 2svh, 18px);
  }
  .home-copy { text-align: center; align-self: center; }
  #gameTitle { font-size: clamp(36px, 11vw, 64px); }
  #gameTitle span { display: inline; }
  .hero-area { align-self: end; width: 100%; }
  .hero-character { width: min(85%, 385px, 49svh); }
  .home-actions { justify-self: center; align-self: end; }
}
@media (max-height: 470px) and (orientation: landscape) {
  .home-shell { padding-inline: 34px; }
  #gameTitle { font-size: clamp(33px, 6vw, 65px); }
  #levels { gap: 7px; padding-top: 10px; }
  #levelGrid { max-width: 445px; gap: 5px; }
  .lv { min-height: 40px; aspect-ratio: auto; }
}
@media (max-height: 480px) and (orientation: landscape) {
  #levelup { padding-top: 132px; padding-bottom: max(14px, var(--bottom)); }
  body:has(#levelup:not(.hidden):not(.is-peeking)) #hud { z-index: 5; }
  #rewardContent { gap: 8px; }
  .reward-head h2 { font-size: 26px; }
  .card { min-height: 126px; }
  .card-front {
    grid-template-rows: auto auto 1fr;
    grid-template-columns: 45px minmax(0, 1fr);
    gap: 4px 5px; padding: 11px 8px; align-content: start;
  }
  .card .ci { grid-row: 1 / 3; grid-column: 1; width: 42px; }
  .card .cn, .card .cl { grid-column: 2; }
  .card .cn { font-size: 15px; }
  .card .cd { grid-column: 1 / -1; font-size: 11px; }
  .card .ck { display: none; }
}
@media (pointer: coarse) { .card .ck { display: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
.item-glyph { width: 72%; height: 72%; }
#rBuild { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; }
#rBuild span { display: inline-flex; align-items: center; gap: 3px; background: #f6e5ed; border-radius: 7px; padding: 3px 6px; font-size: 11px; }
#rBuild .item-glyph { width: 15px; height: 15px; }
.lv-mark { position: absolute; top: 5px; right: 6px; width: 15px; height: 15px; color: #725769; }
.lv-mark > * { display: block; width: 100%; height: 100%; }

.settings-overlay:not(.hidden) .settings-backdrop { animation: veil-in .17s ease-out both; }
.settings-overlay:not(.hidden) .settings-panel { animation: panel-arrive .22s cubic-bezier(.16, 1, .3, 1) both; }
#result:not(.hidden) { animation: veil-in .24s ease-out both; }
@keyframes veil-in { from { opacity: 0; } }
@keyframes panel-arrive { from { opacity: 0; transform: translateY(9px) scale(.97); } }

@media (prefers-reduced-motion: reduce) {
  .settings-overlay:not(.hidden) .settings-backdrop,
  .settings-overlay:not(.hidden) .settings-panel,
  #result:not(.hidden) { animation: none; }
}
