:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
  background: #07090d;
  color: #f8fafc;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: #07090d; }
button, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.landing {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 28px 18px calc(32px + env(safe-area-inset-bottom));
  background: radial-gradient(circle at 50% 0%, #172033 0, #090d14 46%, #06080d 100%);
}
.landing-inner { width: min(680px, 100%); }
.eyebrow { margin: 0 0 8px; color: #93c5fd; font-size: 12px; font-weight: 900; letter-spacing: .14em; }
h1 { margin: 0; font-size: clamp(30px, 8vw, 48px); line-height: 1.08; }
.lead { margin: 14px 0 0; color: #cbd5e1; line-height: 1.7; }
.enter-button {
  width: 100%; min-height: 62px; margin-top: 26px; border: 0; border-radius: 18px;
  background: #ef4444; color: #fff; font-size: 19px; font-weight: 900; cursor: pointer;
}
.mini-note, .notice { margin: 12px 0 0; color: #aeb9c8; font-size: 13px; line-height: 1.6; }
.landing-stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-top: 18px; }
.landing-stats div { padding: 12px 8px; border: 1px solid #263245; border-radius: 14px; background: rgba(17,24,39,.84); text-align: center; }
.landing-stats span { display: block; color: #94a3b8; font-size: 11px; }
.landing-stats strong { display: block; margin-top: 4px; font-size: 17px; }

.camera-mode { position: fixed; inset: 0; z-index: 20; overflow: hidden; background: #000; touch-action: manipulation; }
.live-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
.live-video.mirror { transform: scaleX(-1); }
.camera-shade { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(to bottom, rgba(0,0,0,.52), transparent 21%, transparent 62%, rgba(0,0,0,.68)); }
.framing-guide { position: absolute; inset: 15% 10% 24%; pointer-events: none; }
.corner { position: absolute; width: 34px; height: 34px; border-color: rgba(255,255,255,.72); border-style: solid; }
.corner.tl { top: 0; left: 0; border-width: 2px 0 0 2px; }
.corner.tr { top: 0; right: 0; border-width: 2px 2px 0 0; }
.corner.bl { bottom: 0; left: 0; border-width: 0 0 2px 2px; }
.corner.br { bottom: 0; right: 0; border-width: 0 2px 2px 0; }
.camera-topbar { position: absolute; top: 0; left: 0; right: 0; display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 12px 10px; }
.icon-button, .switch-button { min-height: 44px; border: 1px solid rgba(255,255,255,.2); border-radius: 999px; background: rgba(0,0,0,.52); color: #fff; font-weight: 800; cursor: pointer; backdrop-filter: blur(8px); }
.icon-button { width: 44px; padding: 0; font-size: 18px; }
.switch-button { padding: 0 14px; font-size: 13px; white-space: nowrap; }
.camera-info { min-width: 0; display: flex; justify-content: center; gap: 12px; color: #fff; font-size: 12px; font-weight: 800; text-shadow: 0 1px 4px #000; }
.center-status { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(88%, 560px); text-align: center; pointer-events: none; text-shadow: 0 2px 10px rgba(0,0,0,.9); }
.status-main { font-size: clamp(28px, 8vw, 56px); font-weight: 1000; line-height: 1.08; }
.status-sub { margin-top: 7px; color: rgba(255,255,255,.88); font-size: clamp(13px, 3.5vw, 18px); font-weight: 700; }
.bang { position: absolute; inset: 0; display: none; place-items: center; background: rgba(255,255,255,.92); color: #991b1b; font-size: clamp(74px, 20vw, 180px); font-weight: 1000; letter-spacing: -.06em; pointer-events: none; }
.bang.show { display: grid; }
.camera-bottom { position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; align-items: center; gap: 9px; padding: 10px 16px calc(14px + env(safe-area-inset-bottom)); }
.meter-row { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 36px; padding: 5px 10px; border-radius: 999px; background: rgba(0,0,0,.48); color: #fff; font-size: 12px; backdrop-filter: blur(8px); }
.meter-row label { color: rgba(255,255,255,.75); }
.meter-row select { min-height: 30px; border: 1px solid rgba(255,255,255,.24); border-radius: 999px; padding: 0 24px 0 10px; background: rgba(17,24,39,.92); color: #fff; font-size: 12px; }
.measure-button { width: min(360px, 92%); min-height: 58px; border: 0; border-radius: 999px; background: #ef4444; color: #fff; font-size: 18px; font-weight: 1000; cursor: pointer; box-shadow: 0 8px 30px rgba(0,0,0,.32); }
.measure-button:disabled { opacity: .46; cursor: not-allowed; }
.camera-help { margin: 0; max-width: 520px; color: rgba(255,255,255,.88); font-size: 12px; text-align: center; text-shadow: 0 1px 4px #000; }

.result-mode { position: fixed; inset: 0; z-index: 30; overflow: auto; padding: calc(24px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom)); background: #07090d; }
.result-panel { width: min(760px, 100%); margin: 0 auto; }
.reaction-result { margin: 3px 0 0; font-size: clamp(56px, 17vw, 112px); font-weight: 1000; line-height: 1; letter-spacing: -.06em; }
.reaction-result.false-start { color: #f87171; font-size: clamp(48px, 14vw, 92px); letter-spacing: -.04em; }
.reaction-detail { margin: 10px 0 0; color: #b8c2cf; line-height: 1.6; }
.review-wrap { margin-top: 22px; }
.review-frame { width: 100%; margin: 0 auto; overflow: hidden; border-radius: 16px; background: #000; display: grid; place-items: center; }
.review-frame.portrait { width: min(420px, 100%); aspect-ratio: 9 / 16; }
.review-frame.landscape { width: 100%; aspect-ratio: 16 / 9; }
.review-video { display: block; width: 100%; height: 100%; background: #000; object-fit: contain; }
.review-video.rotate-90 { width: auto; height: auto; max-width: none; max-height: none; transform: rotate(90deg); }
.timeline { position: relative; height: 66px; margin-top: 12px; }
.timeline-line { position: absolute; left: 2%; right: 2%; top: 26px; height: 4px; border-radius: 999px; background: #334155; }
.timeline-marker { position: absolute; top: 13px; width: 2px; height: 30px; background: #fff; transform: translateX(-1px); }
.timeline-marker span { position: absolute; bottom: 32px; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 11px; font-weight: 900; }
.go-marker { background: #f59e0b; }
.move-marker { background: #22c55e; }
.timeline-labels { position: absolute; left: 2%; right: 2%; top: 39px; display: flex; justify-content: space-between; color: #64748b; font-size: 11px; }
.review-note { margin: 4px 0 0; color: #94a3b8; font-size: 12px; line-height: 1.55; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 22px; }
.stat-card { padding: 12px 7px; border: 1px solid #283548; border-radius: 14px; background: #101722; text-align: center; }
.stat-card span { display: block; color: #94a3b8; font-size: 11px; }
.stat-card strong { display: block; margin-top: 5px; font-size: 16px; }
.stats-count { margin: 8px 0 0; color: #64748b; font-size: 12px; }
.history-box { margin-top: 14px; border: 1px solid #283548; border-radius: 14px; background: #0d131d; overflow: hidden; }
.history-box summary { min-height: 48px; display: flex; align-items: center; padding: 0 14px; cursor: pointer; font-weight: 800; }
.history-list, .video-history { padding: 0 14px 14px; }
.history-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 10px 0; border-top: 1px solid #1e293b; font-size: 13px; }
.history-row time { color: #94a3b8; }
.history-row strong.false { color: #f87171; }
.video-item { padding-top: 14px; margin-top: 12px; border-top: 1px solid #1e293b; }
.video-meta { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; color: #cbd5e1; font-size: 12px; }
.video-meta strong.false { color: #f87171; }
.history-video-frame { width: 100%; margin: 0 auto; background: #000; border-radius: 12px; overflow: hidden; display: grid; place-items: center; }
.history-video-frame.portrait { width: min(300px, 100%); aspect-ratio: 9/16; }
.history-video-frame.landscape { aspect-ratio: 16/9; }
.history-video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.result-actions { display: grid; gap: 10px; margin-top: 22px; }
.action-primary, .action-secondary { width: 100%; min-height: 54px; border-radius: 14px; font-weight: 900; cursor: pointer; }
.action-primary { border: 0; background: #ef4444; color: #fff; }
.action-secondary { border: 1px solid #334155; background: #111827; color: #e5e7eb; }
button:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid #93c5fd; outline-offset: 3px; }

@media (orientation: landscape) {
  .camera-bottom { align-items: center; justify-content: flex-end; }
  .measure-button { width: min(380px, 48vw); margin-inline: auto; }
  .camera-help { text-align: center; }
  .framing-guide { inset: 14% 14% 25%; }
}
@media (max-width: 520px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 390px) {
  .camera-info { gap: 7px; font-size: 11px; }
  .switch-button { padding: 0 10px; font-size: 12px; }
  .meter-row { gap: 7px; }
  .landing-stats { grid-template-columns: 1fr; }
}


/* v4: page内でそのまま動画再生できる大きな再生ボタン */
.review-frame,
.history-video-frame { position: relative; }
.inline-play-button {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  width: 68px;
  height: 68px;
  border: 1px solid rgba(255,255,255,.55);
  border-radius: 999px;
  background: rgba(0,0,0,.62);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  display: grid;
  place-items: center;
  padding: 0 0 0 4px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.inline-play-button[hidden] { display: none !important; }
.history-play-button { width: 60px; height: 60px; font-size: 24px; }

/* 録画自体を9:16 / 16:9で生成するため、結果画面もその比率で表示 */
.review-frame.portrait,
.history-video-frame.portrait { aspect-ratio: 9 / 16; }
.review-frame.landscape,
.history-video-frame.landscape { aspect-ratio: 16 / 9; }

/* v5: 広い初期画角 + ピンチズーム + 履歴画面 */
.history-link-button {
  width: 100%; min-height: 50px; margin-top: 12px; border: 1px solid #334155; border-radius: 14px;
  background: rgba(17,24,39,.9); color: #e5e7eb; font-weight: 900; cursor: pointer;
}
.history-mode {
  position: fixed; inset: 0; z-index: 35; overflow: auto;
  padding: calc(20px + env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom));
  background: #07090d;
}
.history-panel { width: min(760px, 100%); margin: 0 auto; }
.history-panel h2 { margin: 0; font-size: clamp(30px, 8vw, 46px); line-height: 1.1; }
.history-back-button {
  min-height: 44px; margin-bottom: 18px; padding: 0 14px; border: 1px solid #334155; border-radius: 999px;
  background: #111827; color: #e5e7eb; font-weight: 800; cursor: pointer;
}
.history-summary { margin-top: 18px; }
.history-section { margin-top: 24px; }
.history-section h3 { margin: 0 0 10px; font-size: 18px; }
.history-section h3 span { color: #94a3b8; font-size: 12px; font-weight: 700; }
.all-history-list {
  padding: 0 14px 4px; border: 1px solid #283548; border-radius: 14px; background: #0d131d;
}
.history-row.with-video { grid-template-columns: 1fr auto auto; align-items: center; }
.history-video-link {
  min-height: 34px; padding: 0 10px; border: 1px solid #334155; border-radius: 999px;
  background: #111827; color: #e5e7eb; font-size: 12px; font-weight: 800; cursor: pointer;
}

/* カメラ映像は最初からできるだけ広く見せ、必要な人だけピンチで寄る */
.live-video {
  object-fit: cover;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  --preview-zoom: 1;
  transform: scale(var(--preview-zoom));
  transform-origin: center center;
}
.live-video.mirror { transform: scaleX(-1) scale(var(--preview-zoom)); }
.zoom-badge {
  position: absolute; z-index: 8; left: 50%; top: calc(68px + env(safe-area-inset-top));
  transform: translateX(-50%); min-width: 64px; padding: 7px 12px; border-radius: 999px;
  background: rgba(0,0,0,.62); color: #fff; text-align: center; font-size: 14px; font-weight: 900;
  border: 1px solid rgba(255,255,255,.24); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  pointer-events: none;
}

@media (max-width: 390px) {
  .history-row.with-video { grid-template-columns: 1fr auto; }
  .history-row.with-video .history-video-link { grid-column: 1 / -1; justify-self: end; }
}


/* v8: 撮影モードを端末画面いっぱいに表示 */
.camera-mode {
  width: 100vw;
  height: 100dvh;
  min-height: 100dvh;
}
.live-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
}
/* 録画は端末の実表示比率で生成するため、結果枠はJSからaspect-ratioを設定 */
.review-frame.dynamic-ratio,
.history-video-frame.dynamic-ratio {
  aspect-ratio: var(--video-aspect, 9 / 16);
}

/* SEO content MVP */
.seo-content {
  padding: 64px 18px 76px;
  background: #080b11;
  border-top: 1px solid #172033;
}
.seo-inner { width: min(760px, 100%); margin: 0 auto; }
.seo-section { padding: 30px 0; border-bottom: 1px solid #1e293b; }
.seo-section:first-child { padding-top: 0; }
.seo-section h2 { margin: 0 0 12px; font-size: clamp(22px, 5.5vw, 30px); line-height: 1.35; letter-spacing: -.02em; }
.seo-section p { margin: 0; color: #cbd5e1; font-size: 15px; line-height: 1.9; }
.howto-list { list-style: none; padding: 0; margin: 18px 0 0; display: grid; gap: 10px; }
.howto-list li { display: grid; grid-template-columns: 38px 1fr; align-items: center; gap: 12px; padding: 13px 14px; border: 1px solid #263245; border-radius: 14px; background: #0d131d; }
.howto-list li > span { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 999px; background: #1e293b; color: #fff; font-weight: 900; }
.howto-list p { line-height: 1.55; }
.average-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; margin-top: 18px; }
.average-card { padding: 16px 13px; border: 1px solid #283548; border-radius: 14px; background: #101722; }
.average-card span { display: block; color: #aeb9c8; font-size: 13px; line-height: 1.45; }
.average-card small { color: #64748b; font-size: 11px; }
.average-card strong { display: block; margin-top: 8px; font-size: 23px; letter-spacing: -.03em; }
.seo-section .source-note { margin-top: 12px; color: #7f8da1; font-size: 12px; line-height: 1.65; }
.source-note a { color: #93c5fd; text-underline-offset: 3px; }
.starter-link-card { display: block; margin-top: 32px; padding: 20px; border: 1px solid #334155; border-radius: 18px; background: linear-gradient(135deg, #111827, #0d131d); color: #fff; text-decoration: none; }
.starter-link-card span { display: block; color: #94a3b8; font-size: 13px; }
.starter-link-card strong { display: block; margin-top: 5px; font-size: 19px; }
.starter-link-card:focus-visible { outline: 3px solid #93c5fd; outline-offset: 3px; }
@media (max-width: 520px) {
  .seo-content { padding: 50px 16px 60px; }
  .average-grid { grid-template-columns: 1fr; }
}
