* { box-sizing: border-box; }
:root { --bg: #0d0221; --deep: #261447; --pink: #f6019d; --hot: #ff3864; --cyan: #2de2e6; --gold: #ffd319; --lime: #7cff4f; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: #fff;
  font-family: 'Baloo 2', 'Nunito', system-ui, 'Noto Sans', sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
#viewport { position: fixed; inset: 0; }
#stage { position: absolute; left: 0; top: 0; width: 1280px; height: 720px; transform-origin: 0 0; overflow: hidden; }
#game { position: absolute; inset: 0; width: 1280px; height: 720px; display: block; touch-action: none; cursor: crosshair; }

.overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: radial-gradient(ellipse at center, rgba(38,20,71,.55), rgba(13,2,33,.88)); animation: fade .2s ease; }
.overlay.hidden, .hidden { display: none !important; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes pop { from { transform: scale(.85); opacity: 0 } to { transform: scale(1); opacity: 1 } }
@keyframes wob { 0%,100% { transform: rotate(-1.5deg) } 50% { transform: rotate(1.5deg) } }
@keyframes bounce { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-6px) } }
@keyframes glow { 0%,100% { text-shadow: 0 0 12px rgba(246,1,157,.8), 0 0 30px rgba(246,1,157,.4) } 50% { text-shadow: 0 0 18px rgba(45,226,230,.9), 0 0 40px rgba(45,226,230,.5) } }

#loading { background: var(--bg) url(assets/menu_bg.webp) center/cover; }
.loader { text-align: center; font-size: 24px; font-weight: 800; background: rgba(13,2,33,.78); padding: 24px 40px; border-radius: 24px; border: 2px solid var(--cyan); }
.spin { width: 56px; height: 56px; margin: 0 auto 10px; border-radius: 50%; border: 6px solid var(--deep); border-top-color: var(--cyan); border-right-color: var(--pink); animation: rot 1s linear infinite; }
.bar { width: 260px; height: 10px; border-radius: 5px; background: var(--deep); overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--cyan), var(--pink)); transition: width .2s; }
@keyframes rot { to { transform: rotate(360deg) } }

