* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #000;
}

#camerafeed {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* スキャンオーバーレイ — 中央のフレームと案内テキスト */
#scanning-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: opacity 0.4s ease;
  font-family: 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
}

#scanning-overlay.hidden {
  opacity: 0;
}

#scan-frame {
  position: relative;
  width: min(70vw, 280px);
  aspect-ratio: 1 / 1;
  overflow: hidden;
  animation: scan-pulse 2s ease-in-out infinite;
}

.scan-corner {
  position: absolute;
  width: 32px;
  height: 32px;
  border: 3px solid #4de8e0;
  filter: drop-shadow(0 0 6px rgba(77, 232, 224, 0.8));
}
.scan-corner.tl { top: 0; left: 0; border-right: none; border-bottom: none; border-top-left-radius: 6px; }
.scan-corner.tr { top: 0; right: 0; border-left: none; border-bottom: none; border-top-right-radius: 6px; }
.scan-corner.bl { bottom: 0; left: 0; border-right: none; border-top: none; border-bottom-left-radius: 6px; }
.scan-corner.br { bottom: 0; right: 0; border-left: none; border-top: none; border-bottom-right-radius: 6px; }

#scan-line {
  position: absolute;
  left: 5%;
  right: 5%;
  height: 2px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(77, 232, 224, 0.8) 50%,
    transparent 100%);
  box-shadow: 0 0 12px rgba(77, 232, 224, 0.9);
  animation: scan-sweep 2.4s ease-in-out infinite;
}

#scan-message {
  margin-top: 28px;
  padding: 12px 22px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  border-radius: 25px;
  font-size: 16px;
  text-align: center;
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  gap: 10px;
}

#scan-message i {
  color: #4de8e0;
  font-size: 18px;
}

@keyframes scan-sweep {
  0%   { top: 0%; opacity: 0.0; }
  10%  { opacity: 1.0; }
  50%  { top: 100%; opacity: 1.0; }
  60%  { opacity: 0.0; }
  100% { top: 0%; opacity: 0.0; }
}

@keyframes scan-pulse {
  0%, 100% { transform: scale(1.0); }
  50%      { transform: scale(1.04); }
}

/* ボタンコンテナ */
#button-container {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 20px;
  z-index: 1000;
}

/* 動画制御ボタン */
#video-control {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.7));
  color: #333;
  border: none;
  font-size: 32px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

#video-control:hover { transform: scale(1.05); }
#video-control:active { transform: scale(0.95); }
.fa-play { margin-left: 4px; }

/* サブボタン */
.social-links,
#gphotos-button {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  font-size: 24px;
  box-shadow: 0 3px 15px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  backdrop-filter: blur(5px);
  overflow: hidden;
}

.social-links:hover,
#gphotos-button:hover { transform: scale(1.1); }

.button-logo {
  width: 35px;
  height: 35px;
  object-fit: contain;
  border-radius: 50%;
}

/* シークバー */
#seekbar-container {
  position: fixed;
  bottom: 140px;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 500px;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.8);
  border-radius: 15px;
  padding: 15px 20px;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  display: none;
}

#seekbar-wrapper {
  display: flex;
  align-items: center;
  gap: 15px;
}

#current-time,
#duration-time {
  color: white;
  font-size: 14px;
  font-family: 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
  min-width: 40px;
  text-align: center;
}

#seekbar {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
  position: relative;
  cursor: pointer;
}

#seekbar-progress {
  height: 100%;
  background: linear-gradient(90deg, #ff6b6b, #feca57);
  border-radius: 3px;
  width: 0%;
}

#seekbar-handle {
  position: absolute;
  top: 50%;
  left: 0%;
  transform: translate(-50%, -50%);
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  cursor: grab;
}

#seekbar-handle:active { cursor: grabbing; }

/* メッセージオーバーレイ — 動画終了時に表示 */
#message-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center,
    rgba(28, 47, 86, 0.92) 0%,
    rgba(10, 18, 36, 0.96) 100%);
  backdrop-filter: blur(8px);
  font-family: 'Hiragino Mincho ProN', 'Yu Mincho', serif;
  pointer-events: auto;
  cursor: pointer;
  opacity: 1;
  transition: opacity 0.5s ease;
  overflow: hidden;
}

#message-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

#message-card {
  position: relative;
  text-align: center;
  color: #fff8e7;
  padding: 40px 28px;
  z-index: 2;
}

.msg-line {
  opacity: 0;
  transform: translateY(20px);
  margin: 14px 0;
  letter-spacing: 0.08em;
}

/* Animations only run while the overlay is visible; JS resets them on show. */
#message-overlay:not(.hidden) .msg-line.msg-brand {
  animation: msg-rise 1.2s cubic-bezier(0.2, 0.7, 0.2, 1) 0.15s forwards;
}
#message-overlay:not(.hidden) .msg-line.msg-celebrate {
  animation: msg-rise 1.2s cubic-bezier(0.2, 0.7, 0.2, 1) 0.9s forwards,
             msg-shimmer 4s ease-in-out 2.2s infinite;
}
#message-overlay:not(.hidden) .msg-line.msg-warm:nth-of-type(3) {
  animation: msg-rise 1.2s cubic-bezier(0.2, 0.7, 0.2, 1) 2.3s forwards;
}
#message-overlay:not(.hidden) .msg-line.msg-warm:nth-of-type(4) {
  animation: msg-rise 1.2s cubic-bezier(0.2, 0.7, 0.2, 1) 3.1s forwards;
}
#message-overlay:not(.hidden) .msg-line.msg-thanks {
  animation: msg-rise 1.2s cubic-bezier(0.2, 0.7, 0.2, 1) 3.9s forwards;
}

