/* ==========================================
   AIストレス疲労診断 デモサイト
   ダーク系サイバーモダンUI
   ========================================== */

/* --- Reset & Base --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0a0a1e;
  --bg-secondary: #0f0f2e;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.08);
  --bg-glass: rgba(255, 255, 255, 0.06);
  --border-glass: rgba(255, 255, 255, 0.1);
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.6);
  --text-muted: rgba(255, 255, 255, 0.4);
  --accent-purple: #8b5cf6;
  --accent-blue: #06b6d4;
  --accent-green: #34d399;
  --accent-red: #f87171;
  --accent-orange: #fb923c;
  --gradient-primary: linear-gradient(135deg, #8b5cf6, #06b6d4);
  --gradient-btn: linear-gradient(135deg, #7c3aed, #8b5cf6, #a78bfa);
  --gradient-good: linear-gradient(135deg, #34d399, #06b6d4);
  --gradient-bad: linear-gradient(135deg, #f87171, #fb923c);
  --font-main: 'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-main);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

#app {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
}

/* --- Demo Banner --- */
.demo-banner {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  padding: 6px 0;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.9), rgba(6, 182, 212, 0.9));
  color: white;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  z-index: 100;
  backdrop-filter: blur(10px);
}

/* --- Screen Management --- */
.screen {
  display: none;
  min-height: 100dvh;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.screen.active {
  display: block;
  opacity: 1;
}

/* --- Buttons --- */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
  padding: 16px 32px;
  background: var(--gradient-btn);
  color: white;
  border: none;
  border-radius: 60px;
  font-size: 1.05rem;
  font-weight: 600;
  font-family: var(--font-main);
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 24px rgba(139, 92, 246, 0.35);
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}

.btn-primary:hover::before {
  opacity: 1;
}

.btn-primary:active {
  transform: scale(0.97);
}

.btn-icon {
  font-size: 1.2rem;
}

.btn-back {
  background: none;
  border: none;
  color: var(--accent-purple);
  font-size: 0.95rem;
  font-family: var(--font-main);
  cursor: pointer;
  padding: 8px;
}

/* --- HOME SCREEN --- */
.home-bg-glow {
  position: fixed;
  top: -200px;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.15) 0%, rgba(6, 182, 212, 0.05) 50%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.home-content {
  position: relative;
  z-index: 1;
  padding: 60px 24px 40px;
  text-align: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  border: 1px solid var(--border-glass);
  border-radius: 60px;
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  animation: pulse-dot 2s ease infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.4); }
  50% { opacity: 0.8; box-shadow: 0 0 0 6px rgba(52, 211, 153, 0); }
}

.hero-title {
  font-size: 2.4rem;
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: 20px;
  letter-spacing: -0.02em;
}

.gradient-text {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-desc {
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 36px;
  max-width: 380px;
  margin-left: auto;
  margin-right: auto;
}

.hero-buttons {
  margin-bottom: 40px;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-bottom: 48px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  text-align: left;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 20px 16px;
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
}

.metric-card:hover {
  background: var(--bg-card-hover);
  transform: translateY(-2px);
}

.metric-icon {
  font-size: 1.5rem;
  margin-bottom: 10px;
}

.metric-card h3 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.metric-card p {
  font-size: 0.72rem;
  line-height: 1.5;
  color: var(--text-muted);
}

/* --- CAMERA SCREEN --- */
.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-glass);
  background: rgba(10, 10, 30, 0.8);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.screen-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

.camera-content {
  padding: 24px 20px;
}

.camera-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 3/4;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #000;
  margin-bottom: 24px;
  border: 2px solid rgba(139, 92, 246, 0.4);
  box-shadow: 0 0 30px rgba(139, 92, 246, 0.15);
}

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

.camera-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.face-guide {
  width: 65%;
  height: 60%;
  border: 2px dashed rgba(139, 92, 246, 0.5);
  border-radius: 50%;
  animation: guide-pulse 2s ease infinite;
}

@keyframes guide-pulse {
  0%, 100% { border-color: rgba(139, 92, 246, 0.5); }
  50% { border-color: rgba(139, 92, 246, 0.2); }
}

.camera-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.camera-placeholder span {
  font-size: 3rem;
}

.camera-placeholder.hidden {
  display: none;
}

.btn-capture {
  margin-bottom: 32px;
}

.tips-section {
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(10px);
}

.tips-section h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 14px;
}

.tip-item {
  font-size: 0.82rem;
  color: var(--text-secondary);
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.tip-item:last-child {
  border-bottom: none;
}

/* --- MEASURING SCREEN --- */
.measuring-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 40px 24px;
  text-align: center;
}

.measuring-visual {
  position: relative;
  width: 140px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 36px;
}

.pulse-ring {
  position: absolute;
  inset: 0;
  border: 2px solid rgba(139, 92, 246, 0.3);
  border-radius: 50%;
  animation: pulse-expand 2s ease-out infinite;
}

.pulse-ring.delay-1 { animation-delay: 0.6s; }
.pulse-ring.delay-2 { animation-delay: 1.2s; }

@keyframes pulse-expand {
  0% { transform: scale(0.5); opacity: 1; }
  100% { transform: scale(1.5); opacity: 0; }
}

.measuring-icon {
  font-size: 3rem;
  z-index: 1;
  animation: icon-float 2s ease-in-out infinite;
}

