:root {
  --bg: #170812;
  --bg2: #2a0f1e;
  --pink: #ff4d8d;
  --pink-soft: #ff86b3;
  --cream: #ffe9f1;
  --card: #24101c;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow-x: hidden;
}

body {
  font-family: "Baloo 2", system-ui, sans-serif;
  color: var(--cream);
  background:
    radial-gradient(1200px 600px at 50% -10%, #3a1226 0%, transparent 60%),
    linear-gradient(160deg, var(--bg) 0%, var(--bg2) 100%);
  min-height: 100dvh;
  user-select: none;
}

#app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
}

/* ---------- Üst bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 4px 8px;
}
.brand {
  font-weight: 800;
  font-size: 26px;
  letter-spacing: -0.5px;
  color: var(--cream);
}
.brand span { color: var(--pink); }

.counter {
  background: rgba(255, 77, 141, 0.15);
  border: 1px solid rgba(255, 77, 141, 0.4);
  border-radius: 999px;
  padding: 6px 14px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.counter-num { font-size: 20px; font-weight: 800; color: var(--pink-soft); }
.counter-label { font-size: 11px; opacity: 0.7; }

/* Oyun ekranındayken üst barı gizle, sayacı köşeye al */
#app.in-game .topbar { display: none; }
/* Sabit yükseklik: flex çocukları viewport'a göre paylaşsın, taşma olmasın */
#app.in-game {
  height: 100dvh;
  overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}
.photo-wrap .counter {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 6;
  padding: 4px 12px;
  background: rgba(20, 4, 10, 0.6);
  backdrop-filter: blur(4px);
}

/* ---------- EKRAN 1: Seçim ---------- */
.select-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 4px 40px;
}
.select-title {
  font-size: 28px;
  font-weight: 800;
  margin: 8px 0 4px;
  text-align: center;
}
.select-sub {
  margin: 0 0 22px;
  opacity: 0.7;
  font-size: 15px;
}
.photo-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  width: 100%;
}
.photo-card {
  position: relative;
  border: 0;
  padding: 0;
  border-radius: 18px;
  overflow: hidden;
  aspect-ratio: 3 / 4;
  cursor: pointer;
  background: #120309;
  box-shadow: var(--shadow);
  border: 3px solid rgba(255, 255, 255, 0.08);
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.photo-card:active { transform: scale(0.96); }
.photo-card:hover { border-color: var(--pink); }
.photo-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.photo-card-name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  text-align: center;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
}

/* ---------- Sahne (oyun, tam ekran) ---------- */
.game {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 4px 0 12px;
}

/* ---------- Üstteki kedi sahnesi ---------- */
.cat-stage {
  position: relative;
  width: 100%;
  max-width: 420px;
  height: 92px;
  flex: none;
  margin-top: 2px;
}
.cat {
  position: absolute;
  bottom: 0;
  width: 82px;
  height: 96px;
  transition: transform 0.4s cubic-bezier(.34,1.2,.64,1);
  will-change: transform;
}
.cat-male { left: 4%; }
.cat-female { right: 4%; }
.cat { overflow: visible; }

/* Sarılma kolları */
.hug-arms {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%) scale(0.9);
  width: 116px;
  height: 58px;
  z-index: 4;
  opacity: 0;
  transition: opacity 0.3s ease 0.25s, transform 0.3s ease 0.25s;
  pointer-events: none;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.25));
}
.cat-stage.hug .hug-arms { opacity: 1; transform: translateX(-50%) scale(1); }

/* öpüşme/sarılma anı: gözler kapanır, yanaklar kızarır */
.eyes-shut { opacity: 0; }
.eyes-open { opacity: 1; }
.cat-stage.hug .eyes-open { opacity: 0; }
.cat-stage.hug .eyes-shut { opacity: 1; }
.blush { opacity: 0; transition: opacity 0.4s ease; }
.cat-stage.hug .blush { opacity: 0.8; }

/* kuyruk sallama */
.tail { transform-origin: 78% 82%; animation: tailWag 1.6s ease-in-out infinite; }
.cat-female .tail { transform-origin: 22% 82%; animation-delay: 0.4s; }
@keyframes tailWag {
  0%, 100% { transform: rotate(-6deg); }
  50% { transform: rotate(10deg); }
}

