/* ════════════════════════════════════════════════════════════════
   认知镜像 demo · 全局样式
   主题:暗色 + 暖橙点缀,横屏 iPad / 大屏优先
════════════════════════════════════════════════════════════════ */

:root {
  /* Light palette inspired by vitalsense-sdk demo.html — 米白 + 砖橙 */
  --bg-deep:    #f5f0e8;       /* page bg */
  --bg-card:    #ffffff;       /* main surface */
  --bg-soft:    #f7f3ec;       /* subtle inner panels */
  --bg-elev:    #efe9df;       /* deeper inner */
  --line:       rgba(0,0,0,0.10);
  --line-soft:  rgba(0,0,0,0.06);
  --text:       #1a1a1a;       /* primary */
  --text-soft:  #6b6b6b;       /* secondary */
  --text-mute:  #9a9a9a;       /* tertiary */
  --accent:     #c96442;       /* brick orange (matches demo.html) */
  --accent-2:   #e08260;       /* lighter accent */
  --good:       #4a9d6d;
  --warn:       #c9964a;
  --bad:        #c0524a;
  --info:       #5a8fa8;
  --purple:     #8b7bb5;
  --shadow-sm:  0 1px 2px rgba(0,0,0,0.05);
  --shadow-md:  0 2px 8px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg:  0 4px 16px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.04);
  --radius:     12px;
  --radius-sm:  8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  height: 100%;
  background: var(--bg-deep);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}

input, button { font-family: inherit; }

/* ── Stage system ── */
.stage {
  position: fixed; inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
  overflow: hidden;
}
.stage.stage-active {
  opacity: 1;
  pointer-events: auto;
  z-index: 1;
}

/* ════════════════════════════════════════════════════════════════
   1) Login stage
════════════════════════════════════════════════════════════════ */
.login-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 1100px 700px at 25% 20%, rgba(201,100,66,0.10), transparent 60%),
    radial-gradient(ellipse 900px 600px at 80% 80%, rgba(139,123,181,0.08), transparent 60%),
    var(--bg-deep);
  animation: bgFloat 18s ease-in-out infinite alternate;
}
@keyframes bgFloat {
  0%   { background-position: 0% 0%, 100% 100%, 0 0; }
  100% { background-position: 5% 5%, 95% 95%, 0 0; }
}
#stage-login { display: flex; align-items: center; justify-content: center; }
.login-card {
  position: relative; z-index: 2;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 36px 44px 28px;
  width: 520px; max-width: calc(100vw - 32px);
  box-shadow: var(--shadow-lg);
}
.login-brand { text-align: center; margin-bottom: 28px; }
.brand-glyph {
  display: inline-block;
  font-size: 42px;
  color: var(--accent);
  text-shadow: 0 0 30px rgba(255,122,69,0.6);
  margin-bottom: 8px;
}
.brand-title {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 6px;
}
.brand-sub {
  font-size: 12px; color: var(--text-soft);
  letter-spacing: 1px;
}
.login-form { display: flex; flex-direction: column; gap: 14px; }
.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row label {
  font-size: 11px; color: var(--text-mute);
  letter-spacing: 0.5px; text-transform: uppercase;
}
.form-row input {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  color: var(--text); font-size: 14px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.form-row input:focus {
  border-color: var(--accent);
  background: var(--bg-elev);
}
.form-error {
  min-height: 18px; font-size: 12px; color: var(--bad);
}
.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(135deg, var(--accent) 0%, #ff9966 100%);
  color: #fff; border: none;
  padding: 13px 24px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(255,122,69,0.28);
  transition: transform 0.08s, box-shadow 0.15s, opacity 0.15s;
  letter-spacing: 0.5px;
}
.btn-primary:hover { box-shadow: 0 6px 20px rgba(255,122,69,0.38); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.btn-secondary {
  background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--line);
  padding: 11px 22px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-secondary:hover { background: var(--bg-elev); border-color: var(--accent); }
.btn-secondary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-arrow { font-size: 16px; }
.login-footer {
  margin-top: 18px;
  font-size: 11px; color: var(--text-mute); text-align: center;
  letter-spacing: 0.3px;
  line-height: 1.6;
}

/* ── Face login ── */
.face-login-wrap {
  display: flex; flex-direction: column; gap: 16px;
}
.face-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--bg-elev);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
}
.face-frame video {
  width: 100%; height: 100%;
  object-fit: cover;
  transform: scaleX(-1);  /* mirror — feels natural */
  display: block;
}
.face-overlay {
  position: absolute; inset: 0;
  pointer-events: none;
  display: flex; align-items: center; justify-content: center;
}
.face-guide-circle {
  width: 60%; aspect-ratio: 3 / 4;
  border: 2px dashed rgba(201,100,66,0.55);
  border-radius: 50%;
  box-shadow: 0 0 0 9999px rgba(245,240,232,0.20);
}
.face-hint {
  position: absolute; bottom: 10px; left: 0; right: 0;
  text-align: center;
  font-size: 12px; color: var(--text-soft);
  background: rgba(255,255,255,0.7);
  padding: 4px 0;
  letter-spacing: 0.5px;
}
.face-frame.live .face-hint { background: rgba(255,255,255,0.5); }
.face-frame.busy .face-hint { color: var(--accent); font-weight: 600; }
.face-actions {
  display: flex; gap: 10px;
}
.face-actions .btn-secondary { flex: 0 0 auto; }
.face-actions .btn-primary { flex: 1; }

