/**
 * SnookerDesk - Premium English Snooker Style
 * Inspired by classic billiard rooms and refined sporting aesthetics
 */

/* ==================== 字体与变量 ==================== */
:root {
  /* 经典斯诺克绿调色板 */
  --bg-deep: #0a0f0a;
  --bg-dark: #0d140d;
  --bg-main: #121a12;
  --bg-card: #182218;
  --bg-card-alt: #1c2a1c;
  --bg-hover: #243424;
  --bg-elevated: #2a402a;

  /* 文字层次 */
  --text-primary: #f4f0e8;
  --text-secondary: #a8b498;
  --text-muted: #6b7e62;
  --text-faint: #4a5844;

  /* 经典金色 - 球杆/奖杯 */
  --accent-gold: #c9a84c;
  --accent-gold-light: #dbbf6e;
  --accent-gold-dark: #9a7a2e;
  --accent-gold-glow: rgba(201, 168, 76, 0.12);

  /* 斯诺克球台绿 */
  --felt-green: #1e5631;
  --felt-light: #2a7044;

  /* 状态色 */
  --accent-red: #b83232;
  --accent-orange: #d4722a;

  /* 边框系统 */
  --border-subtle: rgba(201, 168, 76, 0.08);
  --border-medium: rgba(201, 168, 76, 0.18);
  --border-strong: rgba(201, 168, 76, 0.35);

  /* 圆角 */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  /* 阴影 */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-inset: inset 0 2px 6px rgba(0, 0, 0, 0.35);

  /* 过渡 */
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 12px;
  padding-bottom: 100px;
}

/* ==================== 头部 ==================== */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  background: linear-gradient(145deg, var(--bg-card) 0%, var(--bg-card-alt) 100%);
  border-radius: var(--radius-xl);
  margin-bottom: 16px;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-md);
}

.logo {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-icon {
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.4));
  transition: var(--transition);
}

.logo-icon:hover {
  transform: scale(1.05);
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.logo-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.03em;
  line-height: 1.1;
}

.logo-title-accent {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--accent-gold);
  letter-spacing: 0.03em;
  line-height: 1.1;
}

.logo-subtitle {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-top: 2px;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.btn-icon {
  background: var(--bg-dark);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background: var(--bg-hover);
  border-color: var(--accent-gold);
  color: var(--accent-gold);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(201, 168, 76, 0.15);
}

.btn-icon svg {
  width: 18px;
  height: 18px;
}

/* ==================== 导航 ==================== */
.nav-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  background: var(--bg-dark);
  padding: 4px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
}

.nav-tab {
  flex: 1;
  padding: 11px 8px;
  background: transparent;
  border: none;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.nav-tab svg {
  width: 16px;
  height: 16px;
}

.nav-tab.active {
  background: linear-gradient(135deg, var(--accent-gold) 0%, var(--accent-gold-dark) 100%);
  color: var(--bg-dark);
  font-weight: 600;
  box-shadow: 0 3px 10px rgba(201, 168, 76, 0.25);
}

.nav-tab:not(.active):hover {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

/* ==================== 卡片 ==================== */
.section-card {
  background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-main) 100%);
  border-radius: var(--radius-xl);
  padding: 22px;
  margin-bottom: 14px;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-md);
}

