/* GAG FLAP: sunset sky, porcelain + plungers, gas-green and Tom pink. Bungee for numbers/titles, Chakra Petch for words. */
@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: #2a1f45;
  --ink-soft: #6a5d88;
  --pink: #ff4fa3;
  --pink-deep: #e0317f;
  --gas: #8fdc3c;
  --gas-deep: #4f9a18;
  --sun: #ffcf3d;
  --shadow: 0 8px 0 rgba(42, 31, 69, .16), 0 18px 40px rgba(42, 31, 69, .22);
}
* { 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: #2a1f45;
  -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; }

.ff { position: fixed; inset: 0; overflow: hidden; }
#sky { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ---------- HUD ---------- */
.hud { position: absolute; left: 0; right: 0; top: 0; z-index: 2; pointer-events: none; display: flex; justify-content: center;
  padding: max(10px, env(safe-area-inset-top)) 12px 0; }
.hud__score { font: 64px/1 'Bungee', sans-serif; color: #fff; -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill;
  text-shadow: 0 6px 0 var(--ink); margin-top: 18px; transition: transform .1s; font-variant-numeric: tabular-nums; }
.hud__score.bump { transform: scale(1.18); }
.hud__tools { position: absolute; top: max(10px, env(safe-area-inset-top)); right: 10px; display: flex; gap: 8px; pointer-events: auto; }
.icon { width: 42px; height: 38px; border: 0; border-radius: 13px; background: rgba(255,255,255,.92); box-shadow: 0 4px 0 rgba(42,31,69,.25);
  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(42,31,69,.25); }
.is-menu .hud, .is-over .hud__tools { visibility: hidden; }

