:root {
  --bg: #050816;
  --panel-bg: rgba(15, 23, 42, 0.75);
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.35);
  --accent-strong: #22d3ee;
  --accent-purple: #818cf8;
  --text-main: #e5e7eb;
  --text-muted: #9ca3af;
  --danger: #f97373;
  --ok: #4ade80;
  --border-subtle: rgba(148, 163, 184, 0.2);
  --gradient-primary: linear-gradient(135deg, #38bdf8, #818cf8);
  --gradient-warm: linear-gradient(135deg, #f97316, #ec4899);
  --gradient-success: linear-gradient(135deg, #4ade80, #22d3ee);
  --surface-1: rgba(15, 23, 42, 0.5);
  --surface-2: rgba(15, 23, 42, 0.85);
  --surface-3: rgba(30, 41, 59, 0.6);
  --glow-primary: 0 0 20px rgba(56, 189, 248, 0.12);
  --glow-strong: 0 0 40px rgba(56, 189, 248, 0.2);
  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

.en-sub {
  font-size: 0.72em;
  opacity: 0.55;
  font-weight: 400;
  margin-left: 4px;
}

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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'SF Pro Text',
    'Segoe UI', sans-serif;
  background: radial-gradient(circle at top, #0f172a 0, #020617 45%, #000 100%);
  color: var(--text-main);
}

body {
  display: flex;
  align-items: stretch;
  justify-content: center;
}

#app {
  width: 100%;
  max-width: 1280px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.glass {
  background: var(--panel-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  box-shadow:
    0 22px 40px rgba(2, 6, 23, 0.7),
    0 0 0 1px rgba(15, 23, 42, 0.8),
    0 0 60px rgba(56, 189, 248, 0.06);
  backdrop-filter: blur(28px) saturate(160%);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.glass:hover {
  box-shadow:
    0 22px 40px rgba(2, 6, 23, 0.7),
    0 0 0 1px rgba(56, 189, 248, 0.15),
    0 0 60px rgba(56, 189, 248, 0.1);
}

.app-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 22px;
  position: relative;
}

.app-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 20px;
  right: 20px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(56, 189, 248, 0.3), rgba(129, 140, 248, 0.3), transparent);
}

.header-memoir-btn {
  padding: 8px 18px;
  font-size: 12px;
  color: #fff;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.8), rgba(99, 102, 241, 0.8));
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: var(--radius-sm);
  cursor: pointer;
  letter-spacing: 0.05em;
  font-weight: 600;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.header-memoir-btn::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
  animation: header-btn-shimmer 3.5s ease-in-out infinite;
}

@keyframes header-btn-shimmer {
  0%, 75% { left: -100%; }
  100% { left: 150%; }
}

.header-memoir-btn:hover {
  background: linear-gradient(135deg, rgba(56, 189, 248, 1), rgba(99, 102, 241, 1));
  box-shadow: 0 0 22px rgba(56, 189, 248, 0.35);
  transform: translateY(-1px);
}

.header-device-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.device-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
  color: #fff;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.7), rgba(168, 85, 247, 0.7));
  border: 1px solid rgba(129, 140, 248, 0.4);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.25s ease;
}

.device-btn:hover {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.9), rgba(168, 85, 247, 0.9));
  box-shadow: 0 0 20px rgba(129, 140, 248, 0.35);
  transform: translateY(-1px);
}

.device-feature-btn {
  padding: 6px 12px;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface-1);
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.device-feature-btn:hover:not(:disabled) {
  color: var(--accent-strong);
  border-color: var(--accent-strong);
}

.device-feature-btn:disabled {
  opacity: 0.8;
  cursor: default;
}

