:root {
  --font: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Heiti TC", system-ui, sans-serif;
  --ink: #1a1030;
  --pink: #ff4f8b;
  --yellow: #ffd23f;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: var(--app-h, 100%); overflow: hidden; background: #1a1030; color: #fff; font-family: var(--font);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; overscroll-behavior: none; touch-action: none; }
canvas#game { position: fixed; top: 0; left: 0; width: 100%; height: var(--app-h, 100vh); display: block; touch-action: none; background: #f0d9bd; }
button { font-family: var(--font); cursor: pointer; border: 0; }
.hidden { display: none !important; }

#flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 30; }
#flash.on { animation: flash .5s ease-out; }
@keyframes flash { 0% { opacity: var(--fo, .9) } 100% { opacity: 0 } }
#danger { position: fixed; inset: 0; pointer-events: none; opacity: 0; z-index: 2;
  background: radial-gradient(ellipse at center, rgba(255,0,0,0) 55%, rgba(220,0,30,.55) 100%); }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.panel { background: rgba(20, 12, 40, .55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,.12); border-radius: 14px; }
#avatar-wrap { position: absolute; left: calc(10px + var(--sal)); top: calc(10px + var(--sat)); width: 54px; height: 54px; }
#avatar { width: 54px; height: 54px; border-radius: 50%; border: 3px solid #ffd23f; box-shadow: 0 3px 10px rgba(0,0,0,.35); object-fit: cover; transition: filter .3s, border-color .3s; }
#avatar-badge { position: absolute; right: -6px; bottom: -4px; font-size: 20px; line-height: 1; filter: drop-shadow(0 1px 2px rgba(0,0,0,.6)); }
#avatar-wrap.st-happy #avatar { border-color: #ff6fa5; animation: av-bounce .5s ease-in-out infinite alternate; }
#avatar-wrap.st-hungry #avatar { border-color: #ffb300; filter: saturate(.5); animation: av-pulse .8s ease-in-out infinite alternate; }
#avatar-wrap.st-tired #avatar { border-color: #8fa3c9; filter: grayscale(.6) brightness(.8); }
#avatar-wrap.st-danger #avatar { border-color: #ff2d3d; box-shadow: 0 0 0 3px rgba(255,45,61,.45), 0 3px 10px rgba(0,0,0,.35); animation: av-shake .12s linear infinite; }
#avatar-wrap.st-hungry #avatar-badge, #avatar-wrap.st-danger #avatar-badge { animation: av-pulse .5s ease-in-out infinite alternate; }
@keyframes av-bounce { to { transform: translateY(-3px) rotate(-4deg); } }
@keyframes av-pulse { to { transform: scale(1.12); } }
@keyframes av-shake { 0% { transform: translateX(-1.5px) } 50% { transform: translateX(1.5px) } 100% { transform: translateX(-1.5px) } }
/* chaser direction arrows */
#arrows { position: absolute; inset: 0; pointer-events: none; }
.arrow { position: absolute; left: 0; top: 0; width: 0; height: 0; display: none; will-change: transform; }
.arrow b { position: absolute; left: -17px; top: -17px; width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--ac, #ff2d3d); box-shadow: 0 2px 8px rgba(0,0,0,.45); }
.arrow em { position: absolute; left: -24px; top: -24px; width: 48px; height: 48px; }
.arrow em::before { content: ""; position: absolute; top: -6px; left: 50%; margin-left: -9px; border: 9px solid transparent; border-bottom: 12px solid var(--ac, #ff2d3d); border-top: 0; }
.arrow b::after { content: "!"; font-weight: 900; font-size: 18px; color: #fff; }
.arrow i { position: absolute; left: -24px; top: 20px; width: 48px; text-align: center; font-style: normal; font-weight: 900; font-size: 12px; color: #fff; text-shadow: 0 1px 3px #000; }
.arrow.near b { animation: av-pulse .3s ease-in-out infinite alternate; }
.arrow.onscreen em { display: none; }
/* sprint speed lines */
#speedlines { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .25s; background-size: cover; background-position: center; will-change: opacity; }
#stats { margin-left: 62px; }
#stats { position: absolute; left: calc(10px + var(--sal)); top: calc(10px + var(--sat)); padding: 8px 10px; width: min(220px, 42vw); }
.bar { display: flex; align-items: center; gap: 6px; height: 22px; }
.bar + .bar { margin-top: 4px; }
.bar .ico { width: 18px; font-size: 15px; text-align: center; }
.bar .lbl { font-size: 11px; font-weight: 800; opacity: .8; width: 26px; }
.track { flex: 1; height: 10px; border-radius: 6px; background: rgba(255,255,255,.14); overflow: hidden; position: relative; }
.fill { height: 100%; width: 50%; border-radius: 6px; transition: width .15s linear; }
#bar-mood .fill { background: linear-gradient(90deg, #ff9f1c, #ff3d7f); }
#bar-hunger .fill { background: linear-gradient(90deg, #c6872c, #ffd166); }
#bar-stamina .fill { background: linear-gradient(90deg, #2ec4ff, #7cffb2); }
.bar.low .fill { animation: blink .5s infinite alternate; background: #ff3b3b !important; }
@keyframes blink { to { opacity: .35 } }

#scorebox { position: absolute; left: 50%; top: calc(8px + var(--sat)); transform: translateX(-50%); text-align: center; }
#score { font-size: clamp(28px, 6vw, 44px); font-weight: 900; letter-spacing: 1px; line-height: 1;
  text-shadow: 0 3px 0 #b8255f, 0 0 18px rgba(255,79,139,.6); }
#score.bump { animation: bump .25s ease-out; }
@keyframes bump { 50% { transform: scale(1.18) } }
#scorebox .srow { display: flex; gap: 5px; justify-content: center; margin-top: 4px; }
#wave { font-size: 12px; font-weight: 900; padding: 2px 8px; border-radius: 10px; background: rgba(20,12,40,.72); color: #fff; border: 1px solid rgba(255,255,255,.25); white-space: nowrap; }
#wave.up { animation: bump .4s ease-out 2; background: rgba(255,82,82,.9); }
#mult { display: inline-block; margin-top: 0; font-size: 12px; font-weight: 900; padding: 2px 8px; border-radius: 10px; background: rgba(255,210,63,.9); color: #3b2300; }

#topright { position: absolute; right: calc(10px + var(--sar)); top: calc(10px + var(--sat)); display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
#minimap { width: clamp(84px, 22vw, 120px); height: clamp(84px, 22vw, 120px); border-radius: 50%; border: 3px solid rgba(255,255,255,.85);
  box-shadow: 0 4px 14px rgba(0,0,0,.35); background: #2a2a3a; }
.tbtns { display: flex; gap: 8px; pointer-events: auto; }
.tbtn { width: 40px; height: 40px; border-radius: 12px; background: rgba(20,12,40,.6); color: #fff; font-size: 18px; border: 1px solid rgba(255,255,255,.18); }
.tbtn.down { transform: scale(.92); }

#toasts { position: absolute; left: 50%; top: calc(86px + var(--sat)); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; width: 90vw; }
.toast { padding: 7px 14px; border-radius: 999px; font-weight: 900; font-size: clamp(13px, 3.4vw, 16px); background: rgba(20,12,40,.75); border: 2px solid rgba(255,255,255,.2);
  animation: tin .25s ease-out; white-space: nowrap; }
.toast.danger { background: rgba(200,20,40,.88); border-color: #ffb3b3; }
.toast.good { background: rgba(30,150,80,.88); border-color: #b9f6ca; }
.toast.out { animation: tout .3s ease-in forwards; }
@keyframes tin { from { transform: translateY(-10px) scale(.9); opacity: 0 } }
@keyframes tout { to { transform: translateY(-8px); opacity: 0 } }

#starve { position: absolute; left: 50%; top: 42%; transform: translateX(-50%); font-weight: 900; font-size: 18px; color: #ffd0d0;
  background: rgba(150,0,20,.75); padding: 8px 16px; border-radius: 14px; animation: blink .6s infinite alternate; }
#starve b { margin-left: 8px; font-size: 22px; color: #fff; }

#popups { position: fixed; inset: 0; pointer-events: none; z-index: 6; overflow: hidden; }
.pop { position: absolute; left: 0; top: 0; font-weight: 900; font-size: clamp(15px, 3.8vw, 20px); white-space: nowrap; color: #fff;
  text-shadow: 0 2px 0 rgba(0,0,0,.6), 0 0 6px rgba(0,0,0,.5); will-change: transform, opacity; }

/* joystick & buttons */
#joy { position: absolute; left: calc(90px + var(--sal)); bottom: calc(90px + var(--sab)); top: auto; width: 116px; height: 116px; margin: -58px 0 0 -58px;
  border-radius: 50%; background: rgba(255,255,255,.08); border: 2px solid rgba(255,255,255,.22); opacity: .55; transition: opacity .15s; }
#joy.active { opacity: 1; bottom: auto; }
#joy-knob { position: absolute; left: 50%; top: 50%; width: 50px; height: 50px; border-radius: 50%; transform: translate(-50%,-50%);
  background: radial-gradient(circle at 35% 30%, #fff, #d9d2ff); box-shadow: 0 4px 12px rgba(0,0,0,.35); }
body.pc #joy { display: none; }
#controls { position: absolute; right: calc(16px + var(--sar)); bottom: calc(18px + var(--sab)); width: 210px; height: 190px; pointer-events: none; }
.cbtn { position: absolute; pointer-events: auto; border-radius: 50%; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: 0 6px 0 rgba(0,0,0,.35), 0 8px 18px rgba(0,0,0,.3); border: 3px solid rgba(255,255,255,.8); touch-action: none; transition: transform .06s; }
.cbtn span { font-size: 28px; line-height: 1; }
.cbtn i { font-style: normal; font-weight: 900; font-size: 15px; margin-top: 2px; text-shadow: 0 1px 2px rgba(0,0,0,.5); }
.cbtn.down { transform: translateY(4px) scale(.95); box-shadow: 0 2px 0 rgba(0,0,0,.35); }
.cbtn.big { width: 104px; height: 104px; right: 0; bottom: 0; background: radial-gradient(circle at 35% 30%, #ff8ab3, #e8226a); }
.cbtn.big.push { background: radial-gradient(circle at 35% 30%, #a5e86a, #3c9a1c); }
.cbtn.big.pee { background: radial-gradient(circle at 35% 30%, #fff27a, #e0b000); }
.cbtn.big.play { background: radial-gradient(circle at 35% 30%, #ffab91, #e64a19); }
.cbtn.big.eat { background: radial-gradient(circle at 35% 30%, #ffe27a, #f39c12); animation: pulse .6s infinite alternate; }
.cbtn.big.steal { background: radial-gradient(circle at 35% 30%, #ce93d8, #7b1fa2); }
@keyframes pulse { to { transform: scale(1.06) } }
.cbtn.small { width: 66px; height: 66px; }
/* roar charge ring + cooldown on the action button */
#roar-ring { position: absolute; right: -8px; bottom: -8px; width: 120px; height: 120px; border-radius: 50%; pointer-events: none; display: none;
  background: conic-gradient(#ffd23f calc(var(--ch, 0) * 360deg), rgba(20,12,40,.6) 0); }
#roar-ring.on { display: block; }
#roar-ring.full { background: #fff; box-shadow: 0 0 20px #ffd23f; }
#btn-action.charging { animation: chshake .08s linear infinite; background: radial-gradient(circle at 35% 30%, #ffe27a, #ff6d00) !important; }
@keyframes chshake { 0% { transform: translate(-1px, 0) } 50% { transform: translate(1px, 1px) } 100% { transform: translate(-1px, 0) } }
#roar-cd { position: absolute; right: -2px; bottom: 80px; z-index: 2; pointer-events: none; min-width: 26px; height: 26px; border-radius: 13px; background: #1a1030; border: 2px solid #ffd23f; color: #ffd23f; font-size: 13px; font-weight: 900; display: flex; align-items: center; justify-content: center; }
.cbtn.small span { font-size: 22px; }
.cbtn.small i { font-size: 12px; }
#btn-sprint { right: 118px; bottom: 6px; background: radial-gradient(circle at 35% 30%, #7fe3ff, #1f8fd6); }
#btn-lie { right: 92px; bottom: 100px; background: radial-gradient(circle at 35% 30%, #c3a6ff, #6d3fd6); }
#btn-lie.on { background: radial-gradient(circle at 35% 30%, #ffb27f, #d65a1f); }
#keyhint { position: absolute; left: 50%; bottom: calc(10px + var(--sab)); transform: translateX(-50%); font-size: 12px; opacity: .7; white-space: nowrap;
  background: rgba(20,12,40,.5); padding: 4px 12px; border-radius: 10px; }
body.touch #keyhint { display: none; }

/* screens */
.screen { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; overflow-y: auto; touch-action: pan-y;
  padding: calc(16px + var(--sat)) 16px calc(16px + var(--sab)); }
#menu { background: linear-gradient(180deg, rgba(26,16,48,.15) 0%, rgba(26,16,48,.35) 55%, rgba(26,16,48,.92) 100%); align-items: flex-end; }
.menu-inner { width: min(440px, 100%); text-align: center; margin: auto 0 0; }
.menu-inner.small { margin: auto; background: rgba(20,12,40,.85); padding: 22px; border-radius: 22px; }
.logo { line-height: .95; filter: drop-shadow(0 6px 0 rgba(0,0,0,.35)); }
.logo .l1 { display: block; font-size: clamp(54px, 15vw, 84px); font-weight: 900; color: var(--yellow); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill;
  transform: rotate(-4deg); animation: wobble 2.4s ease-in-out infinite; }
.logo .l2 { display: inline-block; font-size: clamp(26px, 7vw, 38px); font-weight: 900; background: var(--pink); color: #fff; padding: 2px 14px; border-radius: 10px; transform: rotate(3deg); margin-top: 4px; }
@keyframes wobble { 50% { transform: rotate(3deg) scale(1.03) } }
.tag { margin: 12px 0 14px; font-weight: 800; opacity: .9; font-size: 14px; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.mbtn { display: block; width: 100%; padding: 13px; margin: 8px 0; border-radius: 16px; font-size: 17px; font-weight: 900; color: #fff; background: rgba(255,255,255,.14);
  border: 2px solid rgba(255,255,255,.2); }
.mbtn.primary { background: linear-gradient(180deg, #ff6fa0, #e8226a); border-color: #ffd1e0; font-size: 22px; box-shadow: 0 6px 0 #9c1046; }
.mbtn.primary:active { transform: translateY(4px); box-shadow: 0 2px 0 #9c1046; }
.mbtn.ghost { background: transparent; }
.mbtn.line { background: #06c755; border-color: #9ff0c0; }
.opts { background: rgba(20,12,40,.7); border-radius: 16px; padding: 8px 12px; margin-top: 10px; }
.opt { display: flex; align-items: center; justify-content: space-between; padding: 5px 0; font-weight: 800; font-size: 14px; }
.seg { display: flex; background: rgba(255,255,255,.1); border-radius: 10px; padding: 3px; }
.seg button { background: transparent; color: #fff; padding: 6px 10px; border-radius: 8px; font-weight: 800; font-size: 13px; opacity: .7; }
.seg button.on { background: var(--yellow); color: #3b2300; opacity: 1; }
.best { margin: 10px 0 4px; font-weight: 800; opacity: .9; }
.best b { color: var(--yellow); font-size: 20px; }
.howto-btn { padding: 10px; font-size: 15px; background: rgba(20,12,40,.7); border-color: rgba(255,255,255,.18); }
.hint { font-size: 12px; opacity: .8; margin-top: 6px; }
.ptitle { font-size: 28px; font-weight: 900; margin-bottom: 10px; }

#pause { background: rgba(10,6,20,.55); }
#over { background: rgba(10,6,20,.8); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); overflow: hidden; touch-action: none;
  padding: calc(10px + var(--sat)) calc(10px + var(--sar)) calc(10px + var(--sab)) calc(10px + var(--sal)); }
/* the result card always fits the screen: the screenshot shrinks first, nothing scrolls */
.over-card { width: min(440px, 100%); max-height: 100%; margin: auto; display: flex; flex-direction: column; gap: clamp(4px, 1.2vh, 10px);
  background: radial-gradient(120% 60% at 50% 0%, #4a2a86 0%, #2b1850 45%, #170c2c 100%); border: 2px solid rgba(255,255,255,.16);
  border-radius: 24px; padding: clamp(10px, 2vh, 16px); text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.12);
  animation: pop .4s cubic-bezier(.2,1.6,.4,1); overflow: hidden; }
@keyframes pop { from { transform: scale(.7); opacity: 0 } }
.ocol { display: flex; flex-direction: column; gap: clamp(4px, 1.1vh, 9px); min-height: 0; }
.ocol.l { flex: 1 1 auto; }
.ocol.r { flex-shrink: 0; } /* upright: the numbers and buttons keep their size, only the screenshot gives way (all buttons stay on screen) */
.ohead { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; row-gap: 4px; }
.rip { font-size: clamp(22px, 4.2vh, 32px); font-weight: 900; color: #ff5470; -webkit-text-stroke: 2px #fff; paint-order: stroke fill; transform: rotate(-3deg); line-height: 1.15; padding: 2px 4px; }
.rank { font-size: clamp(12px, 1.9vh, 15px); font-weight: 900; color: #3b2300; background: linear-gradient(180deg, #ffe680, #ffb300); padding: 4px 10px; border-radius: 999px;
  box-shadow: 0 3px 0 #9c6a00; transform: rotate(2deg); white-space: nowrap; }
.rank::before { content: "🏅 "; }
.shot { position: relative; flex: 1 1 30vh; min-height: 70px; max-height: 34vh; margin: 0 4px; border-radius: 14px; overflow: hidden; border: 4px solid #fff; transform: rotate(0.6deg); background: #000;
  box-shadow: 0 8px 20px rgba(0,0,0,.45); }
.shot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.shot .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 10px 7px; display: flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(180deg, rgba(0,0,0,0), rgba(0,0,0,.8)); }
.shot .cap span { font-size: clamp(22px, 3.6vh, 30px); filter: drop-shadow(0 2px 3px rgba(0,0,0,.6)); }
.shot .cap b { font-size: clamp(15px, 2.6vh, 21px); font-weight: 900; color: var(--yellow); text-shadow: 0 2px 0 rgba(0,0,0,.6); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.line { font-size: clamp(11px, 1.7vh, 13px); opacity: .85; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.final { display: flex; align-items: baseline; justify-content: center; gap: 6px; line-height: 1.05; flex-wrap: wrap; }
.final b { font-size: clamp(34px, 6.5vh, 52px); font-weight: 900; color: #fff; text-shadow: 0 3px 0 #b8255f, 0 0 22px rgba(255,79,139,.55); }
.final span { font-weight: 900; color: var(--yellow); font-size: clamp(14px, 2.2vh, 18px); }
.final em { font-style: normal; font-size: 12px; font-weight: 900; color: var(--yellow); margin-left: 4px; }
.final em.new { color: #3b2300; background: var(--yellow); padding: 3px 8px; border-radius: 999px; animation: pulse .5s infinite alternate; }
.sub { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; max-height: calc(2 * (clamp(11px, 1.6vh, 12px) * 1.3 + 8px) + 4px); overflow: hidden; }
.sub span { font-size: clamp(10.5px, 1.55vh, 12px); font-weight: 800; padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,.1); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: clamp(3px, .8vh, 6px); }
.grid div { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.08); border-radius: 10px; padding: clamp(2px, .6vh, 5px) 2px; display: flex; flex-direction: column; align-items: center; min-width: 0; }
.grid div.hot { background: rgba(255,210,63,.18); border-color: rgba(255,210,63,.4); }
.grid i { font-style: normal; font-size: clamp(12px, 2vh, 16px); line-height: 1.1; }
.grid b { font-size: clamp(13px, 2.2vh, 17px); font-weight: 900; line-height: 1.15; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid span { font-size: clamp(9px, 1.35vh, 11px); opacity: .75; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.obtns .mbtn { margin: 0; }
.obtns .mbtn.primary { padding: clamp(8px, 1.6vh, 13px); font-size: clamp(17px, 2.8vh, 22px); }
.obtns .row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin-top: clamp(6px, 1.2vh, 10px); }
.obtns .row .mbtn { font-size: 13px; padding: clamp(7px, 1.3vh, 11px) 2px; border-radius: 12px; }
/* phones held sideways: screenshot on the left, numbers on the right */
@media (min-aspect-ratio: 5/4) and (max-height: 620px) {
  .over-card { flex-direction: row; width: min(860px, 100%); align-items: stretch; }
  .ocol { flex: 1 1 0; justify-content: center; }
  .shot { flex: 1 1 auto; max-height: none; }
}

/* wardrobe / collection / achievements */
.closet-btn { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; background: linear-gradient(180deg, rgba(255,210,63,.22), rgba(255,210,63,.1)); border-color: rgba(255,210,63,.45); }
.closet-btn span { font-size: 15px; }
.closet-btn em { font-style: normal; font-size: 13px; font-weight: 900; color: var(--yellow); white-space: nowrap; }
#closet { align-items: flex-end; background: linear-gradient(180deg, rgba(26,16,48,0) 30%, rgba(26,16,48,.6) 100%); overflow: hidden; touch-action: none; }
.closet-card { width: min(460px, 100%); height: min(56%, 470px); display: flex; flex-direction: column; background: rgba(24,14,46,.94); border: 2px solid rgba(255,255,255,.14);
  border-radius: 22px; overflow: hidden; box-shadow: 0 16px 50px rgba(0,0,0,.5); animation: pop .3s cubic-bezier(.2,1.5,.4,1); }
.chead { display: flex; align-items: center; gap: 8px; padding: 10px 10px 8px; border-bottom: 1px solid rgba(255,255,255,.1); }
.coins { font-weight: 900; font-size: 16px; color: var(--yellow); white-space: nowrap; }
.tabs { flex: 1; display: flex; background: rgba(255,255,255,.08); border-radius: 12px; padding: 3px; }
.tabs button { flex: 1; background: transparent; color: #fff; font-weight: 900; font-size: 14px; padding: 7px 4px; border-radius: 9px; opacity: .7; }
.tabs button.on { background: var(--yellow); color: #3b2300; opacity: 1; }
.chead .x { width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,.12); color: #fff; font-size: 16px; font-weight: 900; }
.cbody { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; padding: 10px; overscroll-behavior: contain; }
.wear { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.wear .it { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 8px 2px 6px; border-radius: 14px; background: rgba(255,255,255,.07); border: 2px solid rgba(255,255,255,.08); color: #fff; }
.wear .it i { font-style: normal; font-size: 26px; line-height: 1.15; }
.wear .it b { font-size: 12px; font-weight: 900; white-space: nowrap; }
.wear .it span { font-size: 10px; opacity: .6; }
.wear .it em { font-style: normal; font-size: 11px; font-weight: 900; margin-top: 2px; color: #cfd8dc; }
.wear .it em.buy { color: var(--yellow); }
.wear .it em.lock { color: #ff8a80; }
.wear .it em.on { color: #7cffb2; }
.wear .it.on { border-color: #7cffb2; background: rgba(124,255,178,.14); }
.wear .it.locked { opacity: .65; }
.wear .it.nope { animation: av-shake .1s linear 4; }
.tip { font-size: 11px; opacity: .7; margin-top: 10px; line-height: 1.5; }
.dex, .deaths { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.card { display: flex; flex-direction: column; align-items: center; padding: 8px 2px; border-radius: 14px; background: rgba(255,255,255,.07); text-align: center; }
.card i { font-style: normal; font-size: 26px; line-height: 1.15; }
.card b { font-size: 12px; font-weight: 900; }
.card span { font-size: 10px; opacity: .8; white-space: nowrap; }
.card span.k { color: #ff8a80; }
.card.unk { opacity: .45; }
.sec { font-weight: 900; font-size: 13px; margin: 12px 0 6px; opacity: .85; }
.ach { display: flex; flex-direction: column; gap: 6px; }
.ach .row { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 12px; background: rgba(255,255,255,.06); opacity: .6; }
.ach .row.ok { opacity: 1; background: rgba(255,210,63,.14); }
.ach .row i { font-style: normal; font-size: 22px; width: 28px; text-align: center; }
.ach .row div { flex: 1; min-width: 0; display: flex; flex-direction: column; text-align: left; }
.ach .row b { font-size: 13px; }
.ach .row span { font-size: 11px; opacity: .75; }
.ach .row em { font-style: normal; font-weight: 900; font-size: 12px; color: var(--yellow); white-space: nowrap; }
@media (max-height: 560px) and (min-aspect-ratio: 13/10) {
  #closet { justify-content: flex-end; align-items: center; background: linear-gradient(90deg, rgba(26,16,48,0) 30%, rgba(26,16,48,.7) 62%); }
  .closet-card { width: min(440px, 56vw); height: 100%; }
}

/* in-game missions & combo */
#missions { width: clamp(138px, 34vw, 190px); padding: 5px 8px; display: flex; flex-direction: column; gap: 3px; }
#missions:empty { display: none; }
#missions .m { display: flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 800; line-height: 1.25; }
#missions .m i { font-style: normal; width: 18px; text-align: center; font-size: 12px; }
#missions .m span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .92; }
#missions .m b { font-size: 11px; color: var(--yellow); }
#missions .m.fresh { animation: mfresh .6s ease-out 2; }
@keyframes mfresh { 50% { background: rgba(124,255,178,.25); transform: translateX(3px); } }
#combo { margin-top: 4px; display: none; flex-direction: column; align-items: center; }
#combo.on { display: flex; }
#combo b { font-size: 13px; font-weight: 900; color: #fff; background: linear-gradient(90deg, #ff8f00, #ff3d7f); padding: 2px 9px; border-radius: 10px; text-shadow: 0 1px 0 rgba(0,0,0,.35); }
#combo b.bump { animation: bump .25s ease-out; }
#combo i { display: block; height: 3px; width: 56px; margin-top: 3px; border-radius: 2px; background: #ffd23f; transform-origin: left; }

#loading { position: fixed; inset: 0; z-index: 50; background: radial-gradient(120% 80% at 50% 30%, #3a1d6e 0%, #1a1030 70%); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; font-weight: 800; padding: 0 28px; transition: opacity .25s; }
#loading.hidden { display: flex !important; opacity: 0; pointer-events: none; }
#loading.gone { display: none !important; }
#loading.quick { background: rgba(20,10,40,.82); }
#loading.quick .ld-logo, #loading.quick .ld-tip { display: none; }
.ld-logo { font-size: 44px; font-weight: 900; color: var(--yellow); -webkit-text-stroke: 2px #1a1030; paint-order: stroke fill; text-shadow: 0 4px 0 #1a1030; display: flex; flex-direction: column; align-items: center; line-height: 1; }
.ld-logo span { font-size: 20px; color: #fff; background: var(--pink); padding: 3px 12px; border-radius: 10px; margin-top: 6px; -webkit-text-stroke: 0; text-shadow: none; }
.ld-dog { font-size: 42px; animation: ld-shiver .12s linear infinite alternate; }
@keyframes ld-shiver { from { transform: translateX(-2px) rotate(-2deg); } to { transform: translateX(2px) rotate(2deg); } }
.ld-bar { width: min(320px, 80vw); height: 14px; border-radius: 10px; background: rgba(255,255,255,.14); border: 2px solid rgba(255,255,255,.35); overflow: hidden; }
.ld-bar b { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ff6fa0, #ffd23f); border-radius: 8px; transition: width .2s ease-out; }
.ld-row { width: min(320px, 80vw); display: flex; justify-content: space-between; gap: 10px; font-size: 13px; color: #e6dcff; }
.ld-row em { font-style: normal; color: var(--yellow); font-weight: 900; }
.ld-tip { margin-top: 8px; font-size: 12px; opacity: .75; text-align: center; max-width: 320px; line-height: 1.5; }
.spin { width: 46px; height: 46px; border-radius: 50%; border: 5px solid rgba(255,255,255,.2); border-top-color: var(--pink); animation: rot 0.8s linear infinite; }
@keyframes rot { to { transform: rotate(360deg) } }

@media (max-height: 460px) {
  #controls { transform: scale(.85); transform-origin: bottom right; }
  #missions { position: fixed; left: calc(72px + var(--sal)); top: calc(94px + var(--sat)); width: 180px; }
  #stats { width: 180px; padding: 6px 8px; }
  #toasts { top: calc(64px + var(--sat)); }
  .menu-inner { margin: auto; }
}

@media (max-height: 560px) and (min-aspect-ratio: 13/10) {
  #menu { justify-content: flex-end; align-items: flex-start; background: linear-gradient(90deg, rgba(26,16,48,0) 30%, rgba(26,16,48,.85) 62%); }
  .menu-inner { width: min(400px, 54vw); margin: auto 0; }
  .logo .l1 { font-size: 48px; } .logo .l2 { font-size: 22px; }
  .tag { margin: 6px 0 8px; font-size: 12px; }
  .mbtn.primary { padding: 9px; font-size: 19px; }
  .opts { padding: 4px 10px; margin-top: 6px; } .opt { padding: 2px 0; }
  .best { margin: 4px 0 2px; }
  .mrow { margin: 5px 0; } .mrow .mbtn { padding: 3px 6px; font-size: 14px; gap: 0; line-height: 1.2; }
  .logo .l1 { font-size: 38px; } .tag { margin: 4px 0 6px; }
}
@media (max-width: 560px) and (min-height: 561px) {
  #stats { width: calc(100vw - 190px); }
  #scorebox { top: calc(86px + var(--sat)); }
  #toasts { top: calc(222px + var(--sat)); }
}

#glmsg { position: fixed; inset: 0; z-index: 60; background: rgba(26,16,48,.92); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; font-weight: 800; }
#debug { position: fixed; left: calc(6px + var(--sal)); bottom: calc(6px + var(--sab)); z-index: 70; font: 600 11px/1.3 ui-monospace, Menlo, monospace; color: #b9ff9a; background: rgba(0,0,0,.65); padding: 4px 8px; border-radius: 6px; pointer-events: none; max-width: 92vw; }

/* Full-screen layers use the measured app height. iOS home-screen apps with a translucent status bar
   report a viewport one status-bar shorter than the screen, which left an empty band at the bottom. */
#flash, #danger, #hud, #popups, .screen, #loading, #glmsg { inset: auto; top: 0; left: 0; width: 100%; height: var(--app-h, 100vh); }
/* never select text, show the copy/lookup bubble, or the save-image menu on long press */
*, *::before, *::after { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
img { pointer-events: none; -webkit-user-drag: none; }
button { touch-action: manipulation; }

/* menu: daily + closet side by side */
.mrow { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0; }
.mrow .mbtn { margin: 0; padding: 9px 6px; font-size: 15px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.mrow .mbtn em { font-style: normal; font-size: 11px; opacity: .85; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.daily-btn { background: linear-gradient(180deg, rgba(94,200,255,.35), rgba(30,110,200,.35)); border-color: rgba(150,220,255,.6); }
/* bark-off */
#barkoff { position: absolute; left: 50%; top: 24%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none;
  background: rgba(20,10,40,.55); border: 2px solid rgba(255,210,63,.6); border-radius: 18px; padding: 8px 14px 10px; z-index: 6; }
#barkoff.hidden { display: none; }
.bo-t { font-weight: 900; font-size: 16px; color: #fff; text-shadow: 0 2px 0 #000; }
.bo-t b { color: var(--yellow); margin-left: 6px; }
.bo-ring { position: relative; width: 74px; height: 74px; }
.bo-ring i { position: absolute; left: 50%; top: 50%; border-radius: 50%; transform: translate(-50%,-50%); }
#bo-target { width: 40px; height: 40px; border: 4px solid rgba(255,255,255,.55); }
#bo-target.on { border-color: var(--yellow); box-shadow: 0 0 16px var(--yellow); }
#bo-shrink { width: 40px; height: 40px; border: 3px solid #ff6fa0; will-change: transform; }
.bo-dots { display: flex; gap: 6px; }
.bo-dots i { width: 16px; height: 16px; border-radius: 50%; background: rgba(255,255,255,.25); font-style: normal; font-size: 11px; line-height: 16px; text-align: center; font-weight: 900; }
.bo-dots i.hit { background: #4cd964; } .bo-dots i.miss { background: #ff3b30; }
.bo-h { font-size: 11px; color: #e6dcff; }
#hud.bo #toasts { opacity: 0; }

/* wardrobe filters, rarity, capsule machine */
.chips { display: flex; gap: 5px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: none; padding: 5px 10px; border-radius: 999px; background: rgba(255,255,255,.1); color: #fff; font-weight: 900; font-size: 12px; }
.chips button.on { background: var(--yellow); color: #3b2300; }
.wear .it span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.wear .it.r-R { border-color: rgba(79,195,247,.35); } .wear .it.r-SR { border-color: rgba(206,147,216,.5); } .wear .it.r-SSR { border-color: rgba(255,213,79,.6); background: rgba(255,213,79,.08); }
.wear .it.on { border-color: #7cffb2; background: rgba(124,255,178,.14); }
.wear .it em.hw { color: #ffab40; }
.wear .it em.neon { color: #7cf1ff; }
.wear .it.neon i { text-shadow: 0 0 8px rgba(124,241,255,.9), 0 0 16px rgba(255,79,216,.6); }
#hw-badge { font-style: normal; margin-left: 2px; }
.banners { display: flex; gap: 6px; margin-bottom: 8px; }
.banners button { flex: 1; padding: 8px 4px; border-radius: 12px; background: rgba(255,255,255,.08); color: #fff; font-weight: 900; font-size: 13px; border: 2px solid transparent; }
.banners button.on { border-color: var(--yellow); background: rgba(255,210,63,.16); }
.banners button.off { opacity: .45; }
.gacha { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 16px; background: linear-gradient(135deg, rgba(94,200,255,.16), rgba(255,111,165,.12)); }
.gacha.hw { background: linear-gradient(135deg, rgba(255,140,0,.28), rgba(106,27,154,.35)); }
.gacha.neon { background: linear-gradient(135deg, rgba(41,232,255,.22), rgba(255,79,216,.26)); }
.gacha.neon .machine .body { background: linear-gradient(180deg, #29e8ff, #c07bff); }
.machine { position: relative; width: 92px; flex: none; }
.machine .dome { position: relative; height: 70px; border-radius: 46px 46px 10px 10px; background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.55), rgba(255,255,255,.12) 60%); border: 3px solid rgba(255,255,255,.7); overflow: hidden; }
.machine .dome i { position: absolute; left: var(--x); top: var(--y); width: 22px; height: 22px; border-radius: 50%; background: linear-gradient(180deg, var(--c) 50%, #fff 50%); box-shadow: inset -2px -2px 4px rgba(0,0,0,.25); }
.machine .body { height: 46px; margin-top: -4px; border-radius: 6px 6px 12px 12px; background: linear-gradient(180deg, #e8226a, #9c1046); position: relative; }
.gacha.hw .machine .body { background: linear-gradient(180deg, #ff8f00, #6a1b9a); }
.machine .slot { position: absolute; left: 12px; bottom: 8px; width: 22px; height: 16px; border-radius: 5px; background: #2a0f22; }
.machine .slot .capsule { position: absolute; left: 1px; top: -3px; width: 20px; height: 20px; border-radius: 50%; opacity: 0; background: linear-gradient(180deg, var(--cap, #ffd54f) 50%, #fff 50%); box-shadow: inset -2px -2px 3px rgba(0,0,0,.25), 0 0 0 1px rgba(0,0,0,.18); }
.machine .crank { position: absolute; right: 10px; top: 8px; width: 28px; height: 28px; border-radius: 50%; background: radial-gradient(circle, #fff 55%, #e3e3e3); border: 4px solid #ffd54f; }
.machine .crank::after { content: ''; position: absolute; left: 50%; top: 50%; width: 30px; height: 6px; margin: -3px 0 0 -15px; background: #ffd54f; border-radius: 3px; box-shadow: 0 1px 0 rgba(0,0,0,.2); }
.machine .crank b { position: absolute; left: 50%; top: -5px; width: 9px; height: 9px; margin-left: -4.5px; border-radius: 50%; background: #ff6fa5; border: 2px solid #fff; z-index: 1; }
/* pulling: the machine stays put. The knob makes one full twist, the capsules inside hop around,
   then one capsule in the colour of the best rarity drops out of the chute and wobbles */
.machine.turning .crank { animation: crank 1s cubic-bezier(.45,.05,.35,1) both; }
.machine.turning .dome i { animation: ball-hop .2s var(--d, 0s) cubic-bezier(.3,.7,.4,1) 6 alternate both; }
.machine.turning .slot .capsule { animation: cap-out .55s .95s cubic-bezier(.3,.7,.4,1) both; }
.machine.turning.rare .dome { animation: rare-glow .25s .8s ease-in-out 3 alternate; }
@keyframes crank { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes ball-hop { to { transform: translate(var(--jx, 0px), var(--jy, -12px)) rotate(var(--jr, 0deg)); } }
@keyframes cap-out { 0% { transform: translateY(-14px) scale(.5); opacity: 0; } 35% { transform: translateY(6px) scale(1); opacity: 1; } 55% { transform: translateY(2px) scale(1.08, .9); } 75% { transform: translateY(5px) rotate(-14deg); } 100% { transform: translateY(5px) rotate(9deg); opacity: 1; } }
@keyframes rare-glow { to { box-shadow: 0 0 18px 6px var(--cap, #ffd54f); border-color: var(--cap, #ffd54f); } }
.ginfo { font-size: 12px; line-height: 1.45; }
.ginfo span { font-size: 10px; opacity: .75; }
.pulls { display: grid; grid-template-columns: 1fr 1.3fr; gap: 8px; margin: 10px 0 4px; }
.pulls .mbtn { margin: 0; padding: 8px 4px; font-size: 15px; display: flex; flex-direction: column; align-items: center; }
.pulls .mbtn em { font-style: normal; font-size: 11px; opacity: .9; }
.pulls .mbtn.nope { animation: av-shake .1s linear 4; }
.gres { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; margin-top: 8px; }
.gres.ten { grid-template-columns: repeat(5, 1fr); }
.gres .cap { display: flex; flex-direction: column; align-items: center; padding: 6px 2px; border-radius: 12px; color: #fff; background: rgba(255,255,255,.07); border: 2px solid var(--rc); box-shadow: 0 0 12px color-mix(in srgb, var(--rc) 45%, transparent); animation: pop .35s cubic-bezier(.2,1.5,.4,1) both; min-width: 0; }
.gres .cap i { font-style: normal; font-size: 24px; }
.gres .cap b { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.gres .cap span { font-size: 10px; color: var(--rc); font-weight: 900; }
.gres .cap em { font-style: normal; font-size: 9px; opacity: .8; white-space: nowrap; }
.gres .cap em.new { color: #7cffb2; font-weight: 900; opacity: 1; }
.gres .cap.r-SSR { background: linear-gradient(180deg, rgba(255,213,79,.3), rgba(255,213,79,.06)); }
.gres .cap:nth-child(2) { animation-delay: .05s; } .gres .cap:nth-child(3) { animation-delay: .1s; } .gres .cap:nth-child(4) { animation-delay: .15s; } .gres .cap:nth-child(5) { animation-delay: .2s; }
.gres .cap:nth-child(6) { animation-delay: .25s; } .gres .cap:nth-child(7) { animation-delay: .3s; } .gres .cap:nth-child(8) { animation-delay: .35s; } .gres .cap:nth-child(9) { animation-delay: .4s; } .gres .cap:nth-child(10) { animation-delay: .45s; }
.tabs button { padding: 7px 2px; font-size: 13px; }
#missions .m.ev { background: linear-gradient(90deg, rgba(255,111,165,.28), rgba(255,210,63,.18)); border-radius: 8px; padding: 2px 4px; }
#missions .m.ev span { display: flex; flex-direction: column; line-height: 1.15; }
#missions .m.ev small { font-size: 9.5px; opacity: .85; font-weight: 700; }

/* swimming */
#air { position: absolute; left: 50%; top: calc(36% + var(--sat, 0px)); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; z-index: 6; }
#air.hidden { display: none; }
#air i { font-style: normal; font-weight: 900; font-size: 14px; color: #fff; text-shadow: 0 2px 0 #000; }
#air .abar { width: 160px; height: 12px; border-radius: 8px; background: rgba(0,0,0,.45); border: 2px solid rgba(255,255,255,.7); overflow: hidden; }
#air .abar b { display: block; height: 100%; background: linear-gradient(90deg, #4fc3f7, #b3e5fc); }
#air.low .abar b { background: linear-gradient(90deg, #ff5252, #ff8a80); }
#air span { font-size: 12px; font-weight: 900; color: #fff; text-shadow: 0 2px 0 #000; }
#air.low span { color: #ffcdd2; animation: pulse .3s infinite alternate; }
.cbtn.big.swim { background: radial-gradient(circle at 35% 30%, #81d4fa, #0277bd); }

/* install */
.install-pill { position: absolute; left: calc(12px + var(--sal, 0px)); top: calc(12px + var(--sat, 0px)); z-index: 3; padding: 8px 14px; border-radius: 999px; font-weight: 900; font-size: 14px; color: #3b2300; background: var(--yellow); box-shadow: 0 4px 0 #b38600, 0 6px 16px rgba(0,0,0,.35); }
.install-pill:active { transform: translateY(3px); box-shadow: 0 1px 0 #b38600; }
.install-pill.hidden { display: none; }
#install-help { z-index: 40; background: rgba(10,6,20,.75); }
.ihelp { width: min(400px, calc(100vw - 32px)); text-align: left; }
.ihelp h3 { margin: 0 0 8px; font-size: 19px; }
.ihelp ol { margin: 6px 0 8px; padding-left: 22px; line-height: 1.7; font-size: 15px; }
.ihelp b { color: var(--yellow); }

.tier { font-size: clamp(12px, 1.9vh, 15px); font-weight: 900; color: #fff; background: var(--tc, #888); padding: 4px 10px; border-radius: 10px; transform: rotate(-3deg); white-space: nowrap; text-shadow: 0 1px 0 rgba(0,0,0,.4); box-shadow: 0 3px 0 rgba(0,0,0,.35); }
.tier::before { content: "評價 "; font-size: .8em; opacity: .9; }
.tier:empty { display: none; }

/* wardrobe v2: always fits the screen, only ever scrolls up/down (portrait and landscape) */
#closet { padding: 8px max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); overflow: hidden; }
.closet-card { width: min(470px, 100%); max-width: 100%; min-width: 0; height: min(58%, 520px); }
.closet-card, .cbody { overflow-x: hidden; }
.cbody { padding: 10px 10px 14px; }
.chead { flex-wrap: wrap; row-gap: 8px; padding: 10px 10px 9px; }
.chead .coins { order: 1; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 15px; }
.chead .x { order: 2; flex: none; }
.chead .tabs { order: 3; flex: 1 1 100%; min-width: 0; }
.tabs button { min-width: 0; white-space: nowrap; font-size: 14px; padding: 8px 2px; }
.chips { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; overflow: visible; padding-bottom: 0; margin-bottom: 10px; }
.chips button { min-width: 0; padding: 7px 2px; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wear, .dex, .deaths { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.wear .it, .card { min-width: 0; padding: 9px 4px 8px; }
.wear .it b, .card b, .wear .it em, .card span { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wear .it i, .card i { font-size: 28px; }
.wear .it b { font-size: 13px; }
.wear .it em { font-size: 11.5px; }
.gacha { min-width: 0; }
.ginfo { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.banners button { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pulls .mbtn { min-width: 0; }
.pulls .mbtn em { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.gres.ten { grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); }
.gres .cap { min-width: 0; }
.gres .cap em { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.ach .row b, .ach .row span { overflow-wrap: anywhere; }
@media (max-height: 560px) and (min-aspect-ratio: 13/10) {
  /* landscape phone: one-row header (coins · tabs · ✕), panel on the right, full height */
  .closet-card { width: min(460px, 58vw); height: 100%; }
  .chead { flex-wrap: nowrap; padding: 7px 8px; }
  .chead .coins { order: 1; flex: 0 1 auto; font-size: 14px; }
  .chead .tabs { order: 2; flex: 1 1 auto; }
  .chead .x { order: 3; width: 32px; height: 32px; }
  .tabs button { font-size: 13px; padding: 6px 2px; }
  .cbody { padding: 8px 8px 12px; }
  .wear, .dex, .deaths { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 6px; }
  .wear .it, .card { padding: 6px 3px 5px; }
  .wear .it i, .card i { font-size: 24px; }
  .chips { margin-bottom: 8px; gap: 5px; }
  .chips button { padding: 5px 2px; font-size: 12px; }
  .gacha { padding: 6px; }
  .machine { width: 78px; }
  .machine .dome { height: 58px; }
  .machine .body { height: 38px; }
  .pulls { margin: 8px 0 2px; }
}

/* missions: foldable (tap the header) */
#missions { pointer-events: none; }
#m-head { pointer-events: auto; display: flex; align-items: center; gap: 5px; width: 100%; padding: 1px 0 2px; background: none; border: 0; color: #fff; font: inherit; font-size: 10.5px; font-weight: 900; text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
#m-head i { font-style: normal; width: 18px; text-align: center; font-size: 12px; }
#m-head span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .8; }
#m-head em { font-style: normal; font-size: 10px; opacity: .8; padding: 1px 6px; border-radius: 8px; background: rgba(255,255,255,.14); }
#m-list { display: flex; flex-direction: column; gap: 3px; }
#missions.closed { width: auto; max-width: min(230px, 42vw); padding: 4px 8px; border-radius: 14px; }
#missions.closed #m-list { display: none; }
#missions.closed #m-head { font-size: 11.5px; padding: 1px 0; }
#missions.closed #m-head span { opacity: 1; }
#missions.closed.peek { border-color: rgba(255,210,63,.8); box-shadow: 0 0 0 2px rgba(255,210,63,.35); }
#missions.closed.peek #m-head span { color: var(--yellow); }

/* how-to-play screen */
#guide { background: rgba(10,6,20,.72); overflow: hidden; touch-action: none;
  padding: calc(10px + var(--sat)) calc(10px + var(--sar)) calc(10px + var(--sab)) calc(10px + var(--sal)); }
.guide-card { width: min(560px, 100%); height: min(100%, 680px); margin: auto; display: flex; flex-direction: column; overflow: hidden;
  background: radial-gradient(120% 50% at 50% 0%, #432477 0%, #24143f 55%, #170c2c 100%); border: 2px solid rgba(255,255,255,.14);
  border-radius: 22px; box-shadow: 0 18px 50px rgba(0,0,0,.55); animation: pop .3s cubic-bezier(.2,1.5,.4,1); }
.g-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 6px 16px; }
.g-head b { font-size: 19px; font-weight: 900; color: var(--yellow); }
.g-head .x { width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,.12); color: #fff; font-size: 16px; font-weight: 900; }
.g-tabs { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 5px; padding: 4px 12px 10px; border-bottom: 1px solid rgba(255,255,255,.1); }
.g-tabs button { min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 2px; border-radius: 12px; background: rgba(255,255,255,.07);
  color: #fff; font-weight: 900; font-size: 12px; white-space: nowrap; opacity: .75; border: 2px solid transparent; }
.g-tabs button i { font-style: normal; font-size: 19px; line-height: 1.1; }
.g-tabs button.on { opacity: 1; background: rgba(255,210,63,.16); border-color: var(--yellow); color: var(--yellow); }
.g-body { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; touch-action: pan-y; overscroll-behavior: contain; padding: 12px; }
.g-bars { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-bottom: 10px; }
.g-bars div { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 1px; padding: 7px 4px; border-radius: 12px; background: rgba(0,0,0,.22); }
.g-bars i { font-style: normal; font-size: 18px; }
.g-bars b { font-size: 12.5px; }
.g-bars span { font-size: 10.5px; opacity: .75; line-height: 1.3; }
.g-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.g-card { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border-radius: 14px; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.08); text-align: left; min-width: 0; }
.g-card > i { font-style: normal; font-size: 26px; line-height: 1; flex: none; width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; border-radius: 10px; background: rgba(255,255,255,.08); }
.g-card > div { min-width: 0; }
.g-card b { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 14px; font-weight: 900; }
.g-card p { margin: 2px 0 0; font-size: 12.5px; line-height: 1.45; opacity: .85; overflow-wrap: anywhere; }
.g-card kbd { font: 800 10.5px/1 inherit; padding: 3px 6px; border-radius: 6px; background: rgba(255,255,255,.14); border-bottom: 2px solid rgba(255,255,255,.25); color: #fff; opacity: .9; }
.g-card.meh { border-color: rgba(176,190,197,.35); } .g-card.love { border-color: rgba(255,111,165,.45); background: rgba(255,111,165,.09); } .g-card.angry { border-color: rgba(255,82,82,.5); background: rgba(255,82,82,.09); }
@media (max-height: 560px) and (min-aspect-ratio: 13/10) {
  .guide-card { width: min(760px, 100%); height: 100%; }
  .g-head { padding: 8px 10px 4px 14px; }
  .g-head b { font-size: 16px; }
  .g-tabs { padding: 2px 10px 8px; }
  .g-tabs button { flex-direction: row; justify-content: center; gap: 4px; padding: 5px 2px; font-size: 12px; }
  .g-tabs button i { font-size: 15px; }
  .g-body { padding: 8px 10px; }
  .g-cards { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px; }
  .g-card { padding: 7px 10px; }
}
@media (min-width: 900px) and (min-height: 600px) { .guide-card { height: min(100%, 560px); } }

/* waves */
#wavebanner { position: absolute; left: 50%; top: 30%; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; z-index: 7; text-align: center; }
#wavebanner.hidden { display: none; }
#wavebanner b { font-size: clamp(40px, 11vw, 72px); font-weight: 900; color: #fff; -webkit-text-stroke: 3px #1a1030; paint-order: stroke fill; text-shadow: 0 5px 0 #e8226a, 0 0 24px rgba(255,79,139,.6); white-space: nowrap; }
#wavebanner span { font-size: clamp(13px, 3.6vw, 17px); font-weight: 900; padding: 5px 14px; border-radius: 999px; background: rgba(20,12,40,.8); border: 2px solid var(--yellow); color: var(--yellow); white-space: nowrap; }
#wavebanner.show { animation: wave-in 2.6s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes wave-in { 0% { transform: translate(-50%, -50%) scale(.4); opacity: 0; } 12% { transform: translate(-50%, -50%) scale(1.08); opacity: 1; } 20% { transform: translate(-50%, -50%) scale(1); } 85% { opacity: 1; } 100% { transform: translate(-50%, -60%) scale(1); opacity: 0; } }
/* death news card */
.obtns .row .mbtn.news { background: linear-gradient(180deg, #ff5252, #c62828); border-color: #ffcdd2; }
#dcard { background: rgba(10,6,20,.86); overflow: hidden; touch-action: none; padding: calc(10px + var(--sat)) calc(10px + var(--sar)) calc(10px + var(--sab)) calc(10px + var(--sal)); }
.dcard-box { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 10px; max-height: 100%; width: min(440px, 100%); animation: pop .3s cubic-bezier(.2,1.5,.4,1); }
.dcard-box img { display: block; max-width: 100%; max-height: calc(100% - 60px); min-height: 0; flex: 1 1 auto; object-fit: contain; border-radius: 14px; box-shadow: 0 14px 40px rgba(0,0,0,.6); }
.dcard-btns { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 6px; width: 100%; flex: none; }
.dcard-btns .mbtn { margin: 0; font-size: 14px; padding: 10px 4px; }
.dcard-btns .mbtn.primary { font-size: 15px; box-shadow: 0 4px 0 #9c1046; }
@media (min-aspect-ratio: 13/10) and (max-height: 560px) { .dcard-box { flex-direction: row; width: auto; height: 100%; } .dcard-box img { max-height: 100%; height: 100%; } .dcard-btns { grid-template-columns: 1fr; width: 150px; } }

/* closet: quests & upgrades */
.sec small { font-weight: 700; font-size: 10.5px; opacity: .7; margin-left: 4px; }
.quests { display: flex; flex-direction: column; gap: 6px; }
.qrow { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: rgba(255,255,255,.07); }
.qrow.ok { background: rgba(124,255,178,.13); }
.qrow i { font-style: normal; font-size: 22px; width: 28px; text-align: center; flex: none; }
.qrow > div { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.qrow b { font-size: 13px; overflow-wrap: anywhere; }
.qbar { display: block; height: 7px; border-radius: 4px; background: rgba(255,255,255,.12); overflow: hidden; }
.qbar em { display: block; height: 100%; background: linear-gradient(90deg, #ff6fa0, #ffd23f); border-radius: 4px; }
.qrow.ok .qbar em { background: #7cffb2; }
.qrow strong { font-size: 12px; color: var(--yellow); white-space: nowrap; flex: none; }
.qrow.ok strong { color: #7cffb2; font-size: 16px; }
.skills { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 7px; }
.sk { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-radius: 14px; background: rgba(255,255,255,.07); border: 2px solid rgba(255,255,255,.08); color: #fff; text-align: left; min-width: 0; }
.sk i { font-style: normal; font-size: 24px; width: 30px; text-align: center; flex: none; }
.sk > div { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sk b { font-size: 13.5px; font-weight: 900; } .sk b small { font-size: 11px; color: var(--yellow); margin-left: 2px; }
.sk span { font-size: 11px; opacity: .8; overflow-wrap: anywhere; line-height: 1.35; }
.sk .pips { display: flex; gap: 3px; opacity: 1; margin-top: 2px; }
.sk .pips u { display: block; width: 14px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.18); }
.sk .pips u.on { background: var(--yellow); }
.sk em { font-style: normal; font-size: 12px; font-weight: 900; color: var(--yellow); white-space: nowrap; flex: none; padding: 5px 8px; border-radius: 10px; background: rgba(255,210,63,.14); }
.sk.poor em { color: #ff8a80; background: rgba(255,82,82,.12); }
.sk.max { border-color: rgba(124,255,178,.45); } .sk.max em { color: #7cffb2; background: rgba(124,255,178,.14); }
.sk.nope { animation: av-shake .1s linear 4; }

.obtns .row .mbtn { white-space: nowrap; overflow: hidden; text-overflow: clip; padding-left: 1px; padding-right: 1px; font-size: clamp(11px, 3.2vw, 13px); }
@media (min-aspect-ratio: 13/10) and (max-height: 560px) { .obtns .row { gap: 4px; } .obtns .row .mbtn { font-size: 11px; letter-spacing: -0.3px; } }

/* comfort (anti motion-sickness) mode */
#comfortvig { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: radial-gradient(ellipse 62% 58% at 50% 52%, rgba(0,0,0,0) 55%, rgba(8,4,18,.55) 82%, rgba(8,4,18,.85) 100%); will-change: opacity; }
#reticle { position: absolute; left: 50%; top: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px; pointer-events: none; display: none; opacity: .45; filter: drop-shadow(0 0 1px rgba(0,0,0,.55)); }
#reticle::before, #reticle::after { content: ''; position: absolute; }
#reticle::before { left: 9px; top: 0; width: 2px; height: 20px; background: linear-gradient(#fff 0 7px, transparent 7px 13px, #fff 13px); }
#reticle::after { top: 9px; left: 0; width: 20px; height: 2px; background: linear-gradient(90deg, #fff 0 7px, transparent 7px 13px, #fff 13px); }

/* ===================== HUD v2: fewer, cleaner, glassier pieces ===================== */
:root { --glass: rgba(16,10,32,.56); --glass-b: rgba(255,255,255,.14); --glass-hi: inset 0 1px 0 rgba(255,255,255,.08); }
.panel { background: var(--glass); border: 1px solid var(--glass-b); border-radius: 16px; box-shadow: 0 6px 20px rgba(0,0,0,.22), var(--glass-hi); }
/* player card: avatar + three slim bars (the icons say what they are, the words are gone) */
#avatar-wrap { left: calc(17px + var(--sal)); top: calc(17px + var(--sat)); width: 42px; height: 42px; z-index: 1; }
#avatar { width: 42px; height: 42px; border-width: 2px; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
#avatar-badge { font-size: 15px; right: -5px; bottom: -4px; }
#stats { margin-left: 0; left: calc(10px + var(--sal)); top: calc(10px + var(--sat)); padding: 9px 12px 9px 60px; width: min(200px, 48vw); min-height: 56px; display: flex; flex-direction: column; justify-content: center; }
.bar { height: 12px; gap: 6px; } .bar + .bar { margin-top: 5px; }
.bar .ico { width: 14px; font-size: 11px; }
.bar .lbl { display: none; }
.track { height: 7px; border-radius: 4px; background: rgba(255,255,255,.12); box-shadow: inset 0 1px 2px rgba(0,0,0,.25); }
.fill { border-radius: 4px; }
/* score + one combined pill (multiplier | wave · weather) + combo */
#score { font-size: clamp(30px, 6.4vw, 44px); letter-spacing: .5px; font-variant-numeric: tabular-nums; text-shadow: 0 2px 0 rgba(160,30,90,.9), 0 0 16px rgba(255,79,139,.45); }
#scorebox .srow { display: inline-flex; gap: 0; margin-top: 5px; border-radius: 999px; overflow: hidden; background: var(--glass); border: 1px solid var(--glass-b); box-shadow: 0 3px 10px rgba(0,0,0,.2); }
#mult { border-radius: 0; padding: 3px 9px; background: linear-gradient(180deg, #ffe066, #ffc93c); color: #3b2300; font-size: 12px; }
#wave { border: 0; border-radius: 0; background: transparent; padding: 3px 10px; font-size: 12px; font-weight: 800; }
#wave.up { background: rgba(255,82,82,.85); }
#combo b { background: linear-gradient(90deg, #ff9f1c, #ff3d7f); border-radius: 999px; padding: 2px 10px; font-size: 12px; box-shadow: 0 3px 10px rgba(255,61,127,.35); }
#combo i { height: 2px; width: 50px; opacity: .9; }
/* top right: minimap + pause only (switching the view is in the pause menu / V key) */
#minimap { border: 2px solid rgba(255,255,255,.75); box-shadow: 0 6px 18px rgba(0,0,0,.3); }
.tbtn { width: 38px; height: 38px; border-radius: 12px; background: var(--glass); border: 1px solid var(--glass-b); font-size: 15px; box-shadow: 0 4px 12px rgba(0,0,0,.2), var(--glass-hi); }
/* one message line at a time (old and new cross-fade in the same spot) */
#toasts { display: grid; justify-items: center; gap: 0; }
#toasts > .toast { grid-area: 1 / 1; }
.toast { display: flex; align-items: center; gap: 8px; padding: 7px 14px 7px 10px; border-radius: 12px; font-weight: 800; font-size: clamp(12.5px, 3.3vw, 15px);
  background: rgba(16,10,32,.8); border: 1px solid rgba(255,255,255,.14); box-shadow: 0 8px 22px rgba(0,0,0,.28); max-width: 88vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; animation: tin2 .28s cubic-bezier(.2,1.2,.4,1); }
.toast::before { content: ''; width: 4px; height: 16px; border-radius: 2px; background: #b39ddb; flex: none; }
.toast.good, .toast.danger { background: rgba(16,10,32,.84); border-color: rgba(255,255,255,.14); }
.toast.good::before { background: #7cffb2; }
.toast.danger { border-color: rgba(255,82,99,.55); } .toast.danger::before { background: #ff5263; }
.toast.out { animation: tout2 .26s ease-in forwards; }
@keyframes tin2 { from { transform: translateY(-8px); opacity: 0; } }
@keyframes tout2 { to { transform: translateY(-6px); opacity: 0; } }
/* achievement / quest / mission cards: slide up at the bottom centre, between the joystick and the buttons */
#notes { position: absolute; left: 50%; bottom: calc(236px + var(--sab)); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; pointer-events: none; }
.note { display: flex; align-items: center; gap: 9px; max-width: min(280px, 72vw); padding: 7px 12px 7px 7px; border-radius: 14px; background: rgba(16,10,32,.84); border: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 8px 22px rgba(0,0,0,.3), var(--glass-hi); animation: nin .38s cubic-bezier(.2,1.3,.4,1); }
.note i { font-style: normal; width: 32px; height: 32px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; flex: none; background: rgba(255,210,63,.16); border: 1px solid rgba(255,210,63,.5); }
.note.green i { background: rgba(124,255,178,.14); border-color: rgba(124,255,178,.5); }
.note.violet i { background: rgba(206,147,216,.16); border-color: rgba(206,147,216,.55); }
.note.blue i { background: rgba(94,200,255,.15); border-color: rgba(94,200,255,.55); }
.note div { min-width: 0; display: flex; flex-direction: column; text-align: left; }
.note b { font-size: 12.5px; font-weight: 900; color: #ffe082; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note.green b { color: #9dffc4; } .note.violet b { color: #e1bee7; } .note.blue b { color: #a5e3ff; }
.note span { font-size: 11px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note.out { animation: nout .28s ease-in forwards; }
@keyframes nin { from { transform: translateY(18px) scale(.94); opacity: 0; } }
@keyframes nout { to { transform: translateY(10px); opacity: 0; } }
/* score popups: only 10+ points now, slightly smaller */
.pop { font-size: clamp(14px, 3.5vw, 18px); letter-spacing: .3px; text-shadow: 0 2px 0 rgba(0,0,0,.55), 0 0 10px rgba(0,0,0,.35); }
#missions.closed { box-shadow: 0 4px 12px rgba(0,0,0,.2), var(--glass-hi); }
@media (max-width: 560px) and (min-height: 561px) {
  #stats { width: min(200px, 50vw); }
  #scorebox { top: calc(84px + var(--sat)); }
  #toasts { top: calc(186px + var(--sat)); }
}
@media (max-height: 460px) {
  #stats { width: 176px; padding: 7px 10px 7px 58px; }
  #toasts { top: calc(88px + var(--sat)); }
  #missions { top: calc(74px + var(--sat)); left: calc(10px + var(--sal)); }
  #notes { bottom: calc(14px + var(--sab)); }
}

.opt span small { font-size: 11px; font-weight: 800; color: var(--yellow); margin-left: 2px; white-space: nowrap; }
.opt .seg button { white-space: nowrap; }

/* ---------------------------------------------------------------- map select (covers) */
#mapsel { position: fixed; inset: 0; z-index: 55; background: radial-gradient(120% 80% at 50% 20%, #3a1d6e 0%, #1a1030 72%); overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
#mapsel.hidden { display: none; }
.ms-inner { max-width: 1180px; min-height: 100%; display: flex; flex-direction: column; justify-content: center; margin: 0 auto; padding: max(18px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(22px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); box-sizing: border-box; }
.ms-logo { font-size: 34px; font-weight: 900; color: var(--yellow); -webkit-text-stroke: 2px #1a1030; paint-order: stroke fill; text-shadow: 0 4px 0 #1a1030; text-align: center; line-height: 1; }
.ms-logo span { display: inline-block; font-size: 16px; color: #fff; background: var(--pink); padding: 3px 10px; border-radius: 9px; margin-left: 8px; vertical-align: middle; -webkit-text-stroke: 0; text-shadow: none; }
.ms-title { text-align: center; font-weight: 900; font-size: 17px; margin: 10px 0 14px; color: #e9ddff; letter-spacing: 2px; }
.ms-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); gap: 12px; }
@media (min-width: 900px) { .ms-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.ms-card { position: relative; display: flex; flex-direction: column; justify-content: flex-start; align-items: stretch; width: 100%; padding: 0; border: 2px solid rgba(255,255,255,.18); border-radius: 18px; overflow: hidden; background: #2a1850; color: #fff; text-align: left; cursor: pointer; font-family: inherit;
  box-shadow: 0 6px 0 rgba(0,0,0,.35); transition: transform .12s, border-color .12s; -webkit-tap-highlight-color: transparent; }
.ms-card img, .ms-dice { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: #3b2a66; }
.ms-dice { display: flex; align-items: center; justify-content: center; font-size: 64px; background: linear-gradient(135deg, #ff6fa0, #7b5cff 55%, #29b6f6); }
.ms-cap { padding: 9px 12px 11px; display: flex; flex-direction: column; gap: 3px; }
.ms-cap b { font-size: 18px; font-weight: 900; }
.ms-cap span { font-size: 12.5px; font-weight: 700; color: #cbbcf0; line-height: 1.35; }
.ms-card i { position: absolute; top: 8px; right: 8px; font-style: normal; font-size: 12px; font-weight: 900; background: var(--yellow); color: #1a1030; padding: 3px 9px; border-radius: 999px; }
.ms-card.last { border-color: var(--yellow); }
.ms-card:active, .ms-card.picked { transform: scale(.97); border-color: #fff; }
@media (hover: hover) { .ms-card:hover { transform: translateY(-3px); border-color: rgba(255,255,255,.55); } }
@media (orientation: landscape) and (max-height: 520px) {
  .ms-inner { padding-top: 10px; }
  .ms-logo { font-size: 24px; } .ms-logo span { font-size: 13px; }
  .ms-title { margin: 6px 0 10px; font-size: 14px; }
  .ms-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 9px; }
  .ms-cap { padding: 6px 8px 8px; } .ms-cap b { font-size: 14px; } .ms-cap span { font-size: 10.5px; }
}
@media (orientation: portrait) and (max-width: 520px) { .ms-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } .ms-cap b { font-size: 15px; } .ms-cap span { font-size: 11px; } .ms-card.rnd { grid-column: span 2; } .ms-card.rnd .ms-dice { aspect-ratio: 32 / 9; } }
.map-btn { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; background: linear-gradient(180deg, rgba(41,182,246,.24), rgba(41,182,246,.1)); border-color: rgba(41,182,246,.5); }
.map-btn span { font-size: 15px; } .map-btn em { font-style: normal; font-size: 13px; font-weight: 900; color: #b3e5fc; }
.ms-title { position: relative; }
.ms-x { position: absolute; right: 0; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(255,255,255,.14); color: #fff; font-size: 16px; font-weight: 900; cursor: pointer; }
#mapsel { background: rgba(20,10,40,.86); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }

/* ===================== HUD v3: one small status card at the edge, everything else out of the way =====================
   top-left: avatar + score + three hairline bars in one card · top-right: pause + minimap (wave on its rim) + a
   folded missions chip · centre stays empty for the game; messages are one quiet line */
/* in-game panels: no backdrop blur (it re-blurred the moving 3D view under them every frame on phones),
   a touch more opaque instead so they read the same */
#hud .panel { backdrop-filter: none; -webkit-backdrop-filter: none; background: rgba(20, 12, 40, .7); }
#card { position: absolute; left: calc(8px + var(--sal)); top: calc(8px + var(--sat)); display: flex; align-items: center; gap: 8px;
  padding: 6px 10px 6px 6px; border-radius: 14px; width: auto; min-width: 0; }
#card #avatar-wrap { position: relative; left: auto; top: auto; width: 36px; height: 36px; flex: none; }
#card #avatar { width: 36px; height: 36px; border-width: 2px; }
#card #avatar-badge { font-size: 13px; right: -4px; bottom: -3px; }
#card .ccol { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
#card .crow { display: flex; align-items: baseline; gap: 6px; line-height: 1; }
#score { font-size: 17px; font-weight: 900; letter-spacing: .3px; line-height: 1; font-variant-numeric: tabular-nums; text-shadow: 0 1px 0 rgba(0,0,0,.5); color: #fff; }
#score.bump { animation: sbump .22s ease-out; }
@keyframes sbump { 50% { transform: scale(1.12); color: #ffe082; } }
#mult { font-size: 10px; font-weight: 900; padding: 1px 5px; border-radius: 6px; background: rgba(255,210,63,.92); color: #3b2300; line-height: 1.3; }
#card #stats { position: static; margin: 0; padding: 0; width: clamp(92px, 24vw, 118px); min-height: 0; background: none; border: 0; box-shadow: none; display: flex; flex-direction: column; gap: 3px; }
#card .bar { height: 9px; gap: 4px; } #card .bar + .bar { margin-top: 0; }
#card .bar .ico { width: 11px; font-size: 9px; line-height: 1; }
#card .bar .lbl { display: none; }
#card .track { height: 4px; border-radius: 2px; background: rgba(255,255,255,.16); box-shadow: none; }
#card .fill { border-radius: 2px; }
#combo { position: absolute; left: calc(8px + var(--sal)); top: calc(82px + var(--sat)); margin: 0; align-items: flex-start; }
#combo b { font-size: 11px; padding: 2px 8px; }
#combo i { width: 44px; height: 2px; }
#scorebox { display: none; }
/* top right */
#topright { right: calc(8px + var(--sar)); top: calc(8px + var(--sat)); gap: 6px; }
.mmrow { display: flex; align-items: flex-start; gap: 6px; }
.mmwrap { position: relative; }
#minimap { display: block; width: clamp(72px, 19vw, 96px); height: clamp(72px, 19vw, 96px); border-width: 2px; border-color: rgba(255,255,255,.7); }
#wave { position: absolute; left: 50%; bottom: -7px; transform: translateX(-50%); font-size: 10px; font-weight: 900; padding: 1px 7px; border-radius: 8px; line-height: 1.4;
  background: rgba(16,10,32,.88); border: 1px solid rgba(255,255,255,.22); white-space: nowrap; }
#wave.up { animation: wup .4s ease-out 2; background: rgba(255,82,82,.92); }
@keyframes wup { 50% { transform: translateX(-50%) scale(1.15); } }
#btn-pause { pointer-events: auto; width: 32px; height: 32px; border-radius: 10px; font-size: 13px; padding: 0; }
/* missions: a small chip that opens into the list on tap; progress peeks into the chip for a moment */
#missions { position: static; width: auto; max-width: clamp(150px, 40vw, 210px); padding: 0; margin-top: 4px; gap: 0; border-radius: 11px; pointer-events: auto; }
#missions #m-head { display: flex; align-items: center; gap: 5px; padding: 4px 9px; font-size: 11px; font-weight: 800; color: #fff; background: none; border: 0; font-family: inherit; max-width: 100%; }
#missions #m-head i { font-style: normal; font-size: 11px; }
#missions #m-sum { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#missions #m-tog { font-style: normal; font-size: 9px; opacity: .7; }
#missions:not(.closed) { width: clamp(150px, 40vw, 210px); }
#missions:not(.closed) #m-list { display: flex; flex-direction: column; gap: 3px; padding: 0 8px 6px; }
#missions.closed #m-list { display: none; }
#missions.peek { border-color: rgba(124,255,178,.6); }
#missions.peek #m-sum { color: #b9ffd4; }
/* messages: one quiet line, top centre (below the card on narrow portrait screens) */
#toasts { top: calc(10px + var(--sat)); max-width: calc(100vw - 2 * 190px); width: auto; }
.toast { padding: 5px 11px 5px 8px; border-radius: 10px; font-size: 12.5px; font-weight: 800; background: rgba(16,10,32,.72); box-shadow: 0 4px 14px rgba(0,0,0,.22); max-width: 100%; }
.toast::before { height: 12px; width: 3px; }
#notes { bottom: calc(150px + var(--sab)); }
.note { padding: 5px 10px 5px 5px; } .note i { width: 26px; height: 26px; font-size: 15px; border-radius: 8px; }
.note b { font-size: 11.5px; } .note span { font-size: 10.5px; }
@media (max-width: 640px) and (min-height: 561px) {
  #toasts { top: calc(112px + var(--sat)); max-width: 92vw; }
  #notes { bottom: calc(220px + var(--sab)); }
}
@media (max-height: 460px) {
  #toasts { top: calc(8px + var(--sat)); max-width: calc(100vw - 2 * 200px); }
  #missions { position: static; left: auto; top: auto; }
  #notes { bottom: calc(12px + var(--sab)); }
  #card #stats { width: 100px; }
}

/* first-play coach (tutorial.js) */
#tut { position: fixed; left: 50%; bottom: calc(12px + var(--sab, 0px)); transform: translateX(-50%); width: min(420px, 74vw); z-index: 8; padding: 9px 12px 8px; border-radius: 12px;
  background: rgba(20,12,40,.86); border: 1px solid rgba(255,214,140,.4); color: #fff; font-weight: 800; font-size: 14.5px; line-height: 1.45; text-align: center; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
#tut.off { display: none; } #tut .tb { display: flex; justify-content: space-between; align-items: center; margin-top: 5px; font-size: 11px; font-weight: 700; opacity: .7; }
#tut .tb button { font: inherit; color: #ffd06b; background: none; border: 0; padding: 2px 4px; cursor: pointer; }
.tut-hl { animation: tutp 1.1s ease-in-out infinite; box-shadow: 0 0 0 3px #ffd06b !important; }
@keyframes tutp { 50% { transform: scale(1.1); } }
@media (max-aspect-ratio: 1/1) { #tut { bottom: auto; top: calc(150px + var(--sat, 0px)); width: 86vw; } } /* (between the stick and the buttons when sideways; under the HUD when upright: never over the dog) */

/* weekly leaderboard (leaderboard.js) */
.lb-layer { z-index: 60; background: rgba(10,6,20,.82); }
.lb-card { width: min(460px, 94vw); max-height: 88vh; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; background: #1d1430; border: 1px solid rgba(255,214,140,.3); border-radius: 16px; padding: 14px 16px; color: #fff; }
.lb-card h2 { margin: 0 0 8px; font-size: 19px; color: #ffd06b; }
.lb-big { font-size: 17px; font-weight: 900; margin: 4px 0 10px; } .lb-big b { color: #ffd06b; font-size: 22px; }
.lb-l { display: block; font-size: 12.5px; font-weight: 700; opacity: .9; } .lb-l input { display: block; width: 100%; margin-top: 5px; padding: 9px 10px; border-radius: 10px; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.08); color: #fff; font-size: 16px; font-weight: 800; }
.lb-dim { font-size: 12px; opacity: .72; line-height: 1.5; margin: 8px 0; } .lb-msg { min-height: 1.4em; font-size: 13.5px; font-weight: 800; color: #b9f6ca; }
.lb-row { display: flex; gap: 8px; margin-top: 10px; } .lb-row .mbtn { flex: 1; margin: 0; }
.lb-tabs { display: flex; gap: 4px; flex-wrap: wrap; } .lb-tabs button { flex: 1 0 auto; padding: 6px 7px; border-radius: 9px; font-size: 12.5px; font-weight: 900; background: rgba(255,255,255,.08); color: #fff; border: 0; }
.lb-tabs button.on { background: #ffd06b; color: #2a1c08; }
.lb-list { margin-top: 6px; } .lb-r { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-top: 1px solid rgba(255,255,255,.07); font-weight: 800; }
.lb-r i { width: 30px; text-align: center; font-style: normal; } .lb-r span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .lb-r b { color: #ffd06b; }
.lb-r.me { background: rgba(140,255,184,.12); border-radius: 8px; }
.lb-btn { width: 100%; } .lb-btn em { display: block; font-size: 11px; font-style: normal; opacity: .75; }
#over .lbup { width: 100%; margin-top: 6px; background: linear-gradient(180deg, #ffd06b, #f0a830); color: #2a1c08; font-weight: 900; }
/* v60: messages are never cut off. The box spans the screen width it may use (left: 50% left it only half of it) and a
   long message wraps onto a second line instead of being clipped. */
#toasts { left: 0; right: 0; margin: 0 auto; transform: none; width: max-content; }
@media (max-width: 640px) and (min-height: 561px) { #toasts { top: calc(126px + var(--sat)); } } /* (upright: clear of the 任務 chip) */
.toast { white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.35; text-align: left; overflow-wrap: anywhere; }
/* v60: sideways phones: 再玩一次 and 上傳 side by side, so the share row (存圖 · 分享 · LINE · 快報 · 選單) always fits */
@media (min-aspect-ratio: 5/4) and (max-height: 620px) {
  .obtns { display: grid; grid-template-columns: 1fr 1fr; column-gap: 6px; }
  .obtns .row { grid-column: 1 / -1; }
  #over .lbup { margin-top: 0; font-size: clamp(13px, 2.6vh, 16px); padding-left: 4px; padding-right: 4px; white-space: nowrap; overflow: hidden; }
  #over .lbup .lbx { display: none; } /* (short label here: 🏆 上傳分數) */
  .obtns .mbtn.primary { white-space: nowrap; font-size: clamp(14px, 2.8vh, 19px); padding-left: 4px; padding-right: 4px; }
  #over .lbup.hidden + .row, .obtns:has(.lbup.hidden) .primary { grid-column: 1 / -1; }
}
/* ---------------------------------------------------------------- v62: the result card shows everything, on every phone
   (also short screens: Safari's bars showing, small phones, sideways). Fits first; if a screen is truly too small,
   the card scrolls instead of cutting anything off. Stat labels and numbers size themselves to their box, never "…". */
#over { touch-action: pan-y; }
.over-card { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.grid div { container-type: inline-size; }
.grid b { overflow: visible; text-overflow: clip; font-size: min(clamp(13px, 2.2vh, 17px), 24cqi); }
.grid span { overflow: visible; text-overflow: clip; font-size: min(clamp(9px, 1.35vh, 11px), 18.5cqi); }
.sub { max-height: none; }
.sub span { overflow: visible; text-overflow: clip; }
/* upright but short: each stat on two lines (icon + number, then its name) */
@media (max-aspect-ratio: 5/4) and (max-height: 720px) {
  .grid div { flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: baseline; column-gap: 3px; padding: 3px 2px; }
  .grid i { font-size: 12px; } .grid span { flex-basis: 100%; text-align: center; line-height: 1.2; }
  .shot { min-height: 64px; }
  .ohead { row-gap: 2px; } .rip { font-size: clamp(20px, 3.8vh, 28px); }
  .final b { font-size: clamp(30px, 5.6vh, 46px); }
}
@media (max-aspect-ratio: 5/4) and (max-height: 600px) {
  .over-card { padding: 8px 10px; gap: 4px; } .ocol { gap: 4px; }
  .obtns .mbtn.primary, #over .lbup { padding-top: 7px; padding-bottom: 7px; font-size: 16px; }
  .obtns .row { margin-top: 5px; } .obtns .row .mbtn { padding-top: 6px; padding-bottom: 6px; }
}
/* sideways: the numbers column gets a fixed share (it was squeezed to a sliver and cut its labels short) */
@media (min-aspect-ratio: 5/4) and (max-height: 620px) {
  .ocol.l { flex: 1 1 0; min-width: 0; }
  .ocol.r { flex: 0 0 clamp(250px, 44%, 400px); min-width: 0; }
  .over-card { gap: 10px; }
}
/* sideways and very short (Safari's bars showing: ~300 px tall): compact everything in the numbers column */
@media (min-aspect-ratio: 5/4) and (max-height: 380px) {
  #over { padding-top: calc(6px + var(--sat)); padding-bottom: calc(6px + var(--sab)); }
  .over-card { padding: 8px 10px; border-radius: 18px; }
  .ocol { gap: 4px; }
  .rip { font-size: 20px; -webkit-text-stroke-width: 1.5px; } .rank, .tier { font-size: 11px; padding: 3px 8px; }
  .final b { font-size: 30px; } .final span { font-size: 13px; } .final em { font-size: 11px; }
  .sub span { font-size: 10px; padding: 1px 6px; }
  .grid { gap: 3px; }
  .grid div { flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: baseline; column-gap: 3px; padding: 2px 1px; border-radius: 8px; }
  .grid i { font-size: 11px; } .grid b { font-size: min(14px, 22cqi); } .grid span { flex-basis: 100%; text-align: center; line-height: 1.15; font-size: min(10px, 18.5cqi); }
  .obtns .mbtn.primary, #over .lbup { padding-top: 6px; padding-bottom: 6px; font-size: 15px; }
  .obtns .row { margin-top: 4px; gap: 4px; } .obtns .row .mbtn { padding-top: 5px; padding-bottom: 5px; font-size: 11.5px; }
  .line { font-size: 11px; line-height: 1.25; }
}
