/* PEARL DROP: bright, bubbly, sea-glass. Bungee for numbers and titles, Chakra Petch for words (hub fonts). */
@font-face { font-family: 'Bungee'; src: url('/TomGames/fonts/Bungee-Regular.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'Chakra Petch'; src: url('/TomGames/fonts/ChakraPetch-SemiBold.ttf') format('truetype'); font-weight: 600; font-display: swap; }

:root {
  --ink: #23304f;
  --ink-soft: #5b6a8c;
  --pink: #ff4fa3;
  --pink-deep: #e0317f;
  --aqua: #33c6e8;
  --sun: #ffd23f;
  --card: #ffffff;
  --shadow: 0 10px 0 rgba(35, 48, 79, .12), 0 18px 40px rgba(35, 48, 79, .18);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font: 600 16px/1.35 'Chakra Petch', system-ui, sans-serif; color: var(--ink);
  background: #9be3f7; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
  overscroll-behavior: none; touch-action: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

.pd { position: fixed; inset: 0; display: flex; align-items: stretch; justify-content: center;
  background:
    radial-gradient(120% 70% at 50% 0%, #c9f4ff 0%, rgba(201, 244, 255, 0) 60%),
    radial-gradient(90% 60% at 100% 100%, #ffd1ea 0%, rgba(255, 209, 234, 0) 65%),
    radial-gradient(80% 50% at 0% 90%, #fff3b8 0%, rgba(255, 243, 184, 0) 60%),
    linear-gradient(180deg, #8edcf5 0%, #b7ecfb 45%, #ffe1f0 100%); }

/* drifting bubbles in the background */
.sky { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.sky i { position: absolute; bottom: -120px; width: 70px; height: 70px; border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, rgba(255,255,255,.95) 0 9%, rgba(255,255,255,.35) 10% 38%, rgba(255,255,255,.08) 60%, rgba(255,255,255,.4) 70%, rgba(255,255,255,0) 72%);
  animation: rise 18s linear infinite; opacity: .8; }
.sky i:nth-child(1) { left: 6%; animation-duration: 21s; transform: scale(.6); }
.sky i:nth-child(2) { left: 18%; animation-duration: 15s; animation-delay: -6s; }
.sky i:nth-child(3) { left: 33%; animation-duration: 26s; animation-delay: -3s; transform: scale(.4); }
.sky i:nth-child(4) { left: 52%; animation-duration: 19s; animation-delay: -12s; transform: scale(.8); }
.sky i:nth-child(5) { left: 68%; animation-duration: 23s; animation-delay: -8s; transform: scale(.5); }
.sky i:nth-child(6) { left: 80%; animation-duration: 17s; animation-delay: -2s; }
.sky i:nth-child(7) { left: 91%; animation-duration: 28s; animation-delay: -15s; transform: scale(.45); }
.sky i:nth-child(8) { left: 44%; animation-duration: 31s; animation-delay: -20s; transform: scale(1.3); }
@keyframes rise { from { translate: 0 0; } 50% { translate: 18px -60vh; } to { translate: -10px -130vh; } }
@media (prefers-reduced-motion: reduce) { .sky i { animation: none; display: none; } }

/* ---------- play column ---------- */
.play { position: relative; z-index: 1; display: flex; flex-direction: column; width: 100%; max-width: 560px;
  height: 100%; padding: max(8px, env(safe-area-inset-top)) 10px max(8px, env(safe-area-inset-bottom)); gap: 6px; }

.hud { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 8px; }
.hud__score { background: var(--card); border-radius: 18px; padding: 6px 14px 7px; box-shadow: var(--shadow);
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: baseline; min-width: 0; }
.hud__score small { font: 12px 'Bungee', sans-serif; color: var(--pink); letter-spacing: .04em; grid-row: 1; }
.hud__score b { font: 32px/1 'Bungee', sans-serif; grid-row: 1 / 3; grid-column: 2; text-align: right; font-variant-numeric: tabular-nums;
  color: var(--ink); transition: transform .12s; }
.hud__score b.bump { transform: scale(1.12); color: var(--pink-deep); }
.hud__best { font-size: 12px; color: var(--ink-soft); grid-row: 2; }
.hud__best em { font-style: normal; font-family: 'Bungee', sans-serif; color: var(--ink); }
.hud__next { position: relative; width: 70px; height: 70px; border-radius: 50%; background: var(--card); box-shadow: var(--shadow);
  display: grid; place-items: center; }
.hud__next small { position: absolute; top: -7px; left: 50%; translate: -50% 0; font: 11px 'Bungee', sans-serif; color: #fff;
  background: var(--pink); padding: 1px 8px 0; border-radius: 99px; z-index: 1; }
.hud__next canvas { width: 56px; height: 56px; }
.hud__tools { display: flex; flex-direction: column; gap: 6px; }
.icon { width: 38px; height: 32px; border: 0; border-radius: 12px; background: var(--card); box-shadow: 0 4px 0 rgba(35,48,79,.14);
  display: grid; place-items: center; }
.icon svg { width: 20px; height: 20px; fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.icon svg path:first-child { fill: var(--ink); }
#btn-mute .cross { display: none; }
#btn-mute[aria-pressed="true"] .cross { display: block; }
#btn-mute[aria-pressed="true"] .wave { display: none; }
.icon:active { translate: 0 2px; box-shadow: 0 2px 0 rgba(35,48,79,.14); }

.stage { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; cursor: none; touch-action: none; }
.pd:not(.is-menu):not(.is-over) { touch-action: none; }
.stage canvas { display: block; touch-action: none; }
.is-menu .stage, .is-over .stage { cursor: default; }

.combo { position: absolute; top: 18%; left: 50%; translate: -50% 0; pointer-events: none; font: 30px/1 'Bungee', sans-serif;
  color: #fff; -webkit-text-stroke: 2px var(--pink-deep); paint-order: stroke fill; text-shadow: 0 4px 0 rgba(224,49,127,.35); opacity: 0;
  white-space: nowrap; }
.combo.show { animation: combo .9s ease-out; }
@keyframes combo { 0% { opacity: 0; transform: scale(.4); } 18% { opacity: 1; transform: scale(1.18); } 30% { transform: scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-24px); } }

.chain { background: rgba(255,255,255,.75); border-radius: 18px; padding: 6px 8px; box-shadow: 0 6px 0 rgba(35,48,79,.08); }
.chain ol { list-style: none; margin: 0; padding: 0; display: flex; align-items: center; justify-content: space-between; gap: 2px; }
.chain li { position: relative; flex: 0 0 auto; display: grid; place-items: center; }
.chain li canvas { display: block; filter: grayscale(1) brightness(1.15) opacity(.45); transition: filter .3s, transform .3s; }
.chain li.got canvas { filter: none; }
.chain li.new canvas { animation: got .7s ease-out; }
@keyframes got { 0% { transform: scale(1); } 35% { transform: scale(1.6); } 100% { transform: scale(1); } }
.chain li + li::before { content: ''; position: absolute; left: -3px; top: 50%; width: 3px; height: 3px; border-radius: 50%; background: var(--ink-soft); opacity: .35; }

/* ---------- screens ---------- */
.screen { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom)); overflow-y: auto; touch-action: pan-y; }
.modal { background: rgba(35, 48, 79, .35); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.is-menu .play { filter: blur(2px) saturate(.85); opacity: .55; pointer-events: none; }
.is-menu .hud, .is-menu .chain { visibility: hidden; }

.menu { background: linear-gradient(180deg, rgba(142,220,245,.15), rgba(255,225,240,.35)); gap: 12px; }
.menu__back { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 12px; color: var(--ink); text-decoration: none; font-size: 14px;
  background: rgba(255,255,255,.85); padding: 6px 12px; border-radius: 99px; box-shadow: 0 3px 0 rgba(35,48,79,.12); }
.menu__card { width: min(400px, 100%); background: rgba(255,255,255,.94); border-radius: 28px; box-shadow: var(--shadow);
  padding: 18px 20px 16px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; margin-top: 30px; }
.logo { margin: -54px 0 0; display: flex; flex-direction: column; align-items: center; line-height: .86; font: 400 64px/0.9 'Bungee', sans-serif; letter-spacing: .01em; }
.logo span { display: block; color: #fff; -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill;
  text-shadow: 0 6px 0 var(--ink); }
.logo span:first-child { color: var(--pink); font-size: .9em; transform: rotate(-4deg); }
.logo span:last-child { color: var(--sun); transform: rotate(2deg); }
.menu__tag { margin: 0; color: var(--ink-soft); font-size: 15px; }
.menu__tag b { color: var(--pink-deep); font-family: 'Bungee', sans-serif; font-weight: 400; }
.btn { border: 0; border-radius: 18px; padding: 12px 22px; font: 22px/1 'Bungee', sans-serif; width: 100%; }
.btn--go { background: linear-gradient(180deg, #ff6db5, var(--pink-deep)); color: #fff; box-shadow: 0 6px 0 #a71f5d, 0 12px 20px rgba(224,49,127,.35);
  text-shadow: 0 2px 0 rgba(0,0,0,.15); }
.btn--go:active { translate: 0 4px; box-shadow: 0 2px 0 #a71f5d; }
.btn--quiet { background: #eef4fb; color: var(--ink); font-size: 15px; padding: 10px 16px; box-shadow: 0 4px 0 #d3dceb; }
.btn--quiet:active { translate: 0 2px; box-shadow: 0 2px 0 #d3dceb; }
.menu__links { display: flex; gap: 14px; }
.link { border: 0; background: none; color: var(--ink); text-decoration: underline; text-decoration-color: var(--pink); text-underline-offset: 4px; font-size: 15px; }
.menu__stats { font-size: 13px; color: var(--ink-soft); min-height: 1em; }
.menu__stats b { font-family: 'Bungee', sans-serif; font-weight: 400; color: var(--ink); }
.menu__nav { display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center; font-size: 13px; }
.menu__nav a { color: var(--ink); opacity: .75; text-decoration: none; }

.card { position: relative; width: min(380px, 100%); background: #fff; border-radius: 26px; box-shadow: var(--shadow); padding: 20px;
  display: flex; flex-direction: column; align-items: stretch; gap: 10px; text-align: center; }
.card__title { margin: 0 0 4px; font: 34px/1 'Bungee', sans-serif; color: var(--pink); -webkit-text-stroke: 1.5px var(--ink); paint-order: stroke fill; }
.card__btns { display: flex; flex-direction: column; gap: 8px; }
.card__btns .btn--quiet { display: inline-block; }
.close { position: absolute; top: 8px; right: 10px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: #eef4fb; font-size: 22px; line-height: 1; }
.card--over { animation: pop .45s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { from { transform: scale(.7); opacity: 0; } }
.over__top { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.over__top canvas { width: 110px; height: 110px; }
.over__topname { margin: 0; font-size: 13px; color: var(--ink-soft); }
.over__score { margin: 0; display: flex; flex-direction: column; }
.over__score small { font: 12px 'Bungee', sans-serif; color: var(--ink-soft); }
.over__score b { font: 52px/1 'Bungee', sans-serif; color: var(--ink); }
.over__best { margin: 0; font: 14px 'Bungee', sans-serif; color: var(--ink-soft); }
.over__best.is-new { color: #fff; background: linear-gradient(90deg, var(--pink), #ff9a3f); border-radius: 99px; padding: 4px 12px; align-self: center;
  animation: shine 1.2s ease-in-out infinite alternate; }
@keyframes shine { to { filter: brightness(1.15); transform: scale(1.04); } }
.over__rank { margin: 0; font-size: 14px; color: var(--ink); min-height: 1.2em; }

.how { text-align: left; margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; font-size: 15px; }
.how b { color: var(--pink-deep); }
.how-chain { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: 4px; }

.loading { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; align-content: center; gap: 14px; background: #9be3f7; font: 22px 'Bungee', sans-serif; color: #fff; -webkit-text-stroke: 1px var(--ink); paint-order: stroke fill; }
.loading.done { opacity: 0; pointer-events: none; transition: opacity .3s; }

@media (min-width: 900px) {
  .play { max-width: 600px; }
  .hud__score b { font-size: 36px; }
}
@media (max-height: 640px) {
  .logo { font-size: 48px; margin-top: -40px; }
  .menu__card { gap: 8px; padding: 14px 16px 12px; }
  .btn { padding: 10px 18px; font-size: 19px; }
}

/* jar skins (menu) */
.skins { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; width: 100%; max-width: 360px; }
.skin { border: 2px solid transparent; background: #eef4fb; border-radius: 14px; padding: 6px 2px 5px; display: grid; justify-items: center; gap: 3px;
  font: inherit; color: var(--ink); cursor: pointer; transition: transform .12s, border-color .12s; }
.skin:hover { transform: translateY(-2px); }
.skin[aria-checked="true"] { border-color: var(--aqua); background: #fff; box-shadow: 0 3px 0 #1d93b0; }
.skin i { width: 30px; height: 30px; border-radius: 4px 4px 9px 9px; border: 3px solid; border-top: 0; }
.skin--jar i { background: linear-gradient(#ffffff, #d6f6ff); border-color: #ff9cc8; }
.skin--potty i { background: linear-gradient(#ffffff 55%, #8fd0ff 56%); border-color: #c9d4e2; border-radius: 6px 6px 15px 15px; }
.skin--outhouse i { background: repeating-linear-gradient(90deg, #f0d6ac 0 6px, #d9b47e 6px 7px); border-color: #8d5426; }
.skin--gold i { background: linear-gradient(#fffbe0, #ffe08a); border-color: #ffc21a; box-shadow: 0 0 8px rgba(255,200,40,.8); }
.skin b { font: 10px/1.1 'Bungee', sans-serif; letter-spacing: .02em; text-align: center; }
.skin small { font-size: 9px; line-height: 1.15; color: var(--ink-soft); text-align: center; min-height: 0; }
.skin small:empty { display: none; }
.skin.is-locked { cursor: not-allowed; }
.skin.is-locked i, .skin.is-locked b { filter: grayscale(1); opacity: .45; }
.skin.nope { animation: nope .35s; }
@keyframes nope { 25% { translate: -4px 0; } 50% { translate: 4px 0; } 75% { translate: -2px 0; } }
.over__unlock { margin: 0; align-self: center; font: 13px 'Bungee', sans-serif; color: #7a4b00; background: linear-gradient(90deg, #ffe27a, #ffc21a);
  border-radius: 99px; padding: 5px 14px; animation: got .7s ease-out; }
/* short screens: the menu scrolls from the top instead of cutting the logo (centered when it fits) */
.menu { justify-content: flex-start; padding-top: max(52px, env(safe-area-inset-top)); }
.menu .menu__card { margin-top: auto; }
.menu > :last-child { margin-bottom: auto; }

/* game-over ad can make a screen taller than the window: centre when it fits, scroll from the top when it doesn't (plain centring cuts the top off) */
.screen::before { content: ''; margin-top: auto; }
.screen::after { content: ''; margin-bottom: auto; }
