:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --rock: #f59e0b;
  --scissors: #3b82f6;
  --paper: #10b981;
  --none: #9ca3af;
  --train: #7c3aed;
  --battle: #ef4444;
  --exam: #0ea5e9;
  --radius: 20px;
  --shadow: 0 6px 20px rgba(20, 30, 60, 0.10);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", "Hiragino Sans GB", system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button { font-family: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: not-allowed; opacity: 0.45; }
.hidden { display: none !important; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px;
}
.topbar h1 { margin: 0; font-size: 24px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.pill {
  background: var(--card); border-radius: 999px; padding: 6px 14px;
  font-size: 14px; color: var(--muted); box-shadow: var(--shadow);
}
.pill.ok { color: var(--paper); }
.pill.warn { color: var(--battle); }
.icon-btn {
  background: var(--card); border: none; border-radius: 50%;
  width: 40px; height: 40px; font-size: 20px; box-shadow: var(--shadow);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 20px;
  padding: 0 20px 20px;
  max-width: 1300px;
  margin: 0 auto;
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
}

/* 摄像头 */
.camera-panel { display: flex; flex-direction: column; gap: 10px; }
.camera-box {
  position: relative; width: min(100%, calc(100vh - 150px)); aspect-ratio: 1 / 1;
  background: #111; border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow);
}
.camera-box video {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.camera-box.mirror video { transform: scaleX(-1); }
.camera-msg {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 22px; text-align: center; padding: 30px;
  background: rgba(0,0,0,0.55);
}
.flash {
  position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none;
  transition: opacity 120ms;
}
.flash.on { opacity: 0.5; transition: none; }

.guess {
  position: absolute; left: 12px; right: 12px; bottom: 12px;
  display: flex; align-items: center; gap: 14px;
  background: rgba(255,255,255,0.93); border-radius: 16px; padding: 10px 16px;
}
.guess-emoji { font-size: 56px; line-height: 1; min-width: 64px; text-align: center; }
.guess-text { flex: 1; }
.guess-label { font-size: 28px; font-weight: 700; }
.guess-sure { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 15px; margin-top: 4px; }
.bar { flex: 1; height: 12px; background: #e5e7eb; border-radius: 999px; overflow: hidden; }
.bar.big { height: 18px; }
.bar-fill { height: 100%; width: 0; background: var(--paper); border-radius: 999px; transition: width 150ms; }
.bar-fill.low { background: var(--rock); }

.hint { margin: 0; font-size: 18px; color: var(--muted); min-height: 1.5em; }

/* 四个类别按钮 */
.controls { display: flex; flex-direction: column; gap: 16px; }
.classes {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}
.class-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 10px; display: flex; flex-direction: column; gap: 8px;
}
.capture-btn {
  position: relative; border: none; border-radius: 16px; color: #fff;
  min-height: 120px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 700; gap: 4px;
  box-shadow: inset 0 -6px 0 rgba(0,0,0,0.18);
  transition: transform 80ms;
}
.capture-btn:active, .capture-btn.pressing { transform: scale(0.97); box-shadow: inset 0 0 0 rgba(0,0,0,0); filter: brightness(1.08); }
.capture-btn .emoji { font-size: 44px; line-height: 1; }
.capture-btn .count {
  position: absolute; top: 8px; right: 10px; background: rgba(0,0,0,0.28);
  border-radius: 999px; padding: 2px 10px; font-size: 16px;
}
.capture-btn .sub { font-size: 13px; font-weight: 400; opacity: 0.9; }
.class-rock .capture-btn { background: var(--rock); }
.class-scissors .capture-btn { background: var(--scissors); }
.class-paper .capture-btn { background: var(--paper); }
.class-none .capture-btn { background: var(--none); }
.class-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.thumb {
  width: 44px; height: 44px; border-radius: 8px; background: #e5e7eb; object-fit: cover;
}
.thumb.mirror { transform: scaleX(-1); }
.text-btn {
  background: none; border: 1px solid #d1d5db; border-radius: 999px; padding: 6px 14px;
  font-size: 14px; color: var(--muted);
}
.text-btn.danger { color: var(--battle); border-color: #fca5a5; align-self: center; }
.text-btn.confirm { background: var(--battle); color: #fff; border-color: var(--battle); }

/* 大按钮 */
.actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.big-btn {
  border: none; border-radius: var(--radius); color: #fff; min-height: 90px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 30px; font-weight: 700; box-shadow: var(--shadow);
}
.big-btn-emoji { font-size: 36px; }
.big-btn.train { background: var(--train); }
.big-btn.battle { background: var(--battle); }
.big-btn.exam { background: var(--exam); }
.big-btn.attention { animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.04); } }
.train-progress { display: flex; align-items: center; gap: 12px; font-size: 18px; color: var(--muted); }
.train-progress .bar-fill { background: var(--train); }

/* 遮罩层 */
.overlay {
  position: fixed; inset: 0; background: rgba(20, 24, 40, 0.75);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 10;
}
.battle-card, .settings-card {
  background: var(--card); border-radius: 28px; padding: 24px; width: min(760px, 100%);
  box-shadow: var(--shadow); text-align: center;
}
.battle-score { font-size: 22px; color: var(--muted); }
.battle-score b { color: var(--text); font-size: 28px; }
.battle-stage { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin: 20px 0; }
.battle-title { font-size: 20px; color: var(--muted); }
.battle-emoji { font-size: 110px; line-height: 1.2; }
.battle-emoji.small { font-size: 56px; line-height: 1.1; }
.battle-video {
  width: 150px; height: 150px; object-fit: cover; border-radius: 20px; background: #111;
  display: block; margin: 0 auto;
}
.mirror .battle-video { transform: scaleX(-1); }
.battle-name { font-size: 24px; font-weight: 700; min-height: 1.4em; }
.battle-count { font-size: 96px; font-weight: 800; color: var(--battle); min-width: 120px; }
.battle-result { font-size: 34px; font-weight: 800; min-height: 1.4em; }
.battle-result.win { color: var(--paper); }
.battle-result.lose { color: var(--battle); }
.battle-actions { display: flex; justify-content: center; gap: 14px; margin-top: 18px; align-items: center; }
.battle-actions .big-btn { min-height: 70px; padding: 0 30px; font-size: 26px; }

.settings-card { text-align: left; width: min(460px, 100%); display: flex; flex-direction: column; gap: 14px; }
.settings-card h2 { margin: 0; }
.settings-card label { display: flex; flex-direction: column; gap: 6px; font-size: 16px; }
.settings-card label.row { flex-direction: row; align-items: center; }
.settings-card select { font-size: 16px; padding: 8px; border-radius: 10px; border: 1px solid #d1d5db; }
.small { font-size: 13px; color: var(--muted); margin: 0; }

/* 看看电脑怎么想 */
.think-btn { align-self: flex-start; }
.think { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; display: flex; flex-direction: column; gap: 14px; }
.think-empty { margin: 0; color: var(--muted); font-size: 16px; }
.think-block { display: flex; flex-direction: column; gap: 6px; }
.think-title { font-size: 15px; color: var(--muted); }
.barcode { width: 100%; height: 48px; background: #f3f4f6; border-radius: 8px; display: block; }
.neighbors { display: flex; flex-wrap: wrap; gap: 6px; min-height: 48px; }
.neighbor { border: 3px solid transparent; }
.votes { display: flex; flex-direction: column; gap: 6px; }
.vote-row { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.vote-name { width: 90px; }
.vote-row b { width: 48px; text-align: right; }
.map { width: 100%; aspect-ratio: 16 / 10; background: #f9fafb; border-radius: 12px; display: block; }
.map-legend { display: flex; gap: 14px; font-size: 14px; color: var(--muted); }
.map-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; }

/* 训练舞台 */
.slow-row { font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stage { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.stage-row { display: flex; align-items: center; gap: 10px; }
.stage-item { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.stage-item.grow { flex: 1; min-width: 0; }
.stage-item.grow .barcode { width: 100%; }
.stage-photo { width: 72px; height: 72px; border-radius: 10px; background: #e5e7eb; object-fit: cover; }
.mirror .stage-photo { transform: scaleX(-1); }
.stage-master { font-size: 48px; line-height: 72px; }
.stage-cap { font-size: 13px; color: var(--muted); white-space: nowrap; }
.stage-arrow { font-size: 24px; color: var(--muted); }
.stage-arrow.down { text-align: center; font-size: 16px; }
.bins { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.bin { border: 3px solid; border-radius: 12px; padding: 6px; text-align: center; font-size: 22px; display: flex; flex-direction: column; align-items: center; transition: transform 150ms; }
.bin b { font-size: 18px; }
.bin.drop { transform: scale(1.12); }

/* 找找坏照片 */
.tool-row { display: flex; gap: 10px; flex-wrap: wrap; }
.suspects-card {
  background: var(--card); border-radius: 28px; padding: 24px; width: min(720px, 100%);
  max-height: 90vh; overflow: auto; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px;
}
.suspects-card h2 { margin: 0; font-size: 24px; }
.suspect-list { display: flex; flex-direction: column; gap: 12px; }
.suspect { display: flex; gap: 14px; align-items: center; background: var(--bg); border-radius: 16px; padding: 10px; }
.suspect-img { width: 112px; height: 112px; border-radius: 12px; object-fit: cover; background: #e5e7eb; flex-shrink: 0; }
.mirror .suspect-img { transform: scaleX(-1); }
.suspect-body { display: flex; flex-direction: column; gap: 8px; }
.suspect-reason { font-size: 18px; font-weight: 600; }
.suspect-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.suspect-actions .text-btn { font-size: 15px; padding: 8px 14px; }

/* 考考它 */
.exam-card { width: min(820px, 100%); }
.exam-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.exam-name-row { font-size: 16px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.exam-name-row input {
  font: inherit; font-size: 18px; padding: 6px 12px; border: 1px solid #d1d5db; border-radius: 999px; width: 160px;
  -webkit-user-select: text; user-select: text;
}
.exam-progress { font-size: 20px; color: var(--muted); }
.exam-progress span:first-child { color: var(--text); font-weight: 700; }
.exam-dots { display: flex; gap: 6px; justify-content: center; margin: 12px 0 6px; flex-wrap: wrap; }
.exam-dots span {
  width: 30px; height: 30px; border-radius: 50%; background: #e5e7eb; display: inline-flex;
  align-items: center; justify-content: center; font-size: 16px; font-weight: 800; color: #fff;
}
.exam-dots span.cur { outline: 3px solid var(--exam); outline-offset: 2px; }
.exam-dots span.ok { background: var(--paper); }
.exam-dots span.bad { background: var(--battle); }
.exam-stage { display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: 16px; margin: 12px 0; }
.exam-ask-title { font-size: 22px; color: var(--muted); }
.exam-ask-emoji { font-size: 96px; line-height: 1.2; }
.exam-ask-name { font-size: 32px; font-weight: 800; }
.exam-ask .battle-count { color: var(--exam); font-size: 72px; min-height: 1.1em; }
.exam-score { font-size: 44px; font-weight: 800; margin-top: 8px; }
.exam-pct { font-size: 64px; font-weight: 900; color: var(--exam); line-height: 1.1; }
.exam-breakdown { display: flex; justify-content: center; gap: 18px; margin: 14px 0 6px; font-size: 22px; flex-wrap: wrap; }
.exam-breakdown span { background: var(--bg); border-radius: 999px; padding: 6px 16px; }
.exam-breakdown span.weak { background: #fee2e2; color: var(--battle); font-weight: 700; }
.exam-tip { font-size: 20px; color: var(--text); margin: 8px 0; min-height: 1.4em; }
.exam-history { font-size: 18px; color: var(--muted); margin: 6px 0 12px; }
.exam-history b { color: var(--text); }
.exam-board { background: var(--bg); border-radius: 16px; padding: 10px 16px; text-align: left; }
.exam-board-title { font-size: 15px; color: var(--muted); margin-bottom: 4px; }
.exam-board ol { margin: 0; padding-left: 24px; font-size: 18px; columns: 2; }
.exam-board li { padding: 2px 0; }
.exam-board li.me { font-weight: 800; color: var(--exam); }
@media (max-width: 560px) {
  .actions { grid-template-columns: 1fr 1fr; }
  .actions .big-btn.battle { grid-column: 1 / -1; }
  .exam-stage { grid-template-columns: 1fr; }
  .exam-board ol { columns: 1; }
}