/* ════════════════════════════════════════════════════════════════
   2) Game stage (left grid + right vitals)
════════════════════════════════════════════════════════════════ */
.game-shell {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  background: var(--bg-deep);
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}
/* Game-inner top bar: 内嵌在 game-left 顶部(prototype 风:title-area + stage-panel + scoreboard 横排) */
.game-topbar-inner {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 14px;
  gap: 16px;
}
.game-topbar-inner .title-area { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.game-topbar-inner .title-area h1 {
  font-size: 20px; font-weight: 800; letter-spacing: 0.5px;
  color: var(--text); line-height: 1.1;
}
.game-topbar-inner .title-area .hint {
  font-size: 11px; color: var(--text-mute); letter-spacing: 0.3px;
}
.game-topbar-inner .title-area .user-name {
  font-size: 11px; color: var(--text-mute); margin-top: 2px;
}
/* Stage panel inside game */
.game-topbar-inner .stage-panel {
  display: flex; flex-direction: column; gap: 3px;
  min-width: 84px; align-items: flex-start;
}
.game-topbar-inner .stage-panel .label {
  font-size: 10px; font-weight: 600;
  color: var(--text-mute); letter-spacing: 1.2px;
  text-transform: uppercase;
}
.game-topbar-inner .stage-panel .stage-val {
  font-size: 32px; font-weight: 800;
  color: var(--info); line-height: 1;
}
.game-topbar-inner .stage-progress-track {
  width: 100%; height: 4px;
  background: rgba(0,0,0,0.08); border-radius: 2px; overflow: hidden;
}
.game-topbar-inner .stage-progress-track > div {
  height: 100%; background: var(--info);
  border-radius: 2px; width: 0%;
  transition: width 0.2s ease-out, background 0.3s;
}
/* Scoreboard inside game (white card, red big number, prototype-faithful) */
.game-topbar-inner .scoreboard {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 6px 18px 8px;
  text-align: center;
  box-shadow: 0 2px 0 #d8d2c8;
  min-width: 88px;
  transition: box-shadow 0.3s;
}
.game-topbar-inner .scoreboard.glow-4 { box-shadow: 0 2px 0 #d8d2c8, 0 0 16px rgba(201,100,66,0.35); }
.game-topbar-inner .scoreboard.glow-5 { box-shadow: 0 2px 0 #d8d2c8, 0 0 22px rgba(192,82,74,0.45); }
.game-topbar-inner .scoreboard .label {
  font-size: 10px; font-weight: 600;
  color: var(--text-mute); letter-spacing: 1.2px;
  text-transform: uppercase;
}
.game-topbar-inner .scoreboard .score-val {
  font-size: 30px; font-weight: 800;
  color: var(--bad); line-height: 1.05;
  transition: transform 0.08s;
}
.game-topbar-inner .scoreboard .score-val.bump { transform: scale(1.32); }
.game-topbar-inner .scoreboard .lv {
  font-size: 10px; color: var(--text-mute);
  font-weight: 600; margin-top: 1px;
}

.game-main {
  flex: 1; min-height: 0;
  display: flex; gap: 16px;
  padding: 0 20px 20px;
  align-items: stretch;          /* equal-height columns */
}
.game-left {
  flex: 0 0 58%;
  display: flex; flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 22px;
  box-shadow: var(--shadow-md);
  min-height: 0;
}
.game-right {
  flex: 1;
  display: flex; flex-direction: column;
  min-height: 0;
}
/* ── data-col (照搬 vitalcamera-sdk 0.6.6 demo.html) ── */
#data-col {
  flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0;
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 12px;
  overflow-y: auto;
}
#stats-group {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; flex-shrink: 0;
}
.stat-item {
  background: #f7f3ec; border-radius: var(--radius-sm); padding: 10px 12px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.03);
}
.stat-label {
  font-size: 11px; color: var(--text-mute); text-transform: uppercase;
  letter-spacing: 0.5px; display: block; margin-bottom: 4px;
}
.stat-val {
  font-size: 20px; font-weight: 500; font-variant-numeric: tabular-nums; line-height: 1;
}
.stat-val.active { color: var(--accent); }

/* Gaze + Head row */
#gaze-head-row { display: flex; gap: 8px; }
#gaze-panel, #face-normal-panel {
  background: #f2eee6; border-radius: var(--radius-sm); padding: 10px;
  display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.03);
}
.viz-circle {
  width: 48px; height: 48px; background: var(--bg-card);
  border: 1px solid var(--line); position: relative; flex-shrink: 0; border-radius: 50%;
}
.viz-crosshair-h, .viz-crosshair-v { position: absolute; background: rgba(0,0,0,0.08); }
.viz-crosshair-h { width: 100%; height: 0.5px; top: 50%; }
.viz-crosshair-v { height: 100%; width: 0.5px; left: 50%; }
#gazePointer {
  position: absolute; width: 8px; height: 8px; background: var(--accent);
  border-radius: 50%; transform: translate(-50%, -50%); left: 50%; top: 50%;
  transition: left 0.15s ease, top 0.15s ease;
}
#headArrow { position: absolute; width: 100%; height: 100%; top: 0; left: 0; transition: transform 0.15s ease; }
#headArrow line { stroke: var(--accent); stroke-width: 2; stroke-linecap: round; }
#headArrow polygon { fill: var(--accent); }
.panel-info { display: flex; flex-direction: column; gap: 2px; font-size: 12px; flex: 1; min-width: 0; }
.panel-title {
  font-size: 11px; font-weight: 500; color: var(--text-mute);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.gaze-row { display: flex; justify-content: space-between; }
.gaze-label { color: var(--text-mute); font-size: 12px; }
.gaze-val { font-weight: 500; font-size: 13px; font-variant-numeric: tabular-nums; }

/* Eye + Mouth row */
#eye-mouth-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#eye-state-panel, #mouth-panel {
  background: #f2eee6; border-radius: var(--radius-sm); padding: 8px 10px;
  display: flex; align-items: center; gap: 12px; min-width: 0;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.03);
}
.eye-side { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.eye-pill {
  width: 36px; height: 22px; border-radius: 11px; flex-shrink: 0;
  background: var(--bg-card); border: 1px solid var(--line);
  position: relative; overflow: hidden;
}
.eye-pill::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 14px; height: 14px; border-radius: 50%;
  transform: translate(-50%, -50%);
  background: #c9c0b3; transition: background 0.2s, height 0.2s;
}
.eye-pill.open::after  { background: var(--accent); height: 14px; }
.eye-pill.closed::after { background: #6b6b6b; height: 2px; border-radius: 1px; }
.eye-side-label { font-size: 11px; color: var(--text-mute); width: 14px; }
.eye-side-prob {
  font-size: 12px; font-variant-numeric: tabular-nums;
  color: var(--text-soft); width: 32px;
}
.eye-state-title {
  font-size: 11px; font-weight: 500; color: var(--text-mute);
  text-transform: uppercase; letter-spacing: 0.5px; flex-shrink: 0;
}
.mouth-bar-wrap { flex: 1; display: flex; align-items: center; gap: 6px; min-width: 0; }
.mouth-bar-track {
  flex: 1; height: 8px; border-radius: 4px;
  background: rgba(0,0,0,0.06); overflow: hidden;
}
.mouth-bar-fill { height: 100%; background: var(--accent); transition: width 0.12s; }
.mouth-prob {
  font-size: 12px; font-variant-numeric: tabular-nums;
  color: var(--text-soft); width: 36px; text-align: right;
}
.speak-pill {
  font-size: 10px; padding: 2px 8px; border-radius: 999px; font-weight: 500;
  background: rgba(0,0,0,0.06); color: var(--text-soft);
  flex-shrink: 0; transition: background 0.2s, color 0.2s;
  width: 64px; text-align: center;
}
.speak-pill.on { background: rgba(74,157,109,0.18); color: var(--good); }

/* Emotion panel: vertical bars (8 cols), fill height = prob */
#emotion-panel {
  background: linear-gradient(180deg, #f5f1ea 0%, #f0ebe3 100%);
  border-radius: var(--radius-sm); padding: 8px 10px;
  display: flex; flex-direction: column; gap: 4px; flex-shrink: 0;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.03);
}
#emotion-top {
  display: flex; align-items: center; gap: 8px; padding: 2px 0 6px;
}
#emotionEmoji { font-size: 24px; line-height: 1; }
#emotionLabel { font-weight: 500; font-size: 15px; flex: 1; }
#emotionConf { font-size: 13px; color: var(--text-soft); }
#emotionTime { font-size: 12px; color: var(--text-mute); }
#emo-cols {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px;
  height: 70px;
}
.emo-col {
  display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0;
}
.emo-col-track {
  width: 100%; flex: 1;
  background: rgba(0,0,0,0.05); border-radius: 4px;
  position: relative; overflow: hidden;
}
.emo-col-fill {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 0%; border-radius: 4px;
  transition: height 0.18s ease;
}
.emo-col-name {
  font-size: 10px; color: var(--text-mute);
  letter-spacing: 0.3px;
}

