/* ===== Reset / Base (Mobile-first, Full-bleed) ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  width: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #222;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
  font-size: clamp(16px, 4.2vw, 18px);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  min-height: 100svh;
  min-height: -webkit-fill-available;
  background: #fff;
}

/* ===== Header ===== */
.header {
  padding: 16px;
  padding-top: max(16px, env(safe-area-inset-top));
  text-align: center;
  color: #fff;
  background: #1e4d7b;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
}

.header-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}

.header-logo img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.header h1 {
  font-size: clamp(20px, 5.6vw, 24px);
  font-weight: 800;
  margin-bottom: 6px;
}

.header p {
  font-size: clamp(13px, 3.6vw, 15px);
  opacity: 0.95;
}

/* ===== Chat Container ===== */
.chat-container {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 16px;
  background: #f7f8fb;
}

.message {
  display: flex;
  margin-bottom: 14px;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.bot {
  justify-content: flex-start;
  align-items: flex-start;
}

.message.user {
  justify-content: flex-end;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  margin-right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: transparent;
  flex-shrink: 0;
  overflow: hidden;
}

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

.message-content {
  max-width: 85%;
  padding: 12px 14px;
  border-radius: 16px;
  line-height: 1.6;
  font-size: 1rem;
  word-wrap: break-word;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.message.bot .message-content {
  background: #fff;
  color: #222;
  border-bottom-left-radius: 6px;
}

.message.user .message-content {
  background: #1e4d7b;
  color: #fff;
  border-bottom-right-radius: 6px;
  box-shadow: 0 2px 8px rgba(30, 77, 123, 0.25);
}

/* ===== Input Area (Sticky bottom) ===== */
.input-area {
  background: #fff;
  padding: 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid #e6e6e6;
  flex-shrink: 0;
}

/* ===== Progress Bar Container ===== */
.progress-bar-container {
  margin-bottom: 16px;
  position: relative;
}

.progress-bar {
  width: 100%;
  height: 12px;
  background: #e6e6e6;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
  position: relative;
}

.progress-fill {
  height: 100%;
  background: #f59e0b;
  border-radius: 8px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
  position: relative;
}

.progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0) 100%);
  border-radius: 8px 8px 0 0;
}

.progress-text {
  font-size: 0.85rem;
  font-weight: 800;
  text-align: center;
  margin-top: 6px;
  color: #1e4d7b;
  letter-spacing: 0.02em;
}

.input-group {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 12px 0 8px;
}

input[type="text"],
input[type="number"],
select {
  font-size: 16px;
  height: 52px;
  line-height: 52px;
  flex: 1;
  padding: 0 14px;
  border: 2px solid #e6e6e6;
  border-radius: 12px;
  background: #f7f8fb;
  transition: all 0.15s ease;
  font-family: inherit;
}

input:focus,
select:focus {
  outline: none;
  border-color: #f59e0b;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.14);
}

input::placeholder {
  color: #98a1b3;
}

input.error {
  border-color: #dc2626;
  background: #fef2f2;
}

input.error:focus {
  border-color: #dc2626;
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.14);
}

.input-unit {
  color: #555;
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
  min-width: 44px;
}

/* ===== Buttons ===== */
button {
  font-size: 17px;
  padding: 14px 20px;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
  border: none;
  border-radius: 12px;
  transition: transform 0.1s ease, box-shadow 0.2s ease;
  color: #fff;
  background: #f59e0b;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
  font-family: inherit;
}

button:active {
  transform: scale(0.98);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.option-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.option-button {
  background: #fff;
  color: #f59e0b;
  border: 2px solid #f59e0b;
  box-shadow: none;
}

.option-button:active {
  background: #f59e0b;
  color: #fff;
}

.next-button {
  width: 100%;
  margin-top: 10px;
  min-height: 50px;
  font-size: 1.05rem;
}

/* ===== Result Cards ===== */
.result-card {
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  margin: 12px 0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.rank-display {
  text-align: center;
  padding: 32px 20px;
  border-radius: 20px;
  color: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
  scroll-margin-top: 20px;
}

.rank-display::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 100%);
  pointer-events: none;
}

.rank-label {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  opacity: 0.98;
  margin-bottom: 12px;
  text-transform: none;
  position: relative;
  z-index: 1;
}