.mic-level-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.mic-level-label {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.mic-level-bar {
  flex: 1;
  height: 6px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.mic-level-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  border-radius: 999px;
  transition: width 0.1s ease;
}

.logo-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: 1px solid rgba(56, 189, 248, 0.4);
  background: linear-gradient(135deg, var(--accent-strong), #6366f1, #0b1120);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.08em;
  color: #fff;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.5);
  box-shadow:
    0 0 0 1px rgba(56, 189, 248, 0.3),
    0 8px 24px rgba(8, 47, 73, 0.7),
    0 0 20px rgba(99, 102, 241, 0.2);
  flex-shrink: 0;
}

.header-text h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: linear-gradient(135deg, #e5e7eb 0%, #38bdf8 50%, #818cf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-text p {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.app-main {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.3fr);
  grid-template-rows: minmax(0, 1.2fr) minmax(0, 1.1fr);
  gap: 16px;
}

.panel {
  padding: 18px 20px 16px;
  display: flex;
  flex-direction: column;
  position: relative;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel h2::before {
  content: '';
  width: 3px;
  height: 16px;
  border-radius: 2px;
  background: var(--gradient-primary);
  flex-shrink: 0;
}

.input-panel {
  grid-row: 1 / 3;
}

.scanner-panel {
  grid-column: 2 / 3;
}

.simulation-panel {
  grid-column: 2 / 3;
  padding-top: 6px;
}

.app-footer {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  padding: 8px 0 4px;
  opacity: 0.7;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.app-footer-author {
  opacity: 0.95;
  letter-spacing: 0.02em;
}

/* Debug HUD (development-only overlay) */
.debug-toggle-btn {
  position: fixed;
  right: 16px;
  bottom: 18px;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: radial-gradient(circle at top, rgba(15, 23, 42, 0.9), rgba(15, 23, 42, 0.7));
  color: var(--text-main);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(18px) saturate(160%);
  z-index: 1300;
  opacity: 0.7;
  transition: opacity 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.debug-toggle-btn:hover {
  opacity: 1;
  transform: translateY(-1px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.65);
}

.debug-hud {
  position: fixed;
  right: 16px;
  bottom: 70px;
  width: 260px;
  max-height: 220px;
  padding: 10px 12px 8px;
  border-radius: 14px;
  background: radial-gradient(circle at top left, rgba(15, 23, 42, 0.98), rgba(15, 23, 42, 0.92));
  border: 1px solid rgba(148, 163, 184, 0.5);
  box-shadow:
    0 18px 45px rgba(0, 0, 0, 0.75),
    0 0 30px rgba(56, 189, 248, 0.12);
  backdrop-filter: blur(22px) saturate(180%);
  color: var(--text-main);
  font-size: 11px;
  z-index: 1299;
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
  pointer-events: none;
}

.debug-hud.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.debug-hud-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.debug-hud-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.debug-hud-sub {
  font-size: 10px;
  color: rgba(148, 163, 184, 0.9);
}

.debug-hud-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1px 0;
}

.debug-hud-row--control {
  align-items: center;
  gap: 8px;
}

.debug-label {
  font-size: 10px;
  color: rgba(148, 163, 184, 0.9);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.debug-value {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.debug-fps-value.is-low {
  color: #fb7185;
}

.debug-control {
  display: flex;
  align-items: center;
  gap: 6px;
}

.debug-fps-slider {
  width: 120px;
  accent-color: #38bdf8;
}

.debug-control-value {
  font-size: 10px;
  color: rgba(209, 213, 219, 0.9);
  min-width: 46px;
}

.debug-hud-log {
  margin-top: 6px;
  padding-top: 4px;
  border-top: 1px solid rgba(148, 163, 184, 0.3);
  max-height: 90px;
  overflow: auto;
  font-size: 10px;
  color: rgba(209, 213, 219, 0.9);
}

.debug-log-line + .debug-log-line {
  margin-top: 2px;
}

.section-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Input controls */
.field-group {
  margin-bottom: 10px;
}

.field-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.field-label {
  font-size: 13px;
  color: var(--text-main);
}

.field-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-strong);
  font-variant-numeric: tabular-nums;
}

.slider {
  width: 100%;
  -webkit-appearance: none;
  height: 5px;
  border-radius: 999px;
  background: var(--surface-2);
  outline: none;
  position: relative;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: linear-gradient(135deg, #38bdf8, #818cf8);
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow:
    0 0 0 4px rgba(56, 189, 248, 0.15),
    0 0 16px rgba(56, 189, 248, 0.4);
  cursor: pointer;
  transition: box-shadow 0.2s ease;
}

.slider::-webkit-slider-thumb:hover {
  box-shadow:
    0 0 0 6px rgba(56, 189, 248, 0.2),
    0 0 24px rgba(56, 189, 248, 0.6);
}

.slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: linear-gradient(135deg, #38bdf8, #818cf8);
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow:
    0 0 0 4px rgba(56, 189, 248, 0.15),
    0 0 16px rgba(56, 189, 248, 0.4);
  cursor: pointer;
}

.slider::-moz-range-track {
  height: 5px;
  border-radius: 999px;
  background: var(--surface-2);
}

.year-select {
  width: 100%;
  padding: 9px 14px;
  font-size: 13px;
  color: var(--text-main);
  background: var(--surface-2);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%239ca3af' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 30px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.year-select:hover,
.year-select:focus {
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.15);
}

.pill-toggle {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  overflow: hidden;
  font-size: 12px;
  background: var(--surface-1);
}

.pill-option {
  padding: 6px 16px;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.pill-option .pill-icon {
  font-size: 15px;
  line-height: 1;
}

.pill-option.is-active {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(129, 140, 248, 0.15));
  color: var(--accent-strong);
  font-weight: 600;
}

.activity-options {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.activity-chip {
  flex: 1;
  border-radius: var(--radius-md);
  padding: 8px 8px;
  font-size: 11px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  color: var(--text-muted);
  cursor: pointer;
  text-align: center;
  background: var(--surface-1);
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.activity-chip .activity-icon {
  font-size: 18px;
  line-height: 1;
}

.activity-chip:hover {
  border-color: rgba(56, 189, 248, 0.3);
  background: var(--surface-3);
}

.activity-chip.is-active {
  border-color: var(--accent-strong);
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.15), rgba(129, 140, 248, 0.1));
  color: var(--accent-strong);
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.2);
}

/* Metrics dashboard */
.metrics-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.metric-card {
  border-radius: var(--radius-md);
  border: 1px solid rgba(148, 163, 184, 0.2);
  padding: 10px 12px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.06), rgba(15, 23, 42, 0.8));
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.metric-card:hover {
  border-color: rgba(56, 189, 248, 0.25);
  box-shadow: var(--glow-primary);
}

.metric-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11px;
  color: var(--text-muted);
}

.metric-value {
  font-size: 20px;
  font-weight: 700;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.metric-sub {
  margin-top: 3px;
  font-size: 11px;
  color: var(--text-muted);
}

.metric-ring {
  position: relative;
  width: 100px;
  height: 100px;
  margin: 4px auto;
}

.metric-ring-circle {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  border: 2px solid rgba(15, 23, 42, 0.6);
  background:
    conic-gradient(
      from 270deg,
      #38bdf8 0%,
      #818cf8 calc(var(--progress) * 1%),
      rgba(15, 23, 42, 0.7) calc(var(--progress) * 1%)
    );
  box-shadow:
    0 0 0 1px rgba(148, 163, 184, 0.15),
    0 0 30px rgba(56, 189, 248, 0.25);
  position: relative;
}

.metric-ring-inner {
  position: absolute;
  inset: 9px;
  border-radius: 999px;
  background: radial-gradient(circle at center, #0b1120, #020617);
  border: 1px solid rgba(56, 189, 248, 0.15);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.metric-ring-label {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.metric-ring-value {
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.metric-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 10px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  margin-top: 6px;
  font-weight: 500;
}

.metric-tag-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
}

/* --- Mini-Game Selection Grid --- */
.game-selection {
  margin-top: 16px;
}

.game-selection-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 10px;
}

.game-selection-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: 0.02em;
}

.game-selection-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.game-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.game-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(148, 163, 184, 0.15);
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.6), rgba(30, 41, 59, 0.4));
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
  overflow: visible;
}

