/* 全局样式 */
:root {
  --primary-color: #007bff;
  --primary-hover-color: #0056b3;
  --background-color: #f8f9fa;
  --container-bg: #ffffff;
  --text-color: #343a40;
  --light-text-color: #6c757d;
  --border-color: #dee2e6;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  --warning-bg: #fff3cd;
  --warning-text: #856404;
  --warning-border: #ffeeba;
  --success-color: #28a745;
  --danger-color: #dc3545;
  --warning-color: #ffc107;
}

html {
  box-sizing: border-box;
}
*,
*:before,
*:after {
  box-sizing: inherit;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  background-color: var(--background-color);
  margin: 0;
  padding: 20px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
}

.container {
  max-width: 800px;
  width: 100%;
  background: var(--container-bg);
  padding: clamp(15px, 5vw, 30px);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
h1,
h2,
h3 {
  color: var(--text-color);
  margin-bottom: 0.75em;
}
h1 {
  font-size: clamp(1.5rem, 4vw, 1.8rem);
}
h2 {
  font-size: clamp(1.3rem, 4vw, 1.5rem);
  border-bottom: 2px solid var(--primary-color);
  padding-bottom: 10px;
  margin-top: 30px;
}
h3 {
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--primary-color);
}
h3 svg {
  width: 24px;
  height: 24px;
}
.hidden {
  display: none !important;
}

/* 头部 */
.page-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  text-align: center;
  margin-bottom: 25px;
}
.header-icon {
  width: clamp(28px, 8vw, 36px);
  height: clamp(28px, 8vw, 36px);
  color: var(--primary-color);
}

/* 介绍页面 */
#intro-page .introduction {
  background-color: #e9ecef;
  padding: 15px 20px;
  border-radius: 8px;
  text-align: center;
  font-size: clamp(0.9rem, 3vw, 1.1rem);
  color: var(--light-text-color);
  margin-bottom: 30px;
}
.dimensions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 15px;
}
.dimension-card {
  background: #f8f9fa;
  padding: 15px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 15px;
}
.dimension-card svg {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  color: var(--primary-color);
}
.dimension-card h4 {
  margin: 0 0 5px;
  font-size: 1rem;
}
.dimension-card p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--light-text-color);
}
.start-button-container {
  text-align: center;
  margin-top: 40px;
}

/* 测试页面 */
.progress-container {
  margin-bottom: 30px;
}
.progress-bar-bg {
  width: 100%;
  height: 10px;
  background-color: #e9ecef;
  border-radius: 5px;
  overflow: hidden;
}
.progress-bar {
  width: 0%;
  height: 100%;
  background-color: var(--primary-color);
  border-radius: 5px;
  transition: width 0.3s ease;
}
.progress-text {
  text-align: right;
  margin-top: 8px;
  font-size: 0.9rem;
  color: var(--light-text-color);
}
#question-area {
  min-height: 250px;
  text-align: center; /* 容器居中 */
  margin-bottom: 30px;
  transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;
}
#question-area.is-changing {
  opacity: 0;
  transform: translateY(15px);
}
/* v1.0.4 修改：扩大宽度 */
.question-wrapper {
  max-width: 600px;
  width: 95%; /* 手机上占比更大 */
  margin: 0 auto 20px auto;
  text-align: left;
}
#question-text {
  font-size: clamp(1.2rem, 5vw, 1.4rem);
  font-weight: 500;
  margin: 0;
  line-height: 1.4;
}

/* v1.0.4 新增：维度标签样式 */
.dimension-badge {
  display: inline-block;
  background-color: #e9ecef;
  color: var(--primary-color);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 15px;
}

/* 选项布局优化 */
.options-container {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  max-width: 600px; /* 选项容器也同步加宽 */
  margin: 0 auto;
}
.options-container label {
  display: flex;
  flex-direction: column;
  padding: 12px 20px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}
.options-container input[type="radio"] {
  display: none;
}
.options-container .option-title {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 4px;
}
.options-container .option-desc {
  font-size: 0.9rem;
  color: var(--light-text-color);
}
.options-container input[type="radio"]:checked + label {
  border-color: var(--primary-color);
  background-color: #f0f8ff;
  box-shadow: 0 0 0 2px var(--primary-color);
}
.options-container input[type="radio"]:checked + label .option-desc {
  color: var(--primary-hover-color);
}

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 25px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background-color: #fff;
  color: var(--text-color);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn svg {
  width: 20px;
  height: 20px;
}
.btn-primary {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
}
.btn-success {
  background-color: var(--success-color);
  border-color: var(--success-color);
  color: white;
}
.btn:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
.btn-primary:not(:disabled):hover {
  background-color: var(--primary-hover-color);
  border-color: var(--primary-hover-color);
}
.btn-success:not(:disabled):hover {
  background-color: #218838;
  border-color: #1e7e34;
}
.navigation-buttons {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 20px;
  gap: 15px;
  flex-wrap: wrap; /* 允许按钮换行以适应小屏 */
}

