:root {
  --bg: #e9eef5;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #667085;
  --line: #d8dee8;
  --primary: #1f2937;
  --primary-text: #ffffff;
  --thumb-width: 132px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}

.card {
  width: min(100%, 560px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 18px;
  box-shadow: 0 20px 45px rgba(16, 24, 40, 0.08);
}

.screen { display: none; }
.screen.active { display: block; }

.eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.intro-eyebrow {
  text-align: left;
  margin-bottom: 8px;
}

h1, h2 { margin: 0; line-height: 1.05; }
h1 {
  font-size: 30px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: left;
}
h2 {
  font-size: 15px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-align: left;
  margin-top: 4px;
  color: var(--muted);
}

.subtext, .result-note {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.42;
  font-size: 14px;
  text-align: left;
}
.subtext { max-width: 360px; }

.strip-options {
  margin-top: 14px;
  margin-bottom: 18px;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: flex-start;
}

.strip-card {
  flex: 1 1 0;
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 18px;
  padding: 10px 8px 12px;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.strip-card:hover {
  transform: translateY(-1px);
}

.strip-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(31, 41, 55, 0.08);
}

.strip-thumb {
  width: 100%;
  max-width: var(--thumb-width);
  height: auto;
  display: block;
  margin: 0 auto;
  border: 1px solid var(--line);
  background: #f7f9fc;
}

.strip-label {
  display: block;
  margin-top: 8px;
  font-size: 11px;
  line-height: 1.25;
  color: var(--text);
  font-weight: 600;
}

.preview-wrap {
  margin: 12px auto 0;
  width: min(100%, var(--thumb-width));
}

.preview-wrap canvas {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--line);
  background: #f7f9fc;
  cursor: zoom-in;
}

.topbar {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.camera-controls {
  min-width: 148px;
  display: grid;
  gap: 10px;
}

.select-wrap {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

select {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: white;
  padding: 10px 12px;
  font: inherit;
}

.camera-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1080 / 820;
  overflow: hidden;
  background: #0f172a;
}

video, #guide-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

video {
  object-fit: cover;
  transform: scaleX(-1);
}

#guide-overlay {
  pointer-events: none;
  object-fit: contain;
}

.flash {
  position: absolute;
  inset: 0;
  background: white;
  opacity: 0;
  pointer-events: none;
  z-index: 5;
}

.flash.active { animation: flash 220ms ease-out; }

@keyframes flash {
  from { opacity: 0.9; }
  to { opacity: 0; }
}

.countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(64px, 20vw, 120px);
  font-weight: 800;
  color: white;
  text-shadow: 0 8px 30px rgba(0,0,0,0.35);
  z-index: 6;
}

.hidden { display: none !important; }

.actions-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: stretch;
}
.bottom-actions .btn {
  flex: 1 1 0;
  min-width: 0;
  justify-content: center;
  text-align: center;
}

.camera-footer, .bottom-actions { margin-top: 16px; }
.retake-grid { margin-top: 16px; }

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease, background 120ms ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); color: var(--primary-text); }
.btn-secondary { background: #eef2f7; color: var(--text); }
#btn-home { background: #e4e8ef; }

.retake-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.retake-grid .btn {
  padding-inline: 10px;
  font-size: 13px;
}

.result-wrap { width: min(100%, var(--thumb-width)); }
.result-topbar { margin-bottom: 6px; }

.result-title {
  font-size: 30px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: left;
  color: var(--text);
  margin: 0;
}

.credit {
  margin: 16px 0 0;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
}
.credit a { color: inherit; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
}
.modal-content {
  position: relative;
  z-index: 1;
  width: min(92vw, 460px);
  margin: 24px auto;
  padding: 14px;
  border-radius: 22px;
  background: white;
  box-shadow: 0 24px 50px rgba(0,0,0,0.25);
  max-height: none;
}
#modal-preview-image {
  display: block;
  width: 100%;
  height: auto;
}
.modal-close {
  position: absolute;
  top: 6px;
  right: 10px;
  border: 0;
  background: transparent;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  color: var(--text);
}

@media (max-width: 480px) {
  .bottom-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .bottom-actions .btn {
    font-size: 12px;
    padding: 10px 6px;
    white-space: nowrap;
  }

  :root { --thumb-width: 108px; }
  .card { padding: 14px; border-radius: 22px; }
  h1, .result-title { font-size: 26px; }
  h2 { font-size: 14px; }
  .topbar { flex-direction: column; }
  .result-note, .subtext { text-align: left; }
  .strip-options { gap: 8px; }
  .strip-card { padding: 8px 6px 10px; border-radius: 16px; }
  .strip-label { font-size: 10px; }
  .actions-row > * { flex: 1 1 auto; }
  .camera-controls { min-width: 100%; grid-template-columns: 1fr 1fr; }
  .retake-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .retake-grid .btn { font-size: 12px; }
}


@media (max-width: 480px) {
  .bottom-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .bottom-actions .btn {
    font-size: 12px;
    padding: 10px 6px;
    white-space: nowrap;
  }

  .subtext, .result-note {
    font-size: 13px;
    line-height: 1.32;
  }
  .retake-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .retake-grid .btn,
  .bottom-actions .btn {
    min-height: 44px;
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .bottom-actions {
    gap: 8px;
  }
}


.result-preview-grid {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: flex-start;
  margin-top: 10px;
  margin-bottom: 18px;
}

.motion-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.motion-download {
  width: 100%;
}

#motion-canvas {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--line);
  background: #f7f9fc;
}

@media (max-width: 480px) {
  .result-preview-grid {
    gap: 10px;
  }
  .motion-download {
    font-size: 11px;
    padding: 10px 6px;
  }
}


.bottom-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.bottom-actions .btn {
  width: 100%;
}

@media (max-width: 480px) {
  .bottom-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .bottom-actions .btn {
    font-size: 12px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}


.retake-grid,
.bottom-actions {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.retake-grid .btn,
.bottom-actions .btn {
  width: 100%;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 480px) {
  .retake-grid,
  .bottom-actions {
    gap: 10px;
  }
}
