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

:root {
  --bg: #10131f;
  --bg-2: #1a1f33;
  --panel: #232a45;
  --text: #eef1ff;
  --text-dim: #9aa3c7;
  --primary: #6c5ce7;
  --primary-2: #a29bfe;
  --success: #00b894;
  --danger: #e17055;
  --warn: #fdcb6e;
}

html, body {
  height: 100%;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(1200px 800px at 15% 10%, rgba(108, 92, 231, .28), transparent 60%),
    radial-gradient(1000px 700px at 85% 90%, rgba(0, 184, 148, .16), transparent 60%),
    radial-gradient(800px 600px at 70% 20%, rgba(253, 203, 110, .10), transparent 60%),
    linear-gradient(160deg, #1a1f3a, #10131f 60%);
  color: var(--text);
  overflow: hidden;
}

/* ============ 界面切换 ============ */
.screen {
  display: none;
  position: fixed;
  inset: 0;
  padding: 16px;
  flex-direction: column;
  overflow-y: auto; /* 内容超高时可滚动，防止按钮被隐藏 */
}
.screen.active { display: flex; }

/* ============ 面板 ============ */
.panel {
  margin: auto;
  width: 100%;
  max-width: 520px;
  background: var(--panel);
  border-radius: 20px;
  padding: 24px 28px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .45);
}
.panel h1 {
  font-size: 24px;
  text-align: center;
  margin-bottom: 4px;
  background: linear-gradient(90deg, #a29bfe, #74b9ff, #fd79a8, #a29bfe);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: titleFlow 6s linear infinite;
}
@keyframes titleFlow { to { background-position: -200% 0; } }
.panel h2 { font-size: 22px; text-align: center; margin-bottom: 12px; }
.panel.center { text-align: center; }
.subtitle { color: var(--text-dim); text-align: center; margin-bottom: 12px; font-size: 14px; }

/* 主画面装饰 */
.decor-row {
  text-align: center;
  font-size: 18px;
  letter-spacing: 10px;
  margin-bottom: 8px;
  animation: floatY 3s ease-in-out infinite;
}
@keyframes floatY { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 8px; }
.field input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  border-radius: 10px;
  border: 1px solid #3a4368;
  background: var(--bg-2);
  color: var(--text);
  outline: none;
}
.field input[type="text"]:focus { border-color: var(--primary-2); }

/* 家长/助手协助模式开关 */
.checkbox-field {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--bg-2);
  border: 1px solid #3a4368;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-dim);
}
.checkbox-field input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
  flex: none;
}

/* ============ 级别选择 ============ */
.level-select { display: grid; grid-template-columns: 1fr; gap: 10px; }
.level-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 12px;
  border: 2px solid #3a4368;
  background: var(--bg-2);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  transition: all .15s;
}
.level-option .lv { font-size: 20px; }
.level-option .lv-name { font-weight: 600; }
.level-option .lv-desc { color: var(--text-dim); font-size: 12px; margin-top: 2px; }
.level-option.selected { border-color: var(--primary); background: var(--panel); }
.level-option.selected .lv-name { color: var(--primary-2); }

/* 模式选择（实际参与 / 体验） */
.mode-select { display: grid; grid-template-columns: 1fr; gap: 10px; }

/* 本轮图片数量选择 */
.round-select select {
  width: 100%;
  padding: 10px 12px;
  font-size: 15px;
  border-radius: 10px;
  border: 1px solid #3a4368;
  background: var(--bg-2);
  color: var(--text);
  outline: none;
  cursor: pointer;
}
.mode-option {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 2px solid #3a4368;
  background: var(--bg-2);
  cursor: pointer;
  transition: all .15s;
}
.mode-option input[type="radio"] { display: none; }
.mode-name { font-size: 15px; font-weight: 600; }
.mode-desc { font-size: 11px; color: var(--text-dim); }
.mode-option:has(input:checked) {
  border-color: var(--primary);
  background: var(--panel);
}
.mode-option:has(input:checked) .mode-name { color: var(--primary-2); }

/* 技术测试：弱化样式，放最底部不易发现 */
.trial-row {
  margin-top: 10px;
  text-align: right;
  opacity: .35;
}
.trial-row:hover { opacity: .6; }
.trial-option { cursor: pointer; }
.trial-option input[type="radio"] { display: none; }
.trial-label {
  font-size: 11px;
  color: var(--text-dim);
  border-bottom: 1px dashed rgba(154, 163, 199, .4);
  padding: 2px 2px;
}
.trial-option:has(input:checked) .trial-label {
  color: var(--primary-2);
  border-bottom-color: var(--primary-2);
  opacity: 1;
}

