/* ===== style.css — 儿童护眼拼图游戏全局样式 ===== */
/* 低蓝光暖色调 · 大字体 · 高对比度 */

:root {
  --bg-warm:    #F5EFE6;
  --bg-muted:   #EDE0CC;
  --accent:     #E8A030;
  --accent-dk:  #C07820;
  --green:      #5A9A5A;
  --green-dk:   #3A7A3A;
  --red-soft:   #D05050;
  --text-dark:  #3A2A18;
  --text-mid:   #6A5040;
  --shadow:     rgba(80,50,20,0.18);
  --panel-bg:   rgba(245,239,230,0.96);
  --overlay-bg: rgba(60,40,20,0.72);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: var(--bg-warm);
  color: var(--text-dark);
  font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ═══════════════════ HEADER ═══════════════════ */
#header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 24px;
  background: var(--bg-muted);
  border-bottom: 3px solid var(--accent);
  box-shadow: 0 2px 12px var(--shadow);
  gap: 12px;
}

#header h1 {
  font-size: 28px; font-weight: 800;
  color: var(--accent-dk);
  letter-spacing: 1px;
  white-space: nowrap;
}

/* 关卡指示器 */
#level-indicator {
  display: flex; gap: 10px;
}
.level-dot {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--bg-warm);
  border: 3px solid var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; cursor: pointer;
  transition: transform 0.2s, background 0.2s;
}
.level-dot.active { background: var(--accent); transform: scale(1.2); }
.level-dot.done { background: var(--green); border-color: var(--green-dk); }

/* 防沉迷计时器 */
#eye-timer {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-bg);
  border: 2px solid var(--accent);
  border-radius: 20px;
  padding: 6px 18px;
  font-size: 24px; font-weight: 700;
  color: var(--text-dark);
  white-space: nowrap;
  min-width: 140px;
  justify-content: center;
}
#eye-timer.warning { border-color: var(--red-soft); color: var(--red-soft); animation: pulse-warn 1s ease-in-out infinite; }

@keyframes pulse-warn {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}

/* 摄像头状态标签 */
#cam-badge {
  display: flex; align-items: center; gap: 6px;
  font-size: 20px; font-weight: 600;
  padding: 6px 14px; border-radius: 16px;
  background: var(--panel-bg);
  border: 2px solid var(--bg-muted);
  white-space: nowrap;
}
#cam-badge.on  { border-color: var(--green); color: var(--green); }
#cam-badge.off { border-color: var(--text-mid); color: var(--text-mid); }

/* ═══════════════════ MAIN LAYOUT ═══════════════════ */
#main {
  position: fixed;
  top: 68px; left: 0; right: 0; bottom: 0;
  display: flex; align-items: stretch;
}

/* 左侧视频预览小窗 */
#cam-panel {
  width: 200px; min-width: 160px;
  background: #2A1E12;
  display: flex; flex-direction: column; align-items: center;
  padding: 12px 8px 12px;
  gap: 10px;
  flex-shrink: 0;
}
#cam-panel .cam-label {
  color: #C8B090; font-size: 18px; font-weight: 600;
  text-align: center;
}

#video-wrapper {
  position: relative;
  width: 180px; height: 135px;
  border-radius: 12px; overflow: hidden;
  border: 2px solid #5A4030;
}
#cam-video {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transform: scaleX(-1);
}
#cam-canvas {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}

/* 手势说明 */
.gesture-hint {
  width: 100%;
  background: rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 8px 10px;
  color: #D4B896;
  font-size: 15px;
  line-height: 1.6;
}
.gesture-hint p { margin-bottom: 4px; }
.gesture-hint strong { color: #FFD080; }

/* 右侧游戏画布区 */
#game-area {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 16px;
  overflow: hidden;
}

#puzzle-canvas {
  display: block;
  border-radius: 18px;
  box-shadow: 0 8px 32px var(--shadow);
  border: 4px solid var(--accent);
  cursor: none; /* 隐藏系统光标，用手势光圈代替 */
  max-width: 100%;
  max-height: 100%;
  touch-action: none;
  background: var(--bg-warm);
}

/* ═══════════════════ OVERLAYS ═══════════════════ */
.overlay {
  position: fixed; inset: 0; z-index: 300;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 28px;
  background: var(--overlay-bg);
  backdrop-filter: blur(6px);
}
.overlay.hidden { display: none; }