/* BVP wave */
#wave-frame {
  height: 90px; background: #eee9e0; border-radius: var(--radius-sm);
  position: relative; overflow: hidden; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
}
#wave-frame canvas {
  width: 100%; height: 100%; display: block; background: #eee9e0;
}
.vitals-loading {
  flex: 1; display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--text-mute);
}

/* combo row */
.combo-row {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 14px;
}
.combo-label {
  font-size: 11px; color: var(--text-mute);
  font-weight: 700; letter-spacing: 1.5px;
  width: 56px;
}
.combo-dots { display: flex; gap: 6px; }
.combo-dot {
  display: block;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--bg-elev);
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
}
.combo-dot.active.lv1 { background: var(--good); }
.combo-dot.active.lv2 { background: var(--info); }
.combo-dot.active.lv3 { background: var(--warn); box-shadow: 0 0 6px rgba(201,150,74,0.5); }
.combo-dot.active.lv4 { background: var(--accent); box-shadow: 0 0 8px rgba(201,100,66,0.55); transform: scale(1.15); }
.combo-dot.active.lv5 {
  background: var(--bad); box-shadow: 0 0 12px rgba(192,82,74,0.7);
  transform: scale(1.25); animation: dotPulse 0.6s ease-in-out infinite;
}
@keyframes dotPulse {
  0%,100% { box-shadow: 0 0 8px rgba(192,82,74,0.5); }
  50%     { box-shadow: 0 0 16px rgba(192,82,74,0.85); }
}
.timer-track {
  flex: 1; height: 6px;
  background: var(--bg-elev);
  border-radius: 3px;
  overflow: hidden;
}
.timer-bar {
  height: 100%; width: 100%;
  background: var(--good);
  border-radius: 3px;
  transition: background 0.3s;
}
.hint-badge {
  font-size: 18px;
  opacity: 0;
  transition: opacity 0.3s;
}
.hint-badge.visible { opacity: 1; }