/* ============ 按钮 ============ */
.btn {
  display: inline-block;
  padding: 14px 28px;
  font-size: 16px;
  border-radius: 12px;
  border: 1px solid #3a4368;
  background: var(--bg-2);
  color: var(--text);
  cursor: pointer;
  transition: all .15s;
}
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
  border-color: transparent;
  font-weight: 600;
  margin-top: 8px;
  box-shadow: 0 6px 18px rgba(108, 92, 231, .4);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #7d6df0, #b3acff);
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(108, 92, 231, .55);
}
.btn { transition: transform .12s, box-shadow .12s, background .12s; }
.result-actions { display: flex; gap: 10px; margin-top: 18px; }
.result-actions .btn { flex: 1; }

/* 遮眼倒计时 */
.countdown-num {
  font-size: 96px;
  font-weight: 800;
  color: var(--primary-2);
  margin: 24px 0;
  animation: pulse 1s infinite;
}
.btn-ready {
  margin-top: 20px;
  font-size: 18px;
  padding: 16px;
  background: var(--success);
  border-color: var(--success);
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.12); opacity: .7; }
}
.hint { color: var(--text-dim); font-size: 14px; }

/* ============ 游戏顶部栏 ============ */
.game-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 4px 14px;
  font-size: 14px;
  color: var(--text-dim);
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.badge {
  background: var(--primary);
  color: #fff;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}
.topbar-right { display: flex; gap: 18px; }
.topbar-right b { color: var(--text); }

/* ============ 图案展示区 ============ */
.card-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}
.card-placeholder { font-size: 20px; color: var(--text-dim); }
.card-image {
  max-width: min(92vw, 92vh);
  max-height: 86vh;
  object-fit: contain;
  filter: drop-shadow(0 10px 30px rgba(108, 92, 231, .35));
}

/* 图片淡入 */
.fade-in { animation: fadeIn .5s ease; }
@keyframes fadeIn { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: scale(1); } }

/* ============ 答案区 ============ */
.answer-area { padding: 12px 0 8px; }
.answer-hint { text-align: center; color: var(--text-dim); font-size: 14px; margin-bottom: 8px; min-height: 20px; }
.answer-hint.correct { color: var(--success); font-weight: 600; }
.answer-hint.wrong { color: var(--danger); font-weight: 600; }

/* 语音聆听状态 */
.speech-status {
  text-align: center;
  font-size: 13px;
  color: var(--primary-2);
  margin-bottom: 8px;
  min-height: 18px;
}
.manual-row { text-align: center; margin-bottom: 8px; }
.btn-mini {
  font-size: 12px;
  padding: 4px 14px;
  border-radius: 999px;
  color: var(--primary-2);
  border-color: rgba(162, 155, 254, .4);
  background: transparent;
}

/* 家长/助手协助控制面板（右侧成绩栏下方，竖排） */
.assist-panel {
  position: fixed;
  right: 14px;
  top: 210px;
  z-index: 1010;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(16, 19, 31, .94);
  border: 2px solid rgba(108, 92, 231, .8);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .65);
}
.btn-assist {
  font-size: 16px;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 10px;
  min-width: 110px;
}
.btn-correct { background: var(--success); border-color: var(--success); color: #fff; }
.btn-correct:hover { filter: brightness(1.15); }
.btn-wrong { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-wrong:hover { filter: brightness(1.15); }
.btn-next { background: var(--warn); border-color: var(--warn); color: #2c2c2c; }
.btn-next:hover { filter: brightness(1.1); }
.btn-start { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-start:hover { filter: brightness(1.15); }
.micro-hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 10px;
}

/* 计时 chip */
.timer-chip {
  background: rgba(108, 92, 231, .15);
  padding: 2px 10px;
  border-radius: 999px;
  color: var(--text);
}
.timer-chip b { color: var(--primary-2); font-variant-numeric: tabular-nums; }

.answer-buttons {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}
.answer-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 4px;
  border-radius: 12px;
  border: 2px solid #3a4368;
  background: var(--bg-2);
  cursor: pointer;
  transition: all .15s;
}
.answer-btn img { width: 100%; max-height: 56px; object-fit: contain; pointer-events: none; }
.answer-btn .a-label { font-size: 12px; color: var(--text-dim); }
.answer-btn:hover { border-color: var(--primary-2); transform: translateY(-2px); }
.answer-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.answer-btn.flash-correct { border-color: var(--success); background: rgba(0, 184, 148, .15); }
.answer-btn.flash-wrong { border-color: var(--danger); background: rgba(225, 112, 85, .15); }

/* ============ 结算界面 ============ */
.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 20px 0 8px;
}
.stat {
  background: var(--bg-2);
  border-radius: 12px;
  padding: 14px 4px;
  text-align: center;
}
.stat b { display: block; font-size: 22px; color: var(--primary-2); }
.stat span { font-size: 12px; color: var(--text-dim); }

/* 成就展示 */
.ach-title {
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  color: var(--warn);
  margin: 16px 0 10px;
}
.result-achievements {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.achievement {
  background: var(--bg-2);
  border: 1px solid rgba(253, 203, 110, .35);
  border-radius: 12px;
  padding: 10px 4px;
  text-align: center;
  animation: popIn .4s ease;
}
.achievement .a-icon { font-size: 26px; display: block; }
.achievement .a-name { font-size: 13px; font-weight: 600; color: var(--warn); display: block; margin-top: 4px; }
.achievement .a-desc { font-size: 11px; color: var(--text-dim); display: block; margin-top: 2px; }
@keyframes popIn { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ============ 摄像头监督小窗 ============ */
.cam-box {
  position: fixed;
  left: 14px; /* 左下角，避免与右侧协助面板/聊天栏重叠 */
  bottom: 14px;
  z-index: 1000;
  width: 200px;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  border: 2px solid rgba(108, 92, 231, .5);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .5);
  cursor: move;
}

/* ============ 右侧成绩栏 ============ */
.score-panel {
  position: fixed;
  right: 14px;
  top: 14px;
  width: 202px;
  z-index: 905;
  border-radius: 14px;
  background: rgba(16, 19, 31, .88);
  border: 1px solid rgba(108, 92, 231, .5);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
  padding: 12px;
  display: none;
}
.score-panel.show { display: block; }
.score-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-2);
  text-align: center;
  margin-bottom: 8px;
}
.score-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 3px 2px;
  color: var(--text-dim);
}
.score-row b { color: var(--text); font-variant-numeric: tabular-nums; }