.rank-value {
  font-size: clamp(64px, 20vw, 88px);
  font-weight: 900;
  margin: 10px 0 14px;
  text-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
  letter-spacing: 0.02em;
  position: relative;
  z-index: 1;
  line-height: 1;
}

.rank-comment {
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.5;
  position: relative;
  z-index: 1;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* ランク表示のハイライトアニメーション */
@keyframes rankHighlight {
  0% {
    transform: scale(0.95);
    opacity: 0;
  }
  50% {
    transform: scale(1.02);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes rankPulse {
  0%, 100% {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  }
  50% {
    box-shadow: 0 12px 32px rgba(102, 126, 234, 0.4);
  }
}

.rank-highlight-animation {
  animation: rankHighlight 0.6s ease-out, rankPulse 2s ease-in-out 0.6s 2;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: #222;
  margin: 18px 0 12px;
  padding-bottom: 8px;
  border-bottom: 3px solid #667eea;
}

/* 同意画面用のコンパクト表示 */
.result-card:has(.privacy-content) {
  padding: 12px;
  margin: 8px 0;
}

.result-card:has(.privacy-content) .section-title {
  font-size: 1rem;
  margin: 8px 0 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid #1e4d7b;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.detail-item {
  background: #f7f8fb;
  padding: 12px;
  border-radius: 12px;
  border: 2px solid #e6e6e6;
}

.detail-label {
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 4px;
  font-weight: 700;
}

.detail-value {
  font-size: 1.15rem;
  font-weight: 900;
  color: #222;
}

/* ===== Chart ===== */
.chart-container {
  margin: 16px 0;
  padding: 20px 10px;
  background: #f7f8fb;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  position: relative;
}

#radarChart {
  max-width: 100%;
  width: 100% !important;
  height: auto !important;
  min-height: 350px;
}

/* ===== Advice List ===== */
.advice-list {
  list-style: none;
  padding: 0;
  margin: 12px 0;
}

.advice-list li {
  padding: 10px 12px;
  margin-bottom: 8px;
  background: #f7f8fb;
  border-radius: 10px;
  border-left: 4px solid #f59e0b;
  line-height: 1.6;
  font-size: 0.95rem;
}

/* ランク別のアドバイススタイル */
.advice-rank-S li {
  background: #f0fdf4;
  border-left-color: #10b981;
  color: #065f46;
}

.advice-rank-A li {
  background: #f0f9ff;
  border-left-color: #3b82f6;
  color: #1e40af;
}

.advice-rank-B li {
  background: #fef9e7;
  border-left-color: #f59e0b;
  color: #92400e;
}

.advice-rank-C li {
  background: #fef3e0;
  border-left-color: #f97316;
  color: #c2410c;
}

.advice-rank-D li {
  background: #fef2f2;
  border-left-color: #dc2626;
  color: #991b1b;
  font-weight: 600;
}

/* ===== CTA Buttons ===== */
.cta-buttons {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 16px;
}

.cta-button {
  padding: 14px;
  text-align: center;
  border-radius: 12px;
  font-weight: 800;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 1rem;
  transition: transform 0.1s ease;
}

.cta-button:active {
  transform: scale(0.98);
}

.cta-primary {
  background: #f59e0b;
  color: #fff;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.cta-secondary {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* ===== Checkbox ===== */
.checkbox-group {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
  padding: 12px;
  background: #f7f8fb;
  border-radius: 10px;
  border: 2px solid #e6e6e6;
}

.checkbox-group input[type="checkbox"] {
  width: 24px;
  height: 24px;
  cursor: pointer;
  accent-color: #f59e0b;
}

.checkbox-group label {
  font-size: 0.95rem;
  color: #222;
  cursor: pointer;
  font-weight: 600;
  flex: 1;
  line-height: 1.5;
}

/* ===== Restart Button ===== */
.restart-button {
  width: 100%;
  margin-top: 12px;
  background: #fff;
  color: #1e4d7b;
  border: 2px solid #1e4d7b;
  box-shadow: none;
}

.restart-button:active {
  background: #667eea;
  color: #fff;
}

/* ===== Responsive Adjustments ===== */
/* モザイク化スタイル */
.mosaic-wrapper {
  position: relative;
  margin: 20px 0;
  background: #f9fafb;
  border-radius: 12px;
  padding: 16px;
  overflow: hidden;
}

.mosaic-section {
  filter: blur(6px);
  pointer-events: none;
  user-select: none;
  opacity: 0.5;
  transform: scale(0.85);
  transform-origin: top center;
  margin: -8px;
}

.mosaic-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(2px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  padding: 20px 16px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  width: calc(100% - 32px);
  max-width: 400px;
}

.mosaic-overlay-title {
  font-size: 1rem;
  font-weight: 700;
  color: #1e4d7b;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.mosaic-overlay-text {
  font-size: 0.85rem;
  color: #4b5563;
  margin-bottom: 12px;
  line-height: 1.5;
}

.mosaic-cta-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: #f59e0b;
  color: white;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.88rem;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(245, 158, 11, 0.3);
}

.mosaic-cta-button:hover {
  background: #d97706;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(245, 158, 11, 0.4);
}

/* アドバイスのモザイク化スタイル */
.advice-mosaic-wrapper {
  position: relative;
  margin: 16px 0;
}

.advice-mosaic-section {
  filter: blur(6px);
  pointer-events: none;
  user-select: none;
  opacity: 0.4;
  max-height: 120px;
  overflow: hidden;
}

@media (max-width: 480px) {
  .rank-display {
    padding: 28px 16px;
    margin-bottom: 20px;
    scroll-margin-top: 10px;
  }
  
  .rank-label {
    font-size: 0.95rem;
    margin-bottom: 10px;
  }
  
  .rank-value {
    margin: 8px 0 12px;
  }
  
  .rank-comment {
    font-size: 1.05rem;
  }
  
  .chart-container {
    padding: 15px 5px;
    min-height: 380px;
  }
  
  #radarChart {
    min-height: 330px;
  }
  
  .mosaic-wrapper {
    padding: 12px;
  }
  
  .mosaic-overlay {
    padding: 16px 12px;
    width: calc(100% - 24px);
  }
  
  .mosaic-overlay-title {
    font-size: 0.9rem;
  }
  
  .mosaic-overlay-text {
    font-size: 0.8rem;
  }
  
  .mosaic-cta-button {
    padding: 8px 16px;
    font-size: 0.85rem;
  }
  
  .mosaic-section {
    transform: scale(0.75);
  }
}

@media (max-width: 360px) {
  .rank-display {
    padding: 24px 14px;
  }
  
  .rank-label {
    font-size: 0.9rem;
  }
  
  .rank-comment {
    font-size: 1rem;
  }
  
  .chart-container {
    padding: 12px 3px;
    min-height: 360px;
  }
  
  #radarChart {
    min-height: 310px;
  }
}

