@font-face {
  font-family: 'Lilita One';
  src: url('../fonts/LilitaOne-Regular.ttf') format('truetype');
  font-display: swap;
}
:root {
  --blue: #2f7bff; --blue-d: #1a4fc0; --red: #ff4655; --red-d: #b51d2b;
  --gold: #ffd23f; --gold-d: #d19a00; --green: #3fd16b; --green-d: #1f9a45;
  --ink: #1b2240; --panel: #ffffff; --muted: #6b7393;
  --font: 'Lilita One', 'Arial Rounded MT Bold', 'Trebuchet MS', system-ui, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #8fd3ff; font-family: var(--font); color: var(--ink);
  user-select: none; -webkit-user-select: none; touch-action: none; overscroll-behavior: none; }
canvas#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
button { font-family: var(--font); cursor: pointer; border: 0; color: inherit; }
.hidden { display: none !important; }

/* ------------------------------------------------------------------ buttons */
.btn { --c: var(--blue); --d: var(--blue-d); background: var(--c); color: #fff; font-size: 22px; letter-spacing: 0.5px;
  padding: 12px 22px 14px; border-radius: 16px; box-shadow: 0 5px 0 var(--d), 0 8px 18px rgba(0,0,0,0.18);
  text-shadow: 0 2px 0 rgba(0,0,0,0.25); transition: transform 0.08s, box-shadow 0.08s; position: relative; }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--d), 0 3px 8px rgba(0,0,0,0.2); }