.cam-box video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}.cam-status {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  font-size: 11px;
  text-align: center;
  padding: 3px 4px;
  color: #fff;
  background: rgba(0, 0, 0, .55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

/* ============ 全屏感知图案层 ============ */
.fullscreen-card {
  position: fixed;
  left: 0;
  right: 230px; /* 右侧留出工具栏空间 */
  top: 0;
  bottom: 0;
  z-index: 900;
  background:
    radial-gradient(700px 500px at 50% 30%, rgba(108, 92, 231, .25), transparent 70%),
    radial-gradient(500px 400px at 15% 85%, rgba(0, 184, 148, .14), transparent 70%),
    radial-gradient(400px 300px at 85% 15%, rgba(253, 203, 110, .12), transparent 70%),
    linear-gradient(160deg, #1a1f3a, #10131f 60%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.fullscreen-top { display: none; } /* 图片区纯净：状态信息由右侧成绩栏展示 */
.fullscreen-card .card-image {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: cover; /* 保持比例不变，放大填满整个画面（裁切边缘留白） */
  filter: drop-shadow(0 0 26px rgba(162, 155, 254, .45)) drop-shadow(0 12px 34px rgba(0, 0, 0, .5));
}
#fullscreen-card-content {
  flex: 1;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.fullscreen-top {
  position: absolute;
  top: 14px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 14px;
  color: var(--text-dim);
  padding: 6px 12px;
  background: rgba(0, 0, 0, .35);
}
.fullscreen-top b { color: var(--text); }
.fullscreen-hint {
  position: fixed;
  right: 14px;
  bottom: 24px;
  left: auto;
  width: 202px;
  text-align: left;
  font-size: 14px;
  color: var(--text-dim);
  text-shadow: 0 2px 6px rgba(0, 0, 0, .6);
  z-index: 910;
}
/* 音量条（发声确认时显示麦克风灵敏度反馈，位于右侧工具栏区） */
.volume-box {
  position: fixed;
  right: 14px;
  top: 240px;
  left: auto;
  bottom: auto;
  width: 202px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 910;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(16, 19, 31, .85);
  border: 1px solid rgba(162, 155, 254, .4);
}
.volume-icon { font-size: 22px; }
.volume-indicator {
  width: 100%;
  height: 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .28);
  border: 1px solid rgba(255, 255, 255, .4);
  overflow: hidden;
}
#volume-bar {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #6c5ce7, #a29bfe);
  transition: width .06s linear;
}
.volume-indicator.active #volume-bar {
  background: linear-gradient(90deg, #00b894, #55efc4);
}
.volume-status {
  font-size: 13px;
  color: var(--text);
  min-width: 90px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .7);
}
.fullscreen-card #btn-manual-fs {
  position: absolute;
  bottom: 13%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 910;
}

@media (max-width: 480px) {
  .panel { padding: 24px 18px; }
  .answer-buttons { grid-template-columns: repeat(5, 1fr); gap: 6px; }
  .cam-box { width: 140px; left: 8px; bottom: 8px; }
}
