:root {
  --primary-color: #0d9488;
  --primary-hover: #0f766e;
  --bg-gradient: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  --card-bg: #FFFFFF;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --correct-bg: #10B981;
  --wrong-bg: #dc2626;
  --cell-bg: #F1F5F9;
  --cell-hover: #e2e8f0;
  --border: #e2e8f0;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-gradient);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  color: var(--text-main);
}

/* 站点统一顶部导航条 */
.site-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 18px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
}
.site-topbar-back {
  color: var(--primary-color);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}
.site-topbar-back:hover { color: var(--primary-hover); }
.site-topbar-brand {
  color: var(--text-main);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 1px;
}

.main-wrapper {
  margin: auto;   /* 顶条之外的区域里垂直水平居中 */
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 520px;
  gap: 16px;
  padding: 16px;
}

.container {
  background: var(--card-bg);
  border-radius: 20px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
  width: 100%;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

header {
  text-align: center;
}

h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-main);
}

.subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* 广告容器预留样式 */
.ad-container {
  width: 100%;
  min-height: 60px;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.ad-placeholder {
  width: 100%;
  height: 60px;
  border: 1px dashed rgba(255, 255, 255, 0.4);
  color: rgba(255, 255, 255, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  border-radius: 8px;
}

.ad-modal .ad-placeholder {
  border-color: #E5E7EB;
  color: #9CA3AF;
  margin: 12px 0;
}

/* 控制按钮与导航 */
.controls {
  display: flex;
  gap: 8px;
  width: 100%;
  justify-content: center;
  flex-wrap: wrap;
}

.size-btn {
  background: var(--cell-bg);
  border: 2px solid transparent;
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s ease;
}

.size-btn:hover {
  background: var(--cell-hover);
}

.size-btn.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
  box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.3);
}

/* 仪表盘 */
.dashboard {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  background: #F9FAFB;
  padding: 12px 20px;
  border-radius: 12px;
  border: 1px solid #E5E7EB;
}

.timer-box, .target-box {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.val {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--primary-color);
}

/* 方格布局 */
.grid-container {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: grid;
  gap: 8px;
  margin: 8px 0;
}

.grid-cell {
  background: var(--cell-bg);
  border-radius: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease, background-color 0.2s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.grid-cell:hover {
  background: var(--cell-hover);
}

.grid-cell:active {
  transform: scale(0.95);
}

.grid-cell.correct {
  background: var(--correct-bg) !important;
  color: white;
  animation: pulse 0.3s ease;
}

.grid-cell.wrong {
  background: var(--wrong-bg) !important;
  color: white;
  animation: shake 0.3s ease;
}

.actions {
  display: flex;
  gap: 12px;
  width: 100%;
}

.btn {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--primary-color);
  color: white;
  box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.3);
}

.btn:hover {
  background: var(--primary-hover);
}

.seo-content {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  border-radius: 12px;
  padding: 16px;
  color: white;
  font-size: 0.85rem;
  line-height: 1.5;
  width: 100%;
}

.seo-content h2 {
  font-size: 1rem;
  margin-bottom: 6px;
}

/* 结算弹窗 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 100;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: white;
  padding: 24px;
  border-radius: 20px;
  width: 90%;
  max-width: 380px;
  text-align: center;
  transform: translateY(20px);
  transition: transform 0.3s ease;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

.modal h2 {
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.rating-stars {
  font-size: 2rem;
  color: #F59E0B;
  margin: 6px 0;
}

.modal-stats {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.5;
}

.modal-stats strong {
  color: var(--primary-color);
  font-size: 1.2rem;
}

/* 动画定义 */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}