* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #f5f5f5;
  font-family: Arial, Helvetica, sans-serif;
  color: #171717;
  user-select: none;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 14px 28px;
  font-weight: 800;
  font-size: 18px;
  cursor: pointer;
  background: #111;
  color: white;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

button:active {
  transform: translateY(1px) scale(0.99);
}

#game,
.screen {
  width: 100vw;
  height: 100vh;
}

.hidden {
  display: none !important;
}

#startScreen {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  text-align: center;
  padding: 24px;
}

#startScreen h1 {
  margin: 0;
  font-size: clamp(42px, 8vw, 82px);
  letter-spacing: -2px;
}

#startScreen p {
  margin: 0 0 16px;
  font-size: 18px;
  opacity: 0.75;
}

#gameScreen {
  position: relative;
  background: radial-gradient(circle at center, #ffffff 0%, #f3f3f3 62%, #e9e9e9 100%);
}

#hud {
  position: fixed;
  top: 14px;
  left: 20px;
  right: 20px;
  z-index: 70;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  pointer-events: none;
}

#scoreBox,
#hint {
  font-weight: 950;
  letter-spacing: 1px;
  text-shadow: 0 2px 0 rgba(255,255,255,0.8);
}

#scoreBox {
  font-size: clamp(24px, 2.7vw, 38px);
}

#hint {
  max-width: min(58vw, 820px);
  text-align: right;
  font-size: clamp(26px, 3.2vw, 48px);
  line-height: 1.05;
  opacity: 0.72;
}

#soundBtn {
  position: fixed !important;
  right: 18px !important;
  bottom: 18px !important;
  left: auto !important;
  top: auto !important;
  z-index: 160 !important;

  width: 54px !important;
  height: 54px !important;
  min-width: 54px !important;
  min-height: 54px !important;

  display: grid !important;
  place-items: center !important;
  padding: 0 !important;
  margin: 0 !important;

  border-radius: 999px !important;
  background: rgba(255, 255, 255, 0.88) !important;
  color: #111 !important;
  border: 2px solid rgba(0, 0, 0, 0.14) !important;
  box-shadow: 0 10px 28px rgba(0,0,0,0.16) !important;
  backdrop-filter: blur(8px);

  font-size: 25px !important;
  line-height: 1 !important;
  text-align: center !important;
}

#stage {
  position: relative;
  width: min(100vw, 900px);
  height: 100vh;
  margin: 0 auto;
  overflow: visible;
  touch-action: none;
}

#catLayer {
  position: absolute;
  left: 50%;
  bottom: 54px;
  width: min(86vw, 560px);
  height: min(72vh, 660px);
  transform: translateX(-50%);
}

.cat {
  position: absolute;
  left: 50%;
  bottom: 0;
  max-width: 100%;
  max-height: 100%;
  transform: translateX(-50%);
  pointer-events: none;
  filter: drop-shadow(0 18px 18px rgba(0,0,0,0.08));
}

.cat.normal,
.cat.body {
  height: 100%;
}

.cat-head {
  position: absolute;
  z-index: 4;
  width: 58%;
  left: 54%;
  top: 2%;
  transform: translate(-50%, 0) rotate(-2deg);
  pointer-events: none;
  filter: drop-shadow(0 10px 12px rgba(0,0,0,0.12));
}

.cat-head.lose {
  width: 62%;
  top: -1%;
}

#comb {
  position: fixed;
  z-index: 80;
  width: 120px;
  left: 54vw;
  top: 62vh;
  transform: translate(-50%, -50%) rotate(-28deg);
  transform-origin: 70% 80%;
  pointer-events: none;
  filter: drop-shadow(0 8px 8px rgba(0,0,0,0.22));
}

#brushZone {
  position: absolute;
  z-index: 2;
  left: 18%;
  top: 38%;
  width: 42%;
  height: 34%;
  border-radius: 50%;
  pointer-events: none;
}

#darkOverlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: black;
  opacity: 0;
  pointer-events: none;
  transition: opacity 280ms ease;
}

#deathText {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  pointer-events: none;
  text-align: center;
}

#youDied {
  color: #b10000;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(54px, 16vw, 142px);
  font-weight: 900;
  letter-spacing: 4px;
  text-shadow: 0 4px 0 #000, 0 0 24px rgba(255,0,0,0.5);
}

#deathSubtitle {
  color: #eeeeee;
  font-size: clamp(18px, 3.2vw, 38px);
  font-weight: 800;
  letter-spacing: 1px;
  text-shadow: 0 3px 0 #000, 0 0 18px rgba(0,0,0,0.8);
  opacity: 0;
  transform: translateY(-8px);
  animation: subtitleAppear 0.35s ease-out 0.45s forwards;
}

#restartBtn {
  position: fixed;
  left: 50%;
  bottom: 32px;
  z-index: 130;
  transform: translateX(-50%);
  background: #b10000;
}

.warning #catLayer {
  animation: tinyShake 0.11s infinite;
}

.stare #catHeadStare {
  animation: starePop 0.22s ease-out both;
}

