html, body { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; background: #5cc8ff; overscroll-behavior: none; }
body { font-family: Nunito, ui-rounded, system-ui, -apple-system, Segoe UI, sans-serif; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
#game { position: fixed; inset: 0; display: block; touch-action: none; }
#ui button { font-family: inherit; -webkit-tap-highlight-color: transparent; }

/* ---------- title ---------- */
.bb-title { position: fixed; left: 50%; bottom: max(28px, calc(env(safe-area-inset-bottom) + 18px)); transform: translate(-50%, 30px); width: min(340px, calc(100vw - 40px)); display: flex; flex-direction: column; gap: 12px; opacity: 0; pointer-events: none; transition: opacity .3s, transform .45s cubic-bezier(.2, 1.4, .4, 1); z-index: 10; }
.bb-title.on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.bb-row { display: flex; gap: 12px; }
.bb-btn { position: relative; flex: 1; display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 56px; border: 3px solid #fff; border-radius: 22px; color: #fff; font-weight: 900; font-size: 18px; cursor: pointer; background: linear-gradient(#8aa0ff, #5146e0); box-shadow: 0 5px 0 #3a30b0, 0 10px 18px rgba(10, 0, 80, .3); text-shadow: 0 2px 0 rgba(20, 0, 90, .4); padding: 0 12px; }
.bb-btn svg { width: 24px; height: 24px; flex: none; }
.bb-btn span { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.05; }
.bb-btn small { font-size: 12px; font-weight: 800; opacity: .92; }
.bb-btn.big { min-height: 78px; font-size: 30px; border-radius: 26px; background: linear-gradient(#7cf06a, #22b03e); box-shadow: 0 6px 0 #15852b, 0 12px 22px rgba(0, 60, 20, .35); text-shadow: 0 2px 0 rgba(0, 70, 20, .45); animation: bbBreath 1.8s ease-in-out infinite; }
.bb-btn.big svg { width: 34px; height: 34px; }
.bb-btn.big small { font-size: 15px; }
.bb-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #3a30b0; }
.bb-btn.big:active { box-shadow: 0 2px 0 #15852b; animation: none; }
.bb-btn.locked { background: linear-gradient(#c3c8dc, #8d93ad); box-shadow: 0 5px 0 #6b7190, 0 10px 18px rgba(10, 0, 80, .2); }
.bb-btn.wide { width: 100%; margin-top: 14px; flex: none; }
.bb-boost { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 46px; padding: 4px 14px; border: 3px solid #fff; border-radius: 18px; background: linear-gradient(#5db8ff, #2f6fe0); box-shadow: 0 4px 0 #1f4bb0, 0 8px 14px rgba(0, 30, 90, .28); color: #fff; font-family: inherit; text-align: left; cursor: pointer; text-shadow: 0 1px 0 rgba(0, 0, 60, .35); }
.bb-boost[hidden] { display: none; }
.bb-boost svg { width: 26px; height: 26px; flex: none; }
.bb-boost span { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.1; min-width: 0; }
.bb-boost b { font-size: 16px; font-weight: 900; }
.bb-boost small { font-size: 11.5px; font-weight: 800; opacity: .95; }
.bb-boost:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #1f4bb0; }
.bb-boost:disabled { cursor: default; }
.bb-boost.on { background: linear-gradient(#7cf06a, #22b03e); box-shadow: 0 4px 0 #15852b, 0 8px 14px rgba(0, 60, 20, .3); }
.bb-boost.on b { font-size: 14px; }
.bb-btn .dot { display: none; position: absolute; top: -5px; right: -5px; width: 16px; height: 16px; border-radius: 50%; background: #ff3d6e; border: 3px solid #fff; }
.bb-btn .dot.on { display: block; animation: bbPulse 1.2s ease-in-out infinite; }
.bb-title > .bb-btn:last-child { background: linear-gradient(#ffb23d, #ff7a1a); box-shadow: 0 5px 0 #c9560a, 0 9px 16px rgba(80, 30, 0, .3); text-shadow: 0 1px 0 rgba(120, 40, 0, .45); }
body.land .bb-title { width: min(620px, calc(100vw - 40px)); flex-direction: row; flex-wrap: wrap; bottom: max(16px, calc(env(safe-area-inset-bottom) + 10px)); }
body.land .bb-title .bb-btn.big { flex: 1 1 100%; min-height: 64px; }
body.land .bb-title .bb-row { flex: 2; }
body.land .bb-title > .bb-btn:last-child { flex: 1; }
body.land.short .bb-title { width: min(720px, calc(100vw - 40px)); flex-wrap: nowrap; }
body.land.short .bb-title .bb-btn.big { flex: 1.3; min-height: 58px; font-size: 24px; }
body.land.short .bb-btn { min-height: 52px; font-size: 16px; }
body.land.short .bb-title .bb-row { flex: 2; }

/* ---------- map bar ---------- */
.bb-mapbar { position: fixed; left: max(10px, env(safe-area-inset-left)); top: max(10px, env(safe-area-inset-top)); display: flex; gap: 10px; align-items: center; z-index: 10; opacity: 0; pointer-events: none; transform: translateY(-20px); transition: opacity .25s, transform .35s cubic-bezier(.2, 1.4, .4, 1); }
.bb-mapbar.on { opacity: 1; pointer-events: auto; transform: none; }
.bb-round { width: 48px; height: 48px; border-radius: 16px; border: 3px solid #fff; background: linear-gradient(#8aa0ff, #5146e0); box-shadow: 0 4px 0 #3a30b0; color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.bb-round svg { width: 24px; height: 24px; }
.bb-round:active { transform: translateY(3px); box-shadow: 0 1px 0 #3a30b0; }
.bb-pill { display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px 0 10px; border-radius: 20px; background: rgba(255, 255, 255, .95); box-shadow: 0 4px 0 rgba(30, 30, 90, .25); color: #2b2f6b; font-weight: 900; font-size: 18px; }
.bb-pill svg { width: 24px; height: 24px; color: #ffb800; }

/* ---------- guide line ---------- */
.bb-guide { position: fixed; left: 50%; top: calc(max(8px, env(safe-area-inset-top)) + 72px); transform: translate(-50%, -8px); max-width: calc(100vw - 32px); width: max-content; white-space: normal; text-align: center; line-height: 1.25; padding: 8px 16px; border-radius: 16px; background: rgba(28, 24, 80, .72); color: #fff; font-weight: 800; font-size: 15px; opacity: 0; pointer-events: none; transition: opacity .25s, transform .3s; z-index: 9; box-sizing: border-box; }
.bb-guide.on { opacity: 1; transform: translate(-50%, 0); }
body.land .bb-guide { top: auto; bottom: max(10px, env(safe-area-inset-bottom)); left: auto; right: max(12px, env(safe-area-inset-right)); transform: translate(0, 8px); max-width: min(30vw, 260px); white-space: normal; text-align: center; }
body.land .bb-guide.on { transform: none; }

.bb-toast { position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%) scale(.8); padding: 12px 20px; border-radius: 18px; background: rgba(28, 24, 80, .88); color: #fff; font-weight: 900; font-size: 17px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .3s cubic-bezier(.2, 1.4, .4, 1); z-index: 20; white-space: nowrap; max-width: calc(100vw - 40px); overflow: hidden; text-overflow: ellipsis; }
.bb-toast.on { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* ---------- skins popup ---------- */
.bb-pop { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; background: rgba(10, 14, 40, .55); backdrop-filter: blur(3px); animation: bbFade .2s; }
.bb-card { width: min(380px, calc(100vw - 32px)); max-height: calc(100% - 24px); overflow-y: auto; box-sizing: border-box; background: #fff; border-radius: 24px; padding: 18px; box-shadow: 0 18px 50px rgba(0, 0, 0, .35); text-align: center; color: #1d2340; animation: bbPop .35s cubic-bezier(.2, 1.4, .4, 1); }
.bb-card h2 { margin: 2px 0 12px; font-size: 24px; font-weight: 900; }
.bb-skins { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bb-skin { border: 3px solid #e3e7f5; border-radius: 18px; background: #f4f6ff; padding: 8px 6px 10px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; color: #1d2340; min-height: 44px; }
.bb-skin canvas { width: 100%; max-width: 150px; height: auto; aspect-ratio: 2 / 1; }
.bb-skin .nm { font-weight: 900; font-size: 16px; }
.bb-skin .st { display: flex; align-items: center; gap: 4px; font-weight: 800; font-size: 13px; color: #6a7193; }
.bb-skin .st svg { width: 15px; height: 15px; }
.bb-skin.sel { border-color: #33c27f; background: #eafff3; }
.bb-skin.sel .st { color: #1f9c5f; }
.bb-skin.locked canvas { filter: grayscale(1) opacity(.5); }
body.land.short .bb-skins { grid-template-columns: repeat(4, 1fr); }
body.land.short .bb-card { width: min(640px, calc(100vw - 32px)); padding: 12px 16px; }
body.land.short .bb-card h2 { margin-bottom: 8px; font-size: 20px; }
body.land.short .bb-btn.wide { min-height: 46px; margin-top: 10px; }

/* ---------- result card extras ---------- */
.bb-reslv { font-weight: 900; font-size: 13px; letter-spacing: .5px; color: #8a90b0; text-transform: uppercase; margin-bottom: 2px; }
.bb-stars { display: flex; justify-content: center; gap: 6px; margin: -4px 0 6px; }
.bb-star svg { width: 46px; height: 46px; fill: #dfe3ef; stroke: #c3c9dc; stroke-width: 1.2; }
.bb-star:nth-child(2) svg { width: 56px; height: 56px; margin-top: -8px; }
.bb-star.on { animation: bbStar .5s cubic-bezier(.2, 1.6, .4, 1) both; }
.bb-star.on svg { fill: #ffc928; stroke: #e08a00; filter: drop-shadow(0 3px 0 #d98200); }
.bb-stars.dim { opacity: .55; }
@media (max-height: 440px) { .bb-star svg { width: 34px; height: 34px; } .bb-star:nth-child(2) svg { width: 42px; height: 42px; } .bb-stars { margin: -6px 0 2px; } }

.shake { animation: bbShake .4s; }
@keyframes bbBreath { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.035); } }
@keyframes bbPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.25); } }
@keyframes bbShake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-7px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(4px); } }
@keyframes bbFade { from { opacity: 0; } }
@keyframes bbPop { from { transform: scale(.85); opacity: 0; } }
@keyframes bbStar { from { transform: scale(0) rotate(-40deg); opacity: 0; } }
/* narrow phones / large text: the two small title buttons put the icon above the label so long words fit */
@media (max-width: 359px) {
  .bb-row .bb-btn { flex-direction: column; gap: 2px; padding: 4px 6px; font-size: 15px; min-width: 0; }
  .bb-row .bb-btn svg { width: 20px; height: 20px; }
  .bb-row .bb-btn span { align-items: center; max-width: 100%; overflow-wrap: break-word; text-align: center; }
}
/* short landscape phones: compact result card, buttons side by side */
@media (max-height: 440px) {
  .pp-card.bbs-res { display: flex; flex-wrap: wrap; column-gap: 10px; justify-content: center; align-content: flex-start; width: min(440px, 88vw); }
  .pp-card.bbs-res > * { flex: 0 0 100%; }
  .pp-card.bbs-res > .pp-new { flex: 0 0 auto; margin-bottom: 4px; }
  .pp-card.bbs-res > .pp-b { flex: 1 1 40%; }
  .pp-card.bbs-res h2 { margin-bottom: 4px; }
  .pp-card.bbs-res .pp-big { font-size: 30px; margin: 0; }
  .pp-card.bbs-res .pp-sub { margin-bottom: 2px; }
}
/* free Rainbow bubble on the title in landscape: its own full-width row above the buttons (kept last so it wins over the .land.short rules above) */
body.land .bb-title .bb-boost { flex: 1 1 100%; order: -1; }
body.land.short .bb-title { flex-wrap: wrap; }
body.land.short .bb-title .bb-boost { min-height: 38px; }

.bb-lb { position: fixed; right: calc(max(10px, env(safe-area-inset-right)) + 58px);   /* left of the SDK pause button */ top: max(10px, env(safe-area-inset-top)); z-index: 10; display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px 0 10px; border: 3px solid #fff; border-radius: 20px; background: linear-gradient(#8aa0ff, #5146e0); box-shadow: 0 4px 0 #3a30b0; color: #fff; font: 900 15px/1 inherit; cursor: pointer; }
.bb-lb[hidden] { display: none; }
.bb-store { right: auto; left: max(10px, env(safe-area-inset-left)); background: linear-gradient(#7cf06a, #22b03e); box-shadow: 0 4px 0 #15852b; }
.bb-store:active { box-shadow: 0 1px 0 #15852b; }
.bb-store svg { color: #fff3a0; }
.bb-boost.coin { background: linear-gradient(#ffd96b, #f0a020); box-shadow: 0 4px 0 #b8741a, 0 8px 14px rgba(90, 50, 0, .28); color: #4a2a00; text-shadow: none; }
.bb-boost.coin svg { color: #fff; }
.bb-lb svg { width: 22px; height: 22px; color: #ffd23f; flex: none; }
.bb-lb:active { transform: translateY(3px); box-shadow: 0 1px 0 #3a30b0; }
