/* COC阵型分析助手 - 移动端H5样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

/* 确保hidden属性始终生效（覆盖display:flex/block等） */
[hidden] {
  display: none !important;
}

:root {
  --bg-dark: #1a1207;
  --bg-card: #2a1f0e;
  --bg-card-light: #3d2e15;
  --gold: #ffc542;
  --gold-dark: #d4941a;
  --gold-light: #ffe082;
  --text-main: #f5e6c8;
  --text-dim: #a89070;
  --accent: #ff6b35;
  --accent-light: #ff8c5a;
  --success: #4caf50;
  --danger: #f44336;
  --border: #5a4020;
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
}

body {
  background: 
    radial-gradient(ellipse at top, #3d2e15 0%, #1a1207 60%),
    linear-gradient(180deg, #2a1f0e 0%, #1a1207 100%);
  background-attachment: fixed;
}

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 14px 40px;
}

/* 头部 */
.header {
  text-align: center;
  padding: 20px 0 24px;
}

.header-icon {
  font-size: 48px;
  margin-bottom: 8px;
  filter: drop-shadow(0 2px 8px rgba(255, 197, 66, 0.4));
}

.header h1 {
  font-size: 28px;
  font-weight: 800;
  background: linear-gradient(180deg, var(--gold-light) 0%, var(--gold) 50%, var(--gold-dark) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
  letter-spacing: 2px;
}

.subtitle {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 6px;
}

/* 卡片 */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* 上传区域 */
.upload-card {
  padding: 0;
  overflow: hidden;
}

.upload-zone {
  position: relative;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: var(--bg-card-light);
  border: 2px dashed var(--border);
  border-radius: 14px;
  margin: 12px;
  transition: all 0.2s;
  overflow: hidden;
}

.upload-zone:active {
  border-color: var(--gold);
  background: rgba(255, 197, 66, 0.05);
}

.upload-placeholder {
  text-align: center;
  padding: 30px 20px;
}

.upload-icon {
  font-size: 52px;
  margin-bottom: 12px;
}

.upload-text {
  font-size: 17px;
  font-weight: 600;
  color: var(--gold);
  margin-bottom: 6px;
}

.upload-hint {
  font-size: 12px;
  color: var(--text-dim);
}

.preview-image {
  width: 100%;
  max-height: 400px;
  object-fit: contain;
  display: block;
}

.btn-reset {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

/* 表单 */
.form-group {
  margin-bottom: 14px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  display: block;
  font-size: 13px;
  color: var(--gold);
  font-weight: 600;
  margin-bottom: 6px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-card-light);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-main);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--gold);
}

.form-group input::placeholder {
  color: var(--text-dim);
  font-size: 13px;
}

.form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23ffc542' stroke-width='2' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

/* 英雄等级输入 */
.hero-levels {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.hero-input {
  display: flex;
  align-items: center;
  background: var(--bg-card-light);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.hero-input:focus-within {
  border-color: var(--gold);
}

.hero-name {
  font-size: 12px;
  color: var(--gold);
  font-weight: 600;
  padding: 0 4px 0 10px;
  white-space: nowrap;
}

.hero-input input {
  width: 100%;
  min-width: 0;
  padding: 10px 8px 10px 4px;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 15px;
  outline: none;
  text-align: center;
  -webkit-appearance: none;
  appearance: none;
}

.hero-input input::placeholder {
  color: var(--text-dim);
  font-size: 13px;
}

/* 去掉number输入框的上下箭头 */
.hero-input input::-webkit-outer-spin-button,
.hero-input input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.hero-input input[type=number] {
  -moz-appearance: textfield;
}

/* 分析按钮 */
.btn-analyze {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(180deg, var(--accent-light) 0%, var(--accent) 100%);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(255, 107, 53, 0.4);
  transition: transform 0.1s, box-shadow 0.2s;
  margin-bottom: 14px;
}

.btn-analyze:active {
  transform: scale(0.98);
  box-shadow: 0 2px 8px rgba(255, 107, 53, 0.3);
}

.btn-analyze:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Loading */
.loading {
  text-align: center;
  padding: 40px 20px;
}

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

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

.loading p {
  font-size: 15px;
  color: var(--text-main);
}

.loading-hint {
  font-size: 12px !important;
  color: var(--text-dim) !important;
  margin-top: 6px;
}

/* 结果区域 */
.result-section {
  margin-top: 8px;
}

.result-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 0 4px;
}

.result-icon {
  font-size: 28px;
}

.result-header h2 {
  font-size: 22px;
  font-weight: 800;
  color: var(--gold);
}

.result-card {
  padding: 14px 16px;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 10px;
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(90, 64, 32, 0.4);
}

.result-row:last-child {
  border-bottom: none;
}

.result-label {
  font-size: 14px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.result-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  text-align: right;
}

.result-text {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-main);
}

/* 配兵 */
.army-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.army-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.army-label {
  font-size: 13px;
  color: var(--gold);
  font-weight: 600;
  min-width: 72px;
  flex-shrink: 0;
  padding-top: 1px;
}

