/* PULL MY FINGER — cheesy family-fart arcade chrome */
:root {
  --ink: #2a1a12;
  --pink: #ff2d92;
  --hot: #ff4d8d;
  --yellow: #ffe14a;
  --mint: #5ee0b5;
  --cream: #fff6e0;
  --sky: #7ec8ff;
  --neon: #39f7ff;
  --lime: #c8ff3d;
  --orange: #ff8a2a;
  --fart: #7adf3a;
  --fart-deep: #2f6b14;
  --skin: #f5d76e;
  --panel: rgba(42, 26, 18, 0.92);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  height: 100vh;
  height: 100dvh;
  height: var(--app-h, 100vh);
  background: #1a2410;
  color: var(--cream);
  font-family: "Trebuchet MS", "Arial Black", Impact, sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
  touch-action: manipulation;
  position: fixed;
  inset: 0;
  width: 100%;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, #2a4018 0%, #1a2410 70%);
}

#game {
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
  width: min(100vw, calc(100dvh * 16 / 9));
  height: min(100dvh, calc(100vw * 9 / 16));
  max-width: 100%;
  max-height: 100%;
  image-rendering: auto;
  background: #c4a574;
  display: block;
  box-shadow: 0 0 0 6px var(--ink), 0 0 0 10px var(--lime), 0 20px 80px rgba(0,0,0,.55);
  cursor: crosshair;
  touch-action: none;
}

.hidden { display: none !important; }

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  width: 100%;
  height: 100%;
  margin: auto;
}

#hud-left {
  position: absolute;
  top: max(10px, env(safe-area-inset-top, 0px));
  left: max(12px, env(safe-area-inset-left, 0px));
  z-index: 2;
}

#phase-wrap {
  background: var(--ink);
  color: var(--lime);
  border: 4px solid var(--cream);
  box-shadow: 6px 6px 0 var(--pink), -3px -3px 0 var(--lime);
  padding: 8px 14px;
  transform: rotate(-2deg);
  min-width: 132px;
  text-align: center;
}
#phase-label {
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--mint);
  font-weight: 900;
}
#phase-value {
  font-size: 22px;
  font-weight: 900;
  color: var(--yellow);
  text-shadow: 2px 2px 0 var(--pink);
  line-height: 1.05;
}
#phase-sub {
  margin-top: 6px;
  font-size: 11px;
  font-weight: 800;
  color: var(--ink);
  background: var(--cream);
  display: inline-block;
  padding: 2px 8px;
  transform: rotate(2deg);
}

#hud-score {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  min-width: 280px;
}
#score-label {
  font-size: 14px;
  letter-spacing: 4px;
  color: var(--yellow);
  text-shadow: 0 0 12px var(--pink), 2px 2px 0 var(--ink);
  animation: pulse 0.8s ease-in-out infinite;
}
#score-value {
  font-size: 52px;
  font-weight: 900;
  line-height: 0.9;
  color: #fff;
  -webkit-text-stroke: 4px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 6px 0 var(--fart-deep), 0 0 24px rgba(200, 255, 61, 0.45);
  transition: transform 0.08s ease-out, color 0.08s ease-out;
}
#score-sub {
  font-size: 13px;
  color: var(--ink);
  background: var(--cream);
  display: inline-block;
  padding: 2px 10px;
  margin-top: 2px;
  transform: rotate(-1deg);
  font-weight: 800;
}

#hud-right {
  position: absolute;
  top: max(10px, env(safe-area-inset-top, 0px));
  right: max(12px, env(safe-area-inset-right, 0px));
  text-align: right;
}
#stank-label {
  font-size: 11px;
  letter-spacing: 2px;
  font-weight: 900;
  color: var(--cream);
  margin-bottom: 4px;
}
#stank-meter {
  width: 118px;
  height: 14px;
  border: 3px solid var(--ink);
  background: #0a180c;
  display: inline-block;
  box-shadow: 3px 3px 0 var(--neon);
  overflow: hidden;
  vertical-align: middle;
}
#stank-meter span {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--lime), var(--mint));
  transform-origin: left center;
}
#hint {
  margin-top: 8px;
  font-size: 11px;
  color: var(--cream);
  opacity: 0.8;
}