.section-card h3 {
  color: var(--accent-gold);
  margin-bottom: 20px;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-card h3 svg {
  width: 20px;
  height: 20px;
}

.section-subtitle {
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin: 20px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.form-group label {
  display: block;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 8px;
  letter-spacing: 0.04em;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 13px 16px;
  background: var(--bg-dark);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 3px var(--accent-gold-glow);
  background: var(--bg-main);
}

select option {
  background: var(--bg-dark);
  color: var(--text-primary);
}

/* ==================== 按钮 ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 22px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  letter-spacing: 0.02em;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-gold) 0%, var(--accent-gold-dark) 100%);
  color: var(--bg-dark);
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(201, 168, 76, 0.25);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-gold-light) 0%, var(--accent-gold) 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(201, 168, 76, 0.35);
}

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

.btn-secondary:hover {
  background: var(--bg-elevated);
  border-color: var(--border-medium);
  color: var(--accent-gold);
}

.btn-warning {
  background: linear-gradient(135deg, var(--accent-orange) 0%, #b55c20 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(212, 114, 42, 0.25);
}

.btn-warning:hover {
  filter: brightness(1.08);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(212, 114, 42, 0.35);
}

.btn-danger {
  background: linear-gradient(135deg, var(--accent-red) 0%, #8a2222 100%);
  color: white;
}

.btn-danger:hover {
  filter: brightness(1.08);
  transform: translateY(-2px);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-medium);
  color: var(--text-secondary);
}

.btn-outline:hover {
  background: var(--bg-hover);
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

.btn-large {
  width: 100%;
  padding: 16px;
  font-size: 15px;
  margin-top: 18px;
}

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

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none !important;
  filter: grayscale(0.3);
}

.data-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.data-actions .btn {
  flex: 1;
}

/* ==================== 比分板 ==================== */
.scoreboard {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  background: linear-gradient(145deg, var(--bg-card) 0%, var(--bg-card-alt) 100%);
  border-radius: var(--radius-lg);
  margin-bottom: 12px;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.03);
}

.player-info {
  text-align: center;
  flex: 1;
}

.player-name {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: var(--transition);
  margin-bottom: 4px;
}

.player-name.active-player {
  color: var(--accent-gold);
  font-size: 13px;
  text-shadow: 0 0 20px rgba(201, 168, 76, 0.5);
}

.frames-count {
  display: block;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 38px;
  font-weight: 700;
  color: var(--accent-gold);
  line-height: 1.05;
}

.vs {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 16px;
  color: var(--text-faint);
  font-style: italic;
  padding: 0 8px;
}

/* 计时器 */
.timer-display {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  padding: 12px 20px;
  background: var(--bg-dark);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  border: 1px solid var(--border-subtle);
}

.timer-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.timer-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  display: flex;
  align-items: center;
  gap: 4px;
}

.timer-label svg {
  width: 14px;
  height: 14px;
}

.timer-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  min-width: 52px;
  letter-spacing: 0.05em;
  font-family: 'DM Sans', monospace;
}

.timer-divider {
  color: var(--text-faint);
  font-size: 14px;
}

/* 比分显示 */
.match-scores {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  padding: 14px 24px;
  background: var(--bg-dark);
  border-radius: var(--radius-md);
  margin-bottom: 14px;
  border: 1px solid var(--border-subtle);
}

.match-score {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 44px;
  font-weight: 700;
  min-width: 75px;
  text-align: center;
  color: var(--text-primary);
}

.match-score-divider {
  font-size: 22px;
  color: var(--text-faint);
}

/* ==================== 球台可视化 ==================== */
.table-visualization {
  background: linear-gradient(180deg, #0c170c 0%, #0a140a 100%);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 14px;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-inset), var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.table-visualization::before {
  content: '';
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(201, 168, 76, 0.06);
  border-radius: var(--radius-md);
  pointer-events: none;
}

.reds-zone,
.colors-zone {
  margin-bottom: 12px;
  position: relative;
  z-index: 1;
}

.zone-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 8px;
}

.reds-container {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.red-ball {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 35% 35%, #e74c3c, #a02020);
  box-shadow: inset -2px -2px 4px rgba(0,0,0,0.35), 0 2px 4px rgba(0,0,0,0.4);
  transition: var(--transition);
}

.red-ball.empty {
  background: transparent;
  border: 1.5px dashed var(--text-faint);
  box-shadow: none;
}

.colors-container {
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 8px;
}

.color-ball {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}

.color-ball svg {
  position: absolute;
  top: 1px;
  left: 1px;
}

.color-ball.available {
  opacity: 1;
}

.color-ball.available:hover {
  transform: scale(1.12);
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.5));
}

.color-ball.empty {
  opacity: 0.15;
  border: 2px dashed currentColor;
}

.color-ball.empty svg {
  opacity: 0.3;
}

