.em {
  --sab: env(safe-area-inset-bottom);
  --ink: #fff8fd; --ink2: #d9cbe8; --ink3: #9f8fb8; --edge: rgba(255, 255, 255, 0.13); --glass: rgba(26, 14, 48, 0.7);
  --pop: linear-gradient(135deg, #ff5fc8 0%, #ff8a3d 55%, #ffd23f 100%);
  --gold: linear-gradient(180deg, #fff3b0, #ffc93c 55%, #ff9d1f);
  margin: 0; min-height: 100vh; min-height: 100dvh; color: var(--ink); font-family: var(--font); font-weight: 600; overflow-x: hidden;
  background: radial-gradient(900px 700px at 15% -10%, #5a1f7a, transparent 60%), radial-gradient(800px 700px at 110% 110%, #0f4a80, transparent 60%), #120724;
  -webkit-tap-highlight-color: transparent;
}
.screen[hidden], .modal[hidden] { display: none !important; }
button { font-family: inherit; color: inherit; cursor: pointer; }
.boot { position: fixed; inset: 0; display: grid; place-items: center; background: #120724; z-index: 50; transition: opacity 0.4s; }
.boot.done { opacity: 0; pointer-events: none; }
.spin { width: 46px; height: 46px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, 0.12); border-top-color: #ff5fc8; animation: rot 0.9s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }

/* top bar */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: max(10px, env(safe-area-inset-top)) 14px 10px; background: rgba(18, 7, 36, 0.78); backdrop-filter: blur(14px); border-bottom: 1px solid var(--edge); }
.back, .ib { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 14px; background: rgba(255, 255, 255, 0.08); border: 1px solid var(--edge); color: #fff; text-decoration: none; font-size: 1.5rem; line-height: 1; }
.ib { font-size: 1.05rem; }
.ib.off { opacity: 0.45; }
.brand { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.brand img { width: 42px; height: 42px; filter: drop-shadow(0 6px 12px rgba(255, 95, 200, 0.45)); animation: wob 3s ease-in-out infinite; }
@keyframes wob { 50% { transform: rotate(-8deg) scale(1.06); } }
.brand b { display: block; font: 900 clamp(1.1rem, 4vw, 1.5rem) var(--display); background: var(--pop); -webkit-background-clip: text; background-clip: text; color: transparent; line-height: 1.05; }
.brand small { color: var(--ink2); font-size: 0.82rem; }
.starsum { display: flex; align-items: center; gap: 4px; padding: 6px 12px; border-radius: 99px; background: rgba(255, 201, 60, 0.14); border: 1px solid rgba(255, 201, 60, 0.4); font-weight: 900; white-space: nowrap; }
.starsum img { width: 20px; height: 20px; }

/* home */
.home-body { max-width: 640px; margin: 0 auto; padding: 16px 14px 40px; display: grid; gap: 14px; }
.hero-card { position: relative; display: flex; align-items: center; gap: 16px; padding: 18px; border-radius: 26px; overflow: hidden; background: linear-gradient(135deg, rgba(255, 95, 200, 0.28), rgba(255, 138, 61, 0.2) 55%, rgba(255, 210, 63, 0.16)); border: 1px solid rgba(255, 190, 230, 0.35); box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4); }
.hero-card .me { width: 96px; height: 96px; flex: none; filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.45)); animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px); } }
.hero-card .foes { position: absolute; right: 12px; top: 10px; display: flex; gap: 2px; opacity: 0.9; }
.hero-card .foes img { width: 34px; height: 34px; animation: bob 1.4s ease-in-out infinite; }
.hero-card .foes img:nth-child(2) { animation-delay: 0.2s; } .hero-card .foes img:nth-child(3) { animation-delay: 0.4s; } .hero-card .foes img:nth-child(4) { animation-delay: 0.6s; }
.hero-card .txt { flex: 1; min-width: 0; display: grid; gap: 6px; }
.hero-card .txt small { color: var(--ink2); }
.hero-card .txt b { font: 900 1.35rem var(--display); }
.cta { border: 0; padding: 14px 26px; border-radius: 18px; background: var(--gold); color: #4a2400; font: 900 1.15rem var(--display); letter-spacing: 0.06em; box-shadow: 0 10px 26px rgba(255, 170, 30, 0.35), inset 0 -3px 0 rgba(0, 0, 0, 0.14); transition: transform 0.12s; }
.cta:hover { transform: translateY(-2px) scale(1.02); } .cta:active { transform: scale(0.96); }
.cta.ghost { background: rgba(255, 255, 255, 0.08); color: var(--ink); border: 1px solid var(--edge); box-shadow: none; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile { display: flex; align-items: center; gap: 12px; text-align: left; padding: 14px; border-radius: 22px; border: 1px solid var(--edge); background: var(--glass); box-shadow: 0 12px 28px rgba(0, 0, 0, 0.3); transition: transform 0.15s; }
.tile:hover { transform: translateY(-3px); }
.tile img { width: 48px; height: 48px; flex: none; }
.tile b { display: block; font: 800 1rem var(--display); }
.tile small { color: var(--ink2); font-size: 0.8rem; line-height: 1.25; display: block; }
.daily { background: linear-gradient(135deg, rgba(62, 230, 255, 0.18), rgba(124, 92, 255, 0.2)); border-color: rgba(120, 220, 255, 0.35); }
.coll { background: linear-gradient(135deg, rgba(255, 210, 63, 0.18), rgba(255, 95, 200, 0.18)); border-color: rgba(255, 220, 120, 0.35); }

.world { border-radius: 26px; overflow: hidden; border: 1px solid var(--edge); background: var(--glass); box-shadow: 0 14px 34px rgba(0, 0, 0, 0.35); }
.world.locked { opacity: 0.55; filter: saturate(0.4); }
.whead { position: relative; display: flex; align-items: center; gap: 10px; padding: 14px 16px; }
.whead b { font: 900 1.12rem var(--display); flex: 1; }
.whead .wstars { font-weight: 900; color: #ffe08a; font-size: 0.9rem; }
.whead .wfoes { display: flex; } .whead .wfoes img { width: 28px; height: 28px; margin-left: -6px; filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.5)); }
.w-candy .whead { background: linear-gradient(90deg, rgba(255, 95, 200, 0.4), rgba(255, 95, 200, 0.05)); }
.w-forest .whead { background: linear-gradient(90deg, rgba(95, 208, 104, 0.4), rgba(95, 208, 104, 0.05)); }
.w-ocean .whead { background: linear-gradient(90deg, rgba(59, 167, 255, 0.45), rgba(59, 167, 255, 0.05)); }
.w-space .whead { background: linear-gradient(90deg, rgba(154, 123, 255, 0.45), rgba(154, 123, 255, 0.05)); }
.lvls { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; padding: 14px; }
.lv { position: relative; aspect-ratio: 1; border-radius: 18px; border: 1px solid var(--edge); background: rgba(255, 255, 255, 0.06); display: grid; place-items: center; font: 900 1.15rem var(--display); transition: transform 0.12s; }
.lv:not(:disabled):hover { transform: translateY(-3px) scale(1.04); }
.lv .st { position: absolute; bottom: 4px; left: 0; right: 0; text-align: center; font-size: 0.62rem; letter-spacing: -1px; color: #ffd23f; }
.lv .st i { color: rgba(255, 255, 255, 0.18); font-style: normal; }
.lv.cur { background: var(--pop); color: #fff; border-color: transparent; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.25), 0 10px 26px rgba(255, 95, 200, 0.45); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(255, 255, 255, 0.08), 0 10px 26px rgba(255, 95, 200, 0.6); } }
.lv:disabled { opacity: 0.35; cursor: default; }
.lv.done { background: rgba(255, 255, 255, 0.1); }
.settings { display: flex; justify-content: center; gap: 10px; }
.chip { padding: 9px 16px; border-radius: 99px; border: 1px solid var(--edge); background: rgba(255, 255, 255, 0.07); font-weight: 800; font-size: 0.9rem; }
.chip.off { opacity: 0.45; text-decoration: line-through; }
.how { text-align: center; color: var(--ink3); font-size: 0.85rem; margin: 4px 0 0; }

/* collection */
.skins { max-width: 720px; margin: 0 auto; padding: 16px 14px 40px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.skin { position: relative; display: grid; justify-items: center; gap: 6px; padding: 14px 10px 12px; border-radius: 22px; border: 1px solid var(--edge); background: var(--glass); text-align: center; transition: transform 0.15s; }
.skin:not(.lock):hover { transform: translateY(-3px); }
.skin img { width: 72px; height: 72px; filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.45)); }
.skin b { font: 800 0.98rem var(--display); }
.skin small { color: var(--ink2); font-size: 0.76rem; min-height: 2.4em; line-height: 1.2; }
.skin .pk { font-size: 0.78rem; font-weight: 800; padding: 6px 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.08); border: 1px solid var(--edge); }
.skin.on { border-color: #ffd23f; box-shadow: 0 0 0 2px rgba(255, 210, 63, 0.5), 0 14px 30px rgba(255, 170, 30, 0.2); }
.skin.on .pk { background: var(--gold); color: #4a2400; border: 0; }
.skin.lock img { filter: grayscale(1) brightness(0.35); }
.skin.lock .pk { color: #ffe08a; }

/* game */
#play { position: fixed; inset: 0; touch-action: none; -webkit-user-select: none; user-select: none; }
#cv { position: absolute; inset: 0; display: block; }
.hud { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 12px; padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left)); pointer-events: none; }
.hud > * { pointer-events: auto; }
.hcol { display: grid; line-height: 1.05; }
.hcol small { color: var(--ink2); font-size: 0.76rem; font-weight: 800; letter-spacing: 0.04em; }
.hcol b { font: 800 1.6rem var(--font); letter-spacing: 0.02em; color: #ffd23f; text-shadow: 0 2px 0 rgba(120, 50, 0, 0.6), 0 0 18px rgba(255, 190, 40, 0.35); }
.hpow { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.pw { position: relative; width: 36px; height: 36px; border-radius: 12px; background: rgba(255, 255, 255, 0.08); border: 1px solid var(--edge); display: grid; place-items: center; overflow: hidden; }
.pw img { width: 26px; height: 26px; position: relative; z-index: 1; }
.pw i { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(62, 230, 255, 0.35); }
.hlives { display: flex; gap: 2px; }
.hlives img { width: 24px; height: 24px; }
.hlives img.gone { filter: grayscale(1); opacity: 0.25; }
.combo { position: absolute; left: 50%; top: calc(max(10px, env(safe-area-inset-top)) + 52px); transform: translateX(-50%) scale(0.6); opacity: 0; padding: 6px 16px; border-radius: 99px; background: var(--pop); font: 900 1rem var(--display); letter-spacing: 0.06em; box-shadow: 0 8px 22px rgba(255, 95, 200, 0.45); transition: opacity 0.2s, transform 0.3s cubic-bezier(0.2, 1.8, 0.4, 1); pointer-events: none; }
.combo.on { opacity: 1; transform: translateX(-50%) scale(1); }
.banner { position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%) scale(0.5); opacity: 0; pointer-events: none; text-align: center; transition: opacity 0.2s, transform 0.35s cubic-bezier(0.2, 1.8, 0.4, 1); }
.banner.on { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.banner b { display: block; font: 900 clamp(2.4rem, 11vw, 4.6rem) var(--display); background: var(--gold); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 5px 0 rgba(120, 40, 0, 0.55)) drop-shadow(0 14px 24px rgba(0, 0, 0, 0.5)); white-space: nowrap; }
.banner small { display: inline-block; margin-top: 6px; padding: 5px 14px; border-radius: 99px; background: rgba(0, 0, 0, 0.45); font-weight: 800; }

/* wide screens: legend panels beside the board */
.side { position: absolute; top: 50%; transform: translateY(-50%); width: 210px; display: none; gap: 8px; padding: 16px; border-radius: 22px; background: rgba(14, 7, 30, 0.6); border: 1px solid var(--edge); backdrop-filter: blur(10px); pointer-events: none; }
.side.l { left: 24px; } .side.r { right: 24px; }
.side h4 { margin: 0 0 4px; font: 800 0.85rem var(--display); color: var(--ink2); letter-spacing: 0.06em; text-transform: uppercase; }
.side div { display: flex; align-items: center; gap: 10px; font-size: 0.86rem; color: var(--ink); line-height: 1.2; }
.side img { width: 30px; height: 30px; flex: none; }
.side .foerow { gap: 4px; } .side .foerow img { width: 40px; height: 40px; }
@media (min-width: 1000px) { .side { display: grid; } }

/* modal */
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(8, 3, 18, 0.6); backdrop-filter: blur(6px); animation: fade 0.25s; }
@keyframes fade { from { opacity: 0; } }
.mcard { width: min(400px, calc(100vw - 28px)); max-height: calc(100dvh - 28px); overflow: auto; box-sizing: border-box; padding: 22px; border-radius: 28px; background: linear-gradient(180deg, rgba(52, 24, 84, 0.97), rgba(20, 9, 38, 0.98)); border: 1px solid rgba(255, 190, 230, 0.25); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.1); text-align: center; display: grid; gap: 12px; animation: up 0.35s cubic-bezier(0.2, 1.4, 0.4, 1); }
@keyframes up { from { transform: translateY(30px) scale(0.94); opacity: 0; } }
.mcard h2 { margin: 0; font: 900 1.9rem var(--display); background: var(--pop); -webkit-background-clip: text; background-clip: text; color: transparent; }
.mcard .big { width: 92px; height: 92px; margin: 0 auto; filter: drop-shadow(0 12px 20px rgba(0, 0, 0, 0.5)); animation: bob 1.4s ease-in-out infinite; }
.mstars { display: flex; justify-content: center; gap: 8px; }
.mstars img { width: 56px; height: 56px; opacity: 0.18; filter: grayscale(1); transform: scale(0.6); transition: all 0.35s cubic-bezier(0.2, 1.8, 0.4, 1); }
.mstars img.on { opacity: 1; filter: none; transform: scale(1); }
.mstars img:nth-child(2) { margin-top: -12px; }
.mscore { font: 900 2rem var(--display); }
.mcard p { margin: 0; color: var(--ink2); }
.mcard .xp { color: #8affb5; font-weight: 800; }
.goals { display: grid; gap: 6px; text-align: left; font-size: 0.9rem; }
.goals div { display: flex; gap: 8px; align-items: center; padding: 8px 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.05); }
.goals div.ok { background: rgba(80, 220, 140, 0.14); }
.goals img { width: 20px; height: 20px; }
.btns { display: grid; gap: 10px; }
.btns .cta { width: 100%; }
.board { display: grid; gap: 4px; text-align: left; }
.board div { display: flex; gap: 10px; padding: 7px 12px; border-radius: 10px; background: rgba(255, 255, 255, 0.05); }
.board div.me { background: rgba(255, 210, 63, 0.18); }
.board span:first-child { width: 22px; color: var(--ink3); font-weight: 900; }
.board span:nth-child(2) { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.newskin { display: flex; align-items: center; gap: 10px; justify-content: center; padding: 10px; border-radius: 16px; background: rgba(255, 210, 63, 0.14); border: 1px solid rgba(255, 210, 63, 0.4); font-weight: 800; }
.newskin img { width: 40px; height: 40px; }

@media (max-width: 480px) {
  .brand small { display: none; }
  .brand img { width: 34px; height: 34px; }
  .whead .wfoes { display: none; }
  .hero-card .foes img { width: 26px; height: 26px; }
  .hero-card .me { width: 80px; height: 80px; }
}
@media (max-width: 420px) {
  .pw { width: 30px; height: 30px; } .pw img { width: 22px; height: 22px; }
  .hlives img { width: 20px; height: 20px; }
  .row2 { grid-template-columns: 1fr; }
  .lvls { gap: 7px; padding: 10px; }
  .lv { border-radius: 14px; font-size: 1rem; }
  .starsum { padding: 5px 9px; }
  .skins { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