/* ---------------- menu */
#menu { background: linear-gradient(90deg, rgba(13,2,33,.93) 0%, rgba(13,2,33,.75) 46%, rgba(13,2,33,.2) 72%, rgba(13,2,33,.45) 100%); display: block; }
.menu-left { position: absolute; left: 36px; top: 18px; width: 640px; }
.menu-right { position: absolute; right: 30px; top: 18px; width: 420px; display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.logo { display: flex; flex-direction: column; line-height: .86; margin-bottom: 6px; transform-origin: left center; animation: wob 4s ease-in-out infinite; }
.logo .l1 { font-size: 60px; font-weight: 800; color: #fff; letter-spacing: 2px; -webkit-text-stroke: 2px var(--pink); animation: glow 3s ease-in-out infinite; }
.logo .l2 { font-size: 64px; font-weight: 800; letter-spacing: 12px; background: linear-gradient(180deg, #fff 0%, var(--cyan) 45%, var(--pink) 100%); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 10px rgba(45,226,230,.6)); }
.logo .l3 { font-size: 21px; font-weight: 700; color: var(--gold); margin-top: 6px; letter-spacing: .5px; }
.label { font-size: 14px; font-weight: 800; color: var(--cyan); text-transform: uppercase; letter-spacing: 1.5px; margin: 8px 0 4px; }
.label.inline { margin: 0 8px 0 0; }
.row { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.play-row { margin-top: 14px; }
.modes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.mode { background: rgba(38,20,71,.88); border: 3px solid rgba(45,226,230,.25); border-radius: 14px; padding: 6px 8px; cursor: pointer; text-align: left; color: #fff; font: inherit; transition: transform .1s, border-color .1s; min-height: 76px; overflow: hidden; }
.mode:hover:not(.locked) { transform: translateY(-2px); border-color: rgba(45,226,230,.6); }
.mode.on { border-color: var(--cyan); background: rgba(45,226,230,.22); box-shadow: 0 0 16px rgba(45,226,230,.45); }
.mode.daily { background: linear-gradient(135deg, rgba(246,1,157,.35), rgba(38,20,71,.9)); }
.mode.daily.on { border-color: var(--pink); box-shadow: 0 0 16px rgba(246,1,157,.5); }
.mode b { display: block; font-size: 16px; line-height: 1.1; overflow-wrap: anywhere; }
.mode small { display: block; font-size: 12px; color: #d9cdf5; line-height: 1.15; margin-top: 3px; }
.mode.locked, .map.locked { filter: grayscale(.9) brightness(.6); cursor: not-allowed; }
.daily-info { margin-top: 10px; background: rgba(246,1,157,.18); border: 2px solid var(--pink); border-radius: 14px; padding: 10px 14px; }
.daily-info .dtitle { font-size: 18px; font-weight: 800; }
.daily-info .dsub { font-size: 14px; color: #ffd6ef; }
.maps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.map { position: relative; border-radius: 14px; overflow: hidden; border: 3px solid rgba(45,226,230,.2); cursor: pointer; background: var(--bg); padding: 0; font: inherit; color: #fff; transition: transform .1s; }
.map:hover:not(.locked) { transform: translateY(-2px); }
.map.on { border-color: var(--cyan); box-shadow: 0 0 14px rgba(45,226,230,.45); }
.map canvas { display: block; width: 100%; height: 100px; object-fit: cover; }
.map .an { position: absolute; left: 0; right: 0; bottom: 0; padding: 3px 8px; background: linear-gradient(transparent, rgba(0,0,0,.85)); font-weight: 800; font-size: 15px; text-align: left; line-height: 1.1; }
.map .lk { position: absolute; inset: 0; display: grid; place-items: center; font-size: 15px; font-weight: 800; background: rgba(0,0,0,.45); }
.seg { display: flex; gap: 6px; }
.seg button { font: inherit; font-weight: 800; font-size: 15px; color: #fff; background: rgba(38,20,71,.88); border: 2px solid transparent; border-radius: 10px; padding: 4px 12px; cursor: pointer; }
.seg button.on { border-color: var(--cyan); background: rgba(45,226,230,.25); }
.menu-nav { position: absolute; left: 36px; bottom: 20px; display: flex; gap: 10px; flex-wrap: wrap; max-width: 1200px; }

.card { background: rgba(38,20,71,.85); border: 2px solid rgba(45,226,230,.25); border-radius: 18px; padding: 10px 14px; }
.player { display: flex; gap: 12px; align-items: center; }
.lvl { width: 58px; height: 58px; flex: none; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ff8fd0, var(--pink)); display: grid; place-items: center; font-size: 26px; font-weight: 800; border: 3px solid #fff; box-shadow: 0 0 14px rgba(246,1,157,.6); }
.lvl.small { width: 40px; height: 40px; font-size: 18px; }
.pinfo { flex: 1; min-width: 0; }
.rank { font-size: 17px; font-weight: 800; color: var(--gold); line-height: 1.1; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xp { height: 14px; border-radius: 7px; background: rgba(255,255,255,.12); overflow: hidden; }
.xp i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--cyan), var(--pink)); transition: width .5s; }
.prow { display: flex; justify-content: space-between; margin-top: 4px; font-size: 20px; font-weight: 800; }
.coins b { color: var(--gold); }
.streak { color: #ffb38a; font-size: 16px; }
.charbox { position: relative; padding: 0; overflow: hidden; background: radial-gradient(ellipse at 50% 80%, rgba(45,226,230,.35), rgba(38,20,71,.7) 70%); cursor: pointer; }
.charbox canvas { display: block; width: 100%; height: auto; }
.cname { position: absolute; left: 0; right: 0; bottom: 30px; text-align: center; font-size: 24px; font-weight: 800; text-shadow: 0 2px 0 #000, 0 0 12px var(--pink); }
.cweapon { position: absolute; left: 0; right: 0; bottom: 8px; text-align: center; font-size: 15px; font-weight: 700; color: var(--cyan); text-shadow: 0 2px 0 #000; }
.goal { font-size: 15px; font-weight: 700; color: var(--gold); text-align: center; background: rgba(38,20,71,.85); border-radius: 12px; padding: 6px 10px; }

.btn { font: inherit; font-weight: 800; font-size: 19px; color: #fff; border: 0; cursor: pointer; padding: 9px 20px 11px; border-radius: 14px; position: relative;
  box-shadow: 0 5px 0 rgba(0,0,0,.4), inset 0 2px 0 rgba(255,255,255,.25); transition: transform .08s, filter .15s; }
.btn:hover { filter: brightness(1.12); transform: translateY(-1px); }
.btn:active { transform: translateY(3px) scale(.97); box-shadow: 0 2px 0 rgba(0,0,0,.4); }
.btn:disabled { filter: grayscale(1) brightness(.6); cursor: not-allowed; }
.btn.big { font-size: 32px; padding: 10px 50px 14px; }
.btn.small { font-size: 15px; padding: 4px 12px 6px; }
.btn.cyan { background: linear-gradient(#5ff2f5, #10a4b8); color: #0d0221; box-shadow: 0 5px 0 #065d6b, 0 0 22px rgba(45,226,230,.55), inset 0 2px 0 rgba(255,255,255,.5); }
#btn-play { animation: bounce 1.4s ease-in-out infinite; }
.btn.green { background: linear-gradient(#8cff6b, #2fae2f); color: #08250a; }
.btn.blue { background: linear-gradient(#4f8cff, #1d4fb8); }
.btn.purple { background: linear-gradient(#b98cff, #6a2bd1); }
.btn.gold { background: linear-gradient(#ffe066, #e0a800); color: #3a2200; }
.btn.dark { background: linear-gradient(#4a2f82, #261447); }
.badge { background: var(--hot); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 14px; margin-left: 4px; }

.modal { background: linear-gradient(180deg, #3a1f6e, #1a0b3b); border: 3px solid rgba(45,226,230,.35); border-radius: 24px; padding: 20px 30px; min-width: 440px; max-width: 900px; max-height: 690px; text-align: center; box-shadow: 0 30px 80px rgba(0,0,0,.6), 0 0 30px rgba(246,1,157,.25); animation: pop .22s ease both; display: flex; flex-direction: column; }
.modal.wide { width: 880px; }
.modal.xwide { width: 1140px; max-width: 1140px; }
.modal h2 { margin: 0 0 6px; font-size: 32px; color: var(--cyan); line-height: 1.1; text-shadow: 0 0 12px rgba(45,226,230,.5); }
.modal .h2b { margin-top: 12px; font-size: 26px; }
.sub { margin: 0 0 8px; color: #d9cdf5; font-size: 16px; }
.actions { display: flex; gap: 12px; justify-content: center; margin-top: 14px; }
.stack { display: flex; flex-direction: column; gap: 10px; min-width: 280px; margin: 8px auto; }

.garage { display: flex; gap: 18px; text-align: left; min-height: 0; }
.gprev { width: 360px; flex: none; background: radial-gradient(ellipse at 50% 75%, rgba(45,226,230,.35), rgba(0,0,0,.2) 70%); border-radius: 18px; padding: 8px; text-align: center; }
.gprev canvas { width: 100%; height: auto; display: block; }
.gname { font-size: 17px; font-weight: 800; line-height: 1.2; min-height: 42px; }
.gright { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tabs { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.tab { font: inherit; font-weight: 800; font-size: 17px; color: #fff; background: rgba(38,20,71,.9); border: 2px solid transparent; border-radius: 10px; padding: 4px 16px; cursor: pointer; }
.tab.on { border-color: var(--cyan); background: rgba(45,226,230,.25); }
.ggrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; overflow-y: auto; max-height: 470px; padding: 4px; }
.gitem { background: rgba(13,2,33,.55); border: 3px solid transparent; border-radius: 14px; padding: 6px; cursor: pointer; text-align: center; color: #fff; font: inherit; position: relative; transition: transform .1s; }
.gitem:hover { transform: translateY(-2px); }
.gitem.on { border-color: var(--cyan); box-shadow: 0 0 12px rgba(45,226,230,.45); }
.gitem.sel:not(.on) { border-color: var(--pink); }
.gitem canvas { width: 100%; height: auto; display: block; }
.gitem .gn { font-size: 13px; font-weight: 800; line-height: 1.1; min-height: 29px; overflow-wrap: anywhere; }
.gitem .gl { font-size: 13px; font-weight: 800; color: var(--gold); }
.gitem.locked canvas { filter: grayscale(1) brightness(.45); }

.list { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.list.scroll { max-height: 250px; overflow-y: auto; padding-right: 4px; }
.qrow { display: flex; align-items: center; gap: 12px; background: rgba(13,2,33,.5); border-radius: 12px; padding: 6px 12px; }
.qrow .qt { flex: 1; font-weight: 700; font-size: 16px; line-height: 1.15; }
.qrow .qp { width: 150px; }
.qrow .qp .xp { height: 10px; }
.qrow .qp small { display: block; font-size: 13px; color: #c9b8ef; text-align: center; }
.qrow .qr { width: 76px; text-align: right; font-weight: 800; color: var(--gold); }
.qrow .btn { min-width: 96px; }
.qrow.done { opacity: .55; }

.stgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 8px 0; }
.stcell { background: rgba(13,2,33,.55); border: 2px solid rgba(45,226,230,.2); border-radius: 14px; padding: 10px 6px; display: flex; flex-direction: column; }
.stcell b { font-size: 30px; color: var(--cyan); line-height: 1.1; }
.stcell span { font-size: 14px; color: #d9cdf5; font-weight: 700; }

.howto { text-align: left; font-size: 16px; margin: 4px 0; padding-left: 26px; line-height: 1.3; }
.hitems { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; text-align: left; margin: 8px 0; }
.hitem { display: flex; gap: 6px; align-items: center; background: rgba(13,2,33,.5); border-radius: 10px; padding: 4px 6px; font-size: 12px; line-height: 1.1; }
.hitem img { width: 38px; height: 38px; flex: none; object-fit: contain; }
.hitem b { display: block; font-size: 13px; }
.keys { margin: 3px 0; color: #d9cdf5; font-size: 14px; }

.setrow { display: flex; justify-content: space-between; align-items: center; gap: 30px; margin: 6px 0; font-size: 19px; font-weight: 700; }
.setrow select { font: inherit; font-size: 17px; padding: 4px 10px; border-radius: 10px; background: var(--deep); color: #fff; border: 2px solid var(--cyan); }
.toggle { min-width: 120px; font-size: 16px; }

.result h2 { font-size: 46px; }
.result h2.win { color: var(--gold); text-shadow: 0 0 18px rgba(255,211,25,.6); }
.rbody { display: flex; gap: 20px; align-items: stretch; }
#r-hero { width: 300px; height: 300px; flex: none; background: radial-gradient(ellipse at 50% 70%, rgba(45,226,230,.3), transparent 70%); border-radius: 20px; }
.rright { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.rtable { width: 100%; border-collapse: collapse; font-size: 15px; }
.rtable th { color: var(--cyan); font-size: 13px; text-transform: uppercase; }
.rtable td, .rtable th { padding: 2px 6px; text-align: center; }
.rtable td:nth-child(2) { text-align: left; font-weight: 700; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rtable .dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }
.rtable tr.me { background: rgba(45,226,230,.25); }
.rtable tr.teamrow td { font-size: 20px; font-weight: 800; text-align: center; padding: 4px; }
.rewards { display: flex; align-items: center; gap: 16px; background: rgba(13,2,33,.5); border-radius: 14px; padding: 8px 12px; }
.rxp { flex: 1; display: flex; align-items: center; gap: 10px; }
.rxp .xp { flex: 1; }
.rxp b { color: var(--gold); font-size: 20px; min-width: 90px; }
.rcoin { font-size: 22px; font-weight: 800; } .rcoin b { color: var(--gold); }
.rextra { min-height: 80px; display: flex; flex-direction: column; gap: 3px; text-align: left; font-size: 15px; font-weight: 700; max-height: 130px; overflow-y: auto; }
.rline { animation: pop .3s ease both; }
.rline.gold { color: var(--gold); } .rline.cyan { color: var(--cyan); } .rline.green { color: var(--lime); } .rline.dim { color: #b9a8e0; font-size: 14px; }

.toast { position: absolute; top: 110px; left: 50%; transform: translateX(-50%); background: rgba(38,20,71,.96); border: 2px solid var(--pink); padding: 8px 22px; border-radius: 16px; font-size: 20px; font-weight: 800; z-index: 20; animation: pop .2s ease; max-width: 900px; text-align: center; pointer-events: none; }
.pausebtn { position: absolute; top: 14px; left: 360px; width: 46px; height: 46px; border-radius: 50%; border: 2px solid rgba(45,226,230,.5); background: rgba(13,2,33,.6); color: #fff; font-size: 18px; font-weight: 800; cursor: pointer; z-index: 5; }
#rotate { display: none; position: fixed; inset: 0; background: var(--bg); color: #fff; font-size: 24px; font-weight: 800; align-items: center; justify-content: center; text-align: center; padding: 30px; z-index: 50; }
@media (orientation: portrait) and (max-width: 820px) and (pointer: coarse) { #rotate { display: flex; } }
/* first visit: the PLAY button breathes so a new player knows where to go (no rules wall) */
@keyframes pulse { 0%,100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255,211,25,.0) } 50% { transform: scale(1.06); box-shadow: 0 0 0 10px rgba(255,211,25,.35) } }
.btn.pulse { animation: pulse 1.1s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .btn.pulse { animation: none; } }