.color-ball.next {
  border: 2px solid var(--accent-gold);
  transform: scale(1.15);
  box-shadow: 0 0 18px rgba(201, 168, 76, 0.45), 0 3px 8px rgba(0,0,0,0.4);
  animation: pulse-gold 2s ease-in-out infinite;
}

@keyframes pulse-gold {
  0%, 100% { box-shadow: 0 0 18px rgba(201, 168, 76, 0.45), 0 3px 8px rgba(0,0,0,0.4); }
  50% { box-shadow: 0 0 28px rgba(201, 168, 76, 0.65), 0 3px 8px rgba(0,0,0,0.4); }
}

.color-ball.next:hover {
  transform: scale(1.22);
}

.color-ball:disabled {
  opacity: 0.15;
  cursor: not-allowed;
}

.color-ball .color-points {
  position: absolute;
  bottom: -3px;
  right: -3px;
  background: var(--bg-dark);
  border: 1px solid var(--border-medium);
  color: var(--text-primary);
  font-size: 9px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 8px;
  z-index: 2;
}

/* ==================== 状态栏 ==================== */
.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: var(--bg-dark);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  border: 1px solid var(--border-subtle);
}

.status-badge {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
  letter-spacing: 0.02em;
}

.status-badge.reds {
  background: rgba(184, 50, 50, 0.12);
  color: #d96060;
  border: 1px solid rgba(184, 50, 50, 0.25);
}

.status-badge.colors {
  background: rgba(30, 86, 49, 0.15);
  color: #5ab87a;
  border: 1px solid rgba(30, 86, 49, 0.3);
}

.frame-label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}

/* ==================== 分杆显示 ==================== */
.break-display {
  display: flex;
  justify-content: space-around;
  padding: 16px;
  background: var(--bg-dark);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  border: 1px solid var(--border-subtle);
}

.current-break,
.high-break {
  text-align: center;
}

.break-label {
  display: block;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 4px;
}

.break-value {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 34px;
  font-weight: 700;
  color: var(--accent-gold);
}

.balls-status {
  text-align: center;
  color: var(--text-muted);
  font-size: 11px;
  padding: 8px;
  margin-bottom: 10px;
  letter-spacing: 0.03em;
}

/* ==================== 操作按钮 ==================== */
.action-grid {
  margin-bottom: 10px;
}

.action-btn {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  transition: var(--transition);
  font-family: inherit;
  letter-spacing: 0.02em;
}

.action-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
  transform: none !important;
}

.red-btn {
  background: linear-gradient(135deg, #b03030 0%, #8a2222 100%);
  color: white;
  margin-bottom: 10px;
  box-shadow: 0 4px 14px rgba(184, 50, 50, 0.25);
}

.red-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #c83838 0%, #a02828 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(184, 50, 50, 0.35);
}

.color-btns {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

.color-ball-btn {
  padding: 10px 4px;
  border: none;
  border-radius: var(--radius);
  background: var(--bg-hover);
  color: var(--text-primary);
  font-size: 11px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  border: 1px solid var(--border-subtle);
}

.color-ball-btn:hover:not(:disabled) {
  background: var(--bg-elevated);
  border-color: var(--border-medium);
  transform: translateY(-2px);
}

.color-ball-btn:disabled {
  opacity: 0.2;
  cursor: not-allowed;
}

.color-ball-btn small {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-muted);
  display: block;
}

/* 战术按钮 */
.tactical-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.tactical-actions .btn {
  flex: 1;
  padding: 12px 8px;
  font-size: 12px;
}

.match-end-actions {
  margin-top: 14px;
}

