@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;700;800&family=Inter:wght@300;400;500&display=swap');

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

:root {
  --gold: #d4af37;
  /* Refined metallic gold */
  --gold-soft: rgba(212, 175, 55, 0.4);
  --glass-bg: rgba(15, 15, 15, 0.45);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  --safe-bottom: env(safe-area-inset-bottom, 20px);
  --safe-top: env(safe-area-inset-top, 20px);
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #050505;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: #fff;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

/* Subtle background vignette for depth */
body::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at center, transparent 30%, #000 120%);
  pointer-events: none;
  z-index: 3;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* ── カメラ映像 ── */
#live-video,
#delayed-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: scaleX(-1);
  background: #000;
  transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

#live-video {
  z-index: 1;
}

#delayed-canvas {
  z-index: 2;
  opacity: 0;
  pointer-events: none;
}

#delayed-canvas.active {
  opacity: 1;
  pointer-events: auto;
}

/* ── ロゴ ── */
#logo {
  position: absolute;
  top: calc(24px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  font-family: 'Outfit', sans-serif;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  background: linear-gradient(135deg, #00FFFF 0%, #8A2BE2 50%, #FF1493 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: #fff;
  pointer-events: none;
  animation: logo-glow 3s ease-in-out infinite alternate;
}

@keyframes logo-glow {
  from {
    opacity: 0.8;
    filter: drop-shadow(0 0 8px rgba(138, 43, 226, 0.3));
  }

  to {
    opacity: 1;
    filter: drop-shadow(0 0 16px rgba(0, 255, 255, 0.6));
  }
}

/* ── カメラ切替ボタン ── */
#switch-camera {
  position: absolute;
  top: calc(18px + var(--safe-top));
  right: 24px;
  z-index: 10;
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 50%;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  color: rgba(255, 255, 255, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

#switch-camera:hover {
  color: #fff;
  background: rgba(40, 40, 40, 0.5);
  transform: scale(1.05);
}

#switch-camera:active {
  transform: scale(0.92);
  background: rgba(255, 255, 255, 0.1);
}

/* ── 遅延セレクター ── */
#delay-selector {
  position: absolute;
  bottom: calc(40px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
}

.delay-bar {
  position: relative;
  display: flex;
  gap: 6px;
  padding: 6px;
  border-radius: 40px;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

.delay-btn {
  position: relative;
  z-index: 2;
  width: 64px;
  height: 44px;
  border: none;
  border-radius: 30px;
  background: transparent;
  color: rgba(255, 255, 255, 0.4);
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: color 0.4s ease;
}

.delay-btn:hover {
  color: rgba(255, 255, 255, 0.8);
}

.delay-btn.active {
  color: #000;
  /* Dark text on gold indicator */
  font-weight: 500;
}

.delay-indicator {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 64px;
  height: 44px;
  border-radius: 30px;
  /* Premium metallic gradient */
  background: linear-gradient(135deg, #e6ce8a 0%, #d4af37 50%, #ad8c29 100%);
  box-shadow: 0 4px 15px var(--gold-soft), inset 0 1px 1px rgba(255, 255, 255, 0.4);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  /* Elegant spring */
  z-index: 1;
}

/* インジケーター位置 */
.delay-bar[data-active="0"] .delay-indicator {
  transform: translateX(0);
}

.delay-bar[data-active="1"] .delay-indicator {
  transform: translateX(calc(64px + 6px));
}

.delay-bar[data-active="2"] .delay-indicator {
  transform: translateX(calc((64px + 6px) * 2));
}

.delay-bar[data-active="3"] .delay-indicator {
  transform: translateX(calc((64px + 6px) * 3));
}

/* ── 画面タップフィードバック ── */
@keyframes fade-in {
  from {
    opacity: 0;
    transform: scale(1.02);
    filter: blur(5px);
  }

  to {
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
  }
}

#app {
  animation: fade-in 1.2s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

/* ── メディアクエリ ── */
@media (max-width: 380px) {
  #logo {
    font-size: 22px;
  }

  .delay-btn {
    width: 52px;
    height: 40px;
    font-size: 14px;
  }

  .delay-indicator {
    width: 52px;
    height: 40px;
  }

  .delay-bar[data-active="1"] .delay-indicator {
    transform: translateX(calc(52px + 6px));
  }

  .delay-bar[data-active="2"] .delay-indicator {
    transform: translateX(calc((52px + 6px) * 2));
  }

  .delay-bar[data-active="3"] .delay-indicator {
    transform: translateX(calc((52px + 6px) * 3));
  }
}