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

:root {
  --pink: #ff7eb6;
  --blue: #6ec1ff;
  --yellow: #ffe066;
  --green: #7ee787;
  --purple: #c792ea;
  --bg1: #fff5f8;
  --bg2: #e8f4ff;
  --ink: #2d2438;
  --shadow: 0 12px 30px rgba(45, 36, 56, 0.18);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Comic Sans MS", "Comic Neue", system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(135deg, var(--bg1) 0%, var(--bg2) 100%);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}

.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.screen.active { display: flex; }

/* HOME */
#home {
  align-items: center;
  justify-content: flex-start;
  padding-top: max(40px, env(safe-area-inset-top));
}
#home h1 {
  font-size: clamp(36px, 9vw, 60px);
  margin-top: 20px;
  color: var(--pink);
  text-shadow: 3px 3px 0 #fff, 4px 4px 0 rgba(0,0,0,0.06);
}
#home .subtitle {
  font-size: 18px;
  color: var(--ink);
  opacity: 0.7;
  margin-bottom: 28px;
}
.categories {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  width: min(420px, 92vw);
}
.cat {
  background: #fff;
  border: none;
  border-radius: 22px;
  padding: 22px 12px;
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.cat:active { transform: scale(0.95); }
.cat .emj { font-size: 44px; line-height: 1; }
.hint { margin-top: 24px; opacity: 0.55; font-size: 14px; }

/* GAME */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  flex-shrink: 0;
}
.iconbtn {
  width: 48px; height: 48px;
  border-radius: 50%;
  border: none;
  background: #fff;
  box-shadow: var(--shadow);
  font-size: 22px;
  cursor: pointer;
}
.iconbtn:active { transform: scale(0.92); }
.iconbtn.active { background: var(--green); }
.progress {
  font-size: 18px;
  font-weight: 700;
  background: #fff;
  padding: 8px 16px;
  border-radius: 999px;
  box-shadow: var(--shadow);
}

.cardstage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1200px;
  padding: 12px;
  min-height: 0;
}
.card {
  width: min(360px, 88vw);
  aspect-ratio: 3 / 4;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(.4,.2,.2,1);
  cursor: pointer;
}
.card.flipped { transform: rotateY(180deg); }
.face {
  position: absolute;
  inset: 0;
  background: #fff;
  border-radius: 28px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
  padding: 18px;
}
.face.front { background: linear-gradient(160deg, #fff 0%, #fff5f8 100%); }
.face.back { transform: rotateY(180deg); background: linear-gradient(160deg, #fff 0%, #e8f4ff 100%); }
.emoji {
  font-size: clamp(110px, 30vw, 180px);
  line-height: 1;
  filter: drop-shadow(0 6px 12px rgba(0,0,0,0.12));
  transition: transform 0.3s;
}
.emoji.small { font-size: clamp(70px, 18vw, 110px); }
.word {
  font-size: clamp(28px, 7vw, 40px);
  font-weight: 800;
  margin-top: 18px;
  text-transform: capitalize;
}
.word.greek { color: var(--pink); }
.translit {
  margin-top: 8px;
  font-size: 18px;
  opacity: 0.55;
  font-style: italic;
}

/* Front camera circle overlay — replaces the face area of the emoji.
 * Position (left/top/width) is set per-card from JS via `face` anchor in cards.js.
 * Default values here only act as a fallback before the first applyFaceAnchor() runs.
 */
#video {
  position: absolute;
  left: 50%;
  top: 34%;
  width: 55%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%) scaleX(-1);
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid rgba(255,255,255,0.95);
  box-shadow: 0 8px 22px rgba(0,0,0,0.28), inset 0 0 0 1px rgba(255,126,182,0.35);
  display: none;
  background: #000;
  z-index: 2;
}
.face.front.cam-on #video { display: block; }
/* Keep the emoji at full size — face circle covers its head area, becoming the new face */
.face.front.cam-on .emoji { filter: drop-shadow(0 8px 16px rgba(0,0,0,0.2)); }

/* Snap photo button — pink to draw the eye when camera mode is on */
.ctrl.snap {
  background: linear-gradient(135deg, #ff7eb6 0%, #ffb86c 100%);
  color: #fff;
  box-shadow: 0 8px 22px rgba(255,126,182,0.45);
}
.ctrl.snap:active { transform: scale(0.92); }

.controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  padding: 12px 16px 18px;
  flex-shrink: 0;
}
.ctrl {
  border: none;
  border-radius: 50%;
  background: #fff;
  width: 56px; height: 56px;
  font-size: 24px;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.ctrl.big { width: 72px; height: 72px; font-size: 32px; }
.ctrl:active { transform: scale(0.92); }
.ctrl.listening { background: var(--pink); animation: pulse 1s infinite; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,126,182,0.6); }
  50% { box-shadow: 0 0 0 16px rgba(255,126,182,0); }
}

.status {
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  min-height: 28px;
  padding: 0 16px;
  flex-shrink: 0;
}
.status.ok { color: #2ea043; }
.status.no { color: #d04444; }
.swiphint {
  text-align: center;
  font-size: 12px;
  opacity: 0.4;
  padding-bottom: 8px;
  flex-shrink: 0;
}

.celebrate {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
}
.confetti {
  position: absolute;
  width: 12px; height: 12px;
  border-radius: 3px;
  animation: fall 1.6s ease-out forwards;
}
@keyframes fall {
  0% { transform: translateY(-20px) rotate(0); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}