.game-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.08), transparent);
  opacity: 0;
  transition: opacity 0.25s;
}

.game-card:hover {
  border-color: rgba(56, 189, 248, 0.35);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3), 0 0 20px rgba(56, 189, 248, 0.1);
}

.game-card:hover::after {
  opacity: 1;
}

.game-card:active {
  transform: translateY(0);
}

.game-card.coming-soon {
  opacity: 0.6;
}

.game-card.coming-soon:hover {
  border-color: rgba(148, 163, 184, 0.25);
  box-shadow: none;
  transform: translateY(-1px);
}

.game-card-icon {
  font-size: 28px;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.game-card-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  position: relative;
  z-index: 1;
}

.game-card-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

.game-card-desc {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.4;
}

.game-card-tag {
  display: inline-block;
  font-size: 9px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid;
  width: fit-content;
  margin-top: 4px;
  letter-spacing: 0.03em;
}

/* Game Card Tooltip (hover 3s) */
.game-card-tooltip {
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  transform: translateX(-50%) translateY(-6px);
  width: max(220px, 100%);
  max-width: 320px;
  padding: 12px 14px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-line;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 16px rgba(56, 189, 248, 0.08);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, transform 0.3s, visibility 0.3s;
  z-index: 50;
}

.game-card-tooltip.visible {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.game-card-tooltip::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-bottom-color: rgba(15, 23, 42, 0.96);
}

/* Coming Soon Toast */
.coming-soon-toast {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 10px 24px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-strong);
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
}

.coming-soon-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Scanner / camera */
.scanner-shell {
  flex: 1;
  border-radius: var(--radius-md);
  border: 1px solid rgba(56, 189, 248, 0.15);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, rgba(15, 23, 42, 0.6), #020617);
}

.scanner-shell::before,
.scanner-shell::after {
  content: '';
  position: absolute;
  width: 24px;
  height: 24px;
  border: 2px solid rgba(56, 189, 248, 0.5);
  z-index: 5;
  pointer-events: none;
}

.scanner-shell::before {
  top: 6px;
  left: 6px;
  border-right: none;
  border-bottom: none;
  border-radius: 4px 0 0 0;
  animation: corner-pulse 3s ease-in-out infinite;
}

.scanner-shell::after {
  bottom: 6px;
  right: 6px;
  border-left: none;
  border-top: none;
  border-radius: 0 0 4px 0;
  animation: corner-pulse 3s ease-in-out infinite 1.5s;
}

@keyframes corner-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.scanner-content {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.scanner-shell video,
.scanner-shell .camera-placeholder,
.scanner-shell .scanner-upload-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: saturate(0.8) contrast(1.1);
}

.scanner-upload-img {
  object-fit: contain;
  background: #0f172a;
}

/* AI Tracking overlay canvas */
.tracking-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
  transform: scaleX(-1);
}

/* Tracking toggle row */
.tracking-row {
  display: none;
  gap: 6px;
  flex-wrap: wrap;
}
.tracking-row.visible {
  display: flex;
}

