* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background-color: #000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  position: fixed;
}

#video-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  z-index: 1;
}

#camera-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform-origin: center center;
  transition: transform 0.05s ease-out;
}

/* 上部バー：CSS Gridによる完全3分割固定（文字数で位置が動かない） */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 100;
  display: grid;
  grid-template-columns: 140px 1fr 90px;
  align-items: center;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.75), transparent);
}

.bar-left {
  display: flex;
  gap: 6px;
  justify-content: flex-start;
}

.bar-center {
  display: flex;
  justify-content: center;
}

.bar-right {
  display: flex;
  justify-content: flex-end;
}

.ui-btn {
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  padding: 6px 0;
  min-width: 62px;
  text-align: center;
  border-radius: 16px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.ui-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#zoom-control {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 4px 8px;
  border-radius: 20px;
  backdrop-filter: blur(8px);
}

#zoom-control label {
  color: #fff;
  font-size: 0.75rem;
}

#zoom-slider {
  width: 65px;
  accent-color: #00ff88;
}

#zoom-text {
  color: #fff;
  font-size: 0.75rem;
  min-width: 34px;
  display: inline-block;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#rec-status {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.75);
  padding: 6px 10px;
  border-radius: 16px;
  border: 1px solid rgba(255, 59, 48, 0.7);
}

.rec-dot {
  width: 8px;
  height: 8px;
  background-color: #ff3b30;
  border-radius: 50%;
  animation: blink 1s infinite;
}

#rec-timer {
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* 切替トースト */
#loading-toast {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid #00ff88;
  color: #00ff88;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 150;
  backdrop-filter: blur(5px);
}

/* カウントダウン表示 */
#countdown-overlay {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 150;
  pointer-events: none;
}

#countdown-number {
  font-size: 7.5rem;
  font-weight: 900;
  color: #ffff00;
  text-shadow: 0 0 20px rgba(0, 0, 0, 0.9);
}

/* 下部バー */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding-bottom: max(18px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 30%, transparent);
}

.mode-container {
  display: flex;
  gap: 8px;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 4px;
  border-radius: 20px;
}

.mode-btn {
  background: transparent;
  border: none;
  color: #aaa;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 16px;
  cursor: pointer;
}

.mode-btn.active {
  background: #00ff88;
  color: #000;
  font-weight: 700;
}

.shutter-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 74px;
}

#shutter-btn {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  cursor: pointer;
  outline: none;
  transition: transform 0.08s ease, width 0.15s ease, border-radius 0.15s ease;
}

#shutter-btn:active {
  transform: scale(0.92);
}

.shutter-photo {
  background: #fff;
  border: 4px solid rgba(0, 0, 0, 0.4);
  box-shadow: 0 0 0 3px #fff;
}

.shutter-video-ready {
  background: #ff3b30;
  border: 4px solid rgba(0, 0, 0, 0.4);
  box-shadow: 0 0 0 3px #fff;
}

.shutter-video-recording {
  background: #ff3b30;
  border: 4px solid rgba(0, 0, 0, 0.4);
  box-shadow: 0 0 0 3px #fff;
  border-radius: 10px !important;
  width: 32px !important;
  height: 32px !important;
}

/* 保存案内モーダル */
#save-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  z-index: 200;
  display: flex;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(5px);
}

.modal-box {
  background: #1c1c1e;
  border: 1px solid #333;
  padding: 24px;
  border-radius: 16px;
  text-align: center;
  width: 82%;
  max-width: 320px;
}

.modal-title {
  color: #00ff88;
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.modal-msg {
  color: #ddd;
  font-size: 0.85rem;
  margin-bottom: 18px;
}

.btn-green {
  width: 100%;
  background: #00ff88;
  color: #000;
  border: none;
  padding: 12px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  margin-bottom: 8px;
}

.btn-gray {
  width: 100%;
  background: transparent;
  color: #888;
  border: none;
  padding: 8px;
  font-size: 0.85rem;
  cursor: pointer;
}

.hidden {
  display: none !important;
}