/* ========================================
   双色球中奖检测器 - 样式表
   ======================================== */

:root {
  /* 颜色系统 */
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-card: rgba(30, 30, 50, 0.8);
  --bg-card-hover: rgba(40, 40, 65, 0.9);
  --glass: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.1);

  --text-primary: #f0f0f5;
  --text-secondary: #a0a0b8;
  --text-muted: #6b6b80;

  --red: #e63946;
  --red-glow: rgba(230, 57, 70, 0.4);
  --blue: #457bef;
  --blue-glow: rgba(69, 123, 239, 0.4);
  --green: #2ecc71;
  --green-glow: rgba(46, 204, 113, 0.4);
  --gold: #f1c40f;
  --gold-glow: rgba(241, 196, 15, 0.4);
  --orange: #e67e22;

  --gradient-main: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-red: linear-gradient(135deg, #e63946 0%, #c0392b 100%);
  --gradient-blue: linear-gradient(135deg, #457bef 0%, #2c3e9c 100%);
  --gradient-gold: linear-gradient(135deg, #f1c40f 0%, #e67e22 100%);
  --gradient-green: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);

  /* 尺寸 */
  --ball-size: 48px;
  --ball-size-sm: 38px;
  --radius: 16px;
  --radius-sm: 10px;

  /* 动画 */
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* ========================================
   基础样式
   ======================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(102, 126, 234, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(118, 75, 162, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(230, 57, 70, 0.05) 0%, transparent 50%);
}

.app-container {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 60px;
}

.hidden {
  display: none !important;
}

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

.logo-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.logo-balls {
  display: flex;
  gap: 6px;
  margin-bottom: 4px;
}

.mini-ball {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  animation: ballFloat 3s ease-in-out infinite;
}

.mini-ball.red-ball {
  background: var(--gradient-red);
  box-shadow: 0 4px 15px var(--red-glow);
}

.mini-ball.blue-ball {
  background: var(--gradient-blue);
  box-shadow: 0 4px 15px var(--blue-glow);
  animation-delay: 0.3s;
}

.mini-ball:nth-child(3) {
  animation-delay: 0.6s;
}

@keyframes ballFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.app-header h1 {
  font-size: 28px;
  font-weight: 900;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 2px;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  letter-spacing: 4px;
}

/* ========================================
   通用 Section
   ======================================== */
.section {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  transition: var(--transition);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.section-header h3 {
  font-size: 16px;
  font-weight: 700;
}

.issue-badge {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  color: var(--text-secondary);
}

.issue-select-wrap {
  max-width: 280px;
}

.issue-select {
  min-width: 220px;
  max-width: 100%;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  cursor: pointer;
  padding: 8px 34px 8px 14px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-secondary) 50%),
    linear-gradient(135deg, var(--text-secondary) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 2px),
    calc(100% - 12px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.issue-select:focus {
  border-color: rgba(102, 126, 234, 0.6);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.18);
}

.issue-select:disabled {
  cursor: default;
  opacity: 0.8;
}

/* ========================================
   球体样式
   ======================================== */
.winning-balls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 60px;
}

.ball {
  width: var(--ball-size);
  height: var(--ball-size);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 900;
  color: #fff;
  position: relative;
  animation: ballAppear 0.5s var(--bounce) both;
  cursor: default;
  transition: transform 0.2s ease;
}

.ball:hover {
  transform: scale(1.15);
}

.ball.red {
  background: var(--gradient-red);
  box-shadow: 0 4px 20px var(--red-glow), inset 0 -3px 6px rgba(0,0,0,0.2), inset 0 3px 6px rgba(255,255,255,0.15);
}

.ball.blue {
  background: var(--gradient-blue);
  box-shadow: 0 4px 20px var(--blue-glow), inset 0 -3px 6px rgba(0,0,0,0.2), inset 0 3px 6px rgba(255,255,255,0.15);
}

.ball.matched {
  animation: ballPulse 0.6s ease-in-out;
  box-shadow: 0 0 30px var(--green-glow), 0 0 60px var(--green-glow);
  outline: 3px solid var(--green);
  outline-offset: 3px;
}

.ball.unmatched {
  opacity: 0.35;
  filter: grayscale(0.6);
}

.ball-separator {
  width: 2px;
  height: 30px;
  background: var(--glass-border);
  margin: 0 4px;
}

.ball-sm {
  width: var(--ball-size-sm);
  height: var(--ball-size-sm);
  font-size: 15px;
}

@keyframes ballAppear {
  0% { transform: scale(0) rotate(-180deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

@keyframes ballPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* 球骨架加载动画 */
.balls-loading {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.ball-skeleton {
  width: var(--ball-size);
  height: var(--ball-size);
  border-radius: 50%;
  background: linear-gradient(90deg, var(--glass) 25%, rgba(255,255,255,0.08) 50%, var(--glass) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

.ball-skeleton.blue {
  margin-left: 12px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ========================================
   手动输入开奖号码（备用）
   ======================================== */
.manual-winning {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--glass-border);
}

.winning-input-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* ========================================
   按钮
   ======================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255,255,255,0.15);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.4s, height 0.4s;
}

.btn:active::after {
  width: 200px;
  height: 200px;
}

.btn-icon {
  font-size: 20px;
}

.action-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.camera-status {
  margin: -4px 0 16px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(69, 123, 239, 0.12);
  border: 1px solid rgba(69, 123, 239, 0.22);
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.6;
}

.btn-camera {
  background: var(--gradient-main);
  color: #fff;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-camera:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(102, 126, 234, 0.4);
}

.btn-manual {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
}

.btn-upload {
  background: linear-gradient(135deg, #1f8a70 0%, #2a9d8f 100%);
  color: #fff;
  box-shadow: 0 4px 15px rgba(42, 157, 143, 0.28);
}

.btn-upload:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(42, 157, 143, 0.38);
}

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

.btn-check {
  width: 100%;
  padding: 16px;
  font-size: 18px;
  background: var(--gradient-gold);
  color: #1a1a2e;
  border-radius: var(--radius-sm);
  margin-top: 16px;
  box-shadow: 0 4px 20px var(--gold-glow);
}

.btn-check:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px var(--gold-glow);
}

.btn-primary {
  background: var(--gradient-main);
  color: #fff;
}

.btn-secondary {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
}

.btn-small {
  padding: 8px 16px;
  font-size: 14px;
}

.btn-capture {
  background: var(--gradient-main);
  color: #fff;
  flex: 1;
  padding: 14px;
  font-size: 16px;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-close {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  padding: 14px 20px;
  font-size: 16px;
}

/* ========================================
   摄像头
   ======================================== */
.camera-area {
  margin-bottom: 16px;
}

.camera-preview-container {
  position: relative;
  width: 100%;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #000;
  aspect-ratio: 4/3;
  max-height: 70vh;
}

#cameraVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.scan-frame {
  width: 85%;
  height: 50%;
  border: 2px solid rgba(102, 126, 234, 0.6);
  border-radius: 12px;
  position: relative;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.4);
}

.scan-frame::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--gradient-main);
  animation: scanLine 2s ease-in-out infinite;
}

@keyframes scanLine {
  0%, 100% { top: 0; }
  50% { top: calc(100% - 2px); }
}

.scan-hint {
  color: rgba(255,255,255,0.8);
  font-size: 13px;
  margin-top: 12px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.camera-controls {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 3;
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
}

/* ========================================
   OCR处理中
   ======================================== */
.ocr-processing {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 30px;
  color: var(--text-secondary);
}

.processing-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--glass-border);
  border-top-color: #667eea;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ========================================
   输入框
   ======================================== */
.input-field {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 15px;
  font-family: 'Courier New', monospace;
  transition: var(--transition);
  outline: none;
}

.input-field:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.textarea {
  resize: vertical;
  line-height: 1.8;
  min-height: 120px;
}

.hint-text {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ========================================
   识别结果确认
   ======================================== */
.recognized-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.recognized-item {
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.recognized-item-header {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.recognized-balls {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.recognized-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ========================================
   结果展示
   ======================================== */
.result-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.result-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 16px;
  border: 1px solid var(--glass-border);
  animation: slideUp 0.4s ease both;
}

.result-card.won {
  border-color: var(--gold);
  box-shadow: 0 0 20px var(--gold-glow);
}

.result-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.bet-label {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 600;
}

.prize-badge {
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
}

.prize-badge.won {
  background: var(--gradient-gold);
  color: #1a1a2e;
  animation: prizePulse 1s ease-in-out infinite alternate;
}

.prize-badge.lost {
  background: var(--glass);
  color: var(--text-muted);
}

@keyframes prizePulse {
  0% { box-shadow: 0 0 10px var(--gold-glow); }
  100% { box-shadow: 0 0 25px var(--gold-glow); }
}

.result-balls {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.result-match-info {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--glass-border);
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  gap: 16px;
}

.match-count {
  display: flex;
  align-items: center;
  gap: 4px;
}

.match-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.match-dot.red { background: var(--red); }
.match-dot.blue { background: var(--blue); }

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

/* ========================================
   庆祝动画 (Confetti)
   ======================================== */
.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}

.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  top: -10px;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  0% {
    transform: translateY(0) rotate(0deg) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg) scale(0.5);
    opacity: 0;
  }
}

/* ========================================
   响应式
   ======================================== */
@media (max-width: 480px) {
  :root {
    --ball-size: 40px;
    --ball-size-sm: 32px;
  }

  .app-container {
    padding: 12px;
  }

  .app-header h1 {
    font-size: 24px;
  }

  .section {
    padding: 16px;
  }

  .section-header {
    align-items: flex-start;
    gap: 10px;
  }

  .issue-select-wrap {
    width: 100%;
    max-width: none;
  }

  .issue-select {
    width: 100%;
    min-width: 0;
  }

  .ball {
    font-size: 15px;
  }

  .ball-sm {
    font-size: 13px;
  }

  .action-buttons {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .btn {
    padding: 12px 16px;
    font-size: 14px;
  }
}

@media (max-width: 360px) {
  :root {
    --ball-size: 36px;
    --ball-size-sm: 30px;
  }

  .winning-balls {
    gap: 5px;
  }
}