/* kalpler (sarılınca üstlerinden çıkar) */
.hearts {
  position: absolute;
  left: 50%;
  top: -8px;
  transform: translateX(-50%);
  width: 130px;
  height: 70px;
  pointer-events: none;
  z-index: 2;
}
.heart {
  position: absolute;
  bottom: 0;
  opacity: 0;
  color: #ff5d8f;
  font-size: 20px;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.3));
}
.heart:nth-child(1) { left: 8%; }
.heart:nth-child(2) { left: 28%; font-size: 26px; }
.heart:nth-child(3) { left: 48%; font-size: 18px; }
.heart:nth-child(4) { left: 66%; font-size: 24px; }
.heart:nth-child(5) { left: 84%; font-size: 16px; }
.cat-stage.hug .heart { animation: floatUp 1.7s ease-out infinite; }
.cat-stage.hug .heart:nth-child(2) { animation-delay: 0.25s; }
.cat-stage.hug .heart:nth-child(3) { animation-delay: 0.5s; }
.cat-stage.hug .heart:nth-child(4) { animation-delay: 0.75s; }
.cat-stage.hug .heart:nth-child(5) { animation-delay: 1s; }
@keyframes floatUp {
  0% { opacity: 0; transform: translateY(0) scale(.4) rotate(-8deg); }
  20% { opacity: 1; transform: translateY(-14px) scale(1.1) rotate(4deg); }
  100% { opacity: 0; transform: translateY(-58px) scale(.85) rotate(-6deg); }
}

/* Konuşma balonu */
.bubble {
  position: relative;
  background: var(--cream);
  color: #3a1226;
  border-radius: 20px;
  padding: 14px 20px;
  max-width: 90%;
  text-align: center;
  font-weight: 600;
  font-size: 18px;
  box-shadow: var(--shadow);
  animation: pop 0.35s ease;
}
.bubble::after {
  content: "";
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  border: 12px solid transparent;
  border-top-color: var(--cream);
  border-bottom: 0;
}
.bubble { flex: none; }
.bubble.soft { background: #ffdcec; }
.bubble.soft::after { border-top-color: #ffdcec; }
.bubble p { margin: 0; }

@keyframes pop {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Fotoğraf sarmalayıcı (tam ekranda kalan alanı doldurur) */
.photo-wrap {
  position: relative;
  width: 100%;
  max-width: 420px;
  flex: 1;
  min-height: 0;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 4px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  touch-action: manipulation;
  background: #120309;
}
.photo-wrap:active { transform: scale(0.99); }
.photo-wrap.shake { animation: shake 0.4s cubic-bezier(.36,.07,.19,.97); }

@keyframes shake {
  10%, 90% { transform: translate(-2px, 1px) rotate(-1deg); }
  20%, 80% { transform: translate(4px, -2px) rotate(1.5deg); }
  30%, 50%, 70% { transform: translate(-7px, 2px) rotate(-2deg); }
  40%, 60% { transform: translate(7px, -1px) rotate(2deg); }
}

#faceImg {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

/* Hasar (SVG) katmanı */
.damage-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.damage-layer > * {
  opacity: 0;
  transition: opacity 0.5s ease;
}
.damage-layer > *.show { opacity: 1; }

/* Kızarma tonu tüm surata */
.photo-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 55%, rgba(255, 40, 60, 0.0), transparent 70%);
  pointer-events: none;
  transition: background 0.5s ease;
}
.photo-wrap[data-red="1"]::after { background: radial-gradient(circle at 50% 55%, rgba(255,40,60,.18), transparent 72%); }
.photo-wrap[data-red="2"]::after { background: radial-gradient(circle at 50% 55%, rgba(255,30,50,.32), transparent 78%); }
.photo-wrap[data-red="3"]::after { background: radial-gradient(circle at 50% 55%, rgba(210,20,60,.45), transparent 85%); }

/* Sol / sağ dokunma bölgeleri */
.hit-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  border: 0;
  background: transparent;
  cursor: pointer;
  z-index: 3;
}
.hit-zone.left { left: 0; }
.hit-zone.right { right: 0; }
.hit-zone:active { background: rgba(255, 255, 255, 0.06); }