.army-value {
  font-size: 14px;
  color: var(--text-main);
  line-height: 1.6;
  flex: 1;
}

/* 步骤 */
.steps-list {
  list-style: none;
  counter-reset: step;
}

.steps-list li {
  counter-increment: step;
  position: relative;
  padding: 10px 0 10px 36px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-main);
  border-bottom: 1px solid rgba(90, 64, 32, 0.3);
}

.steps-list li:last-child {
  border-bottom: none;
}

.steps-list li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 10px;
  width: 24px;
  height: 24px;
  background: linear-gradient(180deg, var(--gold-light), var(--gold-dark));
  color: var(--bg-dark);
  font-size: 13px;
  font-weight: 800;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 重新分析按钮 */
.btn-reanalyze {
  width: 100%;
  padding: 14px;
  border: 2px solid var(--gold);
  border-radius: 14px;
  background: transparent;
  color: var(--gold);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
  transition: all 0.2s;
}

.btn-reanalyze:active {
  background: rgba(255, 197, 66, 0.1);
}

/* Toast */
.toast {
  position: fixed;
  top: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(244, 67, 54, 0.95);
  color: #fff;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 999;
  max-width: 90%;
  text-align: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translate(-50%, -20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* 底部 */
.footer {
  text-align: center;
  padding: 24px 0 0;
  font-size: 12px;
  color: var(--text-dim);
}

/* 头部历史按钮 */
.header-top {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.header-top .header-icon {
  margin: 0 auto 8px;
}

.btn-history {
  position: absolute;
  right: 0;
  top: 8px;
  padding: 8px 14px;
  background: var(--bg-card);
  border: 1px solid var(--gold-dark);
  border-radius: 20px;
  color: var(--gold);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn-history:active {
  background: rgba(255, 197, 66, 0.15);
}

/* 反馈区域 */
.feedback-card {
  text-align: center;
}

.feedback-hint {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 14px;
}

.feedback-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.btn-result {
  padding: 12px 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card-light);
  color: var(--text-main);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-result:active {
  transform: scale(0.96);
}

.btn-result.selected {
  border-color: var(--gold);
  background: rgba(255, 197, 66, 0.15);
  color: var(--gold);
}

.feedback-useful {
  display: flex;
  gap: 8px;
}

.btn-useful {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card-light);
  color: var(--text-main);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-useful:active {
  transform: scale(0.96);
}

.btn-useful.selected {
  border-color: var(--gold);
  background: rgba(255, 197, 66, 0.15);
  color: var(--gold);
}

.feedback-saved {
  margin-top: 10px;
  font-size: 14px;
  color: var(--success);
  font-weight: 600;
}

/* 弹窗 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal {
  background: var(--bg-card);
  border-radius: 18px 18px 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s ease;
}

.modal-detail {
  max-height: 90vh;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-header h2 {
  font-size: 18px;
  color: var(--gold);
  font-weight: 700;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg-card-light);
  color: var(--text-main);
  font-size: 22px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.modal-stats {
  padding: 12px 20px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  border-bottom: 1px solid rgba(90, 64, 32, 0.3);
}

.stat-badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--bg-card-light);
  color: var(--text-dim);
}

.stat-badge strong {
  color: var(--gold);
}

.modal-body {
  padding: 12px 20px 24px;
  overflow-y: auto;
  flex: 1;
}

.loading-text {
  text-align: center;
  color: var(--text-dim);
  padding: 30px 0;
  font-size: 14px;
}

/* 历史记录列表项 */
.history-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(90, 64, 32, 0.3);
  cursor: pointer;
}

.history-item:active {
  background: rgba(255, 197, 66, 0.05);
}

.history-thumb {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-card-light);
}

.history-info {
  flex: 1;
  min-width: 0;
}

.history-date {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.history-meta {
  font-size: 14px;
  color: var(--text-main);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-tags {
  margin-top: 6px;
  display: flex;
  gap: 6px;
}

.history-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--bg-card-light);
}

.tag-3star { color: #ffd700; border: 1px solid rgba(255, 215, 0, 0.3); }
.tag-2star { color: #c0c0c0; border: 1px solid rgba(192, 192, 192, 0.3); }
.tag-1star { color: #cd7f32; border: 1px solid rgba(205, 127, 50, 0.3); }
.tag-fail { color: var(--danger); border: 1px solid rgba(244, 67, 54, 0.3); }
.tag-up { color: var(--success); border: 1px solid rgba(76, 175, 80, 0.3); }
.tag-down { color: var(--danger); border: 1px solid rgba(244, 67, 54, 0.3); }

.empty-hint {
  text-align: center;
  color: var(--text-dim);
  padding: 40px 0;
  font-size: 14px;
}

/* 详情弹窗 */
.detail-image {
  width: 100%;
  border-radius: 10px;
  margin-bottom: 14px;
}

.detail-section {
  margin-bottom: 16px;
}

.detail-section h3 {
  font-size: 15px;
  color: var(--gold);
  margin-bottom: 6px;
}

.detail-section p {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-main);
}

.detail-section ol {
  padding-left: 20px;
}

.detail-section ol li {
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 4px;
}