/* ==================== 统计面板 ==================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.stats-grid.secondary {
  grid-template-columns: repeat(2, 1fr);
  padding: 14px;
  background: var(--bg-dark);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.stat-card {
  padding: 16px 12px;
  background: var(--bg-dark);
  border-radius: var(--radius-md);
  text-align: center;
  border: 1px solid var(--border-subtle);
  transition: var(--transition);
}

.stat-card:hover {
  border-color: var(--border-medium);
  transform: translateY(-2px);
}

.stat-card.highlight {
  background: linear-gradient(145deg, var(--accent-gold) 0%, var(--accent-gold-dark) 100%);
  border-color: transparent;
  box-shadow: 0 4px 18px rgba(201, 168, 76, 0.25);
}

.stat-card.highlight .stat-value,
.stat-card.highlight .stat-label {
  color: var(--bg-dark);
}

.stat-value {
  display: block;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.05;
}

.stat-label {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 4px;
}

.stat-value-lg {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 38px;
  font-weight: 700;
  color: var(--accent-gold);
  line-height: 1.05;
}

.stat-item {
  text-align: center;
}

.stat-item .stat-label {
  display: block;
  margin-bottom: 4px;
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* 成就 */
.achievements-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.achievement-item {
  padding: 14px 6px;
  background: var(--bg-dark);
  border-radius: var(--radius);
  text-align: center;
  border: 1px solid var(--border-subtle);
  transition: var(--transition);
}

.achievement-item:hover {
  border-color: var(--border-medium);
  transform: translateY(-2px);
}

.achievement-item svg {
  width: 20px;
  height: 20px;
  margin-bottom: 4px;
}

.achievement-item span {
  display: block;
  font-size: 9px;
  color: var(--text-muted);
  font-weight: 500;
}

.achievement-item.unlocked {
  background: linear-gradient(135deg, rgba(201, 168, 76, 0.15), rgba(201, 168, 76, 0.05));
  border-color: var(--accent-gold);
}

.achievement-item.unlocked svg {
  color: var(--accent-gold);
}

.achievement-item.unlocked span {
  color: var(--accent-gold);
}

/* ==================== 通知 ==================== */
.notification {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  padding: 14px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: calc(100% - 40px);
  text-align: center;
}

.notification.show {
  transform: translateX(-50%) translateY(0);
}