/* ===== Loading ===== */
.loading {
  text-align: center;
  padding: 20px;
  color: #667eea;
  font-weight: 700;
}

.loading::after {
  content: '...';
  animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60%, 100% { content: '...'; }
}

/* ===== Privacy Policy ===== */
.privacy-content {
  font-size: 0.82rem;
  line-height: 1.55;
  color: #444;
  padding: 10px;
  background: #f7f8fb;
  border-radius: 10px;
  margin: 10px 0;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid #e0e4f0;
  -webkit-overflow-scrolling: touch;
}

.privacy-content h3 {
  font-size: 0.88rem;
  font-weight: 800;
  margin: 10px 0 4px;
  color: #222;
  padding-top: 5px;
  border-top: 1px solid #e0e4f0;
}

.privacy-content h3:first-of-type {
  margin-top: 6px;
  padding-top: 0;
  border-top: none;
}

.privacy-content ul {
  margin: 4px 0;
  padding-left: 18px;
  list-style-type: disc;
}

.privacy-content li {
  margin: 3px 0;
  color: #555;
}

.privacy-content p {
  margin: 4px 0;
  color: #444;
}

/* スクロールバーのスタイリング */
.privacy-content::-webkit-scrollbar {
  width: 8px;
}

.privacy-content::-webkit-scrollbar-track {
  background: #e0e4f0;
  border-radius: 4px;
}

.privacy-content::-webkit-scrollbar-thumb {
  background: #667eea;
  border-radius: 4px;
}

.privacy-content::-webkit-scrollbar-thumb:hover {
  background: #5568d3;
}