@keyframes icon-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.measuring-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 12px;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.measuring-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 36px;
}

.progress-container {
  width: 100%;
  max-width: 320px;
  margin-bottom: 40px;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: var(--gradient-primary);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.measuring-steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 300px;
}

.measure-step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--text-muted);
  transition: all 0.3s ease;
}

.measure-step.active {
  color: var(--accent-purple);
}

.measure-step.done {
  color: var(--accent-green);
}

.step-icon {
  font-size: 1rem;
}

/* --- RESULTS SCREEN --- */
.results-content {
  padding: 24px 20px 40px;
}

.results-summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-xl);
  padding: 28px 24px;
  text-align: center;
  backdrop-filter: blur(10px);
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.results-summary-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient-primary);
}

.results-summary-card h3 {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 24px;
}

.score-comparison {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-bottom: 12px;
}

.score-before, .score-after {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.score-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.score-value {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1;
}

.score-bad {
  color: var(--accent-red);
}

.score-good {
  color: var(--accent-green);
}

.score-unit {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.score-arrow {
  display: flex;
  align-items: center;
}

.score-note {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.improvement-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 20px;
  background: rgba(52, 211, 153, 0.12);
  border: 1px solid rgba(52, 211, 153, 0.3);
  border-radius: 60px;
  color: var(--accent-green);
  font-size: 0.9rem;
  font-weight: 700;
}

/* Photo Comparison */
.photo-comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 28px;
}

.photo-card {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  aspect-ratio: 3/4;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
}

.photo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.photo-label {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  backdrop-filter: blur(8px);
}

.label-before {
  background: rgba(248, 113, 113, 0.2);
  color: var(--accent-red);
  border: 1px solid rgba(248, 113, 113, 0.3);
}

.label-after {
  background: rgba(52, 211, 153, 0.2);
  color: var(--accent-green);
  border: 1px solid rgba(52, 211, 153, 0.3);
}

/* Detail Metrics */
.section-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.detail-metrics {
  margin-bottom: 28px;
}

.metric-result-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 18px 16px;
  margin-bottom: 10px;
  backdrop-filter: blur(10px);
  animation: slide-up 0.5s ease backwards;
}

.metric-result-card:nth-child(2) { animation-delay: 0.1s; }
.metric-result-card:nth-child(3) { animation-delay: 0.2s; }
.metric-result-card:nth-child(4) { animation-delay: 0.3s; }
.metric-result-card:nth-child(5) { animation-delay: 0.4s; }
.metric-result-card:nth-child(6) { animation-delay: 0.5s; }
.metric-result-card:nth-child(7) { animation-delay: 0.6s; }

@keyframes slide-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.metric-result-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.metric-result-icon {
  font-size: 1.2rem;
}

.metric-result-name {
  font-size: 0.85rem;
  font-weight: 600;
}

.metric-result-values {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.metric-before, .metric-after {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 1;
}

.metric-before .label, .metric-after .label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

.metric-before .value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--accent-red);
}

.metric-after .value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--accent-green);
}

.metric-before .unit, .metric-after .unit {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.metric-arrow {
  font-size: 1.2rem;
  color: var(--text-muted);
  padding: 0 8px;
}

.metric-bar-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.metric-bar-before, .metric-bar-after {
  height: 4px;
  border-radius: 2px;
  transition: width 1s ease;
}

.metric-bar-before {
  background: var(--gradient-bad);
}

.metric-bar-after {
  background: var(--gradient-good);
}

/* Radar Chart */
.radar-chart-section {
  margin-bottom: 28px;
}

.radar-chart-container {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-xl);
  padding: 24px 16px 16px;
  backdrop-filter: blur(10px);
  text-align: center;
}

#radar-chart {
  width: 100%;
  max-width: 340px;
  height: auto;
  margin: 0 auto;
  display: block;
}

.radar-legend {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 12px;
}

.radar-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.legend-dot.legend-before {
  background: rgba(248, 113, 113, 0.8);
  box-shadow: 0 0 6px rgba(248, 113, 113, 0.4);
}

.legend-dot.legend-after {
  background: rgba(52, 211, 153, 0.8);
  box-shadow: 0 0 6px rgba(52, 211, 153, 0.4);
}

/* AI Comment */
.ai-comment {
  margin-bottom: 28px;
}

.comment-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 20px;
  backdrop-filter: blur(10px);
}

.comment-card p {
  font-size: 0.85rem;
  line-height: 1.8;
  color: var(--text-secondary);
}

.btn-restart {
  margin-bottom: 20px;
}

/* --- Animations --- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-in {
  animation: fadeInUp 0.6s ease forwards;
}

/* --- Responsive --- */
@media (max-width: 400px) {
  .hero-title {
    font-size: 2rem;
  }
  
  .hero-stats {
    gap: 24px;
  }
  
  .stat-value {
    font-size: 1.1rem;
  }
  
  .metrics-grid {
    gap: 8px;
  }
  
  .metric-card {
    padding: 16px 12px;
  }
  
  .score-value {
    font-size: 2.4rem;
  }
}

@media (min-width: 481px) {
  #app {
    border-left: 1px solid var(--border-glass);
    border-right: 1px solid var(--border-glass);
  }
}

/* --- Number animation --- */
.count-up {
  display: inline-block;
}