.notification.success {
  background: linear-gradient(135deg, var(--felt-green), #1a5030);
  border-color: #3a8a5a;
  color: #a8e6c0;
}

.notification.info {
  background: linear-gradient(135deg, #1a3a5a, #15304a);
  border-color: #3a6a9a;
  color: #a0c8e8;
}

.notification.warning {
  background: linear-gradient(135deg, #5a4a1a, #4a3a10);
  border-color: #9a8a2a;
  color: #e8d8a0;
}

.notification.error {
  background: linear-gradient(135deg, #5a1a1a, #4a1010);
  border-color: #9a3a3a;
  color: #e8a0a0;
}

/* ==================== 弹窗 ==================== */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.modal.show,
.modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 28px;
  max-width: 500px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  border: 1px solid var(--border-medium);
  box-shadow: var(--shadow-lg);
  position: relative;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--bg-dark);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: var(--bg-hover);
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.modal-actions .btn {
  flex: 1;
}

.modal-content h3 {
  color: var(--accent-gold);
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 20px;
  padding-right: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-content h3 svg {
  width: 20px;
  height: 20px;
}

/* ==================== 帮助内容 ==================== */
.help-content h4 {
  color: var(--accent-gold);
  font-size: 14px;
  font-weight: 600;
  margin: 20px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-subtle);
}

.help-content p {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.7;
  margin-bottom: 10px;
}

.help-content ul {
  color: var(--text-secondary);
  font-size: 13px;
  padding-left: 20px;
  margin-bottom: 10px;
}

.help-content li {
  margin-bottom: 6px;
}

.help-content strong {
  color: var(--accent-gold);
}

/* ==================== 页面切换 ==================== */
.tab-content {
  display: none;
}

.tab-content:not(.hidden) {
  display: block;
}

/* ==================== 工具类 ==================== */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.text-muted {
  color: var(--text-muted);
}

/* ==================== 历史记录 ==================== */
.history-item {
  padding: 16px;
  background: var(--bg-dark);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  border: 1px solid var(--border-subtle);
  transition: var(--transition);
}

.history-item:hover {
  border-color: var(--border-medium);
  transform: translateX(4px);
}

.history-item h4 {
  color: var(--accent-gold);
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}

.history-item p {
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 6px;
}

/* ==================== 响应式 ==================== */

/* ===== 响应式断点说明 =====
   小手机: < 380px  (已有样式)
   手机:   380px+   (已有样式)
   大手机: 480px+   (Phablet)
   平板:   768px+   (Tablet)
   桌面:   1024px+  (Desktop)
   宽屏:   1280px+  (Wide)
*/

/* ===== PHABLET (480px+) - 大屏手机 ===== */
@media screen and (min-width: 480px) {
  .app {
    padding: 16px;
    max-width: 520px;
    margin: 0 auto;
  }

  .app-header {
    padding: 22px 24px;
    border-radius: var(--radius-xl);
  }

  .logo-title,
  .logo-title-accent {
    font-size: 24px;
  }

  .section-card {
    padding: 24px;
    border-radius: var(--radius-xl);
  }

  .scoreboard {
    padding: 22px 28px;
  }

  .match-score {
    font-size: 48px;
    min-width: 80px;
  }

  .frames-count {
    font-size: 42px;
  }

  .color-ball {
    width: 46px;
    height: 46px;
  }

  .break-value {
    font-size: 38px;
  }

  .stat-value {
    font-size: 36px;
  }

  .achievements-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
  }

  .achievement-item {
    padding: 16px 8px;
  }
}

/* ===== TABLET (768px+) - 平板 ===== */
@media screen and (min-width: 768px) {
  body {
    background: var(--bg-deep);
    display: flex;
    justify-content: center;
    min-height: 100vh;
  }

  .app {
    max-width: 600px;
    padding: 20px;
    padding-bottom: 120px;
    background: var(--bg-deep);
    margin: 0;
  }

  .app-header {
    padding: 24px 28px;
    margin-bottom: 20px;
  }

  .logo-title,
  .logo-title-accent {
    font-size: 26px;
  }

  .section-card {
    padding: 26px;
    margin-bottom: 16px;
  }

  .section-card h3 {
    font-size: 22px;
    margin-bottom: 22px;
  }

  /* 比分板 */
  .scoreboard {
    padding: 24px 32px;
    margin-bottom: 16px;
  }

  .match-score {
    font-size: 54px;
    min-width: 90px;
  }

  .frames-count {
    font-size: 46px;
  }

  .vs {
    font-size: 18px;
  }

  /* 计时器 */
  .timer-display {
    padding: 14px 24px;
    margin-bottom: 16px;
  }

  .timer-value {
    font-size: 17px;
  }

  /* 比分显示 */
  .match-scores {
    padding: 16px 28px;
    margin-bottom: 16px;
  }

  /* 球台可视化 */
  .table-visualization {
    padding: 20px;
    margin-bottom: 16px;
  }

  .color-ball {
    width: 50px;
    height: 50px;
  }

  .red-ball {
    width: 24px;
    height: 24px;
  }

  /* 分杆显示 */
  .break-display {
    padding: 18px;
    margin-bottom: 14px;
  }

  .break-value {
    font-size: 42px;
  }

  /* 操作按钮 */
  .color-btns {
    gap: 8px;
  }

  .color-ball-btn {
    padding: 12px 6px;
  }

  /* 统计网格 */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 16px;
  }

  .stat-card {
    padding: 18px 14px;
  }

  .stat-value {
    font-size: 40px;
  }

  /* 成就网格 */
  .achievements-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
  }

  /* 战术按钮 */
  .tactical-actions {
    gap: 12px;
    margin-bottom: 16px;
  }

  .tactical-actions .btn {
    padding: 14px 10px;
    font-size: 13px;
  }

  /* 弹窗 */
  .modal-content {
    max-width: 550px;
    padding: 32px;
  }

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

  .form-group input,
  .form-group select {
    padding: 15px 18px;
    font-size: 16px;
  }

  .btn {
    padding: 15px 26px;
    font-size: 15px;
  }

  .btn-large {
    padding: 18px;
    font-size: 16px;
  }
}

