/* Gully Tanks — Khel ON brand: navy, orange→pink→purple gradient, teal; Outfit + Nunito (self-hosted) */
:root {
  --navy: #141721; --navy2: #1c2030; --navy3: #262b3f; --line: #343a52;
  --ink: #f4f1ea; --dim: #a9adc2;
  --orange: #ff9a3c; --pink: #f04fa8; --purple: #8b5cf6; --teal: #2fd4c8; --gold: #f2c14e; --lime: #9be15d;
  --grad: linear-gradient(100deg, var(--orange), var(--pink) 55%, var(--purple));
  --head: 'Outfit', 'Nunito', system-ui, sans-serif;
  --body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --r: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--navy); color: var(--ink); font-family: var(--body); }
body { overflow-x: hidden; overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
.hidden { display: none !important; }

#app { max-width: 560px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; padding: 0 16px env(safe-area-inset-bottom); }
#app.wide { max-width: 1100px; }
.bar { display: flex; align-items: center; gap: 10px; height: 52px; flex: none; }
.home { color: var(--ink); text-decoration: none; font-family: var(--head); font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 6px; min-height: 44px; }
.home b { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.k-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--grad); box-shadow: 0 0 10px var(--pink); }
.title { flex: 1; margin: 0; text-align: center; font-family: var(--head); font-size: 20px; font-weight: 800; letter-spacing: .3px; }
.bar-btns { display: flex; gap: 4px; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; }
.icon-btn:active { background: var(--navy3); }
.icon-btn svg { width: 24px; height: 24px; fill: var(--ink); }
#btn-sound .snd-off { display: none; }
#btn-sound.muted .snd-on { display: none; }
#btn-sound.muted .snd-off { display: inline; }

/* ---------- menu ---------- */
#menu { padding-bottom: 24px; }
.hero { text-align: center; margin: 2px 0 10px; }
#hero-canvas { width: 100%; max-width: 360px; height: auto; aspect-ratio: 8 / 3; display: block; margin: 0 auto; }
.tag { margin: 6px 0 0; color: var(--dim); font-size: 15px; line-height: 1.35; }
.mode { width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; background: var(--navy2); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; margin: 8px 0; min-height: 64px; }
button.mode:active { transform: scale(.985); }
.mode.learn { background: linear-gradient(var(--navy2), var(--navy2)) padding-box, var(--grad) border-box; border: 2px solid transparent; }
.m-ico { font-size: 26px; width: 34px; text-align: center; flex: none; }
.m-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.m-txt b { font-family: var(--head); font-size: 18px; }
.m-txt small { color: var(--dim); font-size: 13.5px; }
.m-best { color: var(--gold); font-size: 13px; font-weight: 700; margin-top: 2px; }
.m-best:empty { display: none; }
.m-go { font-size: 28px; color: var(--dim); flex: none; }
.menu-foot { display: flex; gap: 10px; margin-top: 14px; }
.link-btn { flex: 1; min-height: 48px; border-radius: 12px; background: var(--navy2); border: 1px solid var(--line); font-weight: 800; }