.track-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
}
.track-toggle:hover {
  background: var(--surface-3);
  border-color: rgba(148, 163, 184, 0.25);
}
.track-toggle.active {
  color: var(--accent-strong);
  border-color: rgba(56, 189, 248, 0.3);
  background: rgba(56, 189, 248, 0.08);
}
.track-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transition: all 0.3s ease;
}
.track-toggle.active .track-dot {
  box-shadow: 0 0 6px currentColor;
  animation: track-breathe 2s ease-in-out infinite;
}

@keyframes track-breathe {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

.source-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.source-btn {
  flex: 1;
  min-width: 100px;
}

.source-btn.secondary {
  background: transparent;
  color: var(--accent-strong);
  border: 1px solid rgba(56, 189, 248, 0.6);
}

.source-btn.secondary:hover {
  background: rgba(56, 189, 248, 0.15);
}

.upload-input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
}

/* 表情包按鈕行 */
/* --- Scanner Stats Card --- */
.scanner-stats-card {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.7), rgba(30, 41, 59, 0.5));
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sstat-row {
  display: flex;
  gap: 10px;
}

.sstat-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sstat-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.sstat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}

.sstat-value.neg {
  color: #4ade80;
}

.sstat-value.pos {
  color: #fbbf24;
}

.sstat-value.cal {
  color: #fb923c;
  font-size: 15px;
}

.sstat-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  width: fit-content;
  letter-spacing: 0.03em;
}

.sstat-bar {
  height: 4px;
  border-radius: 2px;
  background: rgba(148, 163, 184, 0.12);
  margin-top: 2px;
  overflow: hidden;
}

.sstat-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* --- Scan Tips Carousel --- */
.scanner-tips-carousel {
  background: rgba(56, 189, 248, 0.05);
  border: 1px solid rgba(56, 189, 248, 0.1);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  min-height: 38px;
  display: flex;
  align-items: center;
}

.scanner-tip-text {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  transition: opacity 0.3s ease;
}

/* --- Activity Summary Row --- */
.scanner-activity-row {
  display: flex;
  gap: 8px;
}

.sact-chip {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  background: rgba(148, 163, 184, 0.06);
  border: 1px solid rgba(148, 163, 184, 0.1);
  border-radius: var(--radius-sm);
}

.sact-icon {
  font-size: 16px;
}

.sact-num {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}

.sact-label {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

/* --- Upload Auto-Preview --- */
.scanner-upload-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: var(--radius-md);
}

.scanner-upload-avatar-img {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  object-fit: contain;
  background: #0f172a;
  flex-shrink: 0;
}

.scanner-upload-save {
  flex: 1;
  font-size: 12px;
  padding: 8px 0;
}

/* 回憶錄卡片上的浮動 emoji */
.memoir-card {
  position: relative;
}

.memoir-card-emoji-float {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 22px;
  z-index: 2;
  animation: emoji-float 2s ease-in-out infinite;
  filter: drop-shadow(0 1px 4px rgba(0,0,0,0.3));
}

@keyframes emoji-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.camera-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 12px;
}

.scanner-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.scanner-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent 5%,
    rgba(56, 189, 248, 0.15),
    var(--accent-strong),
    rgba(56, 189, 248, 0.15),
    transparent 95%
  );
  box-shadow:
    0 0 12px rgba(56, 189, 248, 0.6),
    0 0 30px rgba(34, 211, 238, 0.4),
    0 -4px 16px rgba(56, 189, 248, 0.15),
    0 4px 16px rgba(56, 189, 248, 0.15);
  animation: scan 3s linear infinite;
}

.scanner-line::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 4px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(129, 140, 248, 0.3), transparent);
  filter: blur(1px);
}

@keyframes scan {
  0% {
    top: 0%;
  }
  50% {
    top: 80%;
  }
  100% {
    top: 0%;
  }
}

.scanner-hud {
  position: absolute;
  inset: 8px;
  border-radius: 8px;
  border: 1px solid rgba(56, 189, 248, 0.1);
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.08);
  pointer-events: none;
}

.scanner-badge {
  position: absolute;
  top: 10px;
  left: 12px;
  font-size: 10px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(56, 189, 248, 0.5);
  background: rgba(15, 23, 42, 0.85);
  color: var(--accent-strong);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
  font-weight: 600;
}

.scanner-status {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--text-muted);
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(148, 163, 184, 0.15);
  white-space: nowrap;
}

.scanner-controls {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  margin-top: 8px;
  gap: 10px;
}

/* Used by memoir edit pop-up */
.cartoon-select {
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text-main);
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.5);
  border-radius: 8px;
  outline: none;
}

.memoir-edit-pop .emoji-pack-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.memoir-edit-pop .emoji-pack-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.memoir-edit-pop .emoji-pack-btn:hover {
  transform: scale(1.1);
  border-color: rgba(56, 189, 248, 0.3);
}

.memoir-edit-pop .emoji-pack-btn.active {
  border-color: var(--accent-strong);
  background: rgba(56, 189, 248, 0.15);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.25);
}