/* ===== DESKTOP (1024px+) - 桌面 ===== */
@media screen and (min-width: 1024px) {
  .app {
    max-width: 700px;
    padding: 24px;
    padding-bottom: 140px;
  }

  .app-header {
    padding: 28px 32px;
    border-radius: calc(var(--radius-xl) + 4px);
  }

  .logo-title,
  .logo-title-accent {
    font-size: 28px;
  }

  .logo-subtitle {
    font-size: 11px;
  }

  .btn-icon {
    width: 44px;
    height: 44px;
    font-size: 18px;
  }

  .nav-tab {
    padding: 13px 12px;
    font-size: 14px;
  }

  .section-card {
    padding: 28px;
    border-radius: calc(var(--radius-xl) + 2px);
  }

  .section-card h3 {
    font-size: 24px;
  }

  /* 比分板 */
  .scoreboard {
    padding: 28px 36px;
  }

  .match-score {
    font-size: 60px;
    min-width: 100px;
  }

  .frames-count {
    font-size: 50px;
  }

  .player-name {
    font-size: 12px;
  }

  .player-name.active-player {
    font-size: 14px;
  }

  /* 计时器 */
  .timer-display {
    padding: 16px 28px;
  }

  .timer-value {
    font-size: 18px;
    min-width: 58px;
  }

  /* 球台 */
  .color-ball {
    width: 54px;
    height: 54px;
  }

  .red-ball {
    width: 26px;
    height: 26px;
  }

  .colors-container {
    gap: 10px;
  }

  /* 分杆 */
  .break-value {
    font-size: 46px;
  }

  /* 操作按钮 */
  .action-btn {
    padding: 18px;
    font-size: 16px;
  }

  .color-btns {
    gap: 10px;
  }

  .color-ball-btn {
    padding: 14px 8px;
    font-size: 12px;
  }

  /* 统计 */
  .stat-value {
    font-size: 44px;
  }

  .stat-label {
    font-size: 11px;
  }

  /* 弹窗 */
  .modal-content {
    max-width: 600px;
    padding: 36px;
    border-radius: calc(var(--radius-xl) + 4px);
  }

  .modal-content h3 {
    font-size: 24px;
  }

  /* 历史记录 */
  .history-item {
    padding: 18px;
  }
}

/* ===== WIDE (1280px+) - 宽屏 ===== */
@media screen and (min-width: 1280px) {
  .app {
    max-width: 800px;
    padding: 32px;
    padding-bottom: 160px;
  }

  .app-header {
    padding: 32px 40px;
  }

  .logo-title,
  .logo-title-accent {
    font-size: 30px;
  }

  .section-card {
    padding: 32px;
    margin-bottom: 20px;
  }

  /* 比分板 */
  .scoreboard {
    padding: 32px 44px;
    border-radius: calc(var(--radius-xl) + 6px);
  }

  .match-score {
    font-size: 68px;
    min-width: 110px;
  }

  .frames-count {
    font-size: 56px;
  }

  .vs {
    font-size: 20px;
    padding: 0 12px;
  }

  /* 计时器 */
  .timer-display {
    padding: 18px 32px;
    border-radius: var(--radius-lg);
  }

  .timer-value {
    font-size: 20px;
    min-width: 64px;
  }

  .timer-label {
    font-size: 11px;
  }

  /* 球台 */
  .table-visualization {
    padding: 24px;
  }

  .color-ball {
    width: 58px;
    height: 58px;
  }

  .red-ball {
    width: 28px;
    height: 28px;
  }

  .reds-container {
    gap: 6px;
  }

  /* 分杆 */
  .break-value {
    font-size: 50px;
  }

  /* 操作 */
  .red-btn {
    padding: 18px;
    margin-bottom: 12px;
  }

  .color-btns {
    gap: 12px;
  }

  .color-ball-btn {
    padding: 16px 10px;
    font-size: 13px;
  }

  .color-ball-btn small {
    font-size: 10px;
  }

  /* 统计 */
  .stats-grid {
    gap: 16px;
    margin-bottom: 20px;
  }

  .stat-card {
    padding: 20px 16px;
  }

  .stat-value {
    font-size: 48px;
  }

  /* 成就 */
  .achievements-grid {
    gap: 14px;
  }

  .achievement-item {
    padding: 18px 10px;
  }

  .achievement-item svg {
    width: 24px;
    height: 24px;
  }

  /* 弹窗 */
  .modal-content {
    max-width: 650px;
    padding: 40px;
  }

  /* 表单 */
  .form-group input,
  .form-group select {
    padding: 16px 20px;
    font-size: 17px;
  }

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

  .btn-large {
    padding: 20px;
    font-size: 17px;
  }
}

