:root {
  --navy: #14204a;
  --navy2: #1f3a93;
  --gold: #f2c14e;
  --maroon: #8c1d2f;
  --ink: #1b1b2f;
  --paper: #fffdf7;
  --muted: #6b6f80;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #78bb5e; color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  user-select: none; -webkit-user-select: none;
}
canvas { display: block; touch-action: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
.hidden { display: none !important; }

#map { position: fixed; inset: 0; width: 100%; height: 100%; }

/* ---------- HUD ---------- */
.pill {
  background: rgba(20, 32, 74, .9); color: #fff;
  border-radius: 999px; box-shadow: 0 3px 12px rgba(0, 0, 0, .25);
}
.pill.light { background: rgba(255, 253, 247, .94); color: var(--ink); }

#hud {
  position: fixed; top: 0; left: 0; right: 0; pointer-events: none;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 0;
}
#player-card { display: flex; align-items: center; gap: 8px; padding: 5px 14px 5px 5px; }
#avatar-badge {
  width: 38px; height: 38px; border-radius: 50%; background: var(--gold);
  display: grid; place-items: center; font-size: 20px;
}
#lvl { font-weight: 700; font-size: 14px; }
.xpbar { width: 92px; height: 6px; border-radius: 4px; overflow: hidden; margin-top: 4px; background: rgba(255, 255, 255, .25); }
#xpfill { height: 100%; width: 0; background: var(--gold); transition: width .4s; }
#ball-chip { display: flex; gap: 10px; padding: 9px 13px; font-weight: 700; font-size: 14px; }
#ball-chip span { display: flex; align-items: center; gap: 4px; }

#zone-chip {
  position: fixed; left: 50%; transform: translateX(-50%);
  top: calc(64px + env(safe-area-inset-top));
  padding: 6px 14px; font-size: 13px; font-weight: 700; pointer-events: none; white-space: nowrap;
}

.ball-ico {
  --c: #1f3a93;
  display: inline-block; width: 18px; height: 18px; flex: none; border-radius: 50%;
  border: 2px solid var(--ink); vertical-align: middle;
  background: linear-gradient(to bottom, var(--c) 0 42%, var(--ink) 42% 58%, #fff 58%);
}
.ball-ico.honors { --c: #8c1d2f; }
.ball-ico.magna { --c: #d4a017; }

#btn-sound {
  position: fixed; right: 12px; top: calc(64px + env(safe-area-inset-top)); z-index: 20;
  width: 40px; height: 40px; border-radius: 50%; font-size: 18px;
  background: rgba(255, 253, 247, .94); box-shadow: 0 3px 12px rgba(0, 0, 0, .25);
}
.b-charged:focus-visible, .b-fast:focus-visible, .b-actions button:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
#btn-sound:focus-visible, #dock button:focus-visible, #catch-bottom button:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---------- nearby ---------- */
#nearby {
  position: fixed; right: 12px; bottom: calc(112px + env(safe-area-inset-bottom));
  background: rgba(255, 253, 247, .94); border-radius: 14px; padding: 6px 8px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, .2); min-width: 64px; pointer-events: none;
}
.nearby-title { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); text-align: center; }
#nearby-list { display: flex; flex-direction: column; gap: 2px; }
.nb { display: flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; }
.nb img { width: 34px; height: 34px; }
.sil { filter: brightness(0) opacity(.55); }
.seen { filter: grayscale(.85) opacity(.8); }

/* ---------- dock ---------- */
#dock {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 10px;
}
#dock button {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--paper); box-shadow: 0 4px 14px rgba(0, 0, 0, .3);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: transform .1s;
}
#dock button:active { transform: scale(.92); }
#dock .ico { font-size: 24px; line-height: 1; }
#dock .lbl { font-size: 9px; font-weight: 700; margin-top: 2px; }
#dock button.main {
  width: 72px; height: 72px; background: radial-gradient(circle at 35% 30%, #3453b8, var(--navy));
  border: 4px solid var(--gold);
}
#dock button.main .ico { font-size: 34px; }

/* ---------- toast / banner ---------- */
#toast {
  position: fixed; left: 50%; top: calc(108px + env(safe-area-inset-top));
  transform: translate(-50%, -10px); opacity: 0; pointer-events: none;
  background: rgba(20, 32, 74, .94); color: #fff; padding: 10px 16px; border-radius: 14px;
  font-size: 14px; font-weight: 600; max-width: min(92vw, 420px); text-align: center;
  transition: opacity .25s, transform .25s; z-index: 30;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#banner {
  position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%) scale(.6);
  opacity: 0; pointer-events: none; text-align: center; z-index: 40;
  color: var(--gold); font-weight: 900; font-size: 44px; letter-spacing: .02em;
  text-shadow: 0 3px 0 var(--navy), 0 0 22px rgba(0, 0, 0, .45);
  transition: opacity .3s, transform .3s;
}
#banner small { display: block; font-size: 17px; color: #fff; text-shadow: 0 2px 6px rgba(0, 0, 0, .7); }
#banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* ---------- catch screen ---------- */
#catch { position: fixed; inset: 0; z-index: 10; background: #000; }
#catch-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#catch-top {
  position: absolute; top: calc(14px + env(safe-area-inset-top)); left: 0; right: 0;
  text-align: center; pointer-events: none; color: #fff; text-shadow: 0 2px 6px rgba(0, 0, 0, .6);
}
#catch-cp { font-size: 15px; font-weight: 700; opacity: .95; }
#catch-name { font-size: 26px; font-weight: 900; }
#catch-types { display: flex; gap: 6px; justify-content: center; margin-top: 4px; }
.type {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  color: #fff; font-size: 11px; font-weight: 700; text-shadow: none; letter-spacing: .03em;
}
.rar { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; background: #eee; color: var(--ink); text-shadow: none; }
.rar.r4 { background: #c7d2fe; }
.rar.r5 { background: var(--gold); }
#catch-msg {
  position: absolute; left: 0; right: 0; top: 22%; text-align: center; pointer-events: none;
  font-size: 34px; font-weight: 900; color: #fff; opacity: 0;
  text-shadow: 0 3px 0 var(--navy), 0 0 16px rgba(0, 0, 0, .5);
}
#catch-msg.show { animation: pop 1.3s ease-out forwards; }
@keyframes pop {
  0% { opacity: 0; transform: scale(.5); }
  15% { opacity: 1; transform: scale(1.12); }
  25% { transform: scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-14px); }
}
#catch-hint {
  position: absolute; left: 0; right: 0; bottom: calc(210px + env(safe-area-inset-bottom));
  text-align: center; color: #fff; font-weight: 700; font-size: 15px; pointer-events: none;
  text-shadow: 0 2px 6px rgba(0, 0, 0, .7); animation: bob 1.4s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translateY(-6px); } }
