:root {
  --candy-pink: #ff6b9d;
  --candy-yellow: #ffd166;
  --candy-green: #7ae582;
  --candy-blue: #4cc9f0;
  --candy-purple: #c77dff;
  --ink: #20140e;
  --wood-hi: #6b4a30;
  --panel: rgba(24, 14, 10, 0.72);
  --stroke-warm: rgba(255, 224, 178, 0.25);
}

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

html,
body {
  height: 100%;
  overflow: hidden;
  background: #2a1d14;
  font-family:
    'Trebuchet MS',
    'Segoe UI',
    system-ui,
    -apple-system,
    sans-serif;
  color: #fff7ea;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}

#app {
  position: fixed;
  inset: 0;
}

#game {
  position: absolute;
  inset: 0;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

.hidden {
  display: none !important;
}

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

.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.score-box {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: 18px;
  text-align: left;
}

.score-num {
  font-size: clamp(34px, 6vw, 54px);
  font-weight: 900;
  line-height: 1;
  color: #ffe9c2;
  text-shadow:
    0 3px 0 #5a3016,
    0 6px 12px rgba(0, 0, 0, 0.55);
}

.score-num.tick {
  animation: score-tick 0.28s cubic-bezier(0.2, 1.8, 0.4, 1);
}

@keyframes score-tick {
  0% {
    transform: scale(1);
  }
  35% {
    transform: scale(1.22);
  }
  100% {
    transform: scale(1);
  }
}

.hud-best {
  font-size: clamp(13px, 2.4vw, 17px);
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--candy-yellow);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
  margin-top: 2px;
}

.lives {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: calc(64px + env(safe-area-inset-right));
  display: flex;
  gap: 8px;
}

.life-slot {
  width: clamp(26px, 6vw, 36px);
  aspect-ratio: 1;
}

.life-slot svg {
  width: 100%;
  height: 100%;
}

.life-slot .lx {
  stroke: rgba(255, 240, 220, 0.5);
  stroke-width: 7.5;
  stroke-linecap: round;
  fill: none;
  stroke-dasharray: 40;
  stroke-dashoffset: 0;
  transition: stroke 0.2s;
}

.life-slot.lost .lx {
  stroke: #ff4438;
  filter: drop-shadow(0 0 6px rgba(255, 60, 50, 0.9));
}

.life-slot .lx.drawn {
  animation: x-slash-in 0.42s cubic-bezier(0.3, 1.6, 0.4, 1) both;
}

.life-slot .lx2.drawn {
  animation-delay: 0.12s;
}

@keyframes x-slash-in {
  from {
    stroke-dashoffset: 40;
  }
  to {
    stroke-dashoffset: 0;
  }
}

.lives.shake-lives {
  animation: lives-shake 0.4s;
}

@keyframes lives-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-4px);
  }
  55% {
    transform: translateX(5px);
  }
  80% {
    transform: translateX(-2px);
  }
}

