/* Flutter 版 AI Post に寄せたダーク + グラス調 / Poppins。 */
:root {
  --bg: #121212;
  --accent: #6dccc8; /* アプリ primaryColor */
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.7);
  --glass: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.25);
  --radius-btn: 22px;
  --radius-card: 12px;
  --radius-chip: 20px;
}

* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
  margin: 0;
}
body {
  background: #000;
  color: var(--text);
  font-family: "Poppins", "Noto Sans JP", system-ui, -apple-system, sans-serif;
}

#app {
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.screen {
  position: relative;
  width: 100%;
  max-width: 460px;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}
@media (min-width: 480px) {
  .screen {
    height: min(100dvh, 820px);
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  }
}

/* ---- typography / layout helpers ---- */
.title {
  font-size: 1.7rem;
  font-weight: 800;
  line-height: 1.35;
  letter-spacing: -0.4px;
  margin: 0;
}
.kicker {
  font-size: 0.78rem;
  letter-spacing: 0.22em;
  font-weight: 700;
  color: var(--accent);
  margin: 0;
}
.muted {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.7;
  font-weight: 500;
  margin: 0;
}
.center-text {
  text-align: center;
}
.center {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.pad {
  padding: 32px;
  padding-top: max(32px, env(safe-area-inset-top));
  padding-bottom: max(32px, env(safe-area-inset-bottom));
}
.gap > * + * {
  margin-top: 18px;
}

/* ---- buttons (Flutter action button 風) ---- */
.btn {
  display: inline-block;
  border: none;
  border-radius: var(--radius-btn);
  padding: 0 28px;
  height: 52px;
  line-height: 52px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: transform 0.1s ease, opacity 0.1s ease;
}
.btn:active {
  transform: scale(0.97);
}
.btn.wide {
  width: 100%;
}
.btn.filled {
  background: #fff;
  color: #000;
}
.btn.outline {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.6);
}
.btn:disabled {
  opacity: 0.5;
}
.linklike {
  background: none;
  border: none;
  color: var(--muted);
  font-family: inherit;
  text-decoration: underline;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 8px;
  cursor: pointer;
}

/* ---- spinner ---- */
.spinner {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---- stage（全画面画像 + 上下グラデ + 下部操作） ---- */
.stage {
  position: relative;
  height: 100%;
  background: #000;
}
.bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.bg.dim {
  opacity: 0.35;
}
#cam-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}
/* 上 80px と 下 180px のダークグラデーション（Flutter 版に合わせる） */
.grad {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.5) 0,
    rgba(0, 0, 0, 0) 80px,
    rgba(0, 0, 0, 0) calc(100% - 180px),
    rgba(0, 0, 0, 0.6) 100%
  );
}
.stage-inner {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 12px;
  padding: 24px;
  padding-top: max(24px, env(safe-area-inset-top));
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}
.stage-inner.center-items {
  align-items: center;
}

/* 結果画面: 画像を長押し（右クリック）で保存できるよう、操作レイヤーは透過しボタンだけ受ける */
.result .stage-inner {
  pointer-events: none;
}
.result .stage-inner .btn,
.result .stage-inner .linklike {
  pointer-events: auto;
}
.hint {
  background: rgba(0, 0, 0, 0.55);
  color: #ffe9a8;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.85rem;
  line-height: 1.5;
  text-align: center;
}

/* ---- 質問チップ（ガラスの白ピル / 濃色テキスト） ---- */
.top-chip {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  left: 16px;
  right: 16px;
  z-index: 2;
  display: flex;
  justify-content: center;
}
.qchip {
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #111;
  font-weight: 800;
  font-size: 1.15rem;
  line-height: 1.2;
  /* 上下非対称: 日本語フォントのメトリクスで上に寄るのを光学的に中央へ補正 */
  padding: 16px 18px 12px;
  border-radius: var(--radius-chip);
  border: 1px solid rgba(255, 255, 255, 0.75);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
  text-align: center;
}

/* ---- 丸ボタン（戻る等） ---- */
.circle-btn {
  position: absolute;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  cursor: pointer;
}
.circle-btn svg {
  display: block;
}
.circle-btn.top-left {
  top: max(8px, env(safe-area-inset-top));
  left: 8px;
}

