/* === Reset === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  -webkit-tap-highlight-color: transparent;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
}

/* === Variables === */
:root {
  --color-bg: #1a0a0a;
  --color-accent: #e84393;
  --color-accent-light: #fd79a8;
  --color-text: #fff5f5;
  --color-film-bg: #111;
  --color-sprocket: #333;
  --font-display: 'Georgia', serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --crank-radius: 70px;
  --photo-width: 220px;
  --photo-gap: 16px;
}

/* === Screens === */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  width: 100%;
  height: 100dvh;
  height: -webkit-fill-available;
}

.screen.active {
  display: flex;
}

/* === Title Screen === */
#title-screen {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  z-index: 10;
  cursor: pointer;
  touch-action: manipulation;
}

#title-screen.fade-out {
  animation: fadeOut 0.8s ease-out forwards;
}

.title-content {
  text-align: center;
  animation: fadeInUp 1s ease-out;
}

.title-name {
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: normal;
  color: var(--color-text);
  margin-bottom: 2rem;
}

.title-name span {
  color: var(--color-accent);
}

.tap-hint {
  font-size: 0.9rem;
  opacity: 0.5;
  animation: pulse 2s ease-in-out infinite;
}

/* === Main Screen === */
#main-screen {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
}

/* === Film Strip === */
#filmstrip-viewport {
  width: 100%;
  overflow: hidden;
  padding: 2rem 0;
  position: relative;
}

#filmstrip-track {
  display: flex;
  gap: var(--photo-gap);
  will-change: transform;
  padding: 12px 0;
}

.film-frame {
  flex: 0 0 auto;
  width: var(--photo-width);
  aspect-ratio: 3 / 4;
  position: relative;
  border: 3px solid #444;
  border-radius: 4px;
  background: var(--color-film-bg);
  overflow: hidden;
}

.film-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  -webkit-user-drag: none;
  user-select: none;
  pointer-events: none;
}

/* Sprocket holes */
.film-frame::before,
.film-frame::after {
  content: '';
  position: absolute;
  left: 8px;
  right: 8px;
  height: 6px;
  background: repeating-linear-gradient(
    90deg,
    var(--color-sprocket) 0px,
    var(--color-sprocket) 8px,
    transparent 8px,
    transparent 16px
  );
  border-radius: 1px;
  z-index: 1;
}

.film-frame::before { top: 4px; }
.film-frame::after  { bottom: 4px; }

/* === Crank === */
#crank-container {
  position: fixed;
  bottom: calc(3rem + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  touch-action: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  z-index: 5;
}

#crank-pivot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--color-accent);
  position: relative;
  box-shadow: 0 0 12px rgba(232, 67, 147, 0.4);
}

#crank-arm {
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--crank-radius);
  height: 4px;
  background: linear-gradient(90deg, var(--color-accent), var(--color-accent-light));
  border-radius: 2px;
  transform-origin: 0% 50%;
  transform: rotate(0rad);
}

#crank-handle {
  position: absolute;
  right: -18px;
  top: -14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-accent-light);
  box-shadow: 0 0 16px rgba(253, 121, 168, 0.5);
}

/* Larger touch target for the crank */
#crank-handle::after {
  content: '';
  position: absolute;
  inset: -20px;
}

.crank-hint {
  font-size: 0.8rem;
  opacity: 0.4;
  animation: pulse 2s ease-in-out infinite;
  margin-top: 0.5rem;
}

/* === Overlays === */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(26, 10, 10, 0.9);
  z-index: 20;
  animation: fadeIn 0.4s ease-out;
}

.overlay.hidden {
  display: none;
}

.overlay-content {
  text-align: center;
  padding: 2rem;
}

.overlay-content h2 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  margin-bottom: 2rem;
  color: var(--color-text);
}

.overlay-buttons {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
}

.btn {
  padding: 0.8rem 2rem;
  border: none;
  border-radius: 2rem;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease-out, opacity 0.15s;
}

.btn:active {
  transform: scale(0.95);
}

.btn-yes {
  background: var(--color-accent);
  color: white;
}

.btn-no {
  background: transparent;
  color: var(--color-text);
  border: 2px solid var(--color-text);
  opacity: 0.6;
  transition: transform 0.15s ease-out, opacity 0.15s;
}

/* === Celebration === */
#celebration-overlay {
  flex-direction: column;
}

#confetti-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.celebration-text {
  position: relative;
  z-index: 1;
  text-align: center;
  animation: scaleIn 0.5s ease-out;
}

.celebration-text h2 {
  font-family: var(--font-display);
  font-size: 2.4rem;
  color: var(--color-accent-light);
}

/* === Haptic checkbox (hidden) === */
#haptic-checkbox,
#haptic-label {
  position: fixed;
  top: -9999px;
  left: -9999px;
  opacity: 0;
  pointer-events: none;
}

/* === Animations === */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.5);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.7; }
}
