/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0d1a;
  --bg2: #13132a;
  --bg3: #1a1a38;
  --surface: #1e1e3a;
  --border: #2d2d5a;
  --accent: #e91e8c;
  --accent2: #9b59b6;
  --accent3: #3498db;
  --text: #f0f0ff;
  --text2: #a0a0c0;
  --text3: #606080;
  --green: #2ecc71;
  --yellow: #f39c12;
  --orange: #e67e22;
  --red: #e74c3c;
  --radius: 16px;
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ===== SCREENS ===== */
.screen {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  overscroll-behavior: contain;
}
.screen.active {
  opacity: 1;
  pointer-events: all;
}

/* ===== WELCOME SCREEN ===== */
#screen-welcome {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 24px 20px 40px;
}

.welcome-bg {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at 20% 20%, rgba(233,30,140,0.15) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 80%, rgba(155,89,182,0.15) 0%, transparent 60%),
              var(--bg);
  z-index: -1;
}

.welcome-content {
  max-width: 420px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.app-logo {
  width: 100px;
  height: 100px;
  background: linear-gradient(135deg, rgba(233,30,140,0.15), rgba(155,89,182,0.15));
  border-radius: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(233,30,140,0.3);
  box-shadow: 0 0 40px rgba(233,30,140,0.2);
}

.logo-svg { width: 72px; height: 72px; }

.app-title {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--text);
}

.app-title .accent {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.app-subtitle {
  font-size: 0.95rem;
  color: var(--text2);
  text-align: center;
  line-height: 1.7;
}

.features {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.feature {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.feature-icon { font-size: 1.6rem; flex-shrink: 0; }

.feature div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.feature strong {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
}

.feature span {
  font-size: 0.78rem;
  color: var(--text2);
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 16px 24px;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  box-shadow: 0 4px 20px rgba(233,30,140,0.4);
}

.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-arrow { font-size: 1.1rem; }

.privacy-notice {
  font-size: 0.75rem;
  color: var(--text3);
  text-align: center;
  line-height: 1.5;
}

/* ===== CAMERA SCREEN ===== */
#screen-camera {
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.camera-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(13,13,26,0.9);
  backdrop-filter: blur(8px);
  z-index: 10;
  flex-shrink: 0;
}

.btn-icon-round {
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.step-progress {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.step-node {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg3);
  border: 2px solid var(--border);
  color: var(--text2);
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
}

.step-node.active {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 0 12px rgba(233,30,140,0.5);
}

.step-node.done {
  background: var(--green);
  border-color: transparent;
  color: #fff;
}

.step-line {
  width: 24px;
  height: 2px;
  background: var(--border);
  transition: background 0.3s;
}

.step-line.done { background: var(--green); }

.step-label {
  font-size: 0.8rem;
  color: var(--text2);
  min-width: 32px;
  text-align: right;
  flex-shrink: 0;
}

.instruction-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.pose-emoji { font-size: 2.2rem; flex-shrink: 0; }

.instruction-text h2 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.instruction-text p {
  font-size: 0.8rem;
  color: var(--text2);
  line-height: 1.5;
}

.camera-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #000;
  min-height: 0;
}

#video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

#overlay-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: scaleX(-1);
}

.face-oval-guide {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.face-oval-guide svg {
  width: 100%;
  height: 100%;
}

.face-feedback {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(13,13,26,0.8);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.8rem;
  white-space: nowrap;
  backdrop-filter: blur(4px);
}

.feedback-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text3);
  flex-shrink: 0;
}

.face-feedback.detecting .feedback-dot {
  background: var(--yellow);
  animation: pulse 1.2s infinite;
}

.face-feedback.good .feedback-dot { background: var(--green); }
.face-feedback.error .feedback-dot { background: var(--red); }

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

.camera-controls {
  background: rgba(13,13,26,0.95);
  padding: 12px 16px 28px;
  flex-shrink: 0;
}

.capture-hint {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text2);
  margin-bottom: 12px;
  min-height: 20px;
}

.capture-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

.thumb-slot {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  background: var(--bg3);
  border: 2px dashed var(--border);
  overflow: hidden;
}

.thumb-slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.btn-shutter {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: transparent;
  border: none;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.shutter-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.4);
  transition: border-color 0.2s;
}

.shutter-center {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  transition: all 0.2s;
}

.btn-shutter:not(:disabled) .shutter-ring {
  border-color: #fff;
}

.btn-shutter:not(:disabled) .shutter-center {
  background: #fff;
}

.btn-shutter:not(:disabled):active .shutter-center {
  transform: scale(0.88);
  background: rgba(255,255,255,0.8);
}

.btn-shutter:disabled { cursor: not-allowed; opacity: 0.4; }

/* ===== PROCESSING SCREEN ===== */
#screen-processing {
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, var(--bg2), var(--bg));
}

.processing-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 32px 24px;
  width: 100%;
  max-width: 400px;
}

.ai-sphere {
  position: relative;
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sphere-glow {
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(233,30,140,0.3), transparent 70%);
  animation: glowPulse 2s infinite;
}

@keyframes glowPulse {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.1); }
}