.btn-row {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.icon-btn {
  width: clamp(38px, 8vw, 46px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid var(--stroke-warm);
  background: rgba(20, 10, 6, 0.55);
  color: #ffe9c2;
  cursor: pointer;
  display: grid;
  place-items: center;
  backdrop-filter: blur(3px);
  transition: transform 0.12s;
}

.icon-btn:hover {
  transform: scale(1.08);
}

.icon-btn:active {
  transform: scale(0.94);
}

.icon-btn svg {
  width: 60%;
  height: 60%;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.key-hint {
  position: absolute;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 10, 6, 0.66);
  border: 1px solid var(--stroke-warm);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: clamp(11px, 2.6vw, 14px);
  z-index: 6;
  white-space: nowrap;
}

.kbd {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 6px;
  border: 1px solid rgba(255, 236, 200, 0.5);
  border-bottom-width: 3px;
  background: rgba(60, 36, 20, 0.85);
  font-weight: 800;
  font-size: 0.82em;
}

/* --------------------------------------------------------- fx layer */

.fx-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 4;
}

.combo-pop {
  position: absolute;
  transform: translate(-50%, -50%);
  font-weight: 900;
  font-size: clamp(20px, 4.6vw, 34px);
  letter-spacing: 0.04em;
  color: var(--pop-color, var(--candy-yellow));
  -webkit-text-stroke: 1.5px rgba(45, 18, 8, 0.9);
  text-shadow:
    0 0 14px var(--pop-color),
    0 3px 0 rgba(45, 18, 8, 0.9),
    0 6px 14px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
  animation:
    combo-pop-bounce 0.62s cubic-bezier(0.68, -0.6, 0.27, 1.65) both,
    combo-pop-drift 1.5s ease-out both,
    combo-pop-fade 1.5s ease-in both;
}

.combo-bonus {
  text-align: center;
  font-size: 0.82em;
  color: #ffffff;
  -webkit-text-stroke: 0;
  margin-top: 2px;
}

/* the one place elastic bounce is allowed: combo popups */
@keyframes combo-pop-bounce {
  0% {
    transform: translate(-50%, -50%) scale(0.15) rotate(-7deg);
    opacity: 0;
  }
  55% {
    transform: translate(-50%, -50%) scale(1.24) rotate(2deg);
    opacity: 1;
  }
  74% {
    transform: translate(-50%, -50%) scale(0.92) rotate(-1deg);
  }
  86% {
    transform: translate(-50%, -50%) scale(1.06) rotate(0.4deg);
  }
  100% {
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
  }
}

@keyframes combo-pop-drift {
  to {
    transform: translate(-50%, -78%) scale(1.02);
  }
}

@keyframes combo-pop-fade {
  0%,
  62% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.score-float {
  position: absolute;
  transform: translate(-50%, -50%);
  font-weight: 900;
  color: #ffd166;
  font-size: clamp(16px, 3vw, 22px);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.7);
  animation: float-up 0.8s ease-out both;
}

@keyframes float-up {
  from {
    transform: translate(-50%, -50%);
    opacity: 1;
  }
  to {
    transform: translate(-50%, -190%);
    opacity: 0;
  }
}

.banner {
  position: absolute;
  top: 22%;
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(38px, 9vw, 84px);
  font-weight: 900;
  letter-spacing: 0.06em;
  color: var(--candy-pink);
  -webkit-text-stroke: 2px rgba(40, 12, 6, 0.95);
  text-shadow:
    0 0 26px rgba(255, 107, 157, 0.75),
    0 5px 0 rgba(40, 12, 6, 0.95),
    0 10px 26px rgba(0, 0, 0, 0.6);
  z-index: 7;
}

.banner.animate-in {
  animation: banner-slam 0.42s cubic-bezier(0.17, 0.89, 0.32, 1.28) both;
}

@keyframes banner-slam {
  from {
    transform: translateX(-50%) scale(2.4);
    opacity: 0;
  }
  to {
    transform: translateX(-50%) scale(1);
    opacity: 1;
  }
}

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

.screen {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 10;
}

.screen button {
  pointer-events: auto;
}

.toybox-scatter {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.scatter-doodle {
  position: absolute;
  transform: translate(-50%, -50%);
  opacity: 0.85;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.45));
  animation: doodle-settle 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

.scatter-doodle:nth-child(odd) {
  animation-delay: 0.06s;
}
.scatter-doodle:nth-child(3n) {
  animation-delay: 0.12s;
}

@keyframes doodle-settle {
  from {
    opacity: 0;
    scale: 0.2;
    rotate: -30deg;
  }
}

.menu-inner {
  text-align: center;
  pointer-events: none;
  max-width: min(92vw, 720px);
  /* keep the whole card clear of the slice-to-start melon below */
  transform: translateY(-7vh);
}

.title-kicker {
  font-size: clamp(10px, 2.4vw, 14px);
  letter-spacing: 0.42em;
  font-weight: 700;
  color: var(--candy-yellow);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
  margin-bottom: 6px;
}

.title-wrap {
  margin-bottom: 8px;
}

.title {
  font-family: 'Arial Rounded MT Bold', 'Trebuchet MS', 'Segoe UI', sans-serif;
  font-weight: 900;
  font-size: clamp(52px, 13vw, 128px);
  line-height: 0.88;
  letter-spacing: 0.01em;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* juicy carved lettering: gradient flesh + deep rind shadow stack */
  background: linear-gradient(180deg, #ffe07d 0%, #ffb340 42%, #ff7847 58%, #ef476f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 0 #7a2a12) drop-shadow(0 5px 0 #57190c) drop-shadow(0 12px 22px rgba(0, 0, 0, 0.65));
  transform: rotate(-2.2deg);
}

.title .title-ninja {
  font-size: 1.04em;
  transform: rotate(1.6deg) translateY(2px);
  background: linear-gradient(180deg, #b7f48b 0%, #63c96b 45%, #2e8f4e 70%, #1f6b3c 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  font-size: clamp(15px, 3.4vw, 21px);
  font-weight: 700;
  color: #ffefd2;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.85);
  margin-bottom: 18px;
}

.start-btn {
  pointer-events: auto;
  border: none;
  cursor: pointer;
  font: inherit;
  color: #fff;
  padding: 14px 42px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ff8a5c, #ef476f);
  box-shadow:
    0 5px 0 #9c2140,
    0 12px 24px rgba(0, 0, 0, 0.5);
  transition:
    transform 0.1s,
    box-shadow 0.1s;
  display: inline-flex;
  flex-direction: column;
  gap: 1px;
}

.start-btn:hover {
  filter: brightness(1.07);
}

.start-btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #9c2140, 0 6px 14px rgba(0, 0, 0, 0.5);
}

.start-label {
  font-weight: 900;
  font-size: clamp(20px, 4.4vw, 28px);
  letter-spacing: 0.12em;
}

.start-sub {
  font-size: clamp(10px, 2.2vw, 13px);
  opacity: 0.9;
  letter-spacing: 0.08em;
}

.controls-note {
  margin-top: 22px;
  font-size: clamp(11px, 2.6vw, 14px);
  line-height: 1.7;
  color: rgba(255, 240, 216, 0.92);
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.85);
}

/* pause + gameover cards */

.pause-overlay,
.gameover-screen {
  background: rgba(12, 6, 4, 0.55);
  backdrop-filter: blur(4px);
}

.pause-title {
  font-size: clamp(40px, 9vw, 76px);
  font-weight: 900;
  letter-spacing: 0.18em;
  text-shadow: 0 4px 0 rgba(30, 10, 5, 0.9), 0 10px 24px rgba(0, 0, 0, 0.6);
  grid-row: 1;
}

.pause-overlay {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 22px;
}

.resume-btn {
  pointer-events: auto;
  font: inherit;
  font-weight: 900;
  letter-spacing: 0.1em;
  color: #fff;
  padding: 12px 40px;
  font-size: clamp(16px, 3.6vw, 22px);
  border-radius: 999px;
  border: none;
  cursor: pointer;
  background: linear-gradient(180deg, #57cc99, #2e9e6b);
  box-shadow: 0 5px 0 #175539, 0 12px 22px rgba(0, 0, 0, 0.45);
}

.resume-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #175539;
}

.pause-note {
  color: rgba(255, 240, 216, 0.85);
  font-size: clamp(12px, 2.6vw, 15px);
}

.go-card {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: clamp(22px, 5vw, 44px) clamp(30px, 8vw, 84px);
  background: var(--panel);
  border: 2px solid var(--stroke-warm);
  border-radius: 26px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  animation: card-in 0.45s cubic-bezier(0.22, 1.2, 0.36, 1) both;
}

@keyframes card-in {
  from {
    transform: translateY(34px) scale(0.94);
    opacity: 0;
  }
}

.go-kicker {
  font-size: clamp(26px, 6vw, 44px);
  font-weight: 900;
  letter-spacing: 0.22em;
  color: var(--candy-blue);
  text-shadow: 0 0 18px rgba(76, 201, 240, 0.55), 0 3px 0 rgba(10, 20, 26, 0.8);
}

.go-score {
  font-size: clamp(58px, 13vw, 110px);
  font-weight: 900;
  line-height: 1;
  color: #ffe9c2;
  text-shadow: 0 4px 0 #5a3016, 0 10px 26px rgba(0, 0, 0, 0.6);
}

.go-best-row {
  display: flex;
  gap: 6px;
  align-items: baseline;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--candy-yellow);
  font-size: clamp(15px, 3.4vw, 21px);
}