/* mission list */
.sub-head { display: flex; align-items: center; gap: 8px; margin: 4px 0 6px; }
.sub-head h2 { flex: 1; margin: 0; font-family: var(--head); font-size: 22px; }
.back-btn { width: 44px; height: 44px; border-radius: 12px; font-size: 30px; line-height: 1; background: var(--navy2); border: 1px solid var(--line); }
.world { margin: 12px 0 4px; display: flex; align-items: baseline; gap: 8px; }
.world b { font-family: var(--head); font-size: 16px; }
.world small { color: var(--dim); font-size: 13px; }
.mis-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.mis { min-height: 84px; border-radius: 14px; background: var(--navy2); border: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 6px 4px; }
.mis .n { font-family: var(--head); font-size: 22px; font-weight: 800; }
.mis .nm { font-size: 11px; color: var(--dim); line-height: 1.1; text-align: center; }
.mis .st { color: var(--gold); font-size: 12px; letter-spacing: 1px; }
.mis .st i { font-style: normal; color: #3a3f57; }
.mis .st i.on { color: var(--gold); }
.mis.next { box-shadow: 0 0 0 2px var(--teal); }
.mis:disabled { opacity: .4; }
.mis:not(:disabled):active { transform: scale(.96); }

/* ---------- play ---------- */
#play { flex: 1; display: flex; flex-direction: column; min-height: 0; user-select: none; -webkit-user-select: none; touch-action: none; }
#app.playing { padding-top: env(safe-area-inset-top); }
#app.playing .bar { display: none; }
.hud { display: flex; gap: 6px; flex: none; align-items: center; justify-content: center; flex-wrap: wrap; padding: 6px 0 4px; min-height: 40px; }
.chip-t { display: flex; align-items: center; gap: 5px; background: var(--navy2); border-radius: 999px; padding: 3px 10px 3px 4px; font-weight: 800; font-size: 13.5px; border: 2px solid transparent; }
.chip-t i { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: 11px; color: #141721; }
.chip-t b { font-family: var(--head); font-size: 17px; font-variant-numeric: tabular-nums; }
.chip-t.lead { border-color: var(--gold); }
.hud-cell { background: var(--navy2); border-radius: 12px; padding: 3px 10px; font-weight: 800; font-size: 14px; display: flex; gap: 6px; align-items: center; }
.hud-cell b { font-family: var(--head); font-size: 17px; font-variant-numeric: tabular-nums; }
.hearts { color: var(--pink); letter-spacing: 1px; font-size: 16px; }
.hearts .off { color: #3a3f57; }
.arena-wrap { position: relative; flex: none; margin: 0 auto; }
#cv { display: block; border-radius: 16px; box-shadow: 0 0 0 3px #2a2f45, 0 0 0 5px rgba(47,212,200,.35), 0 10px 30px rgba(0,0,0,.45); background: #10131c; touch-action: none; }
.pause-btn { position: absolute; top: 6px; right: 6px; width: 40px; height: 40px; border-radius: 12px; background: rgba(20,23,33,.72); display: grid; place-items: center; }
.pause-btn svg { width: 20px; height: 20px; fill: var(--ink); }
.pop { position: absolute; left: 0; right: 0; top: 38%; text-align: center; pointer-events: none; font-family: var(--head); font-weight: 900; font-size: 26px; color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.35), 0 0 18px var(--pink); opacity: 0; }
.pop.show { animation: pop 1.1s ease-out forwards; }
@keyframes pop { 0% { opacity: 0; transform: scale(.6); } 15% { opacity: 1; transform: scale(1.08); } 70% { opacity: 1; transform: translateY(-14px) scale(1); } 100% { opacity: 0; transform: translateY(-34px); } }
.coach { position: absolute; left: 8px; right: 52px; top: 8px; background: rgba(20,23,33,.94); border: 2px solid var(--teal); border-radius: 14px; padding: 8px 12px; font-weight: 800; font-size: 15px; line-height: 1.3; text-align: center; pointer-events: none; }
.coach small { display: block; font-weight: 600; color: var(--dim); font-size: 13px; margin-top: 2px; }

/* controls: steering pad (drag anywhere inside) + Splash button */
.ctl { flex: 1; min-height: 130px; display: flex; gap: 10px; padding: 8px 0 10px; }
.joy { position: relative; flex: 1.5; border-radius: 18px; background: radial-gradient(circle at 50% 50%, rgba(47,212,200,.10), transparent 70%), var(--navy2); border: 1px solid var(--line); touch-action: none; overflow: hidden; }
.joy-hint { position: absolute; inset: 0; display: grid; place-items: center; color: var(--dim); font-weight: 800; font-size: 13px; pointer-events: none; }
.joy.active .joy-hint { display: none; }
.knob { position: absolute; left: 50%; top: 50%; width: 92px; height: 92px; margin: -46px 0 0 -46px; border-radius: 50%; border: 2px solid rgba(255,255,255,.18); pointer-events: none; display: none; }
.knob::after { content: ''; position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 18px rgba(47,212,200,.6); transform: translate(var(--kx, 0px), var(--ky, 0px)); }
.joy.active .knob { display: block; }
.ctl-p2 .knob::after { background: var(--teal); }
.ctl-p1.two .knob::after { background: var(--orange); box-shadow: 0 0 18px rgba(255,154,60,.6); }
.fire { flex: 1; border-radius: 18px; background: var(--grad); color: #fff; font-family: var(--head); font-weight: 900; font-size: 20px; touch-action: none; display: grid; place-items: center; box-shadow: 0 6px 0 rgba(0,0,0,.25); min-width: 96px; }
.fire.held { filter: brightness(1.2); transform: translateY(3px); box-shadow: 0 3px 0 rgba(0,0,0,.25); }
.ctl-p2 .fire { background: linear-gradient(100deg, var(--teal), var(--purple)); }
.ctl-p2 { transform: rotate(180deg); }
.hint-pulse { animation: hint 1s ease-in-out infinite; }
@keyframes hint { 0%, 100% { box-shadow: 0 0 0 0 rgba(47,212,200,0); } 50% { box-shadow: 0 0 0 4px var(--teal), 0 0 22px var(--teal); } }
.no-touch .ctl { display: none; }
.no-touch .ctl.keys { display: flex; }

/* two players, portrait: compact controls at both ends */
#play.two .ctl { min-height: 104px; flex: none; height: 118px; }
#play.two .hud { padding: 2px 0; min-height: 34px; }

/* landscape / wide: controls at the sides of the arena */
#play.land { flex-direction: row; align-items: center; justify-content: center; gap: 12px; }
#play.land .hud { position: absolute; top: 6px; left: 50%; transform: translateX(-50%); z-index: 2; }
#play.land { position: relative; padding-top: 44px; }
#play.land .ctl { flex: 1; max-width: 260px; height: min(320px, 70vh); flex-direction: column; min-height: 0; }
#play.land .ctl-p2 { transform: none; }
#play.land.solo .ctl-p1 { display: contents; }
#play.land.solo .joy { order: 0; flex: 1; max-width: 260px; height: min(300px, 70vh); }
#play.land.solo .arena-wrap { order: 1; }
#play.land.solo .fire { order: 2; flex: none; width: 150px; height: 150px; border-radius: 50%; }
#play.land.two .ctl-p1 { order: 0; } #play.land.two .arena-wrap { order: 1; } #play.land.two .ctl-p2 { order: 2; }
#play.land .joy { min-height: 140px; }
#play.land.two .fire { flex: none; height: 90px; }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; background: rgba(8,10,16,.72); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px; z-index: 10; }
.card { width: 100%; max-width: 400px; max-height: calc(100dvh - 32px); overflow-y: auto; background: var(--navy2); border: 1px solid var(--line); border-radius: 22px; padding: 22px 18px 18px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.card h2 { font-family: var(--head); font-size: 26px; margin: 4px 0 6px; }
.card h2.grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.card p { color: var(--dim); margin: 6px 0 12px; line-height: 1.4; }
.card .big-emoji { font-size: 46px; }
.stars { font-size: 38px; letter-spacing: 6px; margin: 4px 0 6px; }
.stars i { font-style: normal; color: #3a3f57; display: inline-block; }
.stars i.on { color: var(--gold); animation: star .5s backwards; text-shadow: 0 0 16px rgba(242,193,78,.6); }
.stars i.on:nth-child(2) { animation-delay: .25s; } .stars i.on:nth-child(3) { animation-delay: .5s; }
@keyframes star { from { transform: scale(0) rotate(-60deg); } to { transform: scale(1) rotate(0); } }
.star-why { list-style: none; padding: 0; margin: 4px 0 10px; text-align: left; display: inline-block; }
.star-why li { color: var(--dim); font-size: 14px; margin: 2px 0; }
.star-why li.on { color: var(--ink); }
.star-why li::before { content: '☆ '; color: #3a3f57; }
.star-why li.on::before { content: '★ '; color: var(--gold); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.stats div { background: var(--navy); border-radius: 12px; padding: 8px; }
.stats span { display: block; color: var(--dim); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.stats b { font-family: var(--head); font-size: 20px; }
.btns { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.btn { min-height: 50px; border-radius: 14px; font-weight: 900; font-size: 16.5px; background: var(--navy3); border: 1px solid var(--line); }
.btn.primary { background: var(--grad); border: 0; color: #fff; }
.earned { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 8px 0; }
.chip { background: var(--navy); border: 1px solid var(--gold); color: var(--gold); border-radius: 999px; padding: 4px 10px; font-size: 13px; font-weight: 800; }
.badge-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; text-align: left; margin: 10px 0; }
.badge { background: var(--navy); border-radius: 12px; padding: 8px 10px; display: flex; gap: 8px; align-items: center; opacity: .45; }
.badge.got { opacity: 1; box-shadow: inset 0 0 0 1px var(--gold); }
.badge .bi { font-size: 24px; }
.badge b { display: block; font-size: 13.5px; }
.badge small { color: var(--dim); font-size: 11.5px; line-height: 1.2; display: block; }
.howto { text-align: left; margin: 6px 0; padding-left: 18px; color: var(--ink); line-height: 1.45; }
.howto li { margin: 5px 0; }
.howto kbd { background: var(--navy); border: 1px solid var(--line); border-radius: 6px; padding: 0 5px; font-size: 13px; }
.setup { text-align: left; }
.setup .row { margin: 10px 0; }
.setup .opt-label { display: block; color: var(--dim); font-size: 12.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; margin-bottom: 5px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { flex: 1; min-height: 44px; min-width: 60px; border-radius: 12px; background: var(--navy3); border: 1px solid var(--line); font-weight: 800; font-size: 14.5px; padding: 6px 8px; }
.seg button.on { background: var(--teal); color: var(--navy); border-color: var(--teal); }
.seg button small { display: block; font-weight: 600; font-size: 11.5px; color: var(--dim); }
.seg button.on small { color: var(--navy); }
.result-list { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.result-list div { display: flex; justify-content: space-between; align-items: center; background: var(--navy); border-radius: 12px; padding: 8px 12px; font-weight: 800; }
.result-list div.win { box-shadow: inset 0 0 0 2px var(--gold); }
.result-list .dot { width: 18px; height: 18px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 10px; color: #141721; margin-right: 8px; vertical-align: -3px; }
@media (min-height: 760px) { .ctl { min-height: 150px; } }
@media (prefers-reduced-motion: reduce) { .pop.show, .stars i.on, .hint-pulse { animation: none; opacity: 1; } }
@media (max-width: 345px) { .home span:not(.k-dot), .home { font-size: 0; } .home b { font-size: 0; } .title { font-size: 18px; } .mis .nm { display: none; } .fire { min-width: 80px; font-size: 18px; } }
.keys-hint { text-align: center; color: var(--dim); font-size: 13px; font-weight: 700; margin: 8px 0 0; }
.keys-hint:empty { display: none; }
.center { text-align: center; }