.sphere-icon { font-size: 3rem; position: relative; z-index: 2; }

.ring {
  position: absolute;
  border-radius: 50%;
  border: 1.5px solid rgba(233,30,140,0.3);
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.r1 {
  width: 130px;
  height: 130px;
  animation: orbit1 3s linear infinite;
}

.r2 {
  width: 160px;
  height: 160px;
  animation: orbit2 5s linear infinite reverse;
}

@keyframes orbit1 { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes orbit2 { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.ring-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  display: block;
  margin-top: -4px;
  box-shadow: 0 0 8px var(--accent);
}

.processing-title {
  font-size: 1.3rem;
  font-weight: 700;
}

.progress-bar-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress-track {
  flex: 1;
  height: 6px;
  background: var(--bg3);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 3px;
  width: 0%;
  transition: width 0.5s ease;
}

#progress-pct {
  font-size: 0.85rem;
  color: var(--text2);
  min-width: 38px;
  text-align: right;
}

.analysis-log {
  width: 100%;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.analysis-log li {
  font-size: 0.85rem;
  color: var(--text3);
  padding: 8px 14px;
  background: var(--bg2);
  border-radius: 8px;
  border: 1px solid var(--border);
  transition: all 0.3s;
}

.analysis-log li.active {
  color: var(--accent);
  border-color: rgba(233,30,140,0.3);
  background: rgba(233,30,140,0.08);
}

.analysis-log li.done {
  color: var(--green);
  border-color: rgba(46,204,113,0.2);
  background: rgba(46,204,113,0.06);
}

/* ===== RESULTS SCREEN ===== */
#screen-results {
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: rgba(13,13,26,0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-shrink: 0;
}

.results-header h1 { font-size: 1.1rem; font-weight: 700; }

.header-btns { display: flex; gap: 8px; }

.btn-sm {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.results-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 40px;
  overscroll-behavior: contain;
}

/* Result components */
.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.skin-age-card {
  background: linear-gradient(135deg, rgba(233,30,140,0.15), rgba(155,89,182,0.15));
  border-color: rgba(233,30,140,0.3);
  text-align: center;
  padding: 28px 20px;
}

.skin-age-label {
  font-size: 0.85rem;
  color: var(--text2);
  margin-bottom: 8px;
}

.skin-age-value {
  font-size: 4rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1;
}

.skin-age-unit {
  font-size: 1.2rem;
  color: var(--text2);
  font-weight: 600;
  margin-top: 4px;
}

.skin-score-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.score-track {
  flex: 1;
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
}

.score-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--red), var(--yellow), var(--green));
  transition: width 1s ease;
}

.score-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text3);
  margin-top: 6px;
}

.factor-card { }

.factor-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text2);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.factor-bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.factor-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.factor-label {
  font-size: 0.8rem;
  width: 100px;
  color: var(--text);
  flex-shrink: 0;
}

.factor-bar-track {
  flex: 1;
  height: 10px;
  background: var(--bg);
  border-radius: 5px;
  overflow: hidden;
}

.factor-bar-fill {
  height: 100%;
  border-radius: 5px;
}

.factor-bar-fill.bone { background: var(--accent3); }
.factor-bar-fill.skin { background: var(--accent); }

.factor-pct {
  font-size: 0.82rem;
  font-weight: 700;
  min-width: 36px;
  text-align: right;
}

.features-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.feature-score-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.fs-icon { font-size: 1.4rem; margin-bottom: 6px; }

.fs-name {
  font-size: 0.8rem;
  color: var(--text2);
  margin-bottom: 6px;
  font-weight: 600;
}

.fs-score-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fs-ring {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}

.fs-ring circle { transition: stroke-dasharray 1s ease; }

.fs-score-num {
  font-size: 1.3rem;
  font-weight: 800;
}

.fs-severity {
  font-size: 0.75rem;
  color: var(--text2);
}

.section-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.improve-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.improve-tier {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.tier-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  text-transform: uppercase;
}

.tier-home { background: rgba(46,204,113,0.2); color: var(--green); }
.tier-pro { background: rgba(52,152,219,0.2); color: var(--accent3); }
.tier-medical { background: rgba(233,30,140,0.2); color: var(--accent); }

.tier-cost {
  font-size: 0.75rem;
  color: var(--text2);
  margin-left: auto;
}

.improve-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.improve-tag {
  font-size: 0.78rem;
  padding: 4px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
}

.timeline-text {
  font-size: 0.78rem;
  color: var(--text3);
  margin-top: 8px;
}

.disclaimer {
  font-size: 0.75rem;
  color: var(--text3);
  text-align: center;
  line-height: 1.7;
  padding: 16px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

/* ===== MODAL ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}

.modal.hidden { display: none; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  max-width: 320px;
  width: 100%;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.modal-box p { font-size: 0.9rem; color: var(--text); margin-bottom: 6px; }
.modal-sub { color: var(--text3) !important; font-size: 0.78rem !important; }

.error-icon { font-size: 2.5rem; margin-bottom: 12px; }
.modal-box h3 { font-size: 1rem; margin-bottom: 8px; }