.go-best-label {
  opacity: 0.85;
}

.new-best-tag {
  background: linear-gradient(180deg, #ffe07d, #ff8fa3);
  color: #6b1220;
  font-weight: 900;
  letter-spacing: 0.14em;
  font-size: clamp(12px, 2.8vw, 16px);
  padding: 4px 16px;
  border-radius: 999px;
  box-shadow: 0 3px 10px rgba(255, 143, 163, 0.4);
  animation: best-glow 1.1s ease-in-out infinite alternate;
}

@keyframes best-glow {
  from {
    filter: brightness(1);
  }
  to {
    filter: brightness(1.18);
  }
}

.go-btns {
  display: flex;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.again-btn,
.menu-btn {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 999px;
  padding: 12px 32px;
  font-weight: 900;
  letter-spacing: 0.1em;
  font-size: clamp(14px, 3.2vw, 19px);
  color: #fff;
  transition: transform 0.1s;
}

.again-btn {
  background: linear-gradient(180deg, #ff8a5c, #ef476f);
  box-shadow: 0 5px 0 #9c2140, 0 10px 20px rgba(0, 0, 0, 0.45);
}

.menu-btn.ghost {
  background: transparent;
  border: 2px solid var(--stroke-warm);
  color: #ffe9c2;
  font-weight: 700;
}

.again-btn:hover,
.menu-btn:hover {
  transform: scale(1.05);
}

.again-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #9c2140;
}

.go-hint {
  color: rgba(255, 240, 216, 0.6);
  font-size: clamp(11px, 2.4vw, 13px);
}

@media (max-width: 560px) {
  .controls-note br {
    display: none;
  }
  .key-hint {
    font-size: 10px;
  }
  .life-slot {
    width: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .combo-pop,
  .banner.animate-in,
  .scatter-doodle,
  .score-num.tick {
    animation-duration: 0.01s !important;
    animation-iteration-count: 1 !important;
  }
}