/* ---- camera ---- */
.cam-note {
  position: absolute;
  inset: auto 16px 120px 16px;
  z-index: 2;
  background: rgba(0, 0, 0, 0.6);
  padding: 12px;
  border-radius: var(--radius-card);
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
}
.shutter {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 4px solid #fff;
  background: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  flex-shrink: 0;
}
.shutter:active {
  transform: scale(0.95);
}

/* ---- 2択カード（横並びの正方形ガラスカード） ---- */
.answers {
  display: flex;
  gap: 10px;
}
.answer-card {
  flex: 1;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 12px;
  color: #fff;
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  background: var(--glass);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-card);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease, border-color 0.15s ease;
}
.answer-card:active {
  transform: scale(0.98);
}
.answer-card:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.5);
}
.answer-card:disabled {
  opacity: 0.5;
}

/* ---- Result screen: header meme template (CSS variables) ---- */
.stage.result {
  --header-padding-x: 14px;
  --header-padding-top: 24px;
  --header-padding-bottom: 20px;
  --floating-selfie-size: clamp(72px, 20vw, 98px);
  --floating-selfie-offset-y: 18px;
  --header-question-size: clamp(1.04rem, 4.5vw, 1.26rem);
  --header-answer-size: clamp(1.38rem, 6.7vw, 1.78rem);
  --header-text-gap: 10px;
  --brand-badge-height: clamp(36px, 10vw, 44px);
  --brand-badge-icon-size: clamp(22px, 6vw, 26px);
  --brand-badge-font-size: clamp(0.72rem, 2.6vw, 0.82rem);
  --brand-badge-pad-x: 10px;
  --brand-badge-pad-y: 6px;
  --brand-badge-gap: 8px;
  --brand-badge-right: 3.7%;
  --brand-badge-bottom: 3.5%;
}

.result-share-vignette {
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.55) 0,
    rgba(0, 0, 0, 0.2) 120px,
    rgba(0, 0, 0, 0) 45%,
    rgba(0, 0, 0, 0.4) 78%,
    rgba(0, 0, 0, 0.68) 100%
  );
}

.result-meme-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.result-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  display: block;
  padding-top: max(var(--header-padding-top), env(safe-area-inset-top));
  padding-right: var(--header-padding-x);
  padding-bottom: var(--header-padding-bottom);
  padding-left: var(--header-padding-x);
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.78) 0%,
    rgba(0, 0, 0, 0.5) 72%,
    rgba(0, 0, 0, 0) 100%
  );
  pointer-events: none;
}

.result-floating-selfie {
  position: absolute;
  left: var(--header-padding-x);
  top: calc(100% + var(--floating-selfie-offset-y));
  z-index: 3;
  width: var(--floating-selfie-size);
  height: var(--floating-selfie-size);
  border-radius: clamp(12px, 3vw, 16px);
  overflow: hidden;
  border: 3px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
  background: rgba(0, 0, 0, 0.2);
}
.result-floating-selfie::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.12);
  pointer-events: none;
}
.result-floating-selfie-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.result-header-copy {
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--header-text-gap);
  text-align: left;
}

.result-header-question {
  margin: 0;
  max-width: 100%;
  font-size: var(--header-question-size);
  font-weight: 500;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.88);
}

.result-header-answer {
  margin: 0;
  max-width: 100%;
  font-size: var(--header-answer-size);
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.3px;
  color: #fff;
}

.result-brand-badge {
  position: absolute;
  right: var(--brand-badge-right);
  bottom: var(--brand-badge-bottom);
  min-height: var(--brand-badge-height);
  display: inline-flex;
  align-items: center;
  gap: var(--brand-badge-gap);
  padding: var(--brand-badge-pad-y) var(--brand-badge-pad-x);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.36);
  border: 1px solid rgba(255, 255, 255, 0.24);
}

.result-brand-badge-img {
  display: block;
  width: var(--brand-badge-icon-size);
  height: var(--brand-badge-icon-size);
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.result-brand-badge-label {
  font-size: var(--brand-badge-font-size);
  font-weight: 700;
  color: rgba(255, 255, 255, 0.96);
  line-height: 1;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.hidden {
  display: none !important;
}