/* Eller (sol/sağ) */
.hand {
  position: absolute;
  top: 42%;
  font-size: 90px;
  opacity: 0;
  pointer-events: none;
  filter: drop-shadow(0 6px 8px rgba(0,0,0,.4));
  z-index: 4;
}
.hand-left { left: 8%; }
.hand-right { right: 8%; }
.hand-left.go { animation: slapFromLeft 0.4s ease-out; }
.hand-right.go { animation: slapFromRight 0.4s ease-out; }

@keyframes slapFromLeft {
  0% { transform: translate(-120%, -20%) rotate(-35deg) scale(0.6); opacity: 0; }
  40% { transform: translate(40%, -10%) rotate(10deg) scale(1.15); opacity: 1; }
  100% { transform: translate(120%, 0) rotate(30deg) scale(0.9); opacity: 0; }
}
@keyframes slapFromRight {
  0% { transform: translate(120%, -20%) rotate(35deg) scale(0.6); opacity: 0; }
  40% { transform: translate(-40%, -10%) rotate(-10deg) scale(1.15); opacity: 1; }
  100% { transform: translate(-120%, 0) rotate(-30deg) scale(0.9); opacity: 0; }
}

/* Vuruş kıvılcımı */
.spark {
  position: absolute;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 54px;
  opacity: 0;
  pointer-events: none;
  z-index: 5;
}
.spark.go { animation: spark 0.45s ease-out; }
@keyframes spark {
  0% { opacity: 0; transform: translate(-50%,-50%) scale(0.3); }
  30% { opacity: 1; transform: translate(-50%,-50%) scale(1.2); }
  100% { opacity: 0; transform: translate(-50%,-50%) scale(1.6); }
}

/* ---------- Sansürlü küfür ---------- */
.curse {
  position: absolute;
  left: 50%;
  top: 30%;
  transform: translate(-50%, -50%);
  font-family: "Baloo 2", sans-serif;
  font-weight: 800;
  font-size: 46px;
  color: #ff3b3b;
  text-shadow: 0 2px 0 #fff, 0 0 10px rgba(0,0,0,.5);
  opacity: 0;
  pointer-events: none;
  z-index: 7;
  letter-spacing: 2px;
}
.curse.go { animation: cursePop 0.7s ease-out; }
@keyframes cursePop {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.4) rotate(-10deg); }
  25% { opacity: 1; transform: translate(-50%, -55%) scale(1.15) rotate(6deg); }
  100% { opacity: 0; transform: translate(-50%, -110%) scale(1) rotate(-4deg); }
}

/* ---------- Şişe fırlatma efektleri ---------- */
.photo-wrap { --hit-x: 50%; --hit-y: 30%; }

.bottle {
  position: absolute;
  left: -70px;
  top: 60%;
  width: 52px;
  height: auto;
  opacity: 0;
  transform-origin: 50% 50%;
  pointer-events: none;
  z-index: 8;
}
.photo-wrap.throwing .bottle { animation: fly 0.62s cubic-bezier(.3,.1,.7,1) forwards; }
@keyframes fly {
  0%   { opacity: 1; left: -70px; top: 70%; transform: rotate(-20deg); }
  70%  { opacity: 1; }
  100% { opacity: 1; left: calc(var(--hit-x) - 26px); top: calc(var(--hit-y) - 18px); transform: rotate(320deg); }
}

.flash {
  position: absolute;
  left: var(--hit-x); top: var(--hit-y);
  width: 150px; height: 150px; margin: -75px 0 0 -75px;
  border-radius: 50%; opacity: 0; pointer-events: none; z-index: 8;
  background: radial-gradient(circle, #fff 0%, rgba(255,240,150,.85) 35%, transparent 70%);
}
.photo-wrap.throwing .flash { animation: flashPop 0.45s ease-out 0.62s forwards; }
@keyframes flashPop {
  0% { opacity: 0; transform: scale(.2); }
  25% { opacity: 1; transform: scale(1.05); }
  100% { opacity: 0; transform: scale(1.4); }
}

.impact-lines {
  position: absolute;
  left: var(--hit-x); top: var(--hit-y);
  width: 160px; height: 160px; margin: -80px 0 0 -80px;
  opacity: 0; pointer-events: none; z-index: 8;
}
.photo-wrap.throwing .impact-lines { animation: linesPop 0.4s ease-out 0.62s forwards; }
@keyframes linesPop {
  0% { opacity: 0; transform: scale(.5); }
  30% { opacity: .95; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.25); }
}

