:root {
  --navy: #0f1b4d; --navy-2: #16266b; --line: #3b6cff; --yellow: #ffd83a; --yellow-2: #ffb800;
  --ink: #0a1238; --text: #eef2ff; --muted: #a9b8ef; --red: #ef4444;
  --side: clamp(62px, 7vw, 100px);
  --display: 'Baloo 2', 'Nunito', 'Segoe UI', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1a2450; color: var(--text); font-family: 'Nunito', 'Segoe UI', system-ui, sans-serif; user-select: none; -webkit-user-select: none; touch-action: none; }
canvas#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; color: inherit; }
img { -webkit-user-drag: none; }

/* ---------- shared buttons ---------- */
.big-play {
  display: inline-flex; align-items: center; justify-content: center; gap: .35em;
  padding: .3em 1.1em; border: 4px solid #fff3b0; border-radius: 22px;
  font: 800 clamp(22px, 3.2vw, 44px)/1.1 var(--display); color: var(--ink);
  background: linear-gradient(180deg, #fff27a, var(--yellow) 45%, var(--yellow-2));
  box-shadow: 0 6px 0 #b77f00, 0 0 0 4px var(--navy), 0 12px 30px rgba(255, 200, 0, .35);
  transition: transform .1s;
}
.big-play img { width: 1em; height: 1em; object-fit: contain; }
.big-play:hover { transform: translateY(-2px) scale(1.02); }
.big-play:active { transform: translateY(3px); box-shadow: 0 2px 0 #b77f00, 0 0 0 4px var(--navy); }
.big-play.small { font-size: 22px; margin-top: 14px; }
.pill { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 14px; border: 2px solid var(--line); background: rgba(15, 27, 77, .85); color: #fff; font-weight: 900; font-size: 15px; text-decoration: none; }
.pill img { width: 26px; height: 26px; object-fit: contain; }
.pill:hover { background: var(--navy-2); }
.pill.wide { width: 100%; margin-top: 10px; }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; z-index: 10; }
.screen.dim { display: grid; place-items: center; background: rgba(6, 10, 36, .72); padding: 16px; z-index: 20; }
.dialog { width: min(420px, 100%); max-height: 100%; overflow-y: auto; padding: 22px; border-radius: 20px; text-align: center; background: linear-gradient(180deg, #1a2a78, var(--navy)); border: 3px solid var(--line); box-shadow: 0 20px 60px rgba(0, 0, 0, .6); }
.dialog.wide { width: min(560px, 100%); }
.dialog h2 { margin: 0 0 12px; font: 800 30px var(--display); color: var(--yellow); }
.dialog .big-play { font-size: 26px; }
#dialog-body { text-align: left; font-weight: 700; color: #dbe3ff; font-size: 14.5px; display: grid; gap: 8px; }
#dialog-body .row { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 12px; background: rgba(255, 255, 255, .06); }
#dialog-body .row img { width: 34px; height: 34px; object-fit: contain; flex: none; }
#dialog-body b { color: var(--yellow); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); opacity: 0; z-index: 30; pointer-events: none; padding: 10px 18px; border-radius: 14px; background: var(--navy); border: 2px solid var(--yellow); font-weight: 900; transition: .25s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- main menu (matches the reference artwork) ---------- */
.menu { background: #1c2d6e url('assets/ui/bg.webp') center / cover no-repeat; overflow: hidden; }
.side {
  position: absolute; left: 0; top: 0; bottom: 0; width: var(--side); z-index: 2;
  display: flex; flex-direction: column; align-items: center; gap: clamp(6px, 2vh, 20px); padding-top: 1.5vh;
  background: linear-gradient(180deg, #0c1640, #0a1236); clip-path: polygon(0 0, 100% 0, 88% 100%, 0 100%); box-shadow: 4px 0 0 var(--line);
}
.brand { display: flex; flex-direction: column; align-items: center; text-decoration: none; color: #fff; margin-bottom: 1vh; }
.brand::before { content: '👑'; font-size: clamp(10px, 1.2vw, 16px); line-height: 1; }
.brand span { font: 800 clamp(14px, 1.9vw, 26px)/1 var(--display); letter-spacing: 1px; }
.brand small { font-size: clamp(8px, .8vw, 11px); letter-spacing: 3px; font-weight: 900; }
.nav { width: 72%; aspect-ratio: 1.25; display: grid; place-items: center; border: 0; background: none; border-radius: 12px; padding: 0; }
.nav img { width: clamp(28px, 3.4vw, 48px); height: clamp(28px, 3.4vw, 48px); object-fit: contain; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .4)); }
.nav.on { background: var(--yellow); width: 118%; margin-left: 18%; border-radius: 0 14px 14px 0; box-shadow: 0 0 18px rgba(255, 216, 58, .6); }
.nav:not(.on):hover { background: rgba(255, 255, 255, .08); }
.hero-art { position: absolute; left: calc(var(--side) + 1vw); bottom: 0; height: 96vh; max-width: 52vw; object-fit: contain; object-position: left bottom; filter: drop-shadow(0 12px 18px rgba(0, 0, 0, .35)); }
.menu-right { position: absolute; right: 1.6vw; top: 1.6vh; bottom: 2vh; width: 41vw; padding: 1.4vh 1vw; display: flex; flex-direction: column; align-items: center; justify-content: space-between; gap: 1vh;
  border-radius: 28px; background: linear-gradient(180deg, rgba(12, 22, 70, .08), rgba(12, 22, 70, .26)); backdrop-filter: blur(2.5px); -webkit-backdrop-filter: blur(2.5px); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .1); }
.logo { width: 92%; max-height: 23vh; object-fit: contain; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .35)); }
.menu-right > * { flex: none; }
/* The gameplay card takes whatever height is left, so the column always fits. */
.menu-right > .preview { flex: 1 1 0; min-height: 0; width: 100%; border: 0; padding: 0; background: none; display: flex; align-items: center; justify-content: center; transition: transform .15s; }
.preview img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.preview:hover { transform: scale(1.02); }
.badges { display: flex; gap: 1.6vw; justify-content: center; }
.badges span { display: flex; align-items: center; gap: 8px; padding: 3px 12px 3px 3px; border-radius: 999px; background: rgba(10, 18, 56, .78); font: 800 clamp(10px, 1vw, 14px)/1.15 "Nunito", sans-serif; text-transform: uppercase; }
.badges img { width: clamp(34px, 3.6vw, 52px); height: clamp(34px, 3.6vw, 52px); object-fit: contain; padding: 5px; border-radius: 50%; background: var(--navy); border: 3px solid var(--line); flex: none; }
.chars { display: flex; gap: clamp(4px, .8vw, 10px); justify-content: center; }
.char { position: relative; padding: 0; border: 0; background: none; }
.char img { display: block; width: clamp(46px, 5.2vw, 76px); height: clamp(46px, 5.2vw, 76px); border-radius: 50%; object-fit: cover; background: radial-gradient(circle at 50% 30%, #3b5bd6, var(--navy)); border: 3px solid var(--line); transition: transform .12s; }
.char .sex { position: absolute; right: -3px; bottom: -3px; width: 42%; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; font: 900 clamp(11px, 1.3vw, 18px)/1 sans-serif; color: #fff; border: 2px solid #fff; }
.char .sex.nam { background: #2563eb; }
.char .sex.nu { background: #ec4899; }
.char.sel img { border-color: var(--yellow); box-shadow: 0 0 0 3px var(--navy), 0 0 16px rgba(255, 216, 58, .8); transform: scale(1.08); }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
.panel { position: absolute; top: 10px; display: flex; align-items: center; gap: 8px; padding: 6px 14px 6px 8px; border-radius: 16px; background: rgba(15, 27, 77, .88); border: 2px solid var(--line); box-shadow: 0 6px 18px rgba(0, 0, 0, .35); }
.panel img { width: 38px; height: 38px; object-fit: contain; }
.score { left: 10px; flex-wrap: wrap; max-width: 46vw; }
.score b { font: 800 28px/1 var(--display); color: var(--yellow); }
.score small { margin-left: 4px; color: var(--muted); font-weight: 800; }
.score span { display: block; font-weight: 900; font-size: 13px; }
.score em { flex-basis: 100%; font-style: normal; font-weight: 800; font-size: 12px; color: #fb923c; }
.score em:empty { display: none; }
.timer { left: 50%; transform: translateX(-50%); }
.timer img { width: 30px; height: 30px; }
.timer b { font: 800 26px/1 var(--display); letter-spacing: 1px; }
.timer b.low { color: var(--red); animation: blink .5s infinite alternate; }
@keyframes blink { to { opacity: .5; } }
.top-right { position: absolute; top: 10px; right: 10px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.pause-btn { pointer-events: auto; display: flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 14px; border: 3px solid #fff3b0; background: linear-gradient(180deg, #fff27a, var(--yellow-2)); color: var(--ink); font-weight: 900; font-size: 15px; box-shadow: 0 4px 0 #b77f00; }
.pause-btn .bars { width: 14px; height: 16px; border-left: 5px solid var(--ink); border-right: 5px solid var(--ink); }
#minimap { border-radius: 12px; border: 3px solid #60a5fa; box-shadow: 0 0 0 3px var(--navy), 0 8px 20px rgba(0, 0, 0, .45); max-width: 28vw; }
.alerts { position: absolute; top: 66px; left: 50%; transform: translateX(-50%); width: min(calc(100vw - 380px), 640px); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.banner { display: flex; align-items: center; gap: 10px; padding: 8px 18px 8px 10px; border-radius: 16px; font-weight: 900; font-size: 18px; text-align: left; background: rgba(15, 27, 77, .92); border: 3px solid var(--line); }
.banner img { width: 42px; height: 42px; object-fit: contain; flex: none; }
.banner.danger { background: linear-gradient(180deg, #ef4444, #b91c1c); border-color: #fecaca; box-shadow: 0 0 24px rgba(239, 68, 68, .6); animation: pulse .6s infinite alternate; }
.banner.ok { background: linear-gradient(180deg, #22c55e, #15803d); border-color: #bbf7d0; }
.banner.count { margin-top: 18vh; padding: 0; font: 800 72px var(--display); background: none; border: 0; color: var(--yellow); text-shadow: 0 5px 0 var(--ink), 0 0 20px rgba(0, 0, 0, .5); }
@keyframes pulse { to { transform: scale(1.04); } }
.guard-status { display: flex; align-items: center; gap: 6px; padding: 3px 14px 3px 4px; border-radius: 999px; background: rgba(15, 27, 77, .9); border: 2px solid var(--line); font-weight: 800; font-size: 14px; white-space: nowrap; }
.guard-status img { width: 28px; height: 28px; object-fit: contain; }
.guard-status.danger { background: rgba(220, 38, 38, .95); border-color: #fecaca; }
.combo { position: absolute; top: 30%; left: 50%; transform: translate(-50%, -50%); display: flex; align-items: center; gap: 8px; font: 800 50px var(--display); color: #fb923c; text-shadow: 0 4px 0 var(--ink); opacity: 0; white-space: nowrap; }
.combo img { width: 56px; height: 56px; }
.combo.pop { animation: combo 1.1s ease-out; }
@keyframes combo { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.5); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); } 70% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -80%) scale(1); } }
.flash { position: absolute; bottom: 150px; left: 50%; transform: translateX(-50%); padding: 6px 16px; border-radius: 12px; background: rgba(15, 27, 77, .85); font-weight: 900; font-size: 15px; opacity: 0; transition: opacity .25s; white-space: nowrap; }
.flash.show { opacity: 1; }
.crosshair { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .85); box-shadow: 0 0 0 1px rgba(0, 0, 0, .4); }
.crosshair::after { content: ''; position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px; border-radius: 50%; background: #fff; }
.crosshair.aim { width: 30px; height: 30px; margin: -15px 0 0 -15px; }
.crosshair.on { border-color: var(--red); box-shadow: 0 0 10px rgba(239, 68, 68, .8); }
.shield { position: absolute; bottom: 96px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 6px; padding: 3px 12px 3px 4px; border-radius: 999px; background: #334155; border: 2px solid #cbd5e1; font-weight: 900; }
.shield img { width: 30px; height: 30px; }
.prompt { position: absolute; bottom: 118px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; border-radius: 14px; background: rgba(15, 27, 77, .92); border: 2px solid var(--yellow); font-weight: 900; white-space: nowrap; }
.prompt kbd { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--yellow); color: var(--ink); font: inherit; }
.inventory { position: absolute; bottom: 30px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; padding: 6px; border-radius: 16px; background: rgba(15, 27, 77, .82); border: 2px solid var(--line); }
.slot { position: relative; width: 62px; height: 62px; border-radius: 12px; background: #1a2a6c; border: 2px solid #3656b8; display: grid; place-items: center; }
.slot.sel { border-color: var(--yellow); box-shadow: 0 0 12px rgba(255, 216, 58, .6); }
.slot small { position: absolute; top: 1px; left: 5px; font-size: 11px; font-weight: 900; color: var(--muted); }
.slot img { width: 78%; height: 78%; object-fit: contain; pointer-events: none; }
.slot em { position: absolute; bottom: -2px; right: 2px; font-style: normal; font-size: 11px; font-weight: 900; color: var(--yellow); text-shadow: 0 1px 2px #000; }
.hint { position: absolute; bottom: 6px; left: 0; right: 0; text-align: center; font-size: 11.5px; font-weight: 700; color: rgba(255, 255, 255, .8); text-shadow: 0 1px 3px #000; }
#hurt { position: fixed; inset: 0; pointer-events: none; box-shadow: inset 0 0 120px rgba(239, 68, 68, .8); opacity: 0; z-index: 1; }
#hurt.show { animation: hurt .5s ease-out; }
@keyframes hurt { from { opacity: 1; } to { opacity: 0; } }

/* Skill button: character portrait with a cooldown sweep. */
.skill-btn { position: absolute; bottom: 24px; left: calc(50% + 130px); width: 78px; height: 78px; padding: 0; border-radius: 50%; border: 4px solid #c084fc; background: radial-gradient(circle at 50% 35%, #4c1d95, var(--navy)); pointer-events: auto; box-shadow: 0 0 0 3px var(--navy), 0 0 18px rgba(192, 132, 252, .7); }
.skill-btn img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.skill-btn .cd { position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(rgba(6, 10, 36, .78) var(--left, 0%), transparent 0); display: grid; place-items: center; font: 800 24px var(--display); color: #fff; }
.skill-btn kbd { position: absolute; right: -6px; top: -6px; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 8px; background: var(--yellow); color: var(--ink); font: 900 13px 'Nunito', sans-serif; }
.skill-btn em { position: absolute; left: 50%; bottom: -20px; transform: translateX(-50%); white-space: nowrap; font-style: normal; font-weight: 900; font-size: 12px; color: #f5d0fe; text-shadow: 0 1px 3px #000; }
.skill-btn.ready { animation: skill-ready 1s infinite alternate; }
@keyframes skill-ready { to { box-shadow: 0 0 0 3px var(--navy), 0 0 30px rgba(216, 180, 254, 1); } }
.char-info { margin: 0; max-width: 100%; padding: 6px 14px; border-radius: 14px; background: rgba(10, 18, 56, .82); border: 2px solid #c084fc; font-weight: 800; font-size: clamp(11px, 1.05vw, 15px); text-align: center; }
.char-info b { color: #f5d0fe; }

/* ---------- touch ---------- */
#touch { position: fixed; inset: 0; pointer-events: none; }
.stick { position: absolute; left: 22px; bottom: 22px; width: 136px; height: 136px; border-radius: 50%; background: rgba(15, 27, 77, .35); border: 3px solid rgba(147, 197, 253, .6); pointer-events: auto; }
.stick .arr { position: absolute; font-size: 12px; color: rgba(255, 255, 255, .8); }
.arr.u { top: 6px; left: 50%; transform: translateX(-50%); } .arr.d { bottom: 6px; left: 50%; transform: translateX(-50%); }
.arr.l { left: 8px; top: 50%; transform: translateY(-50%); } .arr.r { right: 8px; top: 50%; transform: translateY(-50%); }
.knob { position: absolute; left: 40px; top: 40px; width: 50px; height: 50px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, #bcd3ff); box-shadow: 0 4px 10px rgba(0, 0, 0, .35); }
.actions { position: absolute; right: 16px; bottom: 16px; width: 250px; height: 230px; }
.act { position: absolute; pointer-events: auto; padding: 0; border: 0; background: none; display: grid; place-items: center; }
.act img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.act.throw { right: 0; bottom: 0; width: 100px; height: 100px; border-radius: 50%; border: 4px solid var(--yellow); background: radial-gradient(circle at 50% 40%, #2a3f99, var(--navy)); box-shadow: 0 0 0 3px rgba(15, 27, 77, .6), 0 0 18px rgba(255, 216, 58, .5); }
.act.throw img { width: 64%; height: 64%; margin-top: -8px; }
.act.throw small { position: absolute; bottom: 10px; font-size: 12px; font-weight: 900; color: var(--yellow); }
.act.throw.on { transform: scale(1.08); box-shadow: 0 0 0 3px rgba(15, 27, 77, .6), 0 0 28px rgba(255, 216, 58, .9); }
.act.interact { right: 124px; bottom: 0; width: 76px; height: 76px; }
.act.interact.ready { animation: ready .8s infinite alternate; }
@keyframes ready { to { transform: scale(1.1); filter: drop-shadow(0 0 10px rgba(255, 216, 58, .9)); } }
.act.jump { right: 6px; bottom: 124px; width: 70px; height: 70px; }
.act.dodge { right: 190px; bottom: 96px; width: 56px; height: 56px; border-radius: 50%; border: 3px solid #7dd3fc; background: radial-gradient(circle at 50% 35%, #1e40af, var(--navy)); color: #fff; box-shadow: 0 0 0 2px rgba(15, 27, 77, .6); }
.act.dodge span { font: 900 24px/1 'Nunito', sans-serif; margin-top: -6px; }
.act.dodge small { position: absolute; bottom: 5px; font-size: 10px; font-weight: 900; color: #bae6fd; }
.act.sprint { right: 112px; bottom: 100px; width: 62px; height: 62px; }
.act.on:not(.throw) { filter: drop-shadow(0 0 10px rgba(255, 216, 58, .9)) brightness(1.15); }
body.touch .hint { display: none; }
body.touch .prompt { bottom: 12px; font-size: 13px; padding: 4px 12px; border-radius: 999px; }
body.touch .prompt kbd { display: none; }
body.touch .inventory { top: 92px; bottom: auto; left: 10px; transform: none; pointer-events: auto; }
body.touch .slot { width: 48px; height: 48px; }
body.touch #minimap { max-width: 150px; }
body.touch .alerts { width: min(54vw, 460px); }
body.touch .flash { bottom: 48px; font-size: 13px; }
body.touch .shield { bottom: 44px; }
body.touch .skill-btn { left: auto; right: 250px; bottom: 26px; width: 70px; height: 70px; }
body.touch .skill-btn kbd { display: none; }

/* ---------- result: leaderboard ----------
   Tall screens: content sits on the slots of the frame art (positions in % of the
   frame, sizes in cqw = % of the frame's width). Short screens: see the end of file. */
.result { display: grid; place-items: center; padding: 12px; background: #1c2d6e url('assets/ui/bg.webp') center / cover no-repeat; }
.result::before { content: ''; position: absolute; inset: 0; backdrop-filter: blur(5px) brightness(.8); -webkit-backdrop-filter: blur(5px) brightness(.8); }
.lb { position: relative; container-type: inline-size; width: min(94vw, calc(96vh * 1086 / 1448)); aspect-ratio: 1086 / 1448; background: url('assets/ui/khung-bxh.webp') center / 100% 100% no-repeat; }
.lb > * { position: absolute; }
.lb-close { right: 1.5%; top: 6%; width: 11%; aspect-ratio: 1; padding: 0; border: 0; background: none; }
.lb-close img { width: 100%; height: 100%; }
.lb-title { left: 11%; width: 78%; top: -1.5%; z-index: 2; filter: drop-shadow(0 .8cqw 1.2cqw rgba(0, 0, 0, .45)); }
.lb-boy { left: 6%; top: 16%; width: 19%; transform: rotate(-4deg); filter: drop-shadow(0 1cqw 1.4cqw rgba(0, 0, 0, .4)); }
.lb-girl { right: 6%; top: 16%; width: 19%; transform: rotate(4deg); filter: drop-shadow(0 1cqw 1.4cqw rgba(0, 0, 0, .4)); }
.lb-rank { left: 29%; right: 29%; top: 17.6%; height: 11.6%; background: url('assets/ui/o-hang.webp') center / 100% 100% no-repeat; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .6cqw; }
.lb-rank b { font: 800 7cqw/1 var(--display); color: var(--yellow); -webkit-text-stroke: .35cqw var(--navy); paint-order: stroke fill; }
.lb .stars { display: flex; gap: 1cqw; }
.lb .stars img { width: 7.4cqw; filter: drop-shadow(0 .4cqw .6cqw rgba(0, 0, 0, .4)); }
.lb .stars img.off { filter: grayscale(1) brightness(.4); }
.lb-table { left: 6.2%; right: 6.2%; top: 30.4%; height: 33.4%; display: flex; flex-direction: column; }
.lb-row { flex: 1; display: grid; grid-template-columns: 23% 36% 20% 21%; align-items: center; text-align: center; font: 900 3.2cqw/1 'Nunito', sans-serif; color: #fff; border-radius: 2cqw; margin: .2cqw .6cqw; }
.lb-head { flex: .85; color: var(--muted); font-size: 2.7cqw; }
#end-rows { flex: 7.4; display: flex; flex-direction: column; }
.lb-row .medal { width: 6cqw; height: 6cqw; justify-self: center; }
.lb-row.gold { background: linear-gradient(180deg, #fde68a, #f59e0b); color: #3a2300; }
.lb-row.silver { background: linear-gradient(180deg, #e2e8f0, #94a3b8); color: #1e293b; }
.lb-row.bronze { background: linear-gradient(180deg, #fdba74, #c2410c); color: #fff; }
.lb-row.me { color: var(--yellow); background: linear-gradient(180deg, #1d4ed8, #1e3a8a); box-shadow: 0 0 0 .5cqw #60a5fa, 0 0 2.4cqw rgba(96, 165, 250, .9); }
.lb-row.gold.me, .lb-row.silver.me, .lb-row.bronze.me { color: inherit; box-shadow: 0 0 0 .6cqw #fff, 0 0 3cqw rgba(255, 255, 255, .9); }
.lb-row.gold.me { background: linear-gradient(180deg, #fde68a, #f59e0b); }
.lb-row.silver.me { background: linear-gradient(180deg, #e2e8f0, #94a3b8); }
.lb-row.bronze.me { background: linear-gradient(180deg, #fdba74, #c2410c); }
.lb-goals { left: 8%; right: 20%; top: 66.6%; height: 12.2%; display: flex; align-items: center; gap: 3cqw; padding-left: 2cqw; }
.lb-goals > img { width: 12cqw; height: 12cqw; flex: none; }
.goals { list-style: none; margin: 0; padding: 0; display: grid; gap: .8cqw; text-align: left; font: 800 2.8cqw/1.15 'Nunito', sans-serif; }
.goals li { display: flex; align-items: center; gap: 1.6cqw; }
.goals img { width: 4.2cqw; height: 4.2cqw; flex: none; }
.goals img.off { filter: grayscale(1) opacity(.35); }
.lb-extra { left: 14%; right: 8%; top: 80.4%; height: 5%; margin: 0; display: flex; align-items: center; justify-content: center; text-align: center; font: 800 2.7cqw/1 'Nunito', sans-serif; color: #dbe3ff; }
.lb-buttons { left: 5%; right: 5%; top: 87.4%; height: 7%; display: flex; align-items: center; justify-content: center; gap: 1.4%; }
.img-btn { height: 100%; padding: 0; border: 0; background: none; display: block; transition: transform .1s; }
.img-btn img { height: 100%; width: auto; display: block; filter: drop-shadow(0 .6cqw .8cqw rgba(0, 0, 0, .4)); }
.img-btn:hover { transform: translateY(-2px) scale(1.03); }
.img-btn:active { transform: translateY(2px); }
#retry-btn { height: 116%; }

/* ---------- phones ---------- */
@media (max-height: 520px) {
  .badges { display: none; }
  .logo { max-height: 22vh; }
  .menu-right { top: 1.5vh; bottom: 2.5vh; gap: .6vh; }
  .char img { width: 42px; height: 42px; }
  .char-info { font-size: 10.5px; padding: 2px 10px; line-height: 1.2; }
  .char img { width: 38px; height: 38px; }
  .skill-btn { width: 60px; height: 60px; }
  body.touch .skill-btn { right: 214px; width: 58px; height: 58px; }
  .menu-right .big-play { font-size: 22px; padding: .22em 1em; }
  .panel { padding: 3px 10px 3px 5px; }
  .panel img { width: 28px; height: 28px; }
  .score b { font-size: 22px; }
  .timer b { font-size: 20px; }
  .alerts { top: 50px; }
  .banner { font-size: 13px; padding: 4px 12px 4px 6px; }
  .banner img { width: 30px; height: 30px; }
  .banner.count { font-size: 50px; }
  .guard-status { font-size: 12px; }
  .combo { font-size: 36px; }
  .actions { transform: scale(.82); transform-origin: right bottom; }
  .stick { transform: scale(.82); transform-origin: left bottom; }
}
@media (orientation: portrait) {
  :root { --side: 0px; }
  .side { display: none; }
  .hero-art { left: 50%; transform: translateX(-50%); top: 20vh; bottom: auto; height: 46vh; max-width: 92vw; object-position: center; }
  .menu-right { inset: auto 3vw 2vh 3vw; width: auto; justify-content: flex-end; backdrop-filter: none; -webkit-backdrop-filter: none; background: linear-gradient(180deg, transparent, rgba(12, 22, 70, .45) 30%); box-shadow: none; }
  .logo { position: fixed; top: 2vh; left: 50%; transform: translateX(-50%); width: 90vw; max-height: 18vh; }
  .preview { display: none; }
  .badges { gap: 3vw; }
  .badges span { font-size: 10px; }
}

/* Leaderboard on short (landscape phone) screens: a plain two-column card. */
@media (max-height: 600px) {
  .lb { container-type: normal; width: min(820px, 100%); aspect-ratio: auto; max-height: 100%; overflow-y: auto; padding: 10px 14px; border-radius: 22px; border: 3px solid var(--line); background: linear-gradient(180deg, rgba(26, 42, 120, .97), rgba(12, 20, 64, .98));
    display: grid; grid-template-columns: 1fr 1.2fr; grid-template-areas: "title table" "rank table" "goals table" "extra table" "buttons buttons"; column-gap: 14px; row-gap: 6px; align-items: center; }
  .lb > * { position: static; }
  .lb-boy, .lb-girl { display: none; }
  .lb-close { position: absolute; right: 6px; top: 6px; width: 34px; }
  .lb-title { grid-area: title; width: min(100%, 300px); justify-self: center; filter: none; }
  .lb-rank { grid-area: rank; width: 220px; height: 74px; justify-self: center; }
  .lb-rank b { font-size: 22px; -webkit-text-stroke: 2px var(--navy); }
  .lb .stars img { width: 30px; }
  .lb-table { grid-area: table; }
  .lb-row { min-height: 26px; font-size: 13px; }
  .lb-head { font-size: 11px; min-height: 20px; }
  .lb-row .medal { width: 22px; height: 22px; }
  .lb-goals { grid-area: goals; padding: 0; gap: 8px; }
  .lb-goals > img { width: 40px; height: 40px; }
  .goals { font-size: 11.5px; gap: 3px; }
  .goals img { width: 16px; height: 16px; }
  .lb-extra { grid-area: extra; font-size: 11px; }
  .lb-buttons { grid-area: buttons; height: 46px; }
  #retry-btn { height: 52px; }
}
.goals .box { width: 4.2cqw; height: 4.2cqw; flex: none; border-radius: 1cqw; background: #fff; border: .4cqw solid #cbd5e1; }
.lb-extra b { color: var(--yellow); }
@media (max-height: 600px) { .goals .box { width: 16px; height: 16px; border-radius: 4px; border-width: 2px; } }

/* ---------- play together ---------- */
.pause-note { margin: -4px 0 12px; font-weight: 800; font-size: 14px; color: #fde68a; }
.play-row { display: flex; align-items: stretch; gap: clamp(6px, .8vw, 12px); }
.together { display: inline-flex; align-items: center; gap: 8px; padding: .25em .9em; border-radius: 20px; border: 3px solid #bae6fd; background: linear-gradient(180deg, #38bdf8, #1d4ed8); color: #fff; font: 800 clamp(13px, 1.25vw, 19px)/1.05 var(--display); text-align: left; box-shadow: 0 5px 0 #1e3a8a, 0 0 0 3px var(--navy); cursor: pointer; }
.together img { width: 1.9em; height: 1.9em; object-fit: contain; }
.together small { display: block; font: 800 .62em 'Nunito', sans-serif; color: #e0f2fe; }
.together:active { transform: translateY(3px); box-shadow: 0 2px 0 #1e3a8a, 0 0 0 3px var(--navy); }
.lobby p { margin: 0 0 12px; font-weight: 700; line-height: 1.4; }
.lobby-note { font-size: 14px; color: #dbeafe; }
.lobby-links { display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; }
.lobby-or { margin: 14px 0 8px; font-weight: 800; color: #93c5fd; font-size: 14px; }
.code-row { display: flex; gap: 8px; justify-content: center; }
.code-row input { width: 130px; padding: 8px 12px; border-radius: 14px; border: 3px solid var(--line); background: #fff; color: var(--ink); font: 800 28px/1 var(--display); letter-spacing: 8px; text-align: center; }
.room-code { display: flex; flex-direction: column; align-items: center; margin-bottom: 10px; font-weight: 800; color: #dbeafe; }
.room-code b { font: 800 46px/1 var(--display); letter-spacing: 10px; color: var(--yellow); text-shadow: 0 3px 0 var(--ink); }
.room-code small { font-size: 12px; color: #93c5fd; }
.room-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; }
.room-list li { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 12px; background: rgba(255, 255, 255, .08); border: 2px solid rgba(255, 255, 255, .12); text-align: left; min-height: 44px; }
.room-list li.me { border-color: var(--yellow); background: rgba(255, 216, 58, .12); }
.room-list li.bot { border-style: dashed; opacity: .75; }
.room-list li.bot small { margin-left: auto; font-size: 11px; color: #93c5fd; }
.room-list .av { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: #fff; }
.room-list .nm { font-weight: 900; }
.room-list .nm small { font-weight: 700; color: #fde68a; }
.room-list .host { font-size: 12px; font-weight: 900; color: var(--yellow); }
.room-list .pt { margin-left: auto; width: 38px; height: 38px; border-radius: 10px; object-fit: cover; border: 2px solid var(--line); }
.lobby-pick { font-weight: 800; font-size: 13px; color: #93c5fd; margin-bottom: 6px; }
.lobby #lobby-chars { margin-bottom: 8px; }
.lobby-wait { color: #fde68a; }
.lobby-err { min-height: 1em; margin: 8px 0 0 !important; color: #fca5a5; font-weight: 800; }
.emote-btn { position: absolute; right: calc(100% + 8px); top: 0; pointer-events: auto; width: 40px; height: 40px; border-radius: 12px; border: 3px solid #fff3b0; background: rgba(15, 27, 77, .85); font-size: 22px; line-height: 1; padding: 0; cursor: pointer; }
.emote-panel { position: fixed; top: 64px; right: 16px; z-index: 15; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 8px; border-radius: 16px; background: rgba(10, 18, 56, .92); border: 3px solid var(--line); }
.emote-panel button { padding: 8px 10px; border-radius: 12px; border: 2px solid rgba(255, 255, 255, .2); background: #1a2a78; color: #fff; font-weight: 900; font-size: 14px; white-space: nowrap; cursor: pointer; }
.emote-panel button:hover { background: #2a3f99; }
@media (max-height: 520px) {
  .together { font-size: 12px; padding: .2em .7em; }
  .lobby .room-code b { font-size: 34px; }
  .room-list li { min-height: 36px; padding: 3px 8px; }
  .room-list .av, .room-list .pt { width: 28px; height: 28px; }
  .emote-panel { top: 50px; }
  .emote-panel button { padding: 5px 8px; font-size: 12px; }
}