#intro-banner {
  position: absolute;
  top: 118px;
  left: 50%;
  transform: translateX(-50%) rotate(-3deg);
  background: var(--orange);
  color: #fff;
  border: 4px solid #fff;
  padding: 8px 18px 12px;
  box-shadow: 8px 8px 0 var(--ink);
  min-width: 280px;
  text-align: center;
  animation: flash 0.35s steps(2) infinite;
  pointer-events: none;
}
.intro-title {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 2px;
}
.intro-sub {
  font-size: 13px;
  margin-top: 2px;
  font-weight: 700;
}
body[data-state="play"] #intro-banner { display: none; }

#title-screen, #pause-screen, #victory-screen, #dead-screen, #clear-screen {
  position: absolute;
  width: 100%;
  height: 100%;
  margin: auto;
  inset: 0;
  overflow: hidden;
  z-index: 3;
}

#title-screen {
  background: repeating-linear-gradient(90deg, #3aaa3a 0 18px, #ffe14a 18px 36px, #5ee0b5 36px 54px, #ff2d92 54px 72px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
#title-screen::before {
  content: "";
  position: absolute;
  inset: 16px;
  background:
    radial-gradient(circle at 20% 20%, #c8ff3d, transparent 40%),
    radial-gradient(circle at 80% 30%, #7adf3a, transparent 40%),
    linear-gradient(#7ec8ff, #3aaa3a);
  border: 6px solid var(--ink);
  pointer-events: none;
}

.marquee {
  position: absolute;
  top: 28px;
  left: 28px;
  right: 28px;
  overflow: hidden;
  background: var(--ink);
  color: var(--lime);
  font-weight: 900;
  letter-spacing: 2px;
  padding: 6px 0;
  z-index: 2;
  border: 3px solid var(--yellow);
  white-space: nowrap;
}
.marquee span {
  display: inline-block;
  padding-left: 100%;
  animation: marquee 16s linear infinite;
}

.title-hero {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 72px 36px 48px;
  max-width: 980px;
  width: 100%;
}

.title-art-wrap {
  position: relative;
  flex: 0 0 auto;
  width: min(240px, 28vw);
  transform: rotate(-3deg);
  filter: drop-shadow(10px 12px 0 var(--ink));
}
.title-art {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  background:
    radial-gradient(circle at 50% 70%, #f5d76e 0 28%, transparent 29%),
    linear-gradient(#7ec8ff 0 42%, #6ecf5a 42% 70%, #c4a574 70%);
  border: 5px solid var(--ink);
  overflow: hidden;
}
.title-art-glow {
  position: absolute;
  inset: -10px;
  border: 3px solid var(--yellow);
  box-shadow: 0 0 28px rgba(200, 255, 61, 0.55), 0 0 0 6px var(--pink);
  pointer-events: none;
}
.art-cloud {
  position: absolute;
  left: 12%;
  top: 10%;
  width: 70%;
  height: 38%;
  background: radial-gradient(circle at 40% 50%, #c8ff3d, #7adf3a 55%, rgba(47,107,20,0.0) 72%);
  filter: blur(1px);
  animation: puff 1.4s ease-in-out infinite;
}
.art-cloud-2 {
  left: 28%;
  top: 22%;
  width: 55%;
  height: 28%;
  opacity: 0.7;
  animation-delay: -0.6s;
}
.art-hand {
  position: absolute;
  left: 22%;
  bottom: 8%;
  width: 56%;
  height: 48%;
}
.art-palm {
  position: absolute;
  left: 8%;
  bottom: 0;
  width: 70%;
  height: 58%;
  background: var(--skin);
  border: 4px solid var(--ink);
  border-radius: 40% 40% 30% 30%;
}
.art-finger {
  position: absolute;
  left: 48%;
  bottom: 48%;
  width: 22%;
  height: 72%;
  background: var(--skin);
  border: 4px solid var(--ink);
  border-radius: 16px 16px 6px 6px;
  transform: rotate(-8deg);
  transform-origin: bottom center;
  animation: wag 0.9s ease-in-out infinite;
}
.art-thumb {
  position: absolute;
  left: 0;
  bottom: 28%;
  width: 28%;
  height: 32%;
  background: var(--skin);
  border: 4px solid var(--ink);
  border-radius: 50%;
}
.art-burst {
  position: absolute;
  right: 6%;
  top: 8%;
  background: var(--pink);
  color: #fff;
  font-weight: 900;
  font-size: 18px;
  padding: 4px 8px;
  border: 3px solid var(--ink);
  transform: rotate(12deg);
  animation: flash 0.4s steps(2) infinite;
}

.title-card {
  position: relative;
  z-index: 2;
  text-align: center;
  background: var(--cream);
  color: var(--ink);
  border: 6px solid var(--ink);
  box-shadow: 12px 12px 0 var(--pink), -8px -8px 0 var(--lime);
  padding: 22px 36px 18px;
  transform: rotate(1deg);
  max-width: 520px;
  flex: 1 1 420px;
}
.eyebrow {
  font-size: 12px;
  letter-spacing: 4px;
  color: var(--pink);
  font-weight: 900;
}
.title-card h1 {
  font-size: clamp(40px, 6.5vw, 62px);
  line-height: 0.85;
  letter-spacing: -2px;
  text-shadow: 4px 4px 0 var(--yellow), 8px 8px 0 var(--fart-deep);
  margin: 8px 0 10px;
}
.tagline {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.5px;
  color: var(--pink);
  line-height: 1.25;
}
.subtag {
  font-size: 12px;
  margin-top: 6px;
  opacity: 0.8;
  font-weight: 700;
}

#btn-start, #btn-resume, #btn-again, #btn-restart-pause, #btn-dead-again, #btn-continue {
  margin-top: 14px;
  font-family: inherit;
  font-size: 20px;
  font-weight: 900;
  padding: 10px 24px;
  border: 4px solid var(--ink);
  background: var(--yellow);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 5px 5px 0 var(--ink);
  letter-spacing: 1px;
  -webkit-tap-highlight-color: rgba(255, 225, 74, 0.4);
  touch-action: manipulation;
}
#btn-start:hover, #btn-resume:hover, #btn-again:hover, #btn-restart-pause:hover, #btn-dead-again:hover, #btn-continue:hover {
  transform: translate(-2px, -2px);
  box-shadow: 7px 7px 0 var(--ink);
  background: var(--lime);
}
button.ghost {
  background: var(--cream);
  margin-left: 8px;
}

.controls {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 14px;
  text-align: left;
  font-size: 12px;
}

#pause-screen, #victory-screen, #dead-screen, #clear-screen {
  background: rgba(12, 18, 8, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

.panel {
  background: var(--cream);
  color: var(--ink);
  border: 6px solid var(--ink);
  padding: 32px 40px;
  text-align: center;
  box-shadow: 10px 10px 0 var(--neon);
  max-width: 560px;
}
.panel h2 {
  font-size: 44px;
  text-shadow: 3px 3px 0 var(--yellow);
}
.panel.victory {
  box-shadow: 10px 10px 0 var(--pink), -6px -6px 0 var(--lime);
}
.panel.dead {
  box-shadow: 10px 10px 0 var(--fart), -6px -6px 0 var(--pink);
}
.panel.dead h2 { color: var(--fart-deep); text-shadow: 3px 3px 0 var(--lime); }
.confetti-label {
  background: var(--pink);
  color: #fff;
  display: inline-block;
  padding: 2px 10px;
  font-weight: 900;
  transform: rotate(-6deg);
}
.panel.dead .confetti-label { background: var(--fart-deep); }

#toast {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--yellow);
  border: 3px solid var(--yellow);
  padding: 8px 16px;
  font-weight: 900;
  z-index: 9;
  pointer-events: none;
  text-align: center;
}


.panel.clear {
  box-shadow: 10px 10px 0 var(--lime), -6px -6px 0 var(--pink);
}
.panel.clear h2 {
  color: var(--fart-deep);
  text-shadow: 3px 3px 0 var(--lime);
  font-size: clamp(32px, 8vw, 48px);
}
.clear-stage {
  font-size: 22px;
  font-weight: 900;
  color: var(--pink);
  letter-spacing: 1px;
  margin: 8px 0 4px;
}
.clear-hint {
  margin-top: 10px;
  font-size: 12px;
  font-weight: 700;
  opacity: 0.7;
}
#btn-continue {
  display: block;
  width: 100%;
  min-height: 64px;
  margin-top: 18px;
  font-size: 24px;
  background: var(--lime);
  padding: 14px 24px;
}

@keyframes pulse { 50% { transform: scale(1.06); } }
@keyframes flash { 50% { filter: brightness(1.35); } }
@keyframes marquee {
  0% { transform: translateX(0); }
  100% { transform: translateX(-100%); }
}
@keyframes puff {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}
@keyframes wag {
  0%, 100% { transform: rotate(-8deg); }
  50% { transform: rotate(6deg); }
}

.ctrl-touch, .hint-touch { display: none; }
body.touch-on .ctrl-kb, body.touch-on .hint-kb { display: none; }
body.touch-on .ctrl-touch, body.touch-on .hint-touch { display: block; }
body.touch-on .controls { grid-template-columns: 1fr; }

img {
  -webkit-user-drag: none;
  user-drag: none;
}

#touch-controls {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}
body.touch-on[data-state="play"] #touch-controls,
body.touch-on[data-state="intro"] #touch-controls {
  display: block;
}

.touch-stick {
  pointer-events: auto;
  position: absolute;
  left: max(4px, env(safe-area-inset-left, 0px));
  bottom: max(8px, env(safe-area-inset-bottom, 0px));
  width: min(176px, 46vmin);
  height: min(176px, 46vmin);
  touch-action: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
}
.stick-base {
  position: relative;
  width: 78%;
  height: 78%;
  border-radius: 50%;
  border: 5px solid var(--yellow);
  background: rgba(26, 46, 20, 0.45);
  box-shadow: 5px 5px 0 rgba(200, 255, 61, 0.4), inset 0 0 0 3px var(--ink);
}
.stick-cross {
  position: absolute;
  inset: 18%;
  border-radius: 50%;
  border: 2px dashed rgba(255, 246, 224, 0.35);
  pointer-events: none;
}
.stick-cross::before,
.stick-cross::after {
  content: "";
  position: absolute;
  background: rgba(255, 225, 74, 0.28);
  pointer-events: none;
}
.stick-cross::before {
  left: 50%;
  top: 8%;
  bottom: 8%;
  width: 3px;
  transform: translateX(-50%);
}
.stick-cross::after {
  top: 50%;
  left: 8%;
  right: 8%;
  height: 3px;
  transform: translateY(-50%);
}
.stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46%;
  height: 46%;
  margin: -23% 0 0 -23%;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #c8ff3d, #3aaa3a 62%, #1f6b28);
  border: 4px solid var(--ink);
  box-shadow: 0 5px 0 var(--yellow), 0 0 12px rgba(200, 255, 61, 0.55);
  pointer-events: none;
}
.stick-label {
  margin-top: 4px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--yellow);
  text-shadow: 2px 2px 0 var(--ink);
  pointer-events: none;
}
.touch-stick.is-held .stick-base {
  background: rgba(26, 46, 20, 0.65);
  box-shadow: 5px 5px 0 var(--lime), inset 0 0 0 3px var(--ink);
}