.attack #stage {
  animation: screenShake 0.055s infinite;
}

.attack #catHeadLose,
.game-over #catHeadLose {
  position: fixed;
  z-index: 100;
  left: 50%;
  top: 50%;
  width: 230vw;
  max-width: none;
  transform: translate(-50%, -50%) rotate(1deg);
}

.attack #catHeadLose {
  animation: catAttackFull 0.58s cubic-bezier(.10,.88,.10,1) forwards;
}

.game-over #catHeadLose {
  animation: none;
}

.brushing #catLayer {
  animation: brushWiggle 0.12s infinite;
}

@keyframes tinyShake {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(calc(-50% + 2px)) translateY(1px); }
}

@keyframes brushWiggle {
  0%, 100% { transform: translateX(-50%) rotate(0deg); }
  50% { transform: translateX(-50%) rotate(-0.8deg); }
}

@keyframes starePop {
  0% { transform: translate(-50%, 0) scale(0.35) rotate(-8deg); opacity: 0; }
  70% { transform: translate(-50%, 0) scale(1.08) rotate(-2deg); opacity: 1; }
  100% { transform: translate(-50%, 0) scale(1) rotate(-2deg); opacity: 1; }
}

@keyframes screenShake {
  0% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(7px, -5px) rotate(0.7deg); }
  50% { transform: translate(-7px, 4px) rotate(-0.7deg); }
  75% { transform: translate(5px, 7px) rotate(0.4deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

@keyframes catAttackFull {
  0% {
    left: 54%;
    top: 30%;
    width: min(46vw, 430px);
    transform: translate(-50%, -50%) scale(0.8) rotate(-7deg);
    opacity: 1;
  }

  16% {
    left: 54%;
    top: 30%;
    width: min(38vw, 350px);
    transform: translate(-50%, -50%) scale(0.72) rotate(-11deg);
  }

  55% {
    left: 50%;
    top: 47%;
    width: 140vw;
    transform: translate(-50%, -50%) scale(1) rotate(4deg);
  }

  100% {
    left: 50%;
    top: 50%;
    width: 230vw;
    transform: translate(-50%, -50%) scale(1) rotate(1deg);
  }
}

@keyframes subtitleAppear {
  to {
    opacity: 0.92;
    transform: translateY(0);
  }
}

@media (max-width: 520px) {
  #catLayer {
    width: 96vw;
    bottom: 72px;
  }

  #comb {
    width: 98px;
  }

  #hud {
    top: 10px;
    left: 12px;
    right: 12px;
  }

  #hint {
    font-size: clamp(20px, 6vw, 34px);
    max-width: 62vw;
  }

  #scoreBox {
    font-size: clamp(18px, 5.5vw, 30px);
  }

  #soundBtn {
    right: 12px !important;
    bottom: 12px !important;
    width: 50px !important;
    height: 50px !important;
    min-width: 50px !important;
    min-height: 50px !important;
    font-size: 23px !important;
  }
}

/* v20 mobile stare sprite fix only.
   Keep the old death animation. Only make cat_head_stare.png behave like
   a full-cat replacement sprite during STARE. */

.stare #catNormal,
.stare #catBody {
  display: none !important;
}

.stare #catHeadStare {
  position: absolute !important;
  z-index: 4 !important;
  left: 50% !important;
  right: auto !important;
  top: auto !important;
  bottom: 0 !important;

  width: auto !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;

  transform: translateX(-50%) !important;
  object-fit: contain !important;
  pointer-events: none !important;
  filter: drop-shadow(0 18px 18px rgba(0,0,0,0.08)) !important;
  animation: stareFullSpriteFixV20 0.22s ease-out both !important;
}

@keyframes stareFullSpriteFixV20 {
  0% {
    transform: translateX(-50%) scale(0.94) rotate(-2deg);
    opacity: 0.2;
  }

  70% {
    transform: translateX(-50%) scale(1.04) rotate(1deg);
    opacity: 1;
  }

  100% {
    transform: translateX(-50%) scale(1) rotate(0deg);
    opacity: 1;
  }
}

/* v30 full-cat stare image.
   Stare now uses assets/images/cat_stare_full.png directly.
   The old cat_head_stare.png / cat_body.png split is removed. */

.cat.stare-full {
  position: absolute;
  left: 50%;
  bottom: 0;
  height: 100%;
  width: auto;
  max-width: 100%;
  max-height: 100%;
  transform: translateX(-50%);
  pointer-events: none;
  object-fit: contain;
  filter: drop-shadow(0 18px 18px rgba(0,0,0,0.08));
}

.stare #catStareFull {
  animation: stareFullPopV30 0.22s ease-out both;
}

@keyframes stareFullPopV30 {
  0% {
    transform: translateX(-50%) scale(0.94) rotate(-2deg);
    opacity: 0.2;
  }

  70% {
    transform: translateX(-50%) scale(1.04) rotate(1deg);
    opacity: 1;
  }

  100% {
    transform: translateX(-50%) scale(1) rotate(0deg);
    opacity: 1;
  }
}

