:root {
  --ink: #f5f0ff;
  --muted: #a99dd1;
  --page: #120a29;
  --hot: #ff3d7f;
  --gold: #ffd23f;
  --go: #2be38b;
  --game: 'Lilita One', 'Arial Rounded MT Bold', system-ui, sans-serif;
  --ui: Inter, system-ui, -apple-system, sans-serif;
  --game-bg: #000;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 800px at 50% -10%, #3b1a7a 0%, var(--page) 60%) fixed, var(--page);
  color: var(--ink);
  font-family: var(--ui);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}
button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- page layout ---------- */
.page { height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px; }

/* ---------- phone ---------- */
.phone {
  position: relative; flex: none;
  width: 390px; height: min(844px, calc(100dvh - 48px));
  padding: 12px; border-radius: 56px; background: #0b0b10;
  box-shadow: 0 0 0 2px #2d2d3a, 0 0 0 7px #15151c, 0 40px 90px rgba(0,0,0,.65);
}
.screen {
  position: relative; height: 100%; overflow: hidden; border-radius: 44px;
  background: var(--game-bg); display: flex; flex-direction: column;
  transition: background .3s;
}

.statusbar {
  position: relative; z-index: 30; flex: none; height: 46px; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
  font: 600 15px var(--ui); color: #fff; background: rgba(0,0,0,.18);
}
.sb-left { min-width: 110px; display: flex; align-items: center; }
.island { position: absolute; left: 50%; top: 10px; width: 110px; height: 30px; margin-left: -55px; background: #000; border-radius: 20px; }
.back { background: none; border: 0; padding: 0; font-size: 12px; font-weight: 600; color: #fff; max-width: 110px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back:not([hidden]) + .clock { display: none; }
.sb-right { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 11px; }
.bars i { width: 3px; background: #fff; border-radius: 1px; }
.bars i:nth-child(1) { height: 4px; } .bars i:nth-child(2) { height: 6px; } .bars i:nth-child(3) { height: 8px; } .bars i:nth-child(4) { height: 11px; opacity: .35; }
.battery { position: relative; width: 25px; height: 12px; border: 1.5px solid rgba(255,255,255,.7); border-radius: 4px; padding: 1px; }
.battery::after { content: ''; position: absolute; right: -4px; top: 3px; width: 2px; height: 4px; background: rgba(255,255,255,.7); border-radius: 0 2px 2px 0; }
.battery i { display: block; height: 100%; width: var(--charge, 87%); background: #fff; border-radius: 2px; }
.battery.low i { background: #ff453a; }

.app { position: relative; flex: 1; min-height: 0; }
.canvas-wrap, .ad-canvas { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
canvas { display: block; touch-action: none; }

.banner {
  flex: none; height: 52px; display: flex; align-items: center; gap: 10px; padding: 0 12px 0 10px;
  background: #fff; color: #1a1a1a; font-size: 12px; position: relative; cursor: default; z-index: 5;
}
.banner .em { font-size: 26px; }
.banner b { display: block; font-size: 13px; }
.banner small { color: #777; }
.banner .badge { position: absolute; top: 3px; right: 6px; font-size: 9px; color: #999; border: 1px solid #ccc; border-radius: 3px; padding: 0 3px; }
.banner .go { margin-left: auto; background: #1a73e8; color: #fff; font-weight: 800; border-radius: 6px; padding: 6px 10px; font-size: 12px; }

/* ---------- overlays ---------- */
.overlay { position: absolute; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; padding: 18px; }
.overlay:empty { display: none; }

.panel {
  width: 100%; max-width: 320px; text-align: center; padding: 26px 22px 22px;
  border-radius: 28px; background: rgba(22, 12, 46, .9); backdrop-filter: blur(8px);
  box-shadow: 0 0 0 3px rgba(255,255,255,.12), 0 20px 50px rgba(0,0,0,.5);
  font-family: var(--game); animation: pop .35s cubic-bezier(.2,1.6,.4,1);
}
.panel-title { font-size: 44px; line-height: 1; color: var(--hot); text-shadow: 0 4px 0 rgba(0,0,0,.4); }
.panel-title.small { font-size: 32px; }
.scoreline { display: flex; justify-content: center; gap: 18px; margin: 12px 0 4px; font-size: 18px; color: var(--muted); }
.scoreline b { color: #fff; font-weight: 400; }
.continue-q { margin: 14px 0 4px; font-size: 22px; }
.quip, .panel p { font-family: var(--ui); font-size: 14px; line-height: 1.45; color: var(--muted); }
.panel p.small { font-size: 12px; opacity: .8; }
.big-emoji { font-size: 64px; line-height: 1; margin-bottom: 8px; }

.ring { position: relative; width: 86px; height: 86px; margin: 4px auto 16px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke: rgba(255,255,255,.12); stroke-width: 9; }
.ring circle.prog { stroke: var(--gold); stroke-linecap: round; stroke-dasharray: 276.5; stroke-dashoffset: 0; animation: drain linear forwards; }
.ring b { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 400; font-size: 36px; }

.btn {
  display: block; width: 100%; margin: 10px 0 0; padding: 14px 18px; border: 0; border-radius: 18px;
  font-family: var(--game); font-size: 22px; color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.25);
  background: linear-gradient(#45ec8b, #1fae55); box-shadow: 0 5px 0 #137a3a, 0 10px 22px rgba(0,0,0,.3);
  transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #137a3a; }
.btn small { font-size: 13px; opacity: .8; }
.btn.blue { background: linear-gradient(#5aa8ff, #2b6fe0); box-shadow: 0 5px 0 #1b4aa0, 0 10px 22px rgba(0,0,0,.3); font-size: 17px; }
.btn.gray { background: linear-gradient(#8b86a3, #5d5873); box-shadow: 0 5px 0 #403b55, 0 10px 22px rgba(0,0,0,.3); font-size: 18px; }
.pulse { animation: pulse 1s ease-in-out infinite; }
.nothanks { display: block; margin: 14px auto 0; background: none; border: 0; color: rgba(255,255,255,.35); font: 11px var(--ui); text-decoration: underline; opacity: 0; pointer-events: none; transition: opacity .6s; }
.nothanks.shown { opacity: 1; pointer-events: auto; }

.splash {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px;
  background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--game-accent, #fff) 55%, transparent), var(--game-bg) 70%);
  font-family: var(--game); text-align: center;
}
.splash h1 { font-weight: 400; font-size: 34px; line-height: 1.05; margin: 18px 0 4px; text-shadow: 0 4px 0 rgba(0,0,0,.3); }
.splash .dev { font: 600 13px var(--ui); opacity: .75; margin: 0 0 26px; }
.splash .tip { font: 13px var(--ui); opacity: .8; margin-top: 16px; max-width: 260px; }
.splash .btn { max-width: 260px; margin-top: 26px; }
.loadbar { width: 220px; height: 14px; border-radius: 8px; background: rgba(0,0,0,.35); overflow: hidden; }
.loadbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), #ff9b3d); border-radius: 8px; animation: load 1.3s ease-in forwards; }
.loadbar.done i { animation: none; width: 100%; }

.app-icon {
  width: 60px; height: 60px; flex: none; display: grid; place-items: center; font-size: 36px; border-radius: 14px;
  background: linear-gradient(145deg, var(--icon-a, #ffd23f), var(--icon-b, #ff3d7f)); box-shadow: inset 0 0 0 1px rgba(255,255,255,.2), 0 4px 10px rgba(0,0,0,.25);
}
.app-icon.big { width: 112px; height: 112px; font-size: 68px; border-radius: 26px; animation: bob 2s ease-in-out infinite; }
.app-icon.sm { width: 34px; height: 34px; font-size: 20px; border-radius: 9px; }

/* install sheet */
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; }
.sheet { width: 100%; background: #f7f7fa; color: #111; border-radius: 26px 26px 0 0; padding: 22px 20px 26px; animation: up .35s cubic-bezier(.2,1,.3,1); font-family: var(--ui); }
.sheet-row { display: flex; align-items: center; gap: 14px; }
.sheet-meta { flex: 1; min-width: 0; }
.sheet-meta b { display: block; font-size: 16px; }
.sheet-meta span { display: block; font-size: 12px; color: #777; }
.get { min-width: 74px; height: 32px; border: 0; border-radius: 16px; background: #e6e9f2; color: #0a66ff; font-weight: 800; font-size: 15px; display: grid; place-items: center; }
.get.loading::after { content: ''; width: 20px; height: 20px; border-radius: 50%; border: 3px solid #cfd6e6; border-top-color: #0a66ff; animation: spin .7s linear infinite; }
.get.open { background: #0a66ff; color: #fff; }
.perm { font-size: 13px; color: #444; margin: 18px 0 6px; line-height: 1.45; }
.iap { font-size: 11px; color: #999; margin: 0; }

/* ---------- the ad ---------- */
.ad { position: absolute; inset: 46px 0 0; z-index: 20; background: #000; display: flex; flex-direction: column; animation: fadein .25s; }
.ad[hidden] { display: none; }
.ad-stage { position: relative; flex: 1; min-height: 0; background: var(--ad-bg); cursor: pointer; overflow: hidden; }
.ad-top { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; align-items: center; gap: 8px; z-index: 3; }
.ad-badge { background: var(--gold); color: #000; font: 800 11px var(--ui); padding: 3px 6px; border-radius: 4px; }
.ad-timer { background: rgba(0,0,0,.6); border: 0; color: #fff; font: 600 12px var(--ui); padding: 6px 10px; border-radius: 14px; }
.ad.ready .ad-timer { background: rgba(255,255,255,.92); color: #000; }
.ad-x { margin-left: auto; width: 18px; height: 18px; padding: 0; border: 0; border-radius: 50%; background: rgba(255,255,255,.18); color: rgba(255,255,255,.4); font-size: 9px; line-height: 18px; transition: all .3s; }
.ad.ready .ad-x { width: 34px; height: 34px; font-size: 16px; line-height: 34px; background: rgba(0,0,0,.7); color: #fff; box-shadow: 0 0 0 2px rgba(255,255,255,.8); }
.ad-headline {
  position: absolute; left: 14px; right: 14px; top: 52px; text-align: center; z-index: 2; pointer-events: none;
  font: 30px/1.05 var(--game); color: var(--gold); -webkit-text-stroke: 1.5px #000;
  text-shadow: 0 4px 0 #000, 0 0 30px rgba(0,0,0,.5); animation: wobble 1.6s ease-in-out infinite;
}
.ad-sub { display: block; margin-top: 6px; font: 600 13px var(--ui); color: #fff; -webkit-text-stroke: 0; text-shadow: 0 1px 3px #000; }
.ad-stamp {
  position: absolute; left: 50%; top: 46%; z-index: 2; pointer-events: none; text-align: center;
  transform: translate(-50%, -50%) rotate(-8deg) scale(0); opacity: 0;
  font-family: var(--game); background: #e5112e; color: #fff; padding: 12px 18px; border-radius: 12px; border: 4px solid #fff;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.ad-stamp b { display: block; font-weight: 400; font-size: 28px; white-space: nowrap; }
.ad-stamp span { font: 600 13px var(--ui); }
.ad-stamp.show { animation: stamp 1.7s ease-out forwards; }
.ad-hand { position: absolute; z-index: 2; left: 58%; bottom: 18%; font-size: 54px; pointer-events: none; animation: tap 1.1s ease-in-out infinite; filter: drop-shadow(0 6px 6px rgba(0,0,0,.4)); }
.ad-card { flex: none; display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: #fff; color: #111; cursor: pointer; }
.ad-meta { flex: 1; min-width: 0; }
.ad-meta b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ad-meta span { display: block; font-size: 11px; color: #777; }
.ad-meta .stars { color: #f5a623; font-size: 12px; }
.ad-meta .stars em { color: #777; font-style: normal; font-size: 11px; }
.ad-cta {
  flex: none; border: 0; border-radius: 12px; padding: 12px 14px; font: 18px var(--game); color: #fff;
  background: linear-gradient(var(--ad-accent), color-mix(in srgb, var(--ad-accent) 70%, #000)); box-shadow: 0 4px 0 color-mix(in srgb, var(--ad-accent) 55%, #000);
  animation: pulse .9s ease-in-out infinite;
}
.ad-fine { margin: 0; padding: 4px 12px 8px; background: #fff; color: #aaa; font-size: 9px; line-height: 1.3; }
.ad-progress { flex: none; height: 4px; background: #333; }
.ad-progress i { display: block; height: 100%; width: 0; background: var(--gold); transition: width linear; }
.ad-confirm { position: absolute; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(0,0,0,.55); }

.toast {
  position: absolute; z-index: 40; left: 50%; top: 56px; max-width: 86%; transform: translate(-50%, -20px); opacity: 0;
  background: rgba(20,12,40,.92); color: #fff; padding: 10px 14px; border-radius: 14px; font-size: 13px; font-weight: 600; text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,.4); transition: all .3s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- motion ---------- */
@keyframes pop { from { transform: scale(.7); opacity: 0; } }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fadein { from { opacity: 0; } }
@keyframes pulse { 50% { transform: scale(1.05); } }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-3deg); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes drain { to { stroke-dashoffset: 276.5; } }
@keyframes load { 0% { width: 0; } 60% { width: 70%; } 85% { width: 72%; } 100% { width: 100%; } }
@keyframes wobble { 0%, 100% { transform: rotate(-2deg) scale(1); } 50% { transform: rotate(2deg) scale(1.06); } }
@keyframes tap { 0%, 100% { transform: translate(0, 0) rotate(-10deg); } 50% { transform: translate(-10px, -14px) rotate(-18deg) scale(.92); } }
@keyframes stamp {
  0% { transform: translate(-50%, -50%) rotate(-8deg) scale(2.4); opacity: 0; }
  15% { transform: translate(-50%, -50%) rotate(-8deg) scale(1); opacity: 1; }
  80% { opacity: 1; }
  100% { transform: translate(-50%, -50%) rotate(-8deg) scale(1); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .pulse, .ad-cta, .ad-headline, .ad-hand, .app-icon.big { animation: none; }
}

/* ---------- responsive ---------- */
@media (max-width: 520px), (max-height: 640px) and (max-width: 900px) {
  .page { padding: 0; }
  .phone { width: 100%; height: 100dvh; padding: 0; border-radius: 0; box-shadow: none; }
  .screen { border-radius: 0; }
  .island { display: none; }
  .statusbar { padding: 0 16px; padding-top: env(safe-area-inset-top); height: calc(36px + env(safe-area-inset-top)); }
  .ad { inset: calc(36px + env(safe-area-inset-top)) 0 0; }
}