.touch-pull {
  pointer-events: auto;
  position: absolute;
  right: max(10px, env(safe-area-inset-right, 0px));
  bottom: max(16px, env(safe-area-inset-bottom, 0px));
  width: min(118px, 30vmin);
  height: min(118px, 30vmin);
  border-radius: 50%;
  border: 5px solid var(--ink);
  background: radial-gradient(circle at 30% 28%, #e0ff8a, var(--lime) 55%, #7ab80a);
  color: var(--ink);
  font-family: inherit;
  font-size: clamp(16px, 4.2vmin, 22px);
  font-weight: 900;
  letter-spacing: 1px;
  line-height: 1.05;
  box-shadow: 0 0 0 4px var(--yellow), 6px 6px 0 var(--ink), 0 0 18px rgba(200, 255, 61, 0.55);
  touch-action: none;
  cursor: pointer;
  transform: rotate(-8deg);
  animation: pulse 0.9s ease-in-out infinite;
  text-shadow: 1px 1px 0 #fff;
}
.touch-pull.is-held,
.touch-pull:active {
  transform: rotate(-8deg) scale(0.94);
  background: var(--pink);
  color: #fff;
  animation: none;
}

.touch-pause {
  pointer-events: auto;
  position: absolute;
  right: max(14px, env(safe-area-inset-right, 0px));
  bottom: calc(max(16px, env(safe-area-inset-bottom, 0px)) + min(118px, 30vmin) + 10px);
  min-width: 72px;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 4px solid var(--ink);
  background: rgba(255, 225, 74, 0.82);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 1px;
  box-shadow: 4px 4px 0 var(--neon);
  touch-action: manipulation;
  cursor: pointer;
  transform: rotate(4deg);
}
.touch-pause:active {
  background: var(--lime);
  transform: rotate(4deg) translate(1px, 1px);
}

@media (max-width: 820px) {
  .title-hero {
    flex-direction: column;
    gap: 14px;
    padding: 64px 20px 40px;
  }
  .title-art-wrap { width: min(150px, 40vw); }
  .title-card {
    max-width: 92%;
    padding: 18px 22px 14px;
  }
  .title-card h1 { font-size: 40px; }
  .controls { font-size: 11px; }
}

@media (orientation: portrait) {
  #game {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: max(100%, calc(var(--app-h, 100dvh) * 16 / 9));
    height: max(100%, calc(var(--app-w, 100vw) * 9 / 16));
    max-width: none;
    max-height: none;
    box-shadow: none;
  }
  #hud-score { min-width: 0; width: min(46vw, 280px); top: max(8px, env(safe-area-inset-top, 0px)); }
  #score-value { font-size: clamp(28px, 8vw, 44px); -webkit-text-stroke: 3px var(--ink); }
  #score-label { font-size: 11px; letter-spacing: 2px; }
  #intro-banner {
    top: max(118px, calc(env(safe-area-inset-top, 0px) + 100px));
    min-width: min(280px, 86vw);
    padding: 6px 12px 10px;
  }
  .intro-title { font-size: 20px; }
  #toast {
    bottom: 32%;
    max-width: 80vw;
    text-align: center;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .touch-stick {
    width: min(128px, 34vmin);
    height: min(128px, 34vmin);
  }
  .touch-pull {
    width: min(88px, 24vmin);
    height: min(88px, 24vmin);
    font-size: 14px;
  }
  .touch-pause {
    bottom: calc(max(8px, env(safe-area-inset-bottom, 0px)) + min(88px, 24vmin) + 8px);
    min-height: 36px;
    font-size: 11px;
  }
  #hud-score { min-width: 180px; }
  #score-value { font-size: 32px; }
  .title-art-wrap { width: min(110px, 22vw); }
  .title-hero { padding: 48px 16px 32px; gap: 12px; }
  .title-card { padding: 10px 16px 10px; }
  .title-card h1 { font-size: 32px; }
  .tagline { font-size: 14px; }
  .marquee { top: 10px; left: 12px; right: 12px; }
}