.shards { position: absolute; left: var(--hit-x); top: var(--hit-y); width: 0; height: 0; pointer-events: none; z-index: 8; }
.shard {
  position: absolute; width: 9px; height: 14px; opacity: 0;
  background: linear-gradient(150deg, #bfe6d8, #6fae9b);
  clip-path: polygon(50% 0, 100% 70%, 55% 100%, 0 60%);
}
.photo-wrap.throwing .shard { animation: shardFly 0.75s ease-out 0.62s forwards; }
.shard:nth-child(1){ --dx:-70px; --dy:-46px; --rot:-160deg; }
.shard:nth-child(2){ --dx: 66px; --dy:-52px; --rot: 190deg; }
.shard:nth-child(3){ --dx:-52px; --dy: 40px; --rot:-120deg; }
.shard:nth-child(4){ --dx: 58px; --dy: 34px; --rot: 140deg; }
.shard:nth-child(5){ --dx:  6px; --dy:-72px; --rot: 220deg; }
.shard:nth-child(6){ --dx:-16px; --dy: 64px; --rot:-200deg; }
@keyframes shardFly {
  0%   { opacity: 1; transform: translate(0,0) rotate(0) scale(.5); }
  70%  { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx),var(--dy)) rotate(var(--rot)) scale(1); }
}

/* Şişe butonu */
.bottle-btn {
  background: linear-gradient(135deg, #f0b429 0%, #e08a00 100%);
  color: #2a1d00;
  box-shadow: 0 8px 20px rgba(224, 138, 0, 0.4);
  font-size: 17px;
  padding: 12px 24px;
  margin-top: 2px;
}

/* ---------- Kontroller ---------- */
.hint {
  margin: 2px 0 0;
  font-size: 13px;
  opacity: 0.55;
  letter-spacing: 0.3px;
}
.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}
.slap-btn { min-width: 120px; }
.sub-controls {
  display: flex;
  gap: 18px;
  margin-top: 6px;
}
.btn {
  border: 0;
  border-radius: 16px;
  padding: 16px 28px;
  font-family: inherit;
  font-weight: 800;
  font-size: 20px;
  color: #fff;
  background: linear-gradient(135deg, var(--pink) 0%, #ff2e6a 100%);
  box-shadow: 0 8px 20px rgba(255, 46, 106, 0.4);
  cursor: pointer;
  transition: transform 0.08s ease;
}
.btn:active { transform: scale(0.94); }
.btn.ghost {
  background: rgba(255, 255, 255, 0.08);
  box-shadow: none;
  padding: 14px 18px;
  font-size: 24px;
  line-height: 1;
}
.reset {
  margin-top: 6px;
  background: none;
  border: 0;
  color: var(--pink-soft);
  font-family: inherit;
  font-size: 14px;
  opacity: 0.7;
  cursor: pointer;
}
.reset:active { opacity: 1; }

/* ---------- Mobil / küçük ekran ayarları ---------- */
@media (max-width: 400px) {
  .bubble { font-size: 15px; padding: 10px 16px; }
  .btn { padding: 13px 20px; font-size: 18px; }
  .slap-btn { min-width: 104px; }
  .cat-stage { height: 82px; }
  .cat { width: 72px; height: 84px; }
  .hint { font-size: 12px; }
}
/* Alçak ekranlarda (yatık telefon / küçük) dikey boşlukları kıs */
@media (max-height: 680px) {
  .cat-stage { height: 74px; margin-top: 0; }
  .cat { width: 66px; height: 78px; }
  .game { gap: 7px; }
  .bubble { font-size: 14px; padding: 9px 14px; }
  .controls .btn { padding: 12px 18px; }
}