/* grid — square cells via aspect-ratio:1 on each cell, container width-driven */
.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  align-self: center;
  width: 100%;
  max-width: 560px;
  margin: 8px auto;
}
.cell {
  border-radius: 10px;
  background: var(--bg-elev);
  box-shadow: 0 2px 0 rgba(0,0,0,0.10), inset 0 1px 0 rgba(255,255,255,0.5);
  cursor: default;
  position: relative;
  aspect-ratio: 1;        /* enforce square */
  transition: background 0.15s, box-shadow 0.15s, transform 0.08s;
}
.cell.lit {
  background: linear-gradient(135deg, #e08260 0%, #c96442 100%);
  box-shadow: 0 3px 0 #8a3a20, 0 0 16px rgba(201,100,66,0.30);
  cursor: pointer;
}
.cell.lit:active { transform: translateY(2px); box-shadow: 0 1px 0 #8a3a20, 0 0 10px rgba(201,100,66,0.20); }
.cell.correct-flash {
  background: linear-gradient(135deg, #79c896 0%, #4a9d6d 100%) !important;
  box-shadow: 0 3px 0 #2e6b48, 0 0 14px rgba(74,157,109,0.30) !important;
}
.cell.wrong-flash {
  background: linear-gradient(135deg, #d97a72 0%, #c0524a 100%) !important;
  box-shadow: 0 3px 0 #882f28, 0 0 14px rgba(192,82,74,0.35) !important;
}
.cell.hint-flash {
  background: linear-gradient(135deg, #e8c270 0%, #c9964a 100%) !important;
  box-shadow: 0 3px 0 #8a6720 !important;
}
.hint-num {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(24px, 5vw, 40px); font-weight: 800; color: #fff;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.score-popup {
  position: fixed; pointer-events: none; z-index: 300;
  font-weight: 800; transform: translateX(-50%);
  white-space: nowrap;
}
.game-hint {
  margin-top: 10px;
  font-size: 11px; color: var(--text-mute);
  text-align: center; letter-spacing: 0.5px;
}

/* end overlay */
.overlay {
  position: absolute; inset: 0;
  display: none; align-items: center; justify-content: center;
  background: rgba(245, 240, 232, 0.88);
  backdrop-filter: blur(8px);
  z-index: 50;
  padding: 24px;
}
.overlay.show { display: flex; }
.overlay-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 36px 44px;
  width: 480px; max-width: 100%;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

/* Big result card — game ends → directly show this (no draw button bridging) */
.overlay-bigcard {
  background: var(--bg-card);
  border: 2px solid var(--accent);
  border-radius: 18px;
  width: 600px; max-width: calc(100% - 32px);
  box-shadow: var(--shadow-lg), 0 0 60px rgba(201,100,66,0.18);
  overflow: hidden;
  animation: cardRise 0.5s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}
@keyframes cardRise {
  0%   { transform: translateY(40px) scale(0.92); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}
.bigcard-header {
  text-align: center;
  padding: 18px 24px 8px;
}
.bigcard-eyebrow {
  font-size: 11px; color: var(--text-mute);
  letter-spacing: 3px; text-transform: uppercase;
  margin-bottom: 6px;
}
.bigcard-title {
  font-size: 13px; color: var(--text-soft);
  letter-spacing: 0.5px;
}
.bigcard-summary {
  display: flex; justify-content: space-around;
  background: var(--bg-soft);
  padding: 14px 28px;
  margin: 0 24px 20px;
  border-radius: var(--radius-sm);
}
.bigcard-summary .item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.bigcard-summary .label {
  font-size: 10px; color: var(--text-mute);
  letter-spacing: 1px; text-transform: uppercase;
}
.bigcard-summary .val {
  font-size: 26px; font-weight: 800; line-height: 1;
}
.bigcard-summary .val.score-c { color: var(--bad); }
.bigcard-summary .val.mem-c   { color: var(--info); }
.bigcard-summary .divider {
  width: 1px; background: var(--line); align-self: stretch;
}
.bigcard-portrait {
  width: 100%;
  height: 220px;
  object-fit: cover;
  background: var(--bg-elev);
  display: block;
}
.bigcard-meta {
  padding: 18px 28px 12px;
  text-align: center;
}
.bigcard-tag {
  font-size: 10px; color: var(--text-mute);
  letter-spacing: 1.5px; text-transform: uppercase;
  margin-bottom: 6px;
}
.bigcard-name {
  font-size: 26px; font-weight: 800;
  color: var(--text); line-height: 1.1;
  margin-bottom: 4px;
}
.bigcard-cat {
  font-size: 11px; color: var(--accent);
  letter-spacing: 0.3px;
  margin-bottom: 12px;
}
.bigcard-desc {
  font-size: 13px; color: var(--text-soft);
  line-height: 1.7;
  text-align: left;
  padding: 0 8px;
  margin-bottom: 10px;
}
.bigcard-motto {
  font-size: 12px; color: var(--text-mute);
  font-style: italic;
  text-align: center;
}
.bigcard-dims {
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 12px 24px;
  margin: 0 24px 16px;
}
.bigcard-dims .dim-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 8px;
}
.bigcard-dims .dim-row:last-child { margin-bottom: 0; }
.bigcard-dims .dim-label {
  font-size: 11px; font-weight: 600;
  color: var(--text-soft); width: 56px; flex-shrink: 0;
}
.bigcard-dims .dim-bar {
  flex: 1; height: 8px;
  background: var(--bg-elev); border-radius: 4px; overflow: hidden;
}
.bigcard-dims .dim-fill {
  height: 100%; border-radius: 4px;
  width: 0%;
  transition: width 0.7s ease-out;
}
.bigcard-dims .dim-num {
  font-size: 12px; font-weight: 700;
  color: var(--text); width: 30px; text-align: right;
}
.bigcard-footer-text {
  font-size: 11px; color: var(--text-mute);
  line-height: 1.7; text-align: left;
  padding: 0 28px 16px;
}
.bigcard-actions {
  display: flex; justify-content: center; gap: 12px;
  padding: 0 28px 24px;
}
.overlay-title {
  font-size: 14px; font-weight: 700;
  color: var(--text-mute); letter-spacing: 3px;
  text-transform: uppercase; margin-bottom: 22px;
}
.result-summary {
  display: flex; justify-content: space-around;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 18px 24px;
  margin-bottom: 20px;
}
.result-item { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.result-label {
  font-size: 10px; color: var(--text-mute);
  letter-spacing: 1px; text-transform: uppercase;
}
.result-val { font-size: 36px; font-weight: 800; line-height: 1; }
.result-val.score-color { color: var(--accent); }
.result-val.mem-color { color: var(--info); }
.result-divider { width: 1px; background: var(--line); align-self: stretch; }

.dim-scores {
  background: var(--bg-soft); border-radius: var(--radius-sm);
  padding: 14px 18px; margin-bottom: 20px;
}
.dim-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px;
}
.dim-row:last-child { margin-bottom: 0; }
.dim-label {
  font-size: 11px; font-weight: 600; color: var(--text-soft);
  width: 56px; flex-shrink: 0;
}
.dim-bar-track {
  flex: 1; height: 8px;
  background: var(--bg-elev); border-radius: 4px; overflow: hidden;
}
.dim-bar-fill {
  height: 100%; border-radius: 4px;
  width: 0%;
  transition: width 0.7s ease-out;
}
.dim-score-num {
  font-size: 12px; font-weight: 700;
  color: var(--text); width: 32px; text-align: right;
}

/* ════════════════════════════════════════════════════════════════
   3) Vitals panel (right of game)
════════════════════════════════════════════════════════════════ */
.vitals-panel { display: flex; flex-direction: column; gap: 10px; }
.v-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.v-stat {
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.v-stat-label {
  display: block; font-size: 10px; color: var(--text-mute);
  letter-spacing: 0.5px; text-transform: uppercase;
  margin-bottom: 4px;
}
.v-stat-val {
  display: block; font-size: 20px; font-weight: 600;
  color: var(--text); line-height: 1;
  font-variant-numeric: tabular-nums;
}
.v-stat-val.active { color: var(--accent); }

.v-section {
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.v-section-title {
  font-size: 10px; color: var(--text-mute);
  letter-spacing: 0.6px; text-transform: uppercase;
  margin-bottom: 6px;
}

.v-emotion-top {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px;
}
.v-emotion-emoji { font-size: 24px; }
.v-emotion-label { font-size: 14px; font-weight: 600; flex: 1; }
.v-emotion-conf { font-size: 12px; color: var(--text-soft); }
.v-bar-row {
  display: flex; align-items: center; gap: 8px;
  padding: 2px 0;
}
.v-bar-name {
  width: 68px; font-size: 11px; color: var(--text-soft);
  text-align: right;
}
.v-bar-track {
  flex: 1; height: 5px;
  background: var(--bg-elev); border-radius: 3px; overflow: hidden;
}
.v-bar-fill {
  height: 100%; width: 0%; border-radius: 3px;
  transition: width 0.3s ease;
}
.v-bar-pct {
  width: 30px; font-size: 11px; color: var(--text-mute);
  text-align: right; font-variant-numeric: tabular-nums;
}

.v-gaze-head { display: flex; gap: 8px; }
.v-gh-card {
  flex: 1; background: var(--bg-soft);
  border-radius: var(--radius-sm); padding: 10px;
  display: flex; align-items: center; gap: 10px;
}
.v-gh-circle {
  width: 50px; height: 50px;
  background: var(--bg-elev);
  border-radius: 50%; position: relative;
  flex-shrink: 0; border: 1px solid var(--line);
}
.v-gh-circle::before, .v-gh-circle::after {
  content: ''; position: absolute;
  background: rgba(255,255,255,0.1);
}
.v-gh-circle::before { width: 100%; height: 1px; top: 50%; }
.v-gh-circle::after { height: 100%; width: 1px; left: 50%; }
#gazePointer {
  position: absolute; width: 8px; height: 8px;
  background: var(--accent); border-radius: 50%;
  transform: translate(-50%, -50%); left: 50%; top: 50%;
  transition: left 0.2s ease, top 0.2s ease;
}
#headArrow { position: absolute; inset: 0; }
#headArrow line { stroke: var(--accent); stroke-width: 2; stroke-linecap: round; }
#headArrow polygon { fill: var(--accent); }
.v-gh-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.v-gh-label {
  font-size: 10px; color: var(--text-mute);
  letter-spacing: 0.5px; text-transform: uppercase;
}
.v-gh-row {
  display: flex; justify-content: space-between;
  font-size: 11px;
}
.v-gh-row span:first-child { color: var(--text-mute); }
.v-gh-row span:last-child { color: var(--text); font-variant-numeric: tabular-nums; }

.v-wave-frame {
  height: 70px; background: var(--bg-elev);
  border-radius: var(--radius-sm);
  position: relative; overflow: hidden;
}
.v-wave-frame canvas {
  width: 100%; height: 100%; display: block;
}

/* ── Eye + Mouth row (vitalcamera-sdk 0.6.6) ── */
.v-eye-mouth-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.v-eye-panel, .v-mouth-panel {
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.03);
  min-width: 0;
}
.v-em-title {
  font-size: 10px; font-weight: 500; color: var(--text-mute);
  text-transform: uppercase; letter-spacing: 0.5px;
  flex-shrink: 0;
}
.v-eye-side {
  display: flex; align-items: center; gap: 6px;
  flex: 1; min-width: 0;
}
.v-eye-side-label {
  font-size: 11px; color: var(--text-mute); width: 14px;
}
.v-eye-pill {
  width: 32px; height: 20px; border-radius: 10px;
  background: var(--bg-card); border: 1px solid var(--line);
  position: relative; overflow: hidden; flex-shrink: 0;
}
.v-eye-pill::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 12px; height: 12px; border-radius: 50%;
  transform: translate(-50%, -50%);
  background: #c9c0b3;
  transition: background 0.2s, height 0.2s;
}
.v-eye-pill.open::after  { background: var(--accent); height: 12px; }
.v-eye-pill.closed::after { background: #6b6b6b; height: 2px; border-radius: 1px; }
.v-eye-side-prob {
  font-size: 11px; color: var(--text-soft);
  width: 30px; font-variant-numeric: tabular-nums;
}

.v-mouth-bar-wrap {
  flex: 1; display: flex; align-items: center; gap: 6px; min-width: 0;
}
.v-mouth-bar-track {
  flex: 1; height: 8px; border-radius: 4px;
  background: rgba(0,0,0,0.06); overflow: hidden;
}
.v-mouth-bar-fill {
  height: 100%; background: var(--accent);
  transition: width 0.12s;
  width: 0%;
}
.v-mouth-prob {
  font-size: 11px; color: var(--text-soft);
  width: 32px; text-align: right;
  font-variant-numeric: tabular-nums;
}
.v-speak-pill {
  font-size: 10px; padding: 2px 8px; border-radius: 999px;
  font-weight: 500;
  background: rgba(0,0,0,0.06); color: var(--text-soft);
  flex-shrink: 0; width: 60px; text-align: center;
  transition: background 0.2s, color 0.2s;
}
.v-speak-pill.on {
  background: rgba(74,157,109,0.18);
  color: var(--good);
}

/* ════════════════════════════════════════════════════════════════
   4) Draw card stage
════════════════════════════════════════════════════════════════ */
.draw-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 1300px 900px at 50% 50%, rgba(201,100,66,0.10), transparent 70%),
    var(--bg-deep);
}
.draw-shell {
  position: relative; z-index: 1;
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
}
.draw-stage {
  display: flex; flex-direction: column; align-items: center;
  gap: 32px; padding: 0 32px;
}
.draw-deck {
  perspective: 1200px;
  width: 320px; height: 460px;
}
.draw-card {
  position: relative;
  width: 100%; height: 100%;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 1.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.draw-card.flipped { transform: rotateY(180deg); }
.card-back, .card-front {
  position: absolute; inset: 0;
  border-radius: 18px;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  overflow: hidden;
  box-shadow: var(--shadow-lg), 0 0 40px rgba(139,123,255,0.25);
}
.card-back {
  background:
    repeating-linear-gradient(45deg,
      rgba(0,0,0,0.04) 0 12px,
      transparent 12px 24px),
    linear-gradient(135deg, #f5e6d8 0%, #e8d4be 100%);
  border: 2px solid var(--accent);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px;
}
.card-back-glyph {
  font-size: 80px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 20px rgba(255,122,69,0.6));
}
.card-back-text {
  font-size: 14px; font-weight: 700;
  letter-spacing: 4px;
  color: var(--accent);
}
.card-front {
  transform: rotateY(180deg);
  background: var(--bg-card);
  border: 2px solid var(--accent);
  display: flex; flex-direction: column;
}
#card-portrait {
  width: 100%; height: 220px; object-fit: cover;
  background: var(--bg-elev);
}
.card-meta {
  flex: 1; padding: 16px 20px;
  display: flex; flex-direction: column; gap: 6px;
}
.card-tag {
  font-size: 10px; color: var(--text-mute);
  letter-spacing: 1px;
}
.card-name {
  font-size: 22px; font-weight: 800;
  color: var(--text);
}
.card-cat {
  font-size: 10px; color: var(--accent-2);
}
.card-desc {
  font-size: 11.5px; color: var(--text-soft);
  line-height: 1.65;
  margin-top: 4px;
}
.card-motto {
  font-size: 11px; color: var(--text-mute);
  font-style: italic;
  margin-top: auto;
}
.draw-controls { display: flex; gap: 12px; align-items: center; }

/* ════════════════════════════════════════════════════════════════
   5) Chat stage
════════════════════════════════════════════════════════════════ */
.chat-shell {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  background: var(--bg-deep);
}
.chat-topbar {
  flex-shrink: 0; height: 52px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}
.chat-status {
  font-size: 12px; padding: 4px 10px;
  border-radius: 12px;
  background: var(--bg-soft);
  color: var(--text-soft);
}
.chat-status.connected { background: rgba(74,157,109,0.15); color: var(--good); }
.chat-status.error { background: rgba(192,82,74,0.15); color: var(--bad); }
.chat-main {
  flex: 1; min-height: 0;
  display: flex; gap: 16px;
  padding: 16px 20px;
}
.chat-left {
  flex: 0 0 58%;
  display: flex; flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.chat-right {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-md);
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.chat-log {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 20px 24px;
  display: flex; flex-direction: column; gap: 12px;
}
.msg {
  max-width: 75%;
  padding: 10px 16px;
  border-radius: 14px;
  font-size: 14px; line-height: 1.55;
  word-wrap: break-word;
}
.msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.msg.agent {
  align-self: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--line);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.msg.sys {
  align-self: center;
  background: transparent;
  color: var(--text-mute);
  font-size: 11px;
  letter-spacing: 0.5px;
}
.chat-footer {
  flex-shrink: 0;
  padding: 14px 20px;
  background: var(--bg-card);
  border-top: 1px solid var(--line);
  display: flex; gap: 10px; align-items: center;
}
.chat-footer input {
  flex: 1;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
}
.chat-footer input:focus { border-color: var(--accent); }

/* ════════════════════════════════════════════════════════════════
   6) Report stage
════════════════════════════════════════════════════════════════ */
.report-shell {
  position: absolute; inset: 0;
  overflow-y: auto;
  padding: 24px;
  background: var(--bg-deep);
}
.report-loading {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px;
}
.spinner {
  width: 42px; height: 42px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.report-loading-text { font-size: 13px; color: var(--text-soft); }

.report-card {
  max-width: 880px; margin: 24px auto;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px 40px;
  box-shadow: var(--shadow-lg);
}
.report-h1 {
  font-size: 24px; font-weight: 800;
  color: var(--text); margin-bottom: 6px;
}
.report-sub {
  font-size: 12px; color: var(--text-mute);
  letter-spacing: 0.5px;
  margin-bottom: 24px;
}
.report-section { margin-bottom: 24px; }
.report-section h3 {
  font-size: 13px; color: var(--accent-2);
  letter-spacing: 1.5px; text-transform: uppercase;
  margin-bottom: 10px;
  border-left: 3px solid var(--accent);
  padding-left: 10px;
}
.report-section p {
  font-size: 13.5px; color: var(--text-soft);
  line-height: 1.75;
}
.report-actions {
  display: flex; gap: 12px;
  margin-top: 24px;
  justify-content: center;
}

/* ════════════════════════════════════════════════════════════════
   Rotation prompt
════════════════════════════════════════════════════════════════ */
.rotate-prompt {
  position: fixed; inset: 0;
  display: none; flex-direction: column; align-items: center; justify-content: center;
  background: var(--bg-deep);
  z-index: 9999;
  gap: 20px;
}
.rotate-icon {
  font-size: 60px; color: var(--accent);
  animation: rotateBob 1.6s ease-in-out infinite;
}
@keyframes rotateBob {
  0%,100% { transform: rotate(0deg); }
  50%     { transform: rotate(90deg); }
}
.rotate-text {
  font-size: 14px; color: var(--text-soft);
  letter-spacing: 0.5px;
}

/* Show rotation prompt only when:
   - portrait orientation AND
   - viewport is mobile-ish (height > width) */
@media (orientation: portrait) and (max-aspect-ratio: 4/3) {
  .rotate-prompt { display: flex; }
}
