:root {
  --sky: #62c6ea;
  --ink: #1d2a44;
  --ink-soft: #4a5876;
  --card: #ffffff;
  --easy: #22c55e;
  --medium: #f59e0b;
  --hard: #ef4444;
  --vhard: #a21caf;
  --gold: #fbbf24;
  --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; }
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--sky);
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-user-select: none; user-select: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }

#cv { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ---------------------------------------------------------------- HUD */

.hud {
  position: fixed; left: 0; right: 0; top: 0; z-index: 5;
  padding: calc(var(--safe-t) + 8px) 12px 6px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  pointer-events: none;
}
.hud > * { pointer-events: auto; }
.hbtn {
  width: 44px; height: 44px; border-radius: 14px;
  background: rgba(255,255,255,.9);
  box-shadow: 0 3px 0 rgba(20,40,70,.25);
  display: grid; place-items: center;
  transition: transform .08s;
}
.hbtn:active { transform: translateY(2px) scale(.96); box-shadow: 0 1px 0 rgba(20,40,70,.25); }
.hbtn svg { width: 22px; height: 22px; fill: var(--ink); stroke: var(--ink); stroke-width: 0; }
.hbtn.gear svg { fill: none; stroke-width: 2.2; stroke-linecap: round; }
.hud-mid { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.lvl-text { font-weight: 900; font-size: 20px; color: #fff; text-shadow: 0 2px 0 rgba(20,40,70,.35); letter-spacing: .3px; }
.tag {
  font-size: 11px; font-weight: 900; letter-spacing: .8px; text-transform: uppercase;
  padding: 3px 9px; border-radius: 99px; color: #fff;
  box-shadow: 0 2px 0 rgba(0,0,0,.18);
}
.tag.easy { background: var(--easy); }
.tag.medium { background: var(--medium); }
.tag.hard { background: var(--hard); }
.tag.vhard { background: var(--vhard); }
.coins {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.9); border-radius: 99px;
  padding: 6px 12px 6px 6px; font-weight: 900; font-size: 16px;
  box-shadow: 0 3px 0 rgba(20,40,70,.25);
  min-width: 70px;
}
.coin {
  width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff3b0, var(--gold) 45%, #d97706);
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.15);
  display: inline-block; flex: none; position: relative;
}
.coin::after { content: ""; position: absolute; inset: 6px; border-radius: 50%; border: 2px solid rgba(255,255,255,.6); }
.coins.bump { animation: bump .35s; }
@keyframes bump { 40% { transform: scale(1.18); } }

/* ---------------------------------------------------------------- boosters */