.btn.green { --c: var(--green); --d: var(--green-d); }
.btn.gold { --c: var(--gold); --d: var(--gold-d); color: #5a3a00; text-shadow: none; }
.btn.red { --c: var(--red); --d: var(--red-d); }
.btn.gray { --c: #b7bdd3; --d: #8a91ad; }
.btn.small { font-size: 16px; padding: 8px 14px 10px; border-radius: 12px; }
.btn:disabled { --c: #c9cee0; --d: #9aa1ba; color: #eef0f7; cursor: default; }
.btn:disabled:active { transform: none; box-shadow: 0 5px 0 var(--d); }
.btn .badge { position: absolute; top: -8px; right: -8px; background: var(--red); color: #fff; border-radius: 999px; min-width: 24px; height: 24px;
  font-size: 15px; line-height: 24px; padding: 0 6px; box-shadow: 0 2px 0 var(--red-d); animation: bob 1s ease-in-out infinite; }
.iconbtn { width: 46px; height: 46px; border-radius: 14px; background: rgba(255,255,255,0.92); font-size: 16px; color: var(--ink);
  box-shadow: 0 4px 0 rgba(0,0,0,0.18); }
.iconbtn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,0.18); }

/* ------------------------------------------------------------------ HUD */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud button { pointer-events: auto; }
.hud-top { position: absolute; top: calc(10px + var(--safe-t)); left: 10px; right: 10px; display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.pill { background: rgba(255,255,255,0.92); border-radius: 999px; padding: 6px 14px 6px 8px; font-size: 20px; display: flex; align-items: center; gap: 8px;
  box-shadow: 0 4px 0 rgba(0,0,0,0.15); min-width: 84px; }
.blob { width: 18px; height: 24px; border-radius: 9px; background: var(--blue); display: inline-block; box-shadow: inset -3px -3px 0 rgba(0,0,0,0.15); }
.levelbox { text-align: center; color: #fff; text-shadow: 0 3px 0 rgba(0,0,0,0.35); font-size: 24px; line-height: 1; padding-top: 4px; }
.stages { display: flex; gap: 6px; justify-content: center; margin-top: 6px; }
.stages i { width: 26px; height: 9px; border-radius: 5px; background: rgba(255,255,255,0.45); box-shadow: 0 2px 0 rgba(0,0,0,0.2); }
.stages i.done { background: var(--green); }
.stages i.cur { background: #fff; }
.stages i.boss.cur { background: var(--gold); }
.hud-bottom { position: absolute; bottom: calc(12px + var(--safe-b)); left: 12px; right: 12px; display: flex; align-items: flex-end; justify-content: space-between; }
.wall { display: flex; align-items: center; gap: 6px; background: rgba(255,255,255,0.92); border-radius: 999px; padding: 6px 12px 6px 8px; box-shadow: 0 4px 0 rgba(0,0,0,0.15); }
.wall .wicon { font-size: 20px; }
.wall .bar { width: clamp(70px, 22vw, 160px); height: 14px; background: #e3e6f2; border-radius: 7px; overflow: hidden; }
.wall .bar i { display: block; height: 100%; width: 100%; background: linear-gradient(#5fe08a, #29b45a); border-radius: 7px; transition: width 0.2s; }
.wall .bar i.low { background: linear-gradient(#ff7b86, #e02a3a); }
.wall b { font-size: 18px; min-width: 28px; text-align: right; font-weight: normal; }
.charge { position: relative; width: 64px; height: 64px; }
.charge .ring { position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(var(--gold) 0deg, rgba(255,255,255,0.5) 0deg);
  box-shadow: 0 4px 0 rgba(0,0,0,0.18); }
.charge .ring::after { content: ''; position: absolute; inset: 7px; border-radius: 50%; background: #fff; }
.charge span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 28px; color: var(--gold-d); z-index: 1; }
.charge.ready .ring { animation: pulse 0.5s ease-in-out infinite alternate; }
.banner { position: absolute; top: 24%; left: 0; right: 0; text-align: center; font-size: clamp(34px, 8vw, 64px); color: #fff;
  text-shadow: 0 4px 0 rgba(0,0,0,0.35), 0 0 30px rgba(0,0,0,0.25); opacity: 0; transform: scale(0.6); transition: opacity 0.25s, transform 0.25s cubic-bezier(.2,1.6,.4,1); }
.banner.show { opacity: 1; transform: scale(1); }
.banner.red { color: #ffdbdf; text-shadow: 0 4px 0 var(--red-d), 0 0 24px rgba(255,40,60,0.6); }
.banner.gold { color: var(--gold); text-shadow: 0 4px 0 #8a5a00, 0 0 24px rgba(255,200,40,0.6); }
.banner small { display: block; font-size: 0.42em; margin-top: 6px; }
.callout { position: absolute; left: 0; right: 0; bottom: calc(150px + var(--safe-b)); text-align: center; font-size: 26px; color: var(--gold);
  text-shadow: 0 3px 0 #8a5a00, 0 0 16px rgba(0,0,0,0.25); opacity: 0; }
.callout.show { animation: callout 1.1s ease-out forwards; }
@keyframes callout { 0% { opacity: 0; transform: translateY(20px) scale(0.7); } 15% { opacity: 1; transform: translateY(0) scale(1.1); } 30% { transform: scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-30px); } }
.tip { position: absolute; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%); width: min(92vw, 520px); background: rgba(27,34,64,0.88);
  color: #fff; font-size: 18px; text-align: center; padding: 12px 16px; border-radius: 14px; opacity: 0; transition: opacity 0.3s; }
.tip.show { opacity: 1; }
.hint { position: absolute; left: 0; right: 0; bottom: 34%; text-align: center; color: #fff; font-size: 26px; text-shadow: 0 3px 0 rgba(0,0,0,0.35); }
.hint .hand { font-size: 48px; animation: drag 1.6s ease-in-out infinite; }
.vignette { position: absolute; inset: 0; box-shadow: inset 0 0 70px 6px rgba(255,20,40,0.6); opacity: 0; transition: opacity 0.35s; }
.vignette.on { opacity: 1; transition: opacity 0.05s; }

/* ------------------------------------------------------------------ menus */
#ui { position: fixed; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; padding: calc(12px + var(--safe-t)) 14px calc(14px + var(--safe-b)); }
.screen.dim { background: rgba(20, 28, 60, 0.45); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.topbar { width: 100%; display: flex; justify-content: flex-end; gap: 8px; align-items: center; }
.coins { color: var(--ink); background: rgba(255,255,255,0.95); border-radius: 999px; padding: 6px 14px 6px 8px; font-size: 22px; display: inline-flex; align-items: center; gap: 6px; box-shadow: 0 4px 0 rgba(0,0,0,0.15); }
.coin { width: 24px; height: 24px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff3a8 0 20%, var(--gold) 21% 70%, var(--gold-d) 71%); display: inline-block; box-shadow: 0 2px 0 rgba(0,0,0,0.15); flex: none; }
.cloudtag { background: rgba(255,255,255,0.85); border-radius: 999px; padding: 6px 12px; font-size: 15px; }
.cloudtag.warn { background: #ffe1a6; }
.logo { margin-top: clamp(10px, 7vh, 70px); text-align: center; line-height: 0.88; transform: rotate(-3deg); }
.logo .l1 { font-size: clamp(56px, 15vw, 110px); color: var(--blue); -webkit-text-stroke: 3px #fff; paint-order: stroke fill; text-shadow: 0 6px 0 var(--blue-d), 0 10px 20px rgba(0,0,0,0.25); }
.logo .l2 { font-size: clamp(56px, 15vw, 110px); color: var(--red); -webkit-text-stroke: 3px #fff; paint-order: stroke fill; text-shadow: 0 6px 0 var(--red-d), 0 10px 20px rgba(0,0,0,0.25); }
.home-mid { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; }
.playbtn { font-size: 40px; padding: 16px 64px 20px; border-radius: 22px; animation: breathe 1.6s ease-in-out infinite; }
.sub { color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,0.35); font-size: 20px; text-align: center; }
.nav { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; width: min(560px, 100%); }
.nav .btn { font-size: 15px; padding: 10px 4px 12px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.nav .btn .ic { font-size: 28px; line-height: 1.1; text-shadow: none; }
.panel { width: min(640px, 100%); flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--panel); border-radius: 22px;
  box-shadow: 0 8px 0 rgba(0,0,0,0.12), 0 20px 50px rgba(0,0,0,0.2); overflow: hidden; margin-top: 8px; }
.panel .hdr { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 12px 10px; background: var(--blue); color: #fff; }
.panel .hdr h2 { margin: 0; font-weight: normal; font-size: 26px; text-shadow: 0 3px 0 rgba(0,0,0,0.25); }
.panel .hdr .coins { font-size: 18px; box-shadow: none; }
.panel .body { flex: 1; overflow-y: auto; padding: 12px; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.card { background: #f2f4fb; border-radius: 16px; padding: 12px; display: grid; grid-template-columns: 52px 1fr auto; gap: 4px 10px; align-items: center; box-shadow: 0 3px 0 #dfe3f0; }
.card .ic { width: 52px; height: 52px; border-radius: 14px; background: #fff; display: grid; place-items: center; font-size: 30px; grid-row: span 2; box-shadow: 0 3px 0 #dfe3f0; }
.card .nm { font-size: 19px; line-height: 1.1; }
.card .lv { color: var(--muted); font-size: 14px; }
.card .ds { grid-column: 2 / 4; color: var(--muted); font-size: 14px; font-family: system-ui, sans-serif; font-weight: 600; }
.card .val { grid-column: 1 / 3; font-size: 17px; color: var(--blue-d); }
.card .val .arrow { color: var(--green-d); }
.card .btn { grid-column: 3; grid-row: 1 / 3; font-size: 18px; padding: 8px 12px 10px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.card .btn .coin { width: 18px; height: 18px; }
.pips { display: flex; gap: 2px; grid-column: 1 / 4; }
.pips i { flex: 1; height: 6px; border-radius: 3px; background: #dfe3f0; }
.pips i.on { background: var(--blue); }
.champ { background: #f2f4fb; border-radius: 16px; padding: 12px; display: grid; grid-template-columns: 70px 1fr; gap: 6px 12px; align-items: center; box-shadow: 0 3px 0 #dfe3f0; }
.champ.eq { box-shadow: 0 0 0 3px var(--gold), 0 3px 0 #dfe3f0; }
.champ .fig { width: 70px; height: 86px; grid-row: span 3; display: grid; place-items: end center; }
.champ .fig i { width: 40px; height: 64px; border-radius: 20px; display: block; box-shadow: inset -6px -6px 0 rgba(0,0,0,0.18); position: relative; }
.champ .fig i::before { content: ''; position: absolute; left: 50%; top: -10px; width: 20px; height: 9px; transform: translateX(-50%); border: 4px solid var(--gold); border-bottom: 0; border-radius: 10px 10px 0 0; }
.champ .nm { font-size: 22px; }
.champ .ds { font-family: system-ui, sans-serif; font-weight: 600; color: var(--muted); font-size: 14px; }
.champ .st { font-size: 14px; color: var(--blue-d); }
.champ .btn { grid-column: 1 / 3; }
.champ.locked { opacity: 0.6; }
.levels { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.lvbtn { aspect-ratio: 1; border-radius: 14px; background: var(--blue); color: #fff; font-size: 24px; box-shadow: 0 4px 0 var(--blue-d); display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.lvbtn .stars { font-size: 12px; color: var(--gold); margin-top: 4px; letter-spacing: -1px; }
.lvbtn.boss { background: #8a1a2a; box-shadow: 0 4px 0 #4a0d18; }
.lvbtn.cur { background: var(--green); box-shadow: 0 4px 0 var(--green-d); animation: bob 1.2s ease-in-out infinite; }
.lvbtn.locked { background: #c9cee0; box-shadow: 0 4px 0 #9aa1ba; color: #eef0f7; cursor: default; }
.world { grid-column: 1 / -1; font-size: 18px; color: var(--muted); margin: 6px 0 0; }
.opts { display: flex; flex-direction: column; gap: 10px; }
.opt { display: flex; align-items: center; justify-content: space-between; background: #f2f4fb; border-radius: 14px; padding: 10px 14px; font-size: 19px; }
.opt small { display: block; font-family: system-ui, sans-serif; font-weight: 600; color: var(--muted); font-size: 13px; }
.toggle { width: 64px; height: 36px; border-radius: 18px; background: #c9cee0; position: relative; transition: background 0.15s; flex: none; }
.toggle::after { content: ''; position: absolute; top: 4px; left: 4px; width: 28px; height: 28px; border-radius: 50%; background: #fff; transition: left 0.15s; box-shadow: 0 2px 0 rgba(0,0,0,0.15); }
.toggle.on { background: var(--green); }
.toggle.on::after { left: 32px; }
.seg { display: flex; background: #dfe3f0; border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { background: transparent; padding: 6px 12px; border-radius: 9px; font-size: 16px; color: var(--muted); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 2px 0 rgba(0,0,0,0.1); }
.fine { font-family: system-ui, sans-serif; font-weight: 600; font-size: 13px; color: var(--muted); line-height: 1.45; }
.fine b { color: var(--ink); }
input.txt { font-family: system-ui, sans-serif; font-size: 18px; padding: 12px 14px; border-radius: 12px; border: 2px solid #dfe3f0; width: 100%; background: #fff; color: var(--ink); user-select: text; -webkit-user-select: text; }
input.txt:focus { outline: none; border-color: var(--blue); }
.notice { background: #fff4d6; border-radius: 12px; padding: 10px 12px; font-family: system-ui, sans-serif; font-weight: 600; font-size: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > .btn { flex: 1; }

/* modal dialogs: pause, results */
.modal { margin: auto; width: min(440px, 100%); background: #fff; border-radius: 24px; padding: 18px 18px 20px; text-align: center;
  box-shadow: 0 10px 0 rgba(0,0,0,0.12), 0 24px 60px rgba(0,0,0,0.3); animation: pop 0.35s cubic-bezier(.2,1.5,.4,1); }
.modal h1 { margin: 2px 0 6px; font-weight: normal; font-size: clamp(32px, 9vw, 44px); line-height: 1; }
.modal h1.win { color: var(--green-d); }
.modal h1.lose { color: var(--red-d); }
.modal .btns { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.bigstars { display: flex; justify-content: center; gap: 6px; margin: 4px 0 6px; }
.bigstars span { font-size: 54px; color: #dfe3f0; transform: scale(0.4); opacity: 0.4; transition: transform 0.3s cubic-bezier(.2,1.8,.4,1), color 0.2s, opacity 0.2s; text-shadow: 0 4px 0 rgba(0,0,0,0.12); }
.bigstars span:nth-child(2) { font-size: 66px; margin-top: -10px; }
.bigstars span.on { color: var(--gold); transform: scale(1); opacity: 1; text-shadow: 0 4px 0 var(--gold-d); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.stats div { background: #f2f4fb; border-radius: 12px; padding: 8px; font-size: 22px; }
.stats small { display: block; font-family: system-ui, sans-serif; font-weight: 700; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.earn { display: inline-flex; align-items: center; gap: 8px; font-size: 36px; color: var(--gold-d); background: #fff8dc; border-radius: 16px; padding: 6px 18px; }
.earn .coin { width: 32px; height: 32px; }
.earnnote { font-family: system-ui, sans-serif; font-weight: 600; font-size: 13px; color: var(--muted); margin-top: 4px; }
.progressbar { height: 18px; background: #f2f4fb; border-radius: 9px; overflow: hidden; margin: 8px 0; }
.progressbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--red), #ff8a4a); border-radius: 9px; }
.suggest { margin-top: 10px; background: #eaf2ff; border-radius: 12px; padding: 10px; font-size: 16px; color: var(--blue-d); }

.toast { position: fixed; left: 50%; top: calc(14px + var(--safe-t)); transform: translate(-50%, -150%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 12px;
  font-size: 17px; z-index: 50; transition: transform 0.3s; pointer-events: none; max-width: 92vw; text-align: center; }
.toast.show { transform: translate(-50%, 0); }

@keyframes breathe { 50% { transform: scale(1.05); } }
@keyframes bob { 50% { transform: translateY(-3px); } }
@keyframes pulse { from { filter: brightness(1); transform: scale(1); } to { filter: brightness(1.25); transform: scale(1.08); } }
@keyframes pop { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes drag { 0%, 100% { transform: translateX(-60px); } 50% { transform: translateX(60px); } }

@media (max-height: 560px) {
  .logo { margin-top: 0; }
  .logo .l1, .logo .l2 { font-size: 52px; }
  .playbtn { font-size: 30px; padding: 10px 48px 14px; }
}