#catch-bottom {
  position: absolute; left: 0; right: 0; bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 10px; padding: 0 16px;
}
#catch-bottom .spacer { flex: 1; }
#catch-bottom button {
  height: 52px; min-width: 52px; padding: 0 12px; border-radius: 26px;
  background: rgba(255, 253, 247, .94); box-shadow: 0 3px 10px rgba(0, 0, 0, .3);
  font-size: 22px; display: flex; align-items: center; gap: 6px;
}
#catch-bottom button b { font-size: 15px; }
#catch-bottom button:disabled { opacity: .45; }
#btn-ball .ball-ico { width: 26px; height: 26px; }

/* ---------- modal ---------- */
#modal {
  position: fixed; inset: 0; z-index: 50; background: rgba(10, 14, 35, .6);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  position: relative; width: min(100%, 620px); max-height: 88vh; overflow-y: auto;
  background: var(--paper); border-radius: 22px 22px 0 0; padding: 22px 16px calc(24px + env(safe-area-inset-bottom));
  animation: up .25s ease-out;
}
@media (min-width: 700px) { #modal { align-items: center; } .sheet { border-radius: 22px; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet .close {
  position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border-radius: 50%;
  background: #eceadf; font-size: 16px; font-weight: 700; z-index: 2;
}
.sheet h2 { margin: 0 0 4px; font-size: 22px; color: var(--navy); }
.sub { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.progress { height: 8px; background: #e6e3d6; border-radius: 6px; overflow: hidden; margin-bottom: 14px; }
.progress div { height: 100%; background: linear-gradient(90deg, var(--navy2), var(--gold)); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(98px, 1fr)); gap: 8px; }
.card {
  position: relative; display: flex; flex-direction: column; align-items: center;
  background: #f1efe6; border-radius: 14px; padding: 8px 4px 8px; min-height: 124px;
}
.card:disabled { cursor: default; }
.card.caught { background: linear-gradient(#fff, #eef1fb); box-shadow: inset 0 0 0 2px #cfd8f5; }
.card img { width: 72px; height: 72px; }
.card .num { position: absolute; top: 5px; left: 8px; font-size: 10px; color: var(--muted); font-weight: 700; }
.card .cnt { position: absolute; top: 5px; right: 8px; font-size: 10px; color: var(--navy2); font-weight: 700; }
.card .cp { font-size: 11px; font-weight: 700; color: var(--muted); }
.card .nm { font-size: 13px; font-weight: 700; }

.sortbar { display: flex; gap: 6px; margin: 4px 0 12px; }
.sortbar button { padding: 6px 12px; border-radius: 999px; background: #eceadf; font-size: 13px; font-weight: 700; }
.sortbar button.on { background: var(--navy); color: #fff; }

.detail { text-align: center; }
.detail img { width: 180px; height: 180px; }
.detail h2 { font-size: 28px; }
.detail .tags { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin: 6px 0 12px; }
.detail p.desc { font-size: 15px; line-height: 1.45; margin: 0 auto 14px; max-width: 420px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 auto 14px; max-width: 420px; }
.stats div { background: #f1efe6; border-radius: 12px; padding: 8px 4px; }
.stats b { display: block; font-size: 18px; color: var(--navy); }
.stats span { font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }

.primary {
  display: inline-block; padding: 13px 28px; border-radius: 999px;
  background: var(--navy); color: #fff; font-weight: 800; font-size: 16px;
  box-shadow: 0 4px 0 #0a1230;
}
.primary:active { transform: translateY(2px); box-shadow: 0 2px 0 #0a1230; }
.ghost { padding: 10px 18px; border-radius: 999px; background: #eceadf; font-weight: 700; font-size: 14px; }
.danger { background: #fde2e2; color: #9b1c1c; }

.items { display: grid; gap: 8px; margin: 10px 0 16px; }
.item { display: flex; align-items: center; gap: 12px; background: #f1efe6; border-radius: 12px; padding: 10px 14px; }
.item .ball-ico { width: 30px; height: 30px; }
.item .emo { font-size: 26px; width: 30px; text-align: center; }
.item .grow { flex: 1; }
.item .grow small { display: block; color: var(--muted); font-size: 12px; }
.item b { font-size: 18px; }
.row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }

.intro { text-align: center; padding-top: 6px; }
.intro .logo { font-size: 54px; }
.intro h1 { margin: 0; font-size: 38px; color: var(--navy); letter-spacing: -.01em; }
.intro h1 span { color: var(--gold); text-shadow: 0 2px 0 var(--navy); }
.intro p { font-size: 15px; line-height: 1.5; max-width: 460px; margin: 8px auto; }
.how { text-align: left; max-width: 440px; margin: 12px auto 16px; padding: 0; list-style: none; display: grid; gap: 8px; font-size: 14px; line-height: 1.4; }
.how li { background: #f1efe6; border-radius: 12px; padding: 8px 12px; }
.fine { font-size: 11px !important; color: var(--muted); margin-top: 16px !important; }

.result { text-align: center; }
.result img { width: 170px; height: 170px; animation: pop2 .5s ease-out; }
@keyframes pop2 { from { transform: scale(.3); } }
.newbadge { display: inline-block; background: var(--gold); color: var(--navy); font-weight: 900; font-size: 12px; padding: 3px 10px; border-radius: 999px; letter-spacing: .08em; }
.xpgain { font-size: 18px; font-weight: 800; color: var(--navy2); margin: 6px 0 16px; }

/* ---------- battles (real-time) ---------- */
#battle {
  position: fixed; inset: 0; z-index: 12; display: flex; flex-direction: column; overflow: hidden;
  --arena: #1f3a93;
  background:
    radial-gradient(ellipse at 72% 22%, rgba(255, 255, 255, .22), transparent 55%),
    radial-gradient(ellipse at 20% 85%, color-mix(in srgb, var(--arena) 55%, transparent), transparent 60%),
    linear-gradient(165deg, var(--arena), #0b1024 80%);
}
#battle.shake { animation: b-shake .3s; }
#battle.shake-big { animation: b-shake .55s; }
@keyframes b-shake {
  15% { transform: translate(-7px, 3px); } 30% { transform: translate(6px, -4px); } 45% { transform: translate(-5px, -2px); }
  60% { transform: translate(4px, 3px); } 75% { transform: translate(-2px, 1px); }
}
.b-field { position: relative; flex: 1; overflow: hidden; min-height: 280px; touch-action: none; cursor: pointer; user-select: none; }
#b-fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }
.b-trainer {
  position: absolute; left: 12px; top: calc(12px + env(safe-area-inset-top));
  color: #fff; font-weight: 800; font-size: 14px; background: rgba(0, 0, 0, .3);
  padding: 7px 14px; border-radius: 999px; z-index: 2;
}
.b-foe, .b-me { position: absolute; display: flex; gap: 10px; }
.b-foe { right: 12px; top: calc(60px + env(safe-area-inset-top)); align-items: flex-start; }
.b-me { left: 10px; bottom: 8px; align-items: flex-end; }
.b-mon {
  --flip: 1; --lx: -34px; --ly: 22px; --glow: #fff;
  width: clamp(120px, 30vw, 210px); height: clamp(120px, 30vw, 210px);
  transform: scaleX(var(--flip));
  background: radial-gradient(ellipse 48% 13% at 50% 91%, rgba(0, 0, 0, .35), transparent 70%);
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .3));
  pointer-events: none;
}
.b-mon.elite { filter: drop-shadow(0 0 14px var(--glow)) drop-shadow(0 4px 6px rgba(0, 0, 0, .3)); }
.b-mon.mine { --flip: -1; --lx: 34px; --ly: -22px; width: clamp(140px, 36vw, 250px); height: clamp(140px, 36vw, 250px); }
.b-mon.enter { animation: b-enter .45s ease-out; }
.b-mon.lunge { animation: b-lunge .24s ease-in-out; }
.b-mon.hurt { animation: b-hurt .4s linear; }
.b-mon.glowup { animation: b-glowup .8s ease-in-out; }
.b-mon.faint { animation: b-faint .7s ease-in forwards; }
@keyframes b-enter { from { opacity: 0; transform: translateY(24px) scaleX(var(--flip)) scale(.8); } }
@keyframes b-lunge { 50% { transform: translate(var(--lx), var(--ly)) scaleX(var(--flip)); } }
@keyframes b-hurt {
  20% { transform: translateX(-9px) scaleX(var(--flip)); filter: brightness(2.2); }
  40% { transform: translateX(9px) scaleX(var(--flip)); filter: none; }
  60% { transform: translateX(-6px) scaleX(var(--flip)); filter: brightness(2.2); }
  80% { transform: translateX(4px) scaleX(var(--flip)); }
}
@keyframes b-glowup { 50% { transform: scaleX(var(--flip)) scale(1.1); filter: drop-shadow(0 0 30px var(--glow)) brightness(1.35); } }
@keyframes b-faint { to { transform: translateY(60px) scaleX(var(--flip)); opacity: 0; filter: grayscale(1); } }
.b-card {
  background: rgba(255, 253, 247, .96); border-radius: 14px; padding: 8px 12px;
  min-width: 160px; max-width: 48vw; box-shadow: 0 4px 14px rgba(0, 0, 0, .35); position: relative; z-index: 2;
}
.b-me .b-card { margin-bottom: 18px; }
.b-name { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-weight: 800; font-size: 15px; }
.b-lv { font-size: 12px; color: var(--muted); white-space: nowrap; }
.b-types { display: flex; gap: 4px; margin-top: 3px; }
.b-types .type { font-size: 10px; padding: 1px 7px; }
.hp { height: 9px; background: #e6e3d6; border-radius: 6px; overflow: hidden; margin-top: 6px; }
.hp div { height: 100%; width: 100%; transition: width .35s ease, background-color .3s; }
.hp .ok { background: #22c55e; } .hp .mid { background: #f59e0b; } .hp .low { background: #ef4444; }
.b-hpnum { font-size: 11px; font-weight: 700; color: var(--muted); text-align: right; margin-top: 2px; font-variant-numeric: tabular-nums; }
.en { height: 5px; background: #e6e3d6; border-radius: 4px; margin-top: 3px; overflow: hidden; }
#bm-en { height: 100%; width: 0; background: linear-gradient(90deg, #facc15, #f97316); transition: width .15s; }
.b-meta { display: flex; align-items: center; gap: 8px; margin-top: 5px; font-size: 12px; min-height: 14px; }
.b-team { display: flex; gap: 4px; }
.b-team i { width: 8px; height: 8px; border-radius: 50%; background: #cbd5e1; }
.b-team i.alive { background: var(--gold); box-shadow: 0 0 0 1px #b8860b; }
.b-shields { display: flex; gap: 3px; }
.sh { width: 12px; height: 14px; background: #ec4899; clip-path: polygon(50% 0, 100% 18%, 92% 68%, 50% 100%, 8% 68%, 0 18%); }
.sh.used { background: #d1d5db; }
.b-float {
  position: absolute; top: 30%; pointer-events: none; z-index: 4;
  font-size: 30px; font-weight: 900; color: #fff; text-shadow: 0 2px 0 #14204a, 0 0 10px rgba(0, 0, 0, .6);
  animation: b-float 1.1s ease-out forwards;
}
.b-float.small { font-size: 18px; }
.b-float.super { color: #fde047; font-size: 38px; }
.b-float.super.small { font-size: 22px; }
.b-float.heal { color: #86efac; }
.b-float.shield { color: #f9a8d4; font-size: 26px; }
@keyframes b-float { from { opacity: 0; transform: translate(-50%, 10px) scale(.7); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.1); } to { opacity: 0; transform: translate(-50%, -50px) scale(1); } }

.b-panel {
  background: var(--paper); border-radius: 20px 20px 0 0; display: grid; gap: 10px; position: relative; z-index: 4;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  box-shadow: 0 -6px 20px rgba(0, 0, 0, .3);
}
#b-msg { font-weight: 800; font-size: 15px; min-height: 1.4em; color: var(--navy); }
.b-controls { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; }
.b-charged {
  --mt: #8b8f99; position: relative; overflow: hidden; border-radius: 16px; min-height: 66px; padding: 8px 10px;
  background: #eceadf; text-align: left; box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--mt) 45%, transparent);
}
.b-charged .fill { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: color-mix(in srgb, var(--mt) 38%, #fff); transition: height .15s; }
.b-charged b, .b-charged small { position: relative; display: block; }
.b-charged b { font-size: 14px; line-height: 1.2; }
.b-charged small { font-size: 11px; color: var(--muted); margin-top: 2px; }
.b-charged:disabled { cursor: default; }
.b-charged.ready { background: var(--mt); color: #fff; animation: b-ready 1s ease-in-out infinite; }
.b-charged.ready .fill { display: none; }
.b-charged.ready small { color: rgba(255, 255, 255, .9); }
.b-charged.sig.ready { background: linear-gradient(135deg, var(--mt), #f2c14e); }
@keyframes b-ready { 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--mt) 35%, transparent), 0 0 24px var(--mt); } }
.b-fast {
  width: 76px; height: 76px; border-radius: 50%; touch-action: none;
  background: radial-gradient(circle at 35% 30%, #fff, #e5e1d3); box-shadow: 0 4px 0 #bdb8a6, 0 6px 14px rgba(0, 0, 0, .2);
  display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 26px;
}
.b-fast small { font-size: 9px; font-weight: 800; max-width: 66px; line-height: 1.1; text-align: center; }
.b-fast:active { transform: translateY(3px); box-shadow: 0 1px 0 #bdb8a6; }
.b-actions { display: flex; gap: 8px; justify-content: space-between; align-items: center; }
.b-actions button { padding: 8px 16px; border-radius: 999px; background: #eceadf; font-weight: 700; font-size: 14px; }
.b-actions button:disabled { opacity: .45; cursor: default; }
.b-hint { font-size: 11px; color: var(--muted); text-align: center; }
@media (max-width: 460px) { .b-hint { display: none; } .b-charged b { font-size: 13px; } }

.b-banner {
  --mt: #1f3a93; position: absolute; left: 50%; top: 36%; z-index: 5; pointer-events: none; opacity: 0;
  transform: translate(-50%, -50%); background: var(--mt); color: #fff; font-weight: 900; font-size: clamp(17px, 4vw, 28px);
  padding: 10px 22px; border-radius: 14px; box-shadow: 0 0 34px var(--mt); text-shadow: 0 2px 0 rgba(0, 0, 0, .35);
  white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis;
}
.b-banner.show { animation: b-banner 1.7s ease-out forwards; }
@keyframes b-banner {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.6); } 12% { opacity: 1; transform: translate(-50%, -50%) scale(1.07); }
  22% { transform: translate(-50%, -50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -60%); }
}
.b-overlay { position: absolute; inset: 0; z-index: 6; display: flex; align-items: center; justify-content: center; background: rgba(5, 8, 20, .45); padding: 16px; }
.mini-box, .prompt-box, .pick-box {
  background: var(--paper); border-radius: 18px; padding: 16px; width: min(420px, 100%);
  display: grid; gap: 10px; text-align: center; box-shadow: 0 10px 40px rgba(0, 0, 0, .45);
}
.mini-box { --mt: #1f3a93; cursor: pointer; }
.mini-box b { font-size: 21px; color: var(--mt); }
.mini-bar { position: relative; height: 36px; border-radius: 18px; background: #e5e1d3; overflow: hidden; }
.mini-bar .z { position: absolute; top: 0; bottom: 0; left: 50%; transform: translateX(-50%); }
.mini-bar .nice { width: 58%; background: #fde68a; }
.mini-bar .great { width: 32%; background: #fbbf24; }
.mini-bar .exc { width: 12%; background: #22c55e; }
.mini-bar .needle { position: absolute; top: 0; bottom: 0; width: 6px; margin-left: -3px; background: #14204a; border-radius: 3px; box-shadow: 0 0 8px #fff; }
#mini-res { font-style: normal; font-weight: 900; font-size: 22px; color: var(--navy); min-height: 1.2em; }
.prompt-box b { font-size: 17px; }
.prompt-box .timer { height: 6px; background: #e5e1d3; border-radius: 3px; overflow: hidden; }
.prompt-box .timer i { display: block; height: 100%; background: #ef4444; animation: b-tdown 3.2s linear forwards; }
@keyframes b-tdown { from { width: 100%; } to { width: 0; } }
.prompt-btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.pick-row { display: flex; align-items: center; gap: 10px; text-align: left; padding: 8px; border-radius: 12px; background: #f1efe6; }
.pick-row img { width: 48px; height: 48px; flex: none; }
.pick-row small { display: block; color: var(--muted); font-size: 12px; }
.pick-row:disabled { opacity: .45; cursor: default; }
.mini-types { display: flex; gap: 3px; margin-top: 3px; justify-content: center; }
.pick-row .mini-types { justify-content: flex-start; }
.mini-types i { width: 10px; height: 10px; border-radius: 50%; }

/* ---------- moves list, league ---------- */
.moves { text-align: left; max-width: 420px; margin: 0 auto 14px; display: grid; gap: 6px; }
.moves h3 { margin: 0; font-size: 15px; color: var(--navy); }
.mv { --mt: #888; display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; background: color-mix(in srgb, var(--mt) 12%, #fff); border-radius: 10px; padding: 8px 10px; }
.mv .dot { grid-row: span 2; width: 10px; height: 10px; border-radius: 50%; background: var(--mt); }
.mv small { color: var(--muted); font-size: 12px; }
.league { text-align: center; }
.lg-rank { font-size: 56px; line-height: 1.1; }
.ranks { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 10px 0 14px; }
.ranks span { background: #f1efe6; border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 700; opacity: .55; }
.ranks span.got { opacity: 1; background: #fff8e1; }
.ranks small { color: var(--muted); font-weight: 400; }
.ch-rules { font-size: 12px !important; background: #f1efe6; border-radius: 10px; padding: 8px 10px; }

/* ---------- challenge / team pick ---------- */
.ch-head { display: flex; align-items: center; gap: 12px; padding-right: 40px; }
.ch-badge { width: 52px; height: 52px; flex: none; border-radius: 50%; background: var(--arena); display: grid; place-items: center; font-size: 26px; }
.ch-head h2 { margin: 0; }
.ch-quote { font-style: italic; color: var(--muted); margin: 10px 0; }
.ch-team { display: flex; gap: 6px; justify-content: center; background: #f1efe6; border-radius: 14px; padding: 6px; }
.ch-team img { width: 72px; height: 72px; }
.challenge h3 { margin: 16px 0 8px; font-size: 16px; color: var(--navy); }
.pick .card.on { background: #fff8e1; box-shadow: inset 0 0 0 3px var(--gold); }
.card .order {
  position: absolute; top: 5px; right: 7px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--navy); color: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center;
}
.row.sticky { position: sticky; bottom: -24px; background: var(--paper); padding: 12px 0 4px; margin-top: 10px; }
.primary:disabled { opacity: .5; cursor: default; }
.bigemoji { font-size: 64px; }

.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 8px; margin: 8px 0 16px; }
.badge {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px;
  background: #f1efe6; border-radius: 12px; padding: 10px 6px; filter: grayscale(1); opacity: .7;
}
.badge.won { filter: none; opacity: 1; background: color-mix(in srgb, var(--arena) 16%, #fff); }
.badge .medal { font-size: 26px; }
.badge b { font-size: 13px; }
.badge small { font-size: 11px; color: var(--muted); }

.ov-wrap { width: 100%; display: flex; justify-content: center; }
.ov-wrap canvas { border-radius: 12px; box-shadow: 0 0 0 1px #d6d2c4; }
#ov-canvas { display: block; cursor: crosshair; }

@media (prefers-reduced-motion: reduce) {
  .b-mon, .b-float, #catch-hint { animation-duration: .01ms !important; }
}

/* ---------- play modes, rarities, shinies ---------- */
#mode-chip {
  position: fixed; left: 12px; top: calc(64px + env(safe-area-inset-top)); z-index: 5;
  padding: 7px 12px; font-size: 12px; font-weight: 800;
}
#mode-chip.live { background: #14204a; color: #fff; }
#zone-chip { top: calc(108px + env(safe-area-inset-top)); max-width: calc(100vw - 32px); overflow: hidden; text-overflow: ellipsis; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0 10px; }
.mode { text-align: left; padding: 10px 12px; border-radius: 14px; background: #f1efe6; box-shadow: inset 0 0 0 2px transparent; }
.mode b { display: block; font-size: 15px; }
.mode small { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.3; }
.mode.on { background: #fff8e1; box-shadow: inset 0 0 0 2px var(--gold); }
.rar.r6 { background: linear-gradient(90deg, #f9a8d4, #c4b5fd); }
.rar.r7 { background: linear-gradient(90deg, #a5b4fc, #fde68a, #f9a8d4); color: #1b1b2f; }
.card .shiny-tag { position: absolute; top: 4px; right: 6px; font-size: 13px; }
@media (max-width: 420px) { .modes { grid-template-columns: 1fr; } }

#osm-credit {
  position: fixed; left: 6px; bottom: calc(2px + env(safe-area-inset-bottom)); z-index: 4;
  font-size: 9px; color: rgba(20,32,74,.75); background: rgba(255,253,247,.7); padding: 1px 5px; border-radius: 4px;
}
#osm-credit a { color: inherit; }

/* ---------- names, online, music ---------- */
#online-chip {
  position: fixed; right: 12px; top: calc(112px + env(safe-area-inset-top)); z-index: 5;
  padding: 7px 12px; font-size: 12px; font-weight: 800;
}
#online-chip.on { background: #0f766e; color: #fff; }
.name-row { display: flex; gap: 8px; margin: 6px 0 12px; }
.name-row input, #music-select {
  flex: 1; font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 12px;
  border: 2px solid #d6d2c4; background: #fff; color: var(--ink); min-width: 0;
}
.name-row input:focus, #music-select:focus { outline: none; border-color: var(--gold); }
.name-row.first { max-width: 440px; margin: 10px auto 4px; }
#music-select { width: 100%; margin: 6px 0 12px; }
.fine-note { font-size: 12px !important; line-height: 1.4; }
.peers { display: grid; gap: 8px; margin: 10px 0; }
.peer { display: flex; align-items: center; gap: 10px; background: #f1efe6; border-radius: 12px; padding: 8px 10px; }
.peer-av { width: 34px; height: 34px; flex: none; border-radius: 50%; color: #fff; font-weight: 900; display: grid; place-items: center; text-transform: uppercase; }
.peer .grow { flex: 1; min-width: 0; }
.peer small { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- evolution ---------- */
.card .evo-tag { position: absolute; top: 4px; left: 6px; font-size: 12px; animation: evo-bob 1.2s ease-in-out infinite; }
@keyframes evo-bob { 50% { transform: translateY(-3px); } }
.evo-line { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 10px 0 4px; flex-wrap: wrap; }
.evo-line span { display: flex; flex-direction: column; align-items: center; padding: 4px; border-radius: 12px; opacity: .75; }
.evo-line span.on { background: rgba(242, 193, 78, .25); opacity: 1; }
.evo-line img { width: 56px !important; height: 56px !important; }
.evo-line img.sil { filter: brightness(0); opacity: .35; }
.evo-line img.seen { filter: grayscale(.8); }
.evo-line small { font-size: 10px; font-weight: 700; }
.evo-line b { color: var(--muted); }
.evo-btn { width: 100%; margin: 6px 0 10px; font-size: 17px; }
.evo-btn:disabled { opacity: .45; filter: grayscale(1); }
.evolving { text-align: center; }
.evo-stage { position: relative; width: 220px; height: 220px; margin: 10px auto; }
.evo-stage img { position: absolute; inset: 20px; width: 180px; height: 180px; }
.evo-from { animation: evo-out 2.6s ease-in forwards; }
.evo-to { opacity: 0; animation: evo-in 1s ease-out 2.6s forwards; }
.evo-rays { position: absolute; inset: 0; border-radius: 50%; background: repeating-conic-gradient(rgba(242,193,78,.55) 0 12deg, transparent 12deg 30deg);
  opacity: 0; animation: evo-rays 3.6s ease-in-out forwards, evo-spin 4s linear infinite; }
.evo-done { opacity: 0; animation: evo-show .5s ease-out 3.2s forwards; }
@keyframes evo-out { 0% { filter: none; transform: scale(1); } 20%, 40%, 60%, 80% { transform: scale(.85); } 10%, 30%, 50%, 70%, 90% { transform: scale(1.08); }
  100% { filter: brightness(8) saturate(0); transform: scale(1.15); opacity: 0; } }
@keyframes evo-in { 0% { opacity: 1; filter: brightness(8) saturate(0); transform: scale(1.3); } 100% { opacity: 1; filter: none; transform: scale(1); } }
@keyframes evo-rays { 0% { opacity: 0; } 60%, 80% { opacity: 1; } 100% { opacity: .35; } }
@keyframes evo-spin { to { transform: rotate(360deg); } }
@keyframes evo-show { to { opacity: 1; } }

/* ---------- subway & ferry ---------- */
.station .st-sign { display: flex; align-items: center; gap: 8px; justify-content: center; font-size: 18px; color: #fff; background: #1f2937; border-radius: 10px; padding: 10px 14px; margin: 4px 0 10px; border-top: 6px solid #0039a6; }
.station .st-sign.ferry { background: #0c4a6e; border-top-color: #f97316; }
.mode:disabled { opacity: .5; }
.st-q { width: 100%; box-sizing: border-box; padding: 10px 12px; border-radius: 10px; border: 2px solid #d5dae6; font-size: 15px; margin-bottom: 8px; }
.st-list { max-height: 52vh; overflow: auto; display: flex; flex-direction: column; gap: 6px; }
.st-row { display: flex; align-items: center; gap: 10px; text-align: left; background: #fff; border: 2px solid #e3e7f0; border-radius: 12px; padding: 8px 10px; cursor: pointer; font: inherit; color: inherit; }
.st-row:hover { border-color: var(--gold); }
.st-row.locked { opacity: .5; }
.st-row .grow { flex: 1; display: flex; flex-direction: column; }
.st-row small { color: var(--muted); font-size: 12px; }
.st-ico { font-size: 22px; }
.st-km { font-size: 12px; font-weight: 700; color: var(--muted); }
#ride { position: fixed; inset: 0; z-index: 90; background: #0b1020; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; animation: ride-in .3s ease-out; }
#ride.ferry { background: linear-gradient(#7cc4f0 0 45%, #1e6fa8 45%); }
#ride.out { animation: ride-out .5s ease-in forwards; }
.ride-tunnel { position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 120px, rgba(255, 214, 120, .55) 120px 136px); animation: ride-lights .25s linear infinite; }
#ride.ferry .ride-tunnel { top: 45%; background: repeating-linear-gradient(90deg, transparent 0 60px, rgba(255, 255, 255, .35) 60px 90px); animation-duration: .8s; }
.ride-vehicle { font-size: 110px; position: relative; animation: ride-shake .18s linear infinite; transform: scaleX(-1); }
.ride-text { position: relative; color: #fff; text-align: center; margin-top: 20px; display: flex; flex-direction: column; gap: 4px; text-shadow: 0 2px 6px #000; }
.ride-text b { font-size: 22px; }
@keyframes ride-lights { to { background-position: -136px 0; } }
@keyframes ride-shake { 50% { transform: scaleX(-1) translateY(3px); } }
@keyframes ride-in { from { opacity: 0; } }
@keyframes ride-out { to { opacity: 0; } }

/* ---------- chat, emotes, meeting trainers ---------- */
#btn-chat { position: fixed; right: 12px; top: calc(152px + env(safe-area-inset-top)); z-index: 5; width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: #fff; box-shadow: 0 3px 10px rgba(0,0,0,.25); font-size: 20px; cursor: pointer; }
#btn-chat b { position: absolute; top: -4px; right: -4px; background: #dc2626; color: #fff; font-size: 11px; min-width: 18px; height: 18px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; }
#chat { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 30; width: min(420px, calc(100vw - 24px));
  background: rgba(255,253,247,.97); border-radius: 18px; box-shadow: 0 10px 30px rgba(0,0,0,.35); display: flex; flex-direction: column; overflow: hidden; }
#chat.hidden, #btn-chat.hidden { display: none; }
.chat-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: var(--navy); color: #fff; }
.chat-head button { background: none; border: 0; color: #fff; font-size: 16px; cursor: pointer; }
#chat-log { height: 190px; overflow-y: auto; padding: 8px 12px; display: flex; flex-direction: column; gap: 5px; font-size: 14px; }
#chat-log .msg { line-height: 1.3; word-wrap: break-word; }
#chat-log .msg b { margin-right: 6px; cursor: pointer; }
#chat-log .emo { font-size: 22px; }
#chat-log .sub { font-size: 12px; }
#chat-emotes { display: flex; gap: 4px; padding: 6px 8px; overflow-x: auto; border-top: 1px solid #e6e2d6; }
#chat-emotes button { flex: none; border: 0; background: #eef1f8; border-radius: 10px; font-size: 20px; padding: 4px 7px; cursor: pointer; font-weight: 900; color: #b91c1c; }
#chat-emotes button:active { transform: scale(1.2); }
.chat-row { display: flex; gap: 6px; padding: 8px; }
.chat-row input { flex: 1; min-width: 0; padding: 9px 12px; border-radius: 999px; border: 2px solid #d5dae6; font-size: 15px; }
.chat-row button { border: 0; border-radius: 999px; background: var(--gold); color: var(--navy); font-weight: 900; padding: 0 16px; cursor: pointer; }
.peer-card { text-align: center; }
.peer-av.big { width: 64px; height: 64px; font-size: 28px; margin: 0 auto 6px; }
#warp { position: fixed; inset: 0; z-index: 90; pointer-events: none; background: radial-gradient(circle, rgba(255,255,255,.95), rgba(167,139,250,.85) 40%, rgba(49,46,129,0) 70%);
  animation: warp 1s ease-in-out forwards; }
@keyframes warp { 0% { opacity: 0; transform: scale(.2); } 45% { opacity: 1; transform: scale(1.4); } 100% { opacity: 0; transform: scale(2.4); } }
#chat.solo .chat-row { display: none; }
#chat.solo #chat-log { height: auto; min-height: 60px; }

/* ---------- accounts ---------- */
.acct-box { display: flex; flex-direction: column; gap: 8px; background: #f4f1e6; border-radius: 14px; padding: 12px; margin-bottom: 8px; }
.acct-box input { padding: 10px 12px; border-radius: 10px; border: 2px solid #d5dae6; font-size: 15px; }
.acct-box small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.acct-box .row { margin: 0; }
.acct-box .sub { margin: 0; }

/* ---------- zoom, quests, arcades ---------- */
#zoom-ctl { position: fixed; left: 12px; bottom: calc(100px + env(safe-area-inset-bottom)); z-index: 6; display: flex; flex-direction: column; gap: 6px; }
#zoom-ctl button { width: 44px; height: 44px; border-radius: 50%; border: 0; background: #fff; box-shadow: 0 3px 10px rgba(0,0,0,.25); font-size: 18px; cursor: pointer; }
#zoom-ctl #zoom-lvl { font-size: 11px; font-weight: 900; color: var(--navy); height: 30px; border-radius: 15px; }
#quest-chip { position: fixed; left: 12px; top: calc(104px + env(safe-area-inset-top)); z-index: 5; padding: 7px 12px; font-size: 12px; font-weight: 800; cursor: pointer; }
#quest-chip.boss { background: linear-gradient(90deg, #4c1d95, #7c3aed); color: #fde047; animation: q-pulse 1.2s ease-in-out infinite; }
@keyframes q-pulse { 50% { box-shadow: 0 0 0 6px rgba(124,58,237,.35); } }
.quests { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.quest { display: flex; align-items: center; gap: 10px; background: #fff; border: 2px solid #e3e7f0; border-radius: 12px; padding: 8px 10px; }
.quest.done { border-color: #86efac; background: #f0fdf4; }
.quest .grow { flex: 1; }
.quest .progress { margin: 4px 0 0; height: 7px; }
.q-ico { font-size: 22px; }
.q-num { font-size: 12px; font-weight: 800; color: var(--muted); }
.boss-card { display: flex; align-items: center; gap: 12px; background: #1e1b4b; color: #fff; border-radius: 16px; padding: 10px 14px; }
.boss-card.ready { background: linear-gradient(135deg, #1e1b4b, #4c1d95); box-shadow: 0 0 18px rgba(250,204,21,.45); }
.boss-card img { width: 90px; height: 90px; }
.boss-card img.sil { filter: brightness(0) drop-shadow(0 0 6px #facc15); }
.boss-card small { display: block; opacity: .8; margin: 2px 0 8px; }
.rc-row { justify-content: center; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.ov-wrap { position: relative; }
#ov-canvas { touch-action: none; cursor: grab; border-radius: 12px; }
.ov-ctl { position: absolute; right: 8px; top: 8px; display: flex; flex-direction: column; gap: 6px; }
.ov-ctl button { width: 38px; height: 38px; border-radius: 50%; border: 0; background: rgba(255,255,255,.95); box-shadow: 0 2px 8px rgba(0,0,0,.25); font-size: 16px; cursor: pointer; }
#mg { position: fixed; inset: 0; z-index: 95; background: radial-gradient(circle at 50% 30%, #4c1d95, #1e1b4b 70%); color: #fff; display: flex; flex-direction: column; align-items: center; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.mg-top { width: 100%; max-width: 520px; display: flex; align-items: center; gap: 12px; padding: calc(12px + env(safe-area-inset-top)) 16px 10px; font-size: 15px; }
.mg-top b { flex: 1; }
.mg-top span { background: rgba(255,255,255,.15); padding: 4px 10px; border-radius: 999px; font-weight: 800; font-variant-numeric: tabular-nums; }
#mg-quit { background: none; border: 0; color: #fff; font-size: 20px; cursor: pointer; }
.mg-body { flex: 1; width: 100%; max-width: 520px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0 16px; box-sizing: border-box; }
.mg-how { padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); opacity: .8; font-size: 13px; text-align: center; }
.mg-holes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; width: min(100%, 420px); }
.mg-hole { position: relative; aspect-ratio: 1; border: 0; border-radius: 50%; background: radial-gradient(ellipse at 50% 70%, #0b0820 45%, #3b2a6b 47%, #5b43a0 70%); overflow: hidden; cursor: pointer; padding: 0; }
.mg-hole img { position: absolute; left: 12%; width: 76%; top: 100%; transition: top .12s ease-out; pointer-events: none; }
.mg-hole.up img { top: 10%; }
.mg-hole.gold { box-shadow: 0 0 22px #facc15; }
.mg-hole.bonk img { top: 10%; filter: brightness(2); transform: scale(.85); }
.mg-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: min(100%, 420px); }
.mg-card { position: relative; aspect-ratio: 3 / 4; border: 0; border-radius: 10px; background: #f2c14e; cursor: pointer; padding: 0; perspective: 400px; }
.mg-card .back { position: absolute; inset: 0; display: grid; place-items: center; font-size: 26px; background: linear-gradient(135deg, #7c3aed, #4c1d95); border-radius: 10px; border: 2px solid #c4b5fd; transition: opacity .15s; }
.mg-card img { width: 90%; opacity: 0; transition: opacity .15s; }
.mg-card.flip .back { opacity: 0; }
.mg-card.flip img { opacity: 1; }
.mg-card.done { background: #86efac; }
.mg-lane { position: relative; width: 100%; height: 120px; background: rgba(255,255,255,.08); border-radius: 60px; overflow: hidden; }
.mg-target { position: absolute; left: 45%; width: 10%; top: 0; bottom: 0; background: rgba(250,204,21,.35); border-left: 3px solid #facc15; border-right: 3px solid #facc15; box-shadow: 0 0 0 16px rgba(250,204,21,.08); }
.mg-runner { position: absolute; top: 28px; width: 64px; height: 64px; }
.mg-result { height: 44px; font-size: 30px; font-weight: 900; margin: 14px 0; }
.mg-result.r3 { color: #facc15; } .mg-result.r2 { color: #86efac; } .mg-result.r1 { color: #93c5fd; } .mg-result.r0 { color: #fca5a5; }
.mg-throw { border: 0; border-radius: 999px; background: #facc15; color: #1e1b4b; font-size: 22px; font-weight: 900; padding: 16px 44px; cursor: pointer; box-shadow: 0 6px 0 #a16207; }
.mg-throw:active { transform: translateY(4px); box-shadow: 0 2px 0 #a16207; }
.mg-left { margin-top: 14px; opacity: .85; }
.mg-top span:empty { display: none; }

/* ---------- more minigames ---------- */
#mg.ok { animation: mg-ok .35s; } #mg.bad { animation: mg-bad .35s; }
@keyframes mg-ok { 30% { box-shadow: inset 0 0 0 8px #4ade80; } }
@keyframes mg-bad { 30% { box-shadow: inset 0 0 0 8px #f87171; } 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
.mg-quiz { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.mg-q { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 18px; }
.mg-q p { margin: 4px 0 0; opacity: .85; font-size: 15px; }
.mg-big { width: 150px; height: 150px; }
.mg-sil { filter: brightness(0) drop-shadow(0 0 8px rgba(255,255,255,.6)); }
.mg-mini { width: 32px; height: 32px; vertical-align: middle; }
.mg-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; max-width: 420px; }
.mg-opt { border: 0; border-radius: 14px; background: #fff; color: #1e1b4b; font-weight: 800; font-size: 15px; padding: 14px 8px; cursor: pointer; min-height: 52px; }
.mg-opt.right { background: #4ade80; } .mg-opt.wrong { background: #f87171; color: #fff; }
.mg-type { display: inline-block; color: #fff; padding: 4px 12px; border-radius: 999px; text-shadow: 0 1px 2px rgba(0,0,0,.4); }
.mg-grid { display: grid; gap: 6px; width: min(100%, 420px); }
.mg-cell { aspect-ratio: 1; border: 0; border-radius: 12px; background: rgba(255,255,255,.12); padding: 3px; cursor: pointer; }
.mg-cell img { width: 100%; height: 100%; }
.mg-scatter { position: relative; width: min(100%, 420px); aspect-ratio: 1; background: rgba(255,255,255,.08); border-radius: 16px; }
.mg-scatter img { position: absolute; width: 17%; }
.mg-simon { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: min(100%, 360px); }
.mg-sp { aspect-ratio: 1; border: 0; border-radius: 24px; opacity: .55; cursor: pointer; padding: 10px; transition: opacity .1s, transform .1s; }
.mg-sp img { width: 100%; height: 100%; }
.mg-sp.s0 { background: #ef4444; } .mg-sp.s1 { background: #3b82f6; } .mg-sp.s2 { background: #22c55e; } .mg-sp.s3 { background: #eab308; }
.mg-sp.lit { opacity: 1; transform: scale(1.06); box-shadow: 0 0 30px rgba(255,255,255,.8); }
.mg-pad { border: 0; border-radius: 28px; background: #312e81; color: #fff; cursor: pointer; font-size: 22px; font-weight: 900; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.mg-pad.big { width: min(100%, 380px); height: min(55vh, 380px); }
.mg-pad img { width: 140px; height: 140px; }
.mg-pad.go { background: #16a34a; } .mg-pad.ok { background: #2563eb; } .mg-pad.bad { background: #b91c1c; }
.mg-pad.mash { background: #ea580c; }
.mg-pad.bump { animation: mg-bump .12s; }
@keyframes mg-bump { 50% { transform: scale(.94); } }
.mg-cv { border-radius: 16px; touch-action: none; display: block; }
.mg-lanes { display: flex; gap: 8px; width: min(100%, 460px); margin-top: 10px; }
.mg-lanes button { flex: 1; border: 0; border-radius: 14px; font-size: 26px; padding: 12px 0; background: #fff; cursor: pointer; }
.mg-lanes button:active { transform: scale(.94); background: #facc15; }
.mg-eq { font-size: 44px; font-weight: 900; }
.mg-cp { font-size: 28px; font-weight: 900; color: #facc15; }
.mg-opts.two { grid-template-columns: 1fr 1fr; }
.mg-bigclock { font-size: 84px; font-weight: 900; font-variant-numeric: tabular-nums; margin-bottom: 24px; }
.mg-bigclock.good { color: #4ade80; } .mg-bigclock.ok { color: #facc15; } .mg-bigclock.bad { color: #f87171; }
.mg-scr { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.mg-scr span { background: #facc15; color: #1e1b4b; font-weight: 900; font-size: 24px; width: 36px; height: 44px; display: grid; place-items: center; border-radius: 8px; }
.mg-word { font-size: 64px; font-weight: 900; background: #fff; border-radius: 18px; padding: 10px 26px; }
.mg-tq { font-size: 19px; font-weight: 800; text-align: center; line-height: 1.35; }

/* ---------- Regi Casino ---------- */
#casino-hud { position: fixed; left: 50%; transform: translateX(-50%); top: calc(12px + env(safe-area-inset-top)); z-index: 7; display: flex; align-items: center; gap: 10px;
  background: rgba(30,27,75,.92); color: #fff; padding: 8px 10px 8px 16px; border-radius: 999px; box-shadow: 0 4px 16px rgba(0,0,0,.4); border: 2px solid #f0abfc; white-space: nowrap; }
#casino-hud.hidden { display: none; }
#casino-hud span { background: rgba(255,255,255,.15); padding: 3px 10px; border-radius: 999px; font-weight: 800; }
#casino-hud button { border: 0; border-radius: 999px; background: #16a34a; color: #fff; font-weight: 900; padding: 6px 12px; cursor: pointer; }
body.in-casino #nearby, body.in-casino #zone-chip, body.in-casino #hud, body.in-casino #mode-chip, body.in-casino #quest-chip, body.in-casino #online-chip { display: none; }
.roul, .bj { text-align: center; }
.wheel-wrap { position: relative; width: 240px; height: 240px; margin: 6px auto 10px; }
.wheel { width: 240px; height: 240px; border-radius: 50%; border: 8px solid #b45309; box-sizing: border-box; position: relative; box-shadow: 0 6px 18px rgba(0,0,0,.35); }
.wheel span { position: absolute; left: 50%; top: 50%; width: 20px; margin-left: -10px; margin-top: -8px; font-size: 10px; font-weight: 900; color: #fff; text-align: center; }
.wheel-hub { position: absolute; left: 50%; top: 50%; width: 76px; height: 76px; margin: -38px; border-radius: 50%; background: #f2c14e; display: grid; place-items: center; font-size: 28px; font-weight: 900; color: #1e1b4b; box-shadow: inset 0 0 0 4px #b45309; }
.wheel-hub.red { background: #b91c1c; color: #fff; } .wheel-hub.black { background: #111827; color: #fff; } .wheel-hub.green { background: #16a34a; color: #fff; }
.wheel-ptr { position: absolute; left: 50%; top: -14px; transform: translateX(-50%); font-size: 22px; color: #f2c14e; text-shadow: 0 2px 3px #000; }
.bet-row { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 8px 0; }
.bet-row b { min-width: 64px; font-size: 18px; }
.bet-row button { padding: 6px 10px; }
.bet-types { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 8px 0 12px; }
.bet-types .bt { border: 0; border-radius: 10px; padding: 10px 6px; font-weight: 800; cursor: pointer; background: #e5e7eb; color: #111827; }
.bet-types .bt.red { background: #b91c1c; color: #fff; } .bet-types .bt.black { background: #111827; color: #fff; } .bet-types .bt.green { background: #16a34a; color: #fff; }
.bt-num { display: flex; gap: 6px; }
.bt-num input { width: 56px; border-radius: 10px; border: 2px solid #d5dae6; text-align: center; font-size: 16px; }
.bt-num .bt { flex: 1; }
.bj-hand { background: #166534; border-radius: 14px; padding: 10px; margin: 8px 0; color: #fff; }
.bj-hand small { display: block; font-weight: 800; margin-bottom: 6px; }
.card { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; width: 46px; height: 64px; margin: 0 3px; border-radius: 7px; background: #fff; color: #111827; font-weight: 900; font-size: 18px; box-shadow: 0 2px 5px rgba(0,0,0,.35); }
.card small { font-size: 16px; }
.card.red { color: #b91c1c; }
.card.back { background: repeating-linear-gradient(45deg, #7c3aed 0 6px, #4c1d95 6px 12px); }
.card.empty { background: rgba(255,255,255,.15); box-shadow: none; }

/* ---------- PvP invite pop-up ---------- */
#duel-pop { position: fixed; left: 50%; top: calc(70px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 120; width: min(420px, calc(100vw - 24px));
  background: #1e1b4b; color: #fff; border: 2px solid #a78bfa; border-radius: 18px; padding: 14px; box-shadow: 0 12px 34px rgba(0,0,0,.45); text-align: center;
  display: flex; flex-direction: column; gap: 6px; animation: pop-in .25s ease-out; }
#duel-pop.hidden { display: none; }
#duel-pop small { opacity: .8; }
#duel-pop .ch-team { background: rgba(255,255,255,.08); }
#duel-pop .pop-btns { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
#duel-pop .ghost { background: rgba(255,255,255,.15); color: #fff; }
@keyframes pop-in { from { transform: translate(-50%, -20px); opacity: 0; } }