.memoir-edit-pop .emoji-pack-btn.draw-face-btn {
  font-size: 11px;
  width: auto;
  padding: 0 8px;
}

.memoir-btn {
  margin-top: 6px;
  width: 100%;
  padding: 8px 14px;
  font-size: 12px;
  color: var(--accent-strong);
  background: transparent;
  border: 1px solid rgba(56, 189, 248, 0.6);
  border-radius: 10px;
  cursor: pointer;
  letter-spacing: 0.06em;
}

.memoir-btn:hover {
  background: rgba(56, 189, 248, 0.15);
}

/* 回憶錄彈層 */
.memoir-modal-wrap {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.memoir-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
}

.memoir-modal-panel {
  position: relative;
  width: 100%;
  max-width: 580px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--surface-2);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(24px);
  padding: 20px 22px;
}

.memoir-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.memoir-modal-title {
  font-size: 16px;
  letter-spacing: 0.08em;
  color: var(--text-main);
  margin: 0;
}

.memoir-close-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(148, 163, 184, 0.2);
  color: var(--text-main);
  font-size: 20px;
  line-height: 1;
  border-radius: 8px;
  cursor: pointer;
}

.memoir-close-btn:hover {
  background: rgba(148, 163, 184, 0.35);
}

.memoir-goal-section {
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.25);
}

.memoir-goal-label {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.memoir-goal-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.memoir-tab {
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.5);
  border-radius: 8px;
  cursor: pointer;
}

.memoir-tab.active {
  color: var(--accent-strong);
  border-color: var(--accent-strong);
  background: rgba(56, 189, 248, 0.15);
}

.memoir-goal-value {
  font-size: 13px;
  color: var(--text-main);
}

.memoir-days-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.memoir-days-input {
  width: 64px;
  padding: 6px 8px;
  font-size: 13px;
  color: var(--text-main);
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.5);
  border-radius: 8px;
}

.memoir-days-progress {
  margin-top: 6px;
  font-size: 12px;
  color: var(--accent-strong);
}

.memoir-list-label {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

.memoir-weight-chart {
  width: 100%;
  height: 100px;
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  border: 1px solid rgba(148, 163, 184, 0.1);
  margin-bottom: 14px;
}

.memoir-heatmap-wrap {
  margin-bottom: 14px;
}

.memoir-heatmap-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.memoir-heatmap {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.memoir-heatmap-cell {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: rgba(148, 163, 184, 0.08);
  transition: background 0.2s ease;
}

.memoir-heatmap-cell.has-data {
  background: rgba(56, 189, 248, 0.4);
}

.memoir-heatmap-cell.has-data-strong {
  background: rgba(56, 189, 248, 0.7);
}

.memoir-progress-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-1);
  overflow: hidden;
  margin-top: 8px;
  margin-bottom: 12px;
}

.memoir-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--gradient-primary);
  transition: width 0.3s ease;
}

.memoir-timeline {
  position: relative;
  padding-left: 28px;
}

.memoir-timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.3), rgba(129, 140, 248, 0.1));
  border-radius: 2px;
}

.memoir-timeline-item {
  position: relative;
  margin-bottom: 16px;
}

.memoir-timeline-item::before {
  content: '';
  position: absolute;
  left: -24px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface-2);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.3);
}

.memoir-timeline-date {
  font-size: 11px;
  color: var(--accent-strong);
  font-weight: 600;
  margin-bottom: 6px;
  letter-spacing: 0.04em;
}

.memoir-card {
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.15);
  background: var(--surface-1);
  display: flex;
  gap: 10px;
  padding: 8px;
  transition: border-color 0.2s ease;
}

.memoir-card:hover {
  border-color: rgba(56, 189, 248, 0.25);
}

.memoir-card-img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  display: block;
  background: #0b1120;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.memoir-card-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.memoir-card-meta {
  font-size: 12px;
  color: var(--text-main);
  font-weight: 500;
}

.memoir-card-weight {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.memoir-card-weight-change {
  font-size: 11px;
  font-weight: 600;
  margin-top: 1px;
}

.memoir-card-weight-change.loss {
  color: var(--ok);
}

.memoir-card-weight-change.gain {
  color: var(--danger);
}

.memoir-empty {
  padding: 30px 20px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  border: 1px dashed rgba(148, 163, 184, 0.2);
  border-radius: var(--radius-md);
}

/* 識別完成提示（掃描區內） */
.recognition-toast {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.9);
  border-radius: 14px;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
}

.recognition-toast.recognition-done {
  opacity: 1;
}

.recognition-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin-bottom: 10px;
  font-size: 28px;
  color: var(--ok);
  border: 2px solid var(--ok);
  border-radius: 50%;
  animation: recognition-pulse 0.6s ease;
}