/* "tap to gag" hint while Tom waits for the first tap */
.ready { position: absolute; left: 50%; top: 58%; translate: -50% 0; z-index: 2; pointer-events: none; text-align: center;
  font: 22px/1.1 'Bungee', sans-serif; color: #fff; -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; white-space: nowrap; }
.ready small { display: block; font: 600 14px 'Chakra Petch', sans-serif; -webkit-text-stroke: 0; color: #fff; text-shadow: 0 2px 0 var(--ink); margin-top: 6px; }
.ready i { display: block; width: 46px; height: 46px; margin: 10px auto 0; border-radius: 50%; border: 4px solid #fff; box-shadow: 0 0 0 4px var(--ink);
  animation: tap 1s ease-in-out infinite; }
@keyframes tap { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(.7); opacity: .6; } }

/* ---------- 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(42, 31, 69, .45); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.menu { justify-content: flex-start; padding-top: max(52px, env(safe-area-inset-top)); gap: 12px; }
.menu .menu__card { margin-top: auto; }
.menu > :last-child { margin-bottom: auto; }
.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,.9); padding: 6px 12px; border-radius: 99px; box-shadow: 0 3px 0 rgba(42,31,69,.2); }
.menu__card { width: min(390px, 100%); background: rgba(255,255,255,.95); 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: 40px; }
.logo { margin: -64px 0 0; display: flex; flex-direction: column; align-items: center; font: 400 66px/0.88 'Bungee', sans-serif; }
.logo span { display: block; -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; text-shadow: 0 7px 0 var(--ink); }
.logo span:first-child { color: var(--gas); transform: rotate(-5deg); }
.logo span:last-child { color: var(--pink); transform: rotate(3deg) translateX(10px); }
.menu__tag { margin: 0; color: var(--ink-soft); font-size: 15px; }
.menu__tag b { color: var(--gas-deep); font-family: 'Bungee', sans-serif; font-weight: 400; }
.btn { border: 0; border-radius: 18px; padding: 13px 22px; font: 23px/1 'Bungee', sans-serif; width: 100%; }
.btn--go { background: linear-gradient(180deg, #a8ef57, var(--gas-deep)); color: #fff; box-shadow: 0 6px 0 #356b0e, 0 12px 20px rgba(79,154,24,.35);
  text-shadow: 0 2px 0 rgba(0,0,0,.2); }
.btn--go:active { translate: 0 4px; box-shadow: 0 2px 0 #356b0e; }
.btn--quiet { background: #f1edf9; color: var(--ink); font-size: 15px; padding: 10px 16px; box-shadow: 0 4px 0 #d9d1ea; }
.btn--quiet:active { translate: 0 2px; box-shadow: 0 2px 0 #d9d1ea; }
.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: #fff; opacity: .85; text-decoration: none; text-shadow: 0 1px 0 var(--ink); }

/* gas colours (looks only), unlocked by best score */
.gases { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; width: 100%; }
.gas { border: 2px solid transparent; background: #f1edf9; border-radius: 14px; padding: 6px 2px 5px; display: grid; justify-items: center; gap: 3px; }
.gas[aria-checked="true"] { border-color: var(--gas-deep); background: #fff; box-shadow: 0 3px 0 var(--gas-deep); }
.gas i { width: 30px; height: 22px; border-radius: 50%; position: relative; }
.gas i::before, .gas i::after { content: ''; position: absolute; border-radius: 50%; background: inherit; }
.gas i::before { width: 16px; height: 16px; left: -6px; top: 6px; }
.gas i::after { width: 12px; height: 12px; right: -4px; top: -4px; }
.gas--green i { background: #9be35a; }
.gas--pink i { background: #ff8cc6; }
.gas--rainbow i { background: linear-gradient(90deg, #ff5f5f, #ffcf3d, #7fd858, #4f9dff, #9a7bff); }
.gas--gold i { background: linear-gradient(135deg, #fff3a8, #ffcf1f 50%, #c98d00); box-shadow: 0 0 8px rgba(255,200,40,.9); }
.gas b { font: 10px/1.1 'Bungee', sans-serif; }
.gas small { font-size: 9px; line-height: 1.15; color: var(--ink-soft); }
.gas small:empty { display: none; }
.gas.is-locked { cursor: not-allowed; }
.gas.is-locked i, .gas.is-locked b { filter: grayscale(1); opacity: .45; }
.gas.nope { animation: nope .35s; }
@keyframes nope { 25% { translate: -4px 0; } 50% { translate: 4px 0; } 75% { translate: -2px 0; } }

.card { position: relative; width: min(370px, 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 2px; font: 38px/1 'Bungee', sans-serif; color: var(--pink); -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; }
.card__btns { display: flex; flex-direction: column; gap: 8px; }
.close { position: absolute; top: 8px; right: 10px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: #f1edf9; 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__row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: center; background: #f6f3fc; border-radius: 18px; padding: 10px; }
.over__medal { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.over__medal canvas { width: 92px; height: 92px; }
.over__medal span { font: 11px/1.1 'Bungee', sans-serif; color: var(--ink-soft); }
.over__nums { display: flex; flex-direction: column; gap: 6px; }
.over__nums small { display: block; font: 11px 'Bungee', sans-serif; color: var(--ink-soft); }
.over__nums b { display: block; font: 40px/1 'Bungee', sans-serif; color: var(--ink); }
.over__nums em { display: block; font: normal 22px/1 'Bungee', sans-serif; color: var(--ink-soft); }
.over__new { margin: 0; align-self: center; font: 14px 'Bungee', sans-serif; color: #fff; background: linear-gradient(90deg, var(--pink), #ff9a3f);
  border-radius: 99px; padding: 4px 14px; animation: shine 1.2s ease-in-out infinite alternate; }
@keyframes shine { to { filter: brightness(1.15); transform: scale(1.05); } }
.over__unlock { margin: 0; align-self: center; font: 13px 'Bungee', sans-serif; color: #2d5a0b; background: linear-gradient(90deg, #c9f59a, #8fdc3c);
  border-radius: 99px; padding: 5px 14px; }
.over__next { margin: 0; font-size: 13px; color: var(--ink-soft); }
.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); }
.medals { list-style: none; margin: 4px 0 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; font-size: 11px; color: var(--ink-soft); }
.medals li { display: grid; justify-items: center; gap: 2px; }
.medals canvas { width: 48px; height: 48px; }
.medals b { font: 10px/1.1 'Bungee', sans-serif; color: var(--ink); }

.loading { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; align-content: center; gap: 14px; background: #2a1f45;
  font: 22px 'Bungee', sans-serif; color: var(--gas); }
.loading.done { opacity: 0; pointer-events: none; transition: opacity .3s; }

@media (max-height: 640px) {
  .logo { font-size: 50px; margin-top: -48px; }
  .menu__card { gap: 8px; padding: 14px 16px 12px; }
  .btn { padding: 10px 18px; font-size: 20px; }
  .hud__score { font-size: 50px; margin-top: 6px; }
}

/* 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; }