/* ===== EXTRA WIDE (1440px+) - 超宽屏 ===== */
@media screen and (min-width: 1440px) {
  .app {
    max-width: 900px;
  }

  .app-header {
    padding: 36px 48px;
  }

  .logo-title,
  .logo-title-accent {
    font-size: 32px;
  }

  .section-card {
    padding: 36px;
  }

  .scoreboard {
    padding: 36px 52px;
  }

  .match-score {
    font-size: 72px;
  }

  .frames-count {
    font-size: 60px;
  }

  .color-ball {
    width: 62px;
    height: 62px;
  }

  .color-ball-btn {
    padding: 18px 12px;
  }
}

/* ===== 横屏模式优化 ===== */
@media screen and (min-width: 768px) and (orientation: landscape) {
  .app {
    padding-top: 16px;
    padding-bottom: 100px;
  }

  .match-score {
    font-size: 48px;
  }

  .frames-count {
    font-size: 40px;
  }

  .timer-display {
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
  }

  .timer-divider {
    display: none;
  }

  /* 横屏时统计改为4列 */
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ===== 安全区域适配 (iPhone X/刘海屏) ===== */
@supports (padding: env(safe-area-inset-bottom)) {
  .app {
    padding-bottom: calc(100px + env(safe-area-inset-bottom));
  }

  @media screen and (min-width: 768px) {
    .app {
      padding-bottom: calc(120px + env(safe-area-inset-bottom));
    }
  }
}

/* ===== 减少动画 (无障碍) ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== 高对比度模式 (无障碍) ===== */
@media (prefers-contrast: high) {
  :root {
    --border-subtle: rgba(201, 168, 76, 0.4);
    --border-medium: rgba(201, 168, 76, 0.6);
    --text-secondary: #c0c0b0;
    --text-muted: #909080;
    --text-faint: #606050;
  }

  .section-card,
  .scoreboard,
  .modal-content {
    border-width: 2px;
  }
}

/* ===== 打印样式 ===== */
@media print {
  .app-header,
  .nav-tabs,
  .tactical-actions,
  .match-end-actions,
  .data-actions,
  .btn:not(.btn-outline),
  .modal-overlay,
  .notification {
    display: none !important;
  }

  .app {
    max-width: 100%;
    padding: 0;
    background: white;
    color: black;
  }

  body {
    background: white;
    color: black;
  }

  .section-card {
    box-shadow: none;
    border: 1px solid #ccc;
    page-break-inside: avoid;
  }

  .scoreboard {
    border: 2px solid black;
  }

  .match-score,
  .frames-count,
  .break-value,
  .stat-value {
    color: black;
    -webkit-text-fill-color: black;
  }
}

/* ===== 小手机优化 (< 380px) ===== */
@media screen and (max-width: 380px) {
  .app {
    padding: 10px;
  }

  .section-card {
    padding: 16px;
    border-radius: var(--radius-lg);
  }

  .app-header {
    padding: 14px 16px;
    margin-bottom: 14px;
  }

  .logo-title,
  .logo-title-accent {
    font-size: 20px;
  }

  .logo-subtitle {
    font-size: 9px;
  }

  .btn-icon {
    width: 36px;
    height: 36px;
  }

  .nav-tab {
    padding: 10px 6px;
    font-size: 12px;
  }

  .nav-tab svg {
    width: 14px;
    height: 14px;
  }

  .scoreboard {
    padding: 16px 20px;
  }

  .match-score {
    font-size: 36px;
    min-width: 60px;
  }

  .frames-count {
    font-size: 32px;
  }

  .vs {
    font-size: 14px;
    padding: 0 6px;
  }

  .color-ball {
    width: 38px;
    height: 38px;
  }

  .red-ball {
    width: 20px;
    height: 20px;
  }

  .break-value {
    font-size: 30px;
  }

  .achievements-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .achievement-item {
    padding: 12px 4px;
  }

  .achievement-item svg {
    width: 18px;
    height: 18px;
  }

  .achievement-item span {
    font-size: 8px;
  }

  .stat-value {
    font-size: 28px;
  }

  .tactical-actions .btn {
    padding: 10px 6px;
    font-size: 11px;
  }

  .modal-content {
    padding: 20px;
    border-radius: var(--radius-lg);
  }

  .form-group input,
  .form-group select {
    padding: 12px 14px;
    font-size: 14px;
  }

  .btn {
    padding: 12px 18px;
    font-size: 13px;
  }
}

/* ==================== 锦标赛样式 ==================== */

.tournament-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tournament-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.tournament-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

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

.tournament-card-name {
  font-weight: 600;
  font-size: 15px;
}

.tournament-card-info {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

.tournament-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.tournament-header h3 {
  margin: 0;
}

.players-section,
.format-section,
.bracket-section {
  margin-bottom: 20px;
}

.players-section h4,
.format-section h4,
.bracket-section h4 {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.player-list-compact {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.player-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: var(--bg-card);
  border-radius: var(--radius);
  font-size: 13px;
}

.player-item .player-num {
  color: var(--text-muted);
  font-size: 11px;
}

.player-item .player-name {
  flex: 1;
}

.player-item .player-seed {
  background: var(--accent);
  color: var(--bg-deep);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
}

.btn-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 0 4px;
}

.btn-remove:hover {
  color: var(--danger);
}

.format-rounds {
  margin-top: 12px;
}

.rounds-timeline {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.round-item {
  padding: 6px 10px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border-left: 3px solid var(--border-medium);
}

.round-item.pending {
  opacity: 0.6;
}

.round-item.completed {
  border-left-color: var(--accent);
  background: rgba(201, 168, 76, 0.1);
}

.round-item .round-name {
  display: block;
  font-size: 11px;
  font-weight: 600;
}

.round-item .round-info {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
}

/* 对阵图 */
.bracket-container {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 12px;
}

.bracket-round {
  min-width: 160px;
}

.round-header {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  padding: 8px;
  background: rgba(201, 168, 76, 0.1);
  border-radius: var(--radius) var(--radius) 0 0;
}

.round-matches {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  background: var(--bg-card);
  border-radius: 0 0 var(--radius) var(--radius);
}

.match-card {
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
}

.match-card:hover {
  border-color: var(--accent);
  transform: scale(1.02);
}

.match-card.empty {
  opacity: 0.5;
  cursor: default;
}

.match-card.empty:hover {
  transform: none;
}

.match-player {
  display: flex;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.match-player:last-child {
  border-bottom: none;
}

.match-player.winner {
  background: rgba(201, 168, 76, 0.15);
}

.match-player.winner .player-name {
  font-weight: 600;
}

.match-player.loser {
  opacity: 0.6;
}

.match-player .player-name {
  font-size: 12px;
}

.match-player .player-score {
  font-weight: 600;
  font-size: 14px;
  color: var(--accent);
}

.tournament-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.tournament-actions .btn {
  flex: 1;
}

.template-info {
  background: var(--bg-card);
  padding: 14px;
  border-radius: var(--radius);
  margin-top: 12px;
}

.template-info p {
  margin-bottom: 8px;
  font-size: 13px;
}

.template-info ul {
  margin: 0;
  padding-left: 20px;
  font-size: 12px;
  color: var(--text-secondary);
}

.template-info li {
  margin-bottom: 4px;
}

/* 弹窗 active 状态 */
.modal.active {
  display: flex;
}