.msg-brand {
  font-size: clamp(20px, 5.4vw, 34px);
  font-weight: 600;
  color: rgba(255, 232, 196, 0.92);
  letter-spacing: 0.1em;
  margin-bottom: 8px;
  text-shadow: 0 0 14px rgba(255, 200, 120, 0.35);
  white-space: nowrap;
}

.msg-celebrate {
  font-size: clamp(34px, 9vw, 56px);
  font-weight: 700;
  background: linear-gradient(120deg, #ffd87a 0%, #ffb347 35%, #ff8c69 65%, #ffd87a 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 28px rgba(255, 200, 120, 0.45);
  filter: drop-shadow(0 4px 18px rgba(255, 180, 80, 0.35));
}

.msg-num {
  font-size: 1.35em;
  margin: 0 0.05em;
  display: inline-block;
  /* The animation's transform creates its own stacking context, which breaks
     inheritance of the parent's background-clip:text gradient.
     Apply the same gradient locally so the digits stay visible. */
  background: linear-gradient(120deg, #ffd87a 0%, #ffb347 35%, #ff8c69 65%, #ffd87a 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 18px rgba(255, 180, 80, 0.4));
  animation: msg-num-pop 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) 1.4s both;
}

.msg-warm {
  font-size: clamp(20px, 5.5vw, 30px);
  font-weight: 500;
  color: #f6f0e0;
  line-height: 1.7;
}

.msg-thanks {
  font-size: clamp(28px, 7.5vw, 44px);
  font-weight: 600;
  color: #ffe9d9;
  margin-top: 24px;
}

.msg-heart {
  display: inline-block;
  color: #ff7aa6;
  margin-left: 0.1em;
  filter: drop-shadow(0 0 12px rgba(255, 122, 166, 0.7));
  animation: msg-heart-beat 1.4s ease-in-out 4.9s infinite;
}

.msg-tap {
  margin-top: 36px;
  font-size: 13px;
  color: rgba(255, 248, 231, 0.55);
  letter-spacing: 0.15em;
  font-family: 'Hiragino Kaku Gothic ProN', sans-serif;
  opacity: 0;
}

#message-overlay:not(.hidden) .msg-tap {
  animation: msg-fade-in 0.8s ease 5.5s forwards;
}

/* スパークル粒子 */
.msg-spark {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ffd87a;
  box-shadow: 0 0 14px 3px rgba(255, 216, 122, 0.85);
  opacity: 0;
}
.msg-spark.s1 { top: 18%; left: 12%; animation: msg-spark 3.5s ease-in-out 0.8s infinite; }
.msg-spark.s2 { top: 25%; right: 14%; animation: msg-spark 3.5s ease-in-out 1.4s infinite; }
.msg-spark.s3 { bottom: 22%; left: 18%; animation: msg-spark 3.5s ease-in-out 2.0s infinite; }
.msg-spark.s4 { bottom: 30%; right: 20%; animation: msg-spark 3.5s ease-in-out 2.6s infinite; }
.msg-spark.s5 { top: 50%; left: 6%; width: 4px; height: 4px; animation: msg-spark 3.5s ease-in-out 1.0s infinite; }
.msg-spark.s6 { top: 45%; right: 8%; width: 4px; height: 4px; animation: msg-spark 3.5s ease-in-out 2.2s infinite; }

@keyframes msg-rise {
  0%   { opacity: 0; transform: translateY(20px); }
  100% { opacity: 1; transform: translateY(0); }
}
@keyframes msg-fade-in {
  to { opacity: 1; }
}
@keyframes msg-num-pop {
  0%   { transform: scale(0.5) rotate(-12deg); opacity: 0; }
  60%  { transform: scale(1.25) rotate(6deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
@keyframes msg-shimmer {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}
@keyframes msg-heart-beat {
  0%, 100% { transform: scale(1); }
  20%      { transform: scale(1.25); }
  40%      { transform: scale(1); }
  60%      { transform: scale(1.18); }
  80%      { transform: scale(1); }
}
@keyframes msg-spark {
  0%, 100% { opacity: 0; transform: scale(0.5); }
  50%      { opacity: 1; transform: scale(1.4); }
}

@media (max-width: 768px) {
  #scan-message { font-size: 14px; padding: 10px 18px; }
  .scan-corner { width: 26px; height: 26px; border-width: 2.5px; }
  #video-control { width: 70px; height: 70px; font-size: 28px; }
  .social-links, #gphotos-button { width: 50px; height: 50px; font-size: 20px; }
  .button-logo { width: 30px; height: 30px; }
  #button-container { gap: 15px; bottom: 30px; }
  #seekbar-container { bottom: 120px; width: 80%; padding: 12px 20px; }
  #seekbar-wrapper { gap: 10px; }
  #current-time, #duration-time { font-size: 12px; min-width: 35px; }
}

@media (max-width: 480px) {
  #seekbar-container { width: 75%; padding: 10px 15px; }
  #seekbar-wrapper { gap: 8px; }
  #current-time, #duration-time { font-size: 11px; min-width: 30px; }
}