/* 结果页面 */
.report-section {
  background-color: #fff;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 25px;
}
.meta-data {
  background-color: #e9ecef;
  text-align: center;
  color: var(--light-text-color);
}
.disclaimer,
.result-disclaimer {
  background-color: var(--warning-bg);
  color: var(--warning-text);
  padding: 15px;
  border-radius: 8px;
  border: 1px solid var(--warning-border);
  text-align: center;
  margin-top: 15px;
}
#risk-assessment .risk-level {
  font-size: 1.2rem;
  font-weight: bold;
  margin-bottom: 10px;
}
#risk-assessment .risk-high {
  color: #dc3545;
}
#risk-assessment .risk-medium {
  color: #ffc107;
}
#risk-assessment .risk-low {
  color: #28a745;
}
#personalized-suggestions ul {
  list-style-type: none;
  padding: 0;
}
#personalized-suggestions li {
  background-color: #f8f9fa;
  padding: 15px;
  border-radius: 5px;
  margin-bottom: 10px;
}
#result-chart-container {
  position: relative;
  height: 40vh;
  max-height: 400px;
  min-height: 300px;
}

/* 表格样式优化 */
table {
  width: 100%;
  border-collapse: collapse;
}
th,
td {
  border: 1px solid var(--border-color);
  padding: 12px;
  text-align: left;
}
th {
  background-color: #f8f9fa;
  font-weight: 600;
}
.text-danger {
  color: var(--danger-color);
  font-weight: bold;
}
.text-warning {
  color: #b58900;
  font-weight: bold;
}
.text-success {
  color: var(--success-color);
}

#total-summary {
  background-color: #e9ecef;
  padding: 15px;
  border-radius: 8px;
}

/* 遮罩层 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}
/* 弹窗主体 */
.modal-content {
  background: white;
  padding: 25px 20px; /* 上下25px，左右20px */
  border-radius: 12px;
  width: 90%;
  max-width: 380px; /* PC端稍微限制一下总宽，不要太宽 */
  text-align: center;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  box-sizing: border-box;
}
/* 输入框 */
/* #manualCodeInput { */
/* width: 100%; padding: 10px; margin: 15px 0; */
/* font-size: 18px; text-align: center; letter-spacing: 2px; */
/* text-transform: uppercase; 输入自动变大写 */
/* border: 2px solid #ddd; border-radius: 6px; box-sizing: border-box; */
/* } */

/* 容器布局：弹性布局让7个框横向排列 */
.code-inputs-container {
  display: flex;
  /* 关键点1：两端对齐，但如果框不够宽，间距会自动拉大，而不是拉大框 */
  justify-content: space-between;
  align-items: center;
  gap: 4px; /* 最小间距 */
  margin: 20px 0;
}

/* 单个小框样式 自动伸缩 */
.char-input {
  /* 关键点2：允许缩小(1)，允许放大(1)，但基准宽度是 45px */
  flex: 1 1 45px;

  /* 关键点3：限制最大宽度！PC上最宽只能是 48px */
  max-width: 48px;

  /* 关键点4：高度固定，配合 max-width 实现接近正方形的视觉效果 */
  height: 48px;

  /* 关键点5：允许无限缩小 (适配 iPhone SE 等超小屏) */
  min-width: 0;

  /* 下面是美化样式 */
  font-size: 22px;
  font-weight: bold;
  text-align: center;
  color: #333;
  border: 1px solid #ccc;
  border-radius: 8px; /* 圆角稍微大一点，现代感更强 */
  outline: none;
  padding: 0;
  transition: all 0.2s;
  background: #f3f3f3; /* 稍微给点背景色，更有质感 */
}

/* 激活/聚焦状态 */
.char-input:focus {
  border-color: #007bff;
  box-shadow: 0 0 5px rgba(0, 123, 255, 0.3);
  transform: translateY(-2px); /* 微微上浮效果 */
}

/* 定义抖动动画 */
@keyframes shake {
  0% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  50% {
    transform: translateX(5px);
  }
  75% {
    transform: translateX(-5px);
  }
  100% {
    transform: translateX(0);
  }
}
.shake {
  animation: shake 0.3s;
  border-color: red !important; /* 可选：出错变红 */
}