@media (max-width: 820px), (pointer: coarse) {
  #btn-start, #btn-resume, #btn-again, #btn-restart-pause, #btn-dead-again, #btn-continue {
    min-height: 52px;
    font-size: 18px;
    padding: 12px 22px;
    width: 100%;
    margin-left: 0;
    margin-right: 0;
  }
  button.ghost { margin-left: 0; }
  .panel { padding: 22px 18px; max-width: min(560px, 94vw); }
  .panel h2 { font-size: clamp(26px, 8vw, 40px); }
  .title-hero {
    padding: max(56px, calc(env(safe-area-inset-top, 0px) + 44px)) 16px max(28px, calc(env(safe-area-inset-bottom, 0px) + 20px));
  }
  .marquee {
    top: max(10px, env(safe-area-inset-top, 0px));
    left: max(10px, env(safe-area-inset-left, 0px));
    right: max(10px, env(safe-area-inset-right, 0px));
  }
}

@media (orientation: portrait) and (max-width: 600px) {
  .title-hero {
    flex-direction: column;
    gap: 10px;
    padding-left: 14px;
    padding-right: 14px;
  }
  .title-art-wrap { width: min(140px, 38vw); }
  .title-card { max-width: 100%; padding: 14px 14px 12px; }
  .title-card h1 { font-size: clamp(32px, 11vw, 48px); }
  .controls { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .touch-pull, .marquee span, #score-label, #intro-banner, .art-finger, .art-cloud, .art-burst {
    animation: none;
  }
}

/* rewarded-ad CTA (only shown on portals with rewarded ads; hidden elsewhere) */
#btn-reward-retry, #btn-reward-bonus {
  background: var(--yellow, #ffe14a);
  color: var(--ink, #1a1a1a);
  width: 100%;
  margin-left: 0;
  margin-top: 6px;
  font-size: 18px;
}
#btn-reward-retry:hover, #btn-reward-bonus:hover {
  background: var(--lime, #c8ff3d);
}
#btn-reward-retry.hidden, #btn-reward-bonus.hidden { display: none; }

/* flat title art rendered from the game itself (replaces the CSS hand/cloud drawing) */
.title-art-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