@keyframes recognition-pulse {
  0% { transform: scale(0.8); opacity: 0; }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

.recognition-toast span:last-child {
  font-size: 14px;
  color: var(--accent-strong);
  letter-spacing: 0.06em;
}

/* 回憶錄卡片：刪除 / 換裝 */
.memoir-card-actions {
  display: flex;
  gap: 6px;
  padding: 6px 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.memoir-card-btn {
  padding: 4px 10px;
  font-size: 11px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  background: rgba(148, 163, 184, 0.25);
  color: var(--text-main);
}

.memoir-card-btn.edit-btn {
  background: rgba(56, 189, 248, 0.25);
  color: var(--accent-strong);
}

.memoir-card-btn.del-btn {
  background: rgba(249, 115, 115, 0.2);
  color: var(--danger);
}

.memoir-card-btn:hover {
  filter: brightness(1.15);
}

/* 換裝編輯彈層 */
.memoir-edit-pop {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  min-width: 220px;
  padding: 16px;
  background: rgba(15, 23, 42, 0.98);
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 14px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  z-index: 10;
}

.memoir-edit-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-strong);
  margin-bottom: 12px;
  text-align: center;
}

.memoir-edit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.memoir-edit-row span:first-child {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 40px;
}

.memoir-edit-row .cartoon-select {
  flex: 1;
}

.memoir-edit-row .primary-btn,
.memoir-edit-row .memoir-card-btn {
  flex: 1;
}

.memoir-edit-row.emoji-row {
  flex-wrap: wrap;
}

.memoir-edit-row.emoji-row .emoji-pack-wrap {
  flex: 1;
  min-width: 180px;
}

/* 減脂切切樂遊戲 */
.header-game-btn {
  padding: 8px 16px;
  font-size: 12px;
  color: #fff;
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.8), rgba(236, 72, 153, 0.8));
  border: 1px solid rgba(249, 115, 22, 0.4);
  border-radius: var(--radius-sm);
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: all 0.2s ease;
  font-weight: 600;
}

.header-game-btn:hover {
  box-shadow: 0 0 20px rgba(249, 115, 22, 0.3);
  transform: translateY(-1px);
}

.game-calories-badge {
  display: none;
  font-size: 11px;
  color: var(--ok);
  background: rgba(74, 222, 128, 0.2);
  padding: 2px 8px;
  border-radius: 6px;
  white-space: nowrap;
}

.game-modal-wrap {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  padding: 16px;
}

.game-modal-panel {
  width: 100%;
  max-width: 680px;
  background: var(--panel-bg);
  border-radius: 18px;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.game-header {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.game-title {
  margin: 0 0 4px;
  font-size: 18px;
  color: var(--text-main);
}

.game-sub {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.game-score-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.game-hp-bar {
  font-size: 14px;
  letter-spacing: 1px;
  margin-left: auto;
  margin-right: 8px;
  display: flex;
  align-items: center;
}

.game-score-label {
  font-size: 12px;
  color: var(--text-muted);
}

.game-score-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--ok);
}

.game-score-unit {
  font-size: 12px;
  color: var(--text-muted);
}

.game-time {
  margin-left: auto;
  font-size: 14px;
  color: var(--accent-strong);
  font-weight: 600;
}

.game-score-detail {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.game-met-indicator {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
  transition: color 0.3s;
}

.game-canvas-wrap {
  width: 100%;
  aspect-ratio: 400/420;
  max-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0f172a;
}

.game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

.game-area {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  max-height: 65vh;
  overflow: hidden;
  background: #000;
}

.game-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  z-index: 0;
}

.game-canvas-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  touch-action: none;
  cursor: crosshair;
}

.game-toolbar {
  display: flex;
  gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
}

.game-tool-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 10px;
  font-size: 12px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 8px;
  background: rgba(148, 163, 184, 0.08);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.game-tool-btn:hover {
  background: rgba(148, 163, 184, 0.18);
  color: var(--text-main);
}

.game-tool-btn.active {
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent);
  border-color: rgba(56, 189, 248, 0.35);
}

.game-status-bar {
  font-size: 12px;
  color: var(--accent);
  padding: 6px 16px;
  text-align: center;
  background: rgba(0, 0, 0, 0.3);
  transition: opacity 0.3s;
}

.game-area-fullbody {
  aspect-ratio: 9/16;
}

.game-fullscreen {
  background: #000;
  padding: 0;
}

.game-fullscreen .game-modal-panel {
  max-width: none;
  width: 100%;
  height: 100%;
  border-radius: 0;
  border: none;
  box-shadow: none;
}

.game-fullscreen .game-area {
  flex: 1;
  max-height: none;
}

.game-fullscreen .game-header {
  padding: 10px 16px;
}

.game-fullscreen .game-footer {
  padding: 8px 16px;
}

.game-hand-hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  background: rgba(0, 0, 0, 0.5);
  padding: 4px 14px;
  border-radius: 20px;
  z-index: 2;
  pointer-events: none;
}

.game-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
}

.game-close-btn {
  width: 100%;
  padding: 10px;
  font-size: 13px;
  color: var(--text-muted);
  background: rgba(148, 163, 184, 0.15);
  border: none;
  border-radius: 10px;
  cursor: pointer;
}