.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 8px 12px calc(var(--safe-b) + 12px);
  display: flex; justify-content: center; gap: 14px;
}
.boost {
  position: relative; width: 78px; height: 70px; border-radius: 18px;
  background: linear-gradient(#ffffff, #e9eef6);
  box-shadow: 0 4px 0 #9fb0c8, 0 6px 14px rgba(20,40,70,.18);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  transition: transform .08s, box-shadow .08s;
}
.boost:active { transform: translateY(3px); box-shadow: 0 1px 0 #9fb0c8; }
.boost.on { background: linear-gradient(#f3e8ff, #ddd0ff); box-shadow: 0 4px 0 #8b5cf6, 0 0 0 3px #a78bfa; animation: glow 1s infinite alternate; }
@keyframes glow { to { box-shadow: 0 4px 0 #8b5cf6, 0 0 0 6px rgba(167,139,250,.5); } }
.boost.dis { opacity: .5; }
.bico svg { width: 28px; height: 28px; fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.boost[data-b="undo"] .bico svg { stroke: #2563eb; }
.boost[data-b="slot"] .bico svg { stroke: #16a34a; }
.boost[data-b="vip"] .bico svg { stroke: #9333ea; }
.blbl { font-size: 11px; font-weight: 900; color: var(--ink-soft); }
.bcnt {
  position: absolute; top: -8px; right: -8px;
  min-width: 24px; height: 24px; padding: 0 6px; border-radius: 99px;
  background: #ef4444; color: #fff; font-size: 13px; font-weight: 900;
  display: flex; align-items: center; gap: 3px; justify-content: center;
  box-shadow: 0 2px 0 rgba(0,0,0,.2);
}
.bcnt.price { background: #1d2a44; font-size: 11px; }
.bcnt.price .coin { width: 13px; height: 13px; }
.bcnt.price .coin::after { inset: 3px; border-width: 1px; }

.vip-banner {
  position: fixed; left: 50%; bottom: calc(var(--safe-b) + 100px); transform: translateX(-50%);
  z-index: 6; background: #7c3aed; color: #fff; font-weight: 900; font-size: 14px;
  padding: 10px 16px; border-radius: 99px; white-space: nowrap;
  box-shadow: 0 4px 0 #5b21b6; animation: floaty 1.2s ease-in-out infinite;
  pointer-events: none;
}
@keyframes floaty { 50% { transform: translate(-50%, -4px); } }

.tip {
  position: fixed; left: 50%; bottom: calc(var(--safe-b) + 100px);
  transform: translateX(-50%); z-index: 6;
  width: min(92vw, 380px);
  background: #fff; border-radius: 18px; padding: 12px 16px;
  font-weight: 800; font-size: 15px; line-height: 1.35; text-align: center;
  box-shadow: 0 5px 0 rgba(20,40,70,.18), 0 10px 30px rgba(20,40,70,.2);
  animation: tipIn .45s cubic-bezier(.2,1.6,.4,1);
  pointer-events: none;
}
.tip b { color: #2563eb; }
@keyframes tipIn { from { transform: translate(-50%, 30px) scale(.8); opacity: 0; } }

.toast {
  position: fixed; left: 50%; top: 34%; z-index: 30;
  transform: translate(-50%, 10px); opacity: 0;
  background: rgba(20,28,45,.88); color: #fff; font-weight: 900; font-size: 15px;
  padding: 10px 18px; border-radius: 99px; white-space: nowrap;
  transition: opacity .2s, transform .2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.intro {
  position: fixed; inset: 0; z-index: 8; display: grid; place-items: center; pointer-events: none;
}
.intro-inner {
  text-align: center; color: #fff;
  animation: introAnim 1.6s cubic-bezier(.2,.9,.3,1) forwards;
}
#introTitle { font-size: 44px; font-weight: 900; text-shadow: 0 4px 0 rgba(20,40,70,.35); letter-spacing: 1px; }
#introSub { display: inline-block; margin-top: 6px; font-size: 16px; font-weight: 900; padding: 6px 16px; border-radius: 99px; letter-spacing: 1.5px; }
.intro.hardlv #introTitle { color: #fff; text-shadow: 0 4px 0 #991b1b, 0 0 30px rgba(239,68,68,.7); }
@keyframes introAnim {
  0% { transform: scale(.4); opacity: 0; }
  18% { transform: scale(1.08); opacity: 1; }
  28% { transform: scale(1); }
  78% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.3); opacity: 0; }
}

/* ---------------------------------------------------------------- screens */

.screen {
  position: fixed; inset: 0; z-index: 10;
  background:
    radial-gradient(600px 400px at 50% 20%, rgba(255,255,255,.35), transparent 70%),
    linear-gradient(#62c6ea, #8fdcc4 55%, #a6e3a1);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(var(--safe-t) + 16px) 16px calc(var(--safe-b) + 16px);
}
.back-link {
  position: absolute; left: 12px; top: calc(var(--safe-t) + 10px);
  width: 44px; height: 44px; border-radius: 14px; background: rgba(255,255,255,.9);
  display: grid; place-items: center; color: var(--ink); text-decoration: none; font-weight: 900; font-size: 22px;
  box-shadow: 0 3px 0 rgba(20,40,70,.25);
}
.screen .gear { position: absolute; right: 12px; top: calc(var(--safe-t) + 10px); }
.home-coins { position: absolute; top: calc(var(--safe-t) + 14px); left: 50%; transform: translateX(-50%); }
.home-inner { display: flex; flex-direction: column; align-items: center; gap: 26px; width: min(100%, 380px); }

.logo { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.logo h1 {
  margin: 0; font-size: 64px; font-weight: 900; color: #fff; letter-spacing: 2px; line-height: 1;
  text-shadow: 0 5px 0 #1e4fc2, 0 10px 20px rgba(20,40,70,.25);
}
.logo h1 span { color: var(--gold); text-shadow: 0 5px 0 #c2410c, 0 10px 20px rgba(20,40,70,.25); margin-left: 6px; }

.logo-bus {
  position: relative; width: 150px; height: 66px; margin-bottom: 10px;
  background: linear-gradient(#ffd25e, #fbbf24 30%, #f59e0b);
  border-radius: 16px 22px 12px 12px;
  box-shadow: inset 0 -12px 0 rgba(0,0,0,.12), 0 6px 0 rgba(20,40,70,.18);
  animation: busIdle 1.2s ease-in-out infinite;
}
.logo-bus .w { position: absolute; top: 12px; width: 26px; height: 22px; border-radius: 6px; background: #bfe6ff; box-shadow: 0 0 0 3px #2a3346; }
.logo-bus .w:nth-child(1) { left: 14px; }
.logo-bus .w:nth-child(2) { left: 48px; }
.logo-bus .w:nth-child(3) { left: 82px; }
.logo-bus .d { position: absolute; top: 9px; right: 12px; width: 22px; height: 36px; border-radius: 5px; background: #9fd6f5; box-shadow: 0 0 0 3px #2a3346; }
.logo-bus .wh { position: absolute; bottom: -12px; width: 26px; height: 26px; border-radius: 50%; background: radial-gradient(circle, #aab3c3 30%, #1f2430 34%); }
.logo-bus .wh.a { left: 20px; } .logo-bus .wh.b { right: 24px; }
@keyframes busIdle { 50% { transform: translateY(-3px) scaleY(1.02); } }
.logo-bus.drive { animation: busDrive 1.4s ease-in-out infinite; }
@keyframes busDrive { 0% { transform: translateX(-12px); } 50% { transform: translateX(12px) translateY(-3px); } 100% { transform: translateX(-12px); } }

.btn-play {
  width: 100%; padding: 18px 20px 16px; border-radius: 26px;
  background: linear-gradient(#4ade80, #22c55e 55%, #16a34a);
  box-shadow: 0 8px 0 #15803d, 0 14px 30px rgba(20,80,40,.3);
  color: #fff; display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: transform .08s, box-shadow .08s;
  animation: breathe 2s ease-in-out infinite;
}
.btn-play:active { transform: translateY(6px); box-shadow: 0 2px 0 #15803d; animation: none; }
@keyframes breathe { 50% { transform: scale(1.03); } }
.play-lbl { font-size: 16px; font-weight: 900; opacity: .9; letter-spacing: 1px; text-transform: uppercase; }
.play-num { font-size: 52px; font-weight: 900; line-height: 1; text-shadow: 0 3px 0 rgba(0,0,0,.18); }
.btn-play .tag { margin-top: 6px; box-shadow: 0 2px 0 rgba(0,0,0,.2); }

.quick { width: 100%; background: rgba(255,255,255,.55); border-radius: 22px; padding: 12px; }
.quick-lbl { text-align: center; font-weight: 900; color: var(--ink-soft); margin-bottom: 10px; letter-spacing: .5px; }
.quick-row { display: flex; gap: 10px; }
.qbtn {
  flex: 1; padding: 13px 0 11px; border-radius: 16px; color: #fff; font-weight: 900; font-size: 17px;
  transition: transform .08s, box-shadow .08s;
}
.qbtn.easy { background: var(--easy); box-shadow: 0 5px 0 #15803d; }
.qbtn.medium { background: var(--medium); box-shadow: 0 5px 0 #b45309; }
.qbtn.hard { background: var(--hard); box-shadow: 0 5px 0 #991b1b; }
.qbtn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0,0,0,.3); }
.link-btn { font-weight: 900; color: #fff; text-decoration: underline; text-underline-offset: 3px; text-shadow: 0 1px 0 rgba(0,0,0,.2); }

.loading { gap: 30px; }
.lbar { width: min(70vw, 260px); height: 14px; border-radius: 99px; background: rgba(255,255,255,.45); overflow: hidden; box-shadow: inset 0 2px 0 rgba(0,0,0,.08); }
.lbar i { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, #fbbf24, #f97316); transition: width .2s; }
.lbar.small { width: 160px; height: 8px; }
.load-text { font-weight: 900; color: #fff; text-shadow: 0 2px 0 rgba(20,40,70,.25); }

.wipe {
  position: fixed; inset: 0; z-index: 20;
  background: linear-gradient(#62c6ea, #8fdcc4);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  animation: fadeIn .18s;
}
.wipe.out { animation: fadeOut .3s forwards; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 6px solid rgba(255,255,255,.4); border-top-color: #fff; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- modal */

.modal {
  position: fixed; inset: 0; z-index: 25;
  background: rgba(15,25,45,.45);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 16px;
  animation: fadeIn .2s;
}
.card {
  width: min(100%, 360px); background: var(--card); border-radius: 28px;
  padding: 22px 20px 20px; text-align: center;
  box-shadow: 0 8px 0 rgba(20,40,70,.2), 0 20px 50px rgba(0,0,0,.25);
  animation: pop .42s cubic-bezier(.2,1.6,.4,1);
}
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
.card h2 { margin: 2px 0 6px; font-size: 30px; font-weight: 900; }
.card p { margin: 0 0 16px; color: var(--ink-soft); font-weight: 700; line-height: 1.4; }
.card .ico-big { font-size: 54px; line-height: 1; margin-bottom: 6px; }
.btns { display: flex; flex-direction: column; gap: 12px; }
.mbtn {
  width: 100%; padding: 14px; border-radius: 18px; font-weight: 900; font-size: 18px; color: #fff;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .08s, box-shadow .08s;
}
.mbtn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0,0,0,.25) !important; }
.mbtn.green { background: linear-gradient(#4ade80, #22c55e); box-shadow: 0 5px 0 #15803d; }
.mbtn.blue { background: linear-gradient(#60a5fa, #3b82f6); box-shadow: 0 5px 0 #1d4ed8; }
.mbtn.purple { background: linear-gradient(#c084fc, #a855f7); box-shadow: 0 5px 0 #7e22ce; }
.mbtn.gray { background: #e8edf5; color: var(--ink); box-shadow: 0 5px 0 #b8c3d6; }
.mbtn.dis { opacity: .45; pointer-events: none; }
.mbtn .coin { width: 18px; height: 18px; }
.mbtn .coin::after { inset: 4px; }

.stars { display: flex; justify-content: center; gap: 6px; margin: 4px 0 10px; }
.star { width: 64px; height: 64px; transform: scale(0); animation: starIn .5s cubic-bezier(.2,1.8,.4,1) forwards; }
.star:nth-child(2) { width: 78px; height: 78px; margin-top: -12px; }
.star svg { width: 100%; height: 100%; }
.star.off svg path { fill: #dfe5ee; stroke: #c3ccda; }
@keyframes starIn { to { transform: scale(1) rotate(0); } from { transform: scale(0) rotate(-90deg); } }
.reward { display: inline-flex; align-items: center; gap: 8px; font-size: 26px; font-weight: 900; background: #fff7d6; padding: 6px 16px; border-radius: 99px; margin-bottom: 16px; }

.settings { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; text-align: left; }
.toggle { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-radius: 16px; background: #f1f4f9; font-weight: 800; }
.sw { position: relative; width: 50px; height: 30px; border-radius: 99px; background: #c6cfdd; transition: background .2s; flex: none; }
.sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.2); transition: transform .2s cubic-bezier(.3,1.5,.5,1); }
.sw.on { background: var(--easy); }
.sw.on::after { transform: translateX(20px); }
.lang-seg { display: flex; gap: 6px; }
.lang-seg button { padding: 5px 12px; border-radius: 10px; background: #dfe5ee; font-weight: 900; }
.lang-seg button.on { background: var(--ink); color: #fff; }

.how { text-align: left; display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.how div { display: flex; gap: 12px; align-items: flex-start; font-weight: 700; color: var(--ink-soft); line-height: 1.35; }
.how b { color: var(--ink); }
.how .n { flex: none; width: 28px; height: 28px; border-radius: 50%; background: #3b82f6; color: #fff; display: grid; place-items: center; font-weight: 900; }

@media (min-height: 760px) {
  .logo h1 { font-size: 72px; }
}
@media (max-height: 600px) {
  .home-inner { gap: 14px; }
  .logo h1 { font-size: 48px; }
  .play-num { font-size: 40px; }
}

.rotate { display: none; }
@media (orientation: landscape) and (max-height: 500px) {
  .rotate {
    display: grid; place-items: center; position: fixed; inset: 0; z-index: 100;
    background: linear-gradient(#62c6ea, #8fdcc4); font-size: 64px;
  }
}

.win-pic { display: flex; justify-content: center; margin: 0 0 10px; }
.win-pic canvas {
  image-rendering: pixelated; border-radius: 10px; background: #efe3c8; padding: 8px;
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.06);
  animation: picIn .6s .5s cubic-bezier(.2,1.6,.4,1) both;
}
@keyframes picIn { from { transform: scale(.3) rotate(-8deg); opacity: 0; } }
.bar { gap: 22px; }

.hud-spacer { width: 44px; height: 44px; }

/* Two-word logo: stack it so it fits phones. */
.logo h1 { display: flex; flex-direction: column; align-items: center; font-size: 48px; line-height: 0.95; }
.logo h1 span { margin-left: 0; font-size: 0.78em; }
@media (min-height: 760px) { .logo h1 { font-size: 56px; } }
@media (max-height: 600px) { .logo h1 { font-size: 36px; } }