.overlay-box {
  background: var(--bg-warm);
  border-radius: 28px;
  padding: 40px 48px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.4);
  text-align: center;
  max-width: 580px; width: 90%;
  border: 4px solid var(--accent);
}
.overlay-box h2 {
  font-size: 44px; font-weight: 900;
  color: var(--accent-dk);
  margin-bottom: 16px;
  line-height: 1.2;
}
.overlay-box p {
  font-size: 26px; color: var(--text-mid);
  line-height: 1.6; margin-bottom: 10px;
}
.overlay-box .sub {
  font-size: 22px; color: var(--text-mid);
}

/* 大按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 10px;
  padding: 18px 42px;
  font-size: 28px; font-weight: 800;
  border: none; border-radius: 50px;
  cursor: pointer;
  transition: transform 0.18s, box-shadow 0.18s;
  box-shadow: 0 6px 20px var(--shadow);
  position: relative;
  overflow: hidden;
}
.btn:hover, .btn:focus { transform: translateY(-3px) scale(1.04); outline: none; }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, #E8A030, #C07820);
  color: white;
}
.btn-green {
  background: linear-gradient(135deg, #5A9A5A, #3A7A3A);
  color: white;
}

/* 悬停充能进度环 */
.btn .hover-ring {
  position: absolute; inset: 0;
  border-radius: 50px; overflow: hidden;
  pointer-events: none;
}
.btn .hover-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 0%; background: rgba(255,255,255,0.22);
  transition: width 0.05s linear;
}

/* ═══════════════════ 护眼休息遮罩 ═══════════════════ */
#rest-overlay .rest-box {
  background: linear-gradient(160deg, #FFF8E8, #EDE8DC);
  border-color: var(--green);
}
#rest-overlay h2 { color: var(--green-dk); }
#rest-overlay .rest-countdown {
  font-size: 80px; font-weight: 900; color: var(--green);
  line-height: 1; margin: 10px 0;
}
#rest-overlay .eye-anim { font-size: 72px; animation: blink-eye 3s ease-in-out infinite; }
@keyframes blink-eye {
  0%, 90%, 100% { transform: scaleY(1); }
  95%            { transform: scaleY(0.08); }
}

/* ═══════════════════ 通关庆祝遮罩 ═══════════════════ */
#win-overlay .win-box { border-color: var(--green); }
#win-overlay h2 { color: var(--green-dk); }

#confetti-canvas {
  position: fixed; inset: 0; z-index: 290;
  pointer-events: none;
}

/* 按钮组 */
.btn-row {
  display: flex; flex-wrap: wrap; gap: 20px;
  justify-content: center; margin-top: 8px;
}

/* ═══════════════════ 开始菜单 ═══════════════════ */
#start-overlay .start-box {
  max-width: 640px;
  border-color: var(--accent);
}
#start-overlay h2 { font-size: 48px; }
.level-cards {
  display: flex; gap: 16px; flex-wrap: wrap; justify-content: center;
  margin: 10px 0 24px;
}
.level-card {
  background: var(--bg-muted);
  border: 3px solid var(--accent);
  border-radius: 18px;
  padding: 16px 20px; cursor: pointer;
  transition: transform 0.18s, border-color 0.18s;
  text-align: center;
  min-width: 140px;
}
.level-card:hover { transform: scale(1.06); border-color: var(--accent-dk); }
.level-card .emoji { font-size: 40px; }
.level-card .name  { font-size: 20px; font-weight: 700; color: var(--text-dark); margin-top: 6px; }
.level-card .desc  { font-size: 17px; color: var(--text-mid); }

/* ═══════════════════ 加载中 ═══════════════════ */
#loading-overlay p { font-size: 30px; color: #EED090; }
.spinner {
  width: 72px; height: 72px;
  border: 7px solid rgba(255,220,100,0.3);
  border-top-color: #FFD080;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════ 响应式（大屏优先）═══════════════════ */
@media (max-width: 800px) {
  #cam-panel { width: 140px; }
  #video-wrapper { width: 128px; height: 96px; }
  #header h1 { font-size: 22px; }
  #eye-timer { font-size: 20px; }
  .btn { font-size: 22px; padding: 14px 30px; }
  .overlay-box h2 { font-size: 34px; }
  .overlay-box p { font-size: 22px; }
}

@media (max-width: 540px) {
  #cam-panel { display: none; }
  #header h1 { font-size: 18px; }
}