.game-close-btn:hover {
  background: rgba(148, 163, 184, 0.25);
  color: var(--text-main);
}

.game-result {
  padding: 20px 16px;
  text-align: center;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
}

.game-result-title {
  margin: 0 0 8px;
  font-size: 16px;
  color: var(--text-main);
}

.game-result-title strong {
  color: var(--ok);
}

.game-result-sub {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.game-result .primary-btn {
  margin: 0 auto;
}

.primary-btn {
  border-radius: 999px;
  border: none;
  padding: 6px 14px;
  font-size: 12px;
  background: radial-gradient(circle at top, var(--accent-strong), #0ea5e9);
  color: #0b1120;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.9),
    0 14px 30px rgba(8, 47, 73, 0.8),
    0 0 40px rgba(34, 211, 238, 0.9);
}

.primary-btn:active {
  transform: translateY(1px);
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.9),
    0 10px 22px rgba(8, 47, 73, 0.9),
    0 0 30px rgba(34, 211, 238, 0.7);
}

.secondary-note {
  font-size: 11px;
  color: var(--text-muted);
}

/* Body visualization & future simulation */
.visualization-shell {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.silhouette-panel {
  border-radius: var(--radius-md);
  border: 1px solid rgba(148, 163, 184, 0.2);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.4), transparent);
  transition: border-color 0.2s ease;
}

.silhouette-panel:hover {
  border-color: rgba(56, 189, 248, 0.25);
}

.silhouette-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11px;
  color: var(--text-muted);
}

.silhouette-label {
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.silhouette-tag {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.7);
}

.silhouette-canvas-shell {
  margin-top: 2px;
  border-radius: 10px;
  background: radial-gradient(circle at top, #020617, #020617 45%, #020617 100%);
  position: relative;
  overflow: hidden;
  aspect-ratio: 1 / 1.5;
  width: 100%;
}

.silhouette-grid {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(
      rgba(15, 23, 42, 0.7) 1px,
      rgba(15, 23, 42, 0.05) 1px
    ),
    linear-gradient(
      90deg,
      rgba(15, 23, 42, 0.7) 1px,
      rgba(15, 23, 42, 0.05) 1px
    );
  background-size: 100% 18px, 20px 100%;
  opacity: 0.6;
}

canvas.silhouette-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.future-controls {
  margin-top: 6px;
}

.future-header {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.future-target {
  color: var(--accent-strong);
}

.change-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  padding: 2px 7px;
  font-size: 10px;
  color: var(--text-muted);
}

.change-chip.positive {
  border-color: var(--ok);
  color: var(--ok);
}

.change-chip.negative {
  border-color: var(--danger);
  color: var(--danger);
}

.change-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
}

/* Camera Recognition Modal */
.cam-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 6, 23, 0.9);
  backdrop-filter: blur(10px);
  animation: onboard-fadeIn 0.3s ease;
}

.cam-modal {
  width: 92%;
  max-width: 720px;
  max-height: 90vh;
  background: var(--surface-2);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(56, 189, 248, 0.15);
  box-shadow: 0 0 60px rgba(56, 189, 248, 0.08), 0 24px 48px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.cam-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
}

.cam-modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}

.cam-modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-main);
  font-size: 18px;
  line-height: 1;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s;
}

.cam-modal-close:hover {
  background: rgba(148, 163, 184, 0.3);
}

.cam-modal-mode-row {
  display: flex;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.cam-mode-card {
  flex: 1;
  padding: 16px 14px;
  border-radius: var(--radius-md);
  border: 2px solid rgba(148, 163, 184, 0.15);
  background: var(--surface-1);
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.cam-mode-card:hover {
  border-color: rgba(56, 189, 248, 0.3);
}

.cam-mode-card.active {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.1), rgba(129, 140, 248, 0.06));
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.12);
}

.cam-mode-icon {
  font-size: 36px;
  line-height: 1;
}

.cam-mode-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

.cam-mode-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

.cam-modal-body {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #000;
  min-height: 280px;
  max-height: 50vh;
  display: flex;
  flex-direction: column;
}

.cam-modal-body.result-mode {
  overflow-y: auto;
  max-height: 65vh;
  background: var(--surface-1);
}

.cam-modal-video-wrap {
  position: relative;
  flex: 1;
  min-height: 280px;
  width: 100%;
}

.cam-modal-video-wrap .tracking-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  transform: scaleX(-1); /* 与视频镜像一致，保证骨骼点与面部对齐 */
}

.cam-modal-video {
  width: 100%;
  height: 100%;
  object-fit: contain; /* 与 overlay 坐标一致，避免裁剪导致错位 */
  transform: scaleX(-1);
  display: block;
}