/* #manualCodeInput:focus { border-color: #007bff; outline: none; } */
/* 按钮 */
#verifyBtn {
  width: 100%;
  padding: 10px;
  background: #007bff;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
}
#verifyBtn:disabled {
  background: #ccc;
  cursor: not-allowed;
}
.btn-text {
  background: none;
  border: none;
  color: #666;
  margin-top: 10px;
  cursor: pointer;
}

#msgBox {
  color: #6c757d;
  font-size: 14px;
  min-height: 20px;
  margin: 20px 0 12px 0;
}

/* 错误提示 */
.error-msg {
  color: #dc3545;
  font-size: 14px;
  min-height: 20px;
  margin: 20px 0 12px 0;
}

#msgBox.error-msg {
  color: #dc3545;
}

/* 只有在你觉得默认的蓝色选中背景太丑时才加这个 */
/* ::selection { background: transparent; color: inherit; } */

/* 锁定状态的按钮样式 */
#verifyBtn:disabled {
  background-color: #a0cfff; /* 变浅色 */
  cursor: not-allowed;
  opacity: 0.7;
}

/* 如果你想加个等待的图标 */
.btn-locked::after {
  content: " ⏳";
}

/* 页脚 */
.footer {
  text-align: center;
  margin-top: 30px;
  font-size: 0.9rem;
  color: var(--light-text-color);
}
.footer p {
  margin: 5px 0;
}

/* --- 模态框样式 --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  animation: fadeIn 0.3s;
}
.modal-content {
  background-color: white;
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  width: 90%;
  max-width: 450px;
  text-align: center;
  animation: slideUp 0.3s;
}
.modal-header svg {
  margin-bottom: 15px;
}
.modal-header h2 {
  margin: 0 0 20px 0;
  border: none;
  padding: 0;
  font-size: 1.6rem;
}
.summary-list {
  list-style: none;
  padding: 0;
  margin: 0 0 25px 0;
  text-align: left;
  border-top: 1px solid #eee;
  border-bottom: 1px solid #eee;
}
.summary-list li {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid #f8f9fa;
}
.summary-list li:last-child {
  border-bottom: none;
}
.btn-large {
  width: 100%;
  padding: 15px;
  font-size: 1.1rem;
}

/* --- 加载动画样式 --- */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 1001;
}
.loader {
  border: 5px solid #f3f3f3;
  border-top: 5px solid var(--primary-color);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}
.loading-text {
  font-size: 1.1rem;
  color: var(--light-text-color);
  font-weight: 500;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}
@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* 响应式设计 */
@media (max-width: 768px) {
  body {
    padding: 0;
  }
  .container {
    padding: 0;
    border-radius: 0;
    min-height: 100vh;
    box-shadow: none;
  }
  .page-header,
  .report-section,
  .navigation-buttons,
  .footer,
  #intro-page .introduction,
  .dimensions-grid,
  #intro-page h2,
  #question-area {
    margin-left: 15px;
    margin-right: 15px;
  }
  .report-section {
    padding: 15px;
  }

  .progress-text {
    padding-right: 15px;
  }
}

/* =========================================
   针对超小屏幕 (如 iPhone SE, 320px宽) 的微调
   ========================================= */
@media (max-width: 360px) {
  .modal-content {
    padding: 20px 10px; /* 左右边距减小，给输入框留空间 */
  }
  .char-input {
    height: 40px; /* 高度变矮 */
    font-size: 18px; /* 字体变小 */
    border-radius: 4px;
  }
}

/* v1.0.4 修改：仅在超小屏幕（<480px）时使用卡片式表格 */
@media (max-width: 480px) {
  /* #result-table thead {
    display: none;
  }
  #result-table,
  #result-table tbody,
  #result-table tr,
  #result-table td {
    display: block;
    width: 100%;
  }
  #result-table tr {
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    overflow: hidden;
  }
  #result-table td {
    text-align: right;
    padding-left: 50%;
    position: relative;
    border: none;
    border-bottom: 1px solid #f2f2f2;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-height: 44px;
  }
  #result-table td:last-child {
    border-bottom: none;
  }
  #result-table td::before {
    content: attr(data-label);
    position: absolute;
    left: 10px;
    width: calc(50% - 20px);
    padding-right: 10px;
    text-align: left;
    font-weight: 600;
    color: var(--text-color);
  } */

  /* 按钮适配 */
  .btn {
    padding: 10px 15px;
    font-size: 0.9rem;
  }
  .navigation-buttons {
    flex-direction: row;
    justify-content: space-around;
    width: calc(100% - 30px);
  }
  #prev-btn,
  #reset-btn,
  #restart-btn-ingame,
  #export-btn {
    width: auto;
    flex-grow: 1;
  }
}