.cam-modal-guide {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cam-guide-silhouette {
  border: 2px dashed rgba(56, 189, 248, 0.4);
  border-radius: var(--radius-md);
  position: relative;
  transition: all 0.3s ease;
}

.cam-guide-silhouette.half-body {
  width: 55%;
  height: 70%;
}

.cam-guide-silhouette.full-body {
  width: 40%;
  height: 90%;
}

.cam-guide-label {
  position: absolute;
  bottom: -24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: rgba(56, 189, 248, 0.7);
  white-space: nowrap;
  background: rgba(0, 0, 0, 0.6);
  padding: 2px 10px;
  border-radius: 999px;
}

.cam-modal-notice {
  padding: 10px 20px;
  font-size: 12px;
  color: var(--accent);
  background: rgba(56, 189, 248, 0.06);
  border-top: 1px solid rgba(56, 189, 248, 0.1);
  text-align: center;
}

.cam-modal-notice.warn {
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.06);
  border-top-color: rgba(251, 191, 36, 0.1);
}

.cam-modal-footer {
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid rgba(148, 163, 184, 0.15);
}

.cam-modal-footer .primary-btn {
  flex: 1;
}

.cam-capture-group {
  display: flex;
  gap: 8px;
  flex: 1;
}

.cam-capture-btn {
  flex: 1;
  padding: 10px 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, #38bdf8, #6366f1);
  transition: all 0.2s;
}

.cam-capture-btn:hover:not(:disabled) {
  filter: brightness(1.15);
  transform: translateY(-1px);
  box-shadow: 0 4px 18px rgba(56, 189, 248, 0.35);
}

.cam-capture-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.cam-capture-btn[data-seconds="10"] {
  background: linear-gradient(135deg, #6366f1, #a855f7);
}

.cam-modal-cancel {
  padding: 10px 20px;
  font-size: 13px;
  color: var(--text-muted);
  background: rgba(148, 163, 184, 0.12);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s;
}

.cam-modal-cancel:hover {
  background: rgba(148, 163, 184, 0.2);
  color: var(--text-main);
}

.cam-modal-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 14px;
  gap: 8px;
  height: 100%;
}

.cam-modal-placeholder .cam-ph-icon {
  font-size: 40px;
  opacity: 0.5;
}

/* Capture result page */
.cam-result-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px;
}

.cam-result-photo,
.cam-result-avatar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: rgba(15, 23, 42, 0.6);
  border-radius: var(--radius-md);
  padding: 8px;
  border: 1px solid rgba(148, 163, 184, 0.15);
}

.cam-result-img {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  border-radius: 8px;
}

.cam-result-avatar-img {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: contain;
  border-radius: 8px;
  background: #0f172a;
}

.cam-result-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.cam-result-emoji-section {
  padding: 10px 12px 8px;
  border-top: 1px solid rgba(148, 163, 184, 0.1);
}

.cam-result-emoji-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 8px;
}

.cam-result-emoji-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cam-emoji-btn {
  width: 36px;
  height: 36px;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(148, 163, 184, 0.08);
  border: 1.5px solid rgba(148, 163, 184, 0.15);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
}

.cam-emoji-btn:hover {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.3);
  transform: scale(1.12);
}

.cam-emoji-btn.active {
  background: rgba(56, 189, 248, 0.18);
  border-color: #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.25);
}

.cam-emoji-none {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.cam-emoji-none.active {
  color: #38bdf8;
}

/* Onboarding overlay */
.onboarding-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 6, 23, 0.92);
  backdrop-filter: blur(12px);
  animation: onboard-fadeIn 0.4s ease;
}

@keyframes onboard-fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.onboarding-card {
  width: 90%;
  max-width: 420px;
  background: var(--surface-2);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(56, 189, 248, 0.15);
  box-shadow: 0 0 60px rgba(56, 189, 248, 0.1), 0 24px 48px rgba(0, 0, 0, 0.5);
  padding: 36px 32px;
  text-align: center;
  animation: onboard-slideUp 0.4s ease;
}

@keyframes onboard-slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.onboarding-icon {
  font-size: 52px;
  margin-bottom: 16px;
  display: block;
  animation: onboard-bounce 0.6s ease;
}

@keyframes onboard-bounce {
  0% { transform: scale(0.5); }
  60% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

.onboarding-title {
  font-size: 22px;
  font-weight: 800;
  margin: 0 0 10px;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.onboarding-desc {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0 0 24px;
}

.onboarding-steps {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
}

.onboarding-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.3);
  transition: all 0.3s ease;
}

.onboarding-dot.active {
  background: var(--accent);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.4);
  width: 24px;
}

.onboarding-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.onboarding-next {
  padding: 10px 28px;
  font-size: 14px;
  font-weight: 600;
  color: #0b1120;
  background: var(--gradient-primary);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.onboarding-next:hover {
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.3);
  transform: translateY(-1px);
}

.onboarding-skip {
  padding: 10px 20px;
  font-size: 13px;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.onboarding-skip:hover {
  color: var(--text-main);
  border-color: rgba(148, 163, 184, 0.5);
}

@media (max-width: 900px) {
  #app {
    max-width: 100%;
    padding: 10px;
  }

  .app-main {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto;
  }

  .input-panel,
  .scanner-panel,
  .simulation-panel {
    grid-column: auto;
    grid-row: auto;
  }

  .visualization-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto;
  }
}

