:root {
  color-scheme: dark;
  --stroke: rgba(142, 244, 255, 0.18);
  --text: #f6fbff;
  --muted: #a9c1cf;
  --cyan: #59f2ff;
  --orange: #ff9b56;
  --gold: #ffd96c;
  --panel: rgba(6, 25, 38, 0.84);
  --purple: #ba55d3;
}

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

html, body {
  height: 100%; overflow: hidden;
  background: linear-gradient(180deg, #0a2131 0%, #04111a 100%);
  color: var(--text);
  font-family: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

body { display: grid; place-items: center; }

/* ======== App Shell ======== */
.app-shell {
  position: relative; width: 100vw; height: 100vh;
  display: grid; place-items: center; overflow: hidden;
}

#game-canvas {
  width: 100vw; height: 100vh; display: block;
  background: #04111a; border: none; border-radius: 0;
}

#camera-feed { display: none; }

.hidden { opacity: 0 !important; visibility: hidden !important; pointer-events: none !important; }
.menu-panel { display: none !important; }

/* ======== Camera Preview (top-right) ======== */
.camera-preview {
  position: fixed; top: 20px; right: 20px;
  width: 320px; border-radius: 16px; overflow: hidden;
  background: rgba(4, 17, 28, 0.92);
  border: 2px solid rgba(89, 242, 255, 0.25);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
  z-index: 9999;
}

.camera-preview-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  background: rgba(89, 242, 255, 0.08);
  border-bottom: 1px solid rgba(89, 242, 255, 0.12);
}

.camera-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #ff4444;
  box-shadow: 0 0 8px rgba(255, 68, 68, 0.6);
  animation: blink-dot 1.5s ease-in-out infinite;
}

@keyframes blink-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.camera-label {
  font-size: 20px; font-weight: 700; letter-spacing: 0.15em;
  color: var(--cyan);
  font-family: "Bahnschrift", "Segoe UI Semibold", monospace;
}

.camera-preview-body {
  position: relative; width: 100%; aspect-ratio: 4/3;
  background: #07131d; overflow: hidden;
}

#camera-preview-canvas {
  width: 100%; height: 100%; display: block;
  transform: scaleX(-1);
}

.detection-box {
  position: absolute;
  top: 12%; left: 18%; width: 64%; height: 76%;
  border: 2px dashed rgba(89, 242, 255, 0.35);
  border-radius: 12px;
  pointer-events: none;
  transition: all 0.3s ease;
}

.detection-box.detected {
  border-color: #4cff88;
  border-style: solid;
  box-shadow: inset 0 0 20px rgba(76, 255, 136, 0.08), 0 0 15px rgba(76, 255, 136, 0.15);
}

.countdown-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  transition: opacity 0.3s ease;
}

.countdown-number {
  font-size: 80px; font-weight: 900;
  color: var(--cyan);
  text-shadow: 0 0 40px rgba(89, 242, 255, 0.6), 0 0 80px rgba(89, 242, 255, 0.3);
  animation: pulse-count 1s ease-in-out infinite;
  font-family: "Bahnschrift", "Segoe UI", sans-serif;
}

@keyframes pulse-count {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

/* ======== Standby Screen ======== */
.standby-screen {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(circle at 50% 38%, rgba(89, 242, 255, 0.07), transparent 55%),
    radial-gradient(circle at 30% 70%, rgba(255, 155, 86, 0.04), transparent 40%),
    linear-gradient(180deg, rgba(10, 33, 49, 0.96), rgba(4, 17, 26, 0.99));
  z-index: 50;
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.standby-screen.fade-out {
  opacity: 0; transform: scale(1.04);
  pointer-events: none;
}

.standby-content {
  text-align: center;
  animation: float-gentle 4s ease-in-out infinite alternate;
}

@keyframes float-gentle {
  0% { transform: translateY(5px); }
  100% { transform: translateY(-5px); }
}

.standby-logo {
  position: relative; width: 200px; height: 200px;
  margin: 0 auto 50px;
}

.logo-ring {
  position: absolute; inset: 0;
  border: 2px solid rgba(89, 242, 255, 0.28);
  border-radius: 50%;
  animation: spin-ring 10s linear infinite;
}

.logo-ring.ring-2 {
  inset: 18px;
  border-color: rgba(255, 155, 86, 0.22);
  animation-direction: reverse; animation-duration: 14s;
}

@keyframes spin-ring {
  to { transform: rotate(360deg); }
}

.logo-icon {
  position: absolute; inset: 40px;
  display: flex; align-items: center; justify-content: center;
  font-size: 52px; font-weight: 900; color: var(--cyan);
  background: rgba(89, 242, 255, 0.06);
  border-radius: 50%;
  border: 1px solid rgba(89, 242, 255, 0.18);
  text-shadow: 0 0 20px rgba(89, 242, 255, 0.4);
}

.standby-title {
  font-size: 96px; font-weight: 800; letter-spacing: 4px;
  background: linear-gradient(135deg, #59f2ff 30%, #ff9b56 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 24px;
}

.standby-subtitle {
  font-size: 38px; color: var(--muted);
  margin-bottom: 8px; letter-spacing: 1.5px;
}

.standby-subtitle-line2 {
  font-size: 38px; color: var(--muted);
  margin-bottom: 52px; letter-spacing: 1.5px;
  text-align: center;
}

.standby-hint {
  display: inline-flex; align-items: center; gap: 14px;
  padding: 26px 52px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(89, 242, 255, 0.15);
  color: rgba(255, 255, 255, 0.7);
  font-size: 30px;
}

.hint-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--cyan);
  animation: blink-dot 1.5s ease-in-out infinite;
}

/* ======== Modal Overlay (shared) ======== */
.modal-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(2, 8, 16, 0.65);
  backdrop-filter: blur(6px);
  z-index: 200;
  transition: opacity 0.5s ease;
}

.modal-overlay.fade-out {
  opacity: 0; pointer-events: none;
}

/* ======== AI Analysis Card ======== */
.ai-analysis-card {
  width: 680px; padding: 56px 64px;
  background: linear-gradient(180deg, rgba(14, 40, 60, 0.96), rgba(5, 18, 28, 0.97));
  border: 2px solid rgba(89, 242, 255, 0.22);
  border-radius: 26px;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.55), 0 0 50px rgba(89, 242, 255, 0.08);
  animation: card-in 0.45s ease-out;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(28px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.ai-card-header {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 18px;
}

.ai-icon { font-size: 52px; }

.ai-card-title {
  font-size: 38px; font-weight: 700; color: var(--cyan);
  letter-spacing: 1px;
}

.ai-card-divider {
  height: 1px; margin-bottom: 22px;
  background: linear-gradient(90deg, rgba(89, 242, 255, 0.28), transparent 80%);
}

.ai-card-row {
  display: flex; align-items: baseline; gap: 14px;
  margin-bottom: 16px;
}

.ai-label {
  font-size: 28px; font-weight: 600; color: var(--cyan);
  white-space: nowrap;
}

.ai-value {
  font-size: 42px; font-weight: 700; color: #fff;
}

.ai-personality-row { margin-bottom: 22px; }

.ai-personality {
  font-size: 30px; color: rgba(255, 255, 255, 0.85);
  line-height: 1.7;
}

.ai-card-footer { text-align: center; margin-top: 10px; }

.ai-countdown {
  font-size: 26px; color: var(--cyan);
  animation: blink-dot 1.5s ease-in-out infinite;
}

/* ======== Game Popup Card ======== */
.game-popup-card {
  width: 800px; padding: 70px; text-align: center;
  background: linear-gradient(180deg, rgba(14, 40, 60, 0.96), rgba(5, 18, 28, 0.97));
  border: 2px solid rgba(89, 242, 255, 0.22);
  border-radius: 26px;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.55);
  animation: card-in 0.4s ease-out;
}

.popup-icon { font-size: 88px; margin-bottom: 26px; }

.popup-title {
  font-size: 56px; font-weight: 700; color: #fff;
  margin-bottom: 24px;
}

.popup-message {
  font-size: 34px; color: var(--muted);
  line-height: 1.65; margin-bottom: 20px;
}

.popup-countdown { margin-top: 14px; }

#popup-countdown-text {
  font-size: 26px; color: var(--cyan);
  animation: blink-dot 1.5s ease-in-out infinite;
}

/* ======== Visitor Stats (top-left) ======== */
.visitor-stats {
  position: fixed; top: 20px; left: 20px;
  padding: 12px 22px; border-radius: 14px;
  background: rgba(4, 17, 28, 0.92);
  border: 2px solid rgba(89, 242, 255, 0.25);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
  z-index: 9998;
}

.visitor-header {
  display: flex; align-items: center; gap: 10px;
}

.visitor-icon {
  font-size: 22px;
}

.visitor-date-btn {
  font-size: 18px; font-weight: 600; color: var(--cyan);
  cursor: pointer; padding: 3px 10px; border-radius: 6px;
  background: rgba(89, 242, 255, 0.1);
  border: 1px solid rgba(89, 242, 255, 0.2);
  transition: all 0.2s ease;
}

.visitor-date-btn:hover {
  background: rgba(89, 242, 255, 0.2);
}

.visitor-label {
  font-size: 18px; font-weight: 600; color: var(--muted);
}

.visitor-count {
  font-size: 26px; font-weight: 700; color: #fff;
  min-width: 40px; text-align: right;
}

.visitor-date-picker {
  position: absolute; top: 100%; left: 0; margin-top: 8px;
  padding: 10px; border-radius: 12px;
  background: rgba(4, 17, 28, 0.96);
  border: 2px solid rgba(89, 242, 255, 0.3);
  color: #fff; font-size: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* ======== User Type Badge (below visitor stats) ======== */
.user-type-badge {
  position: fixed; top: 100px; left: 24px;
  padding: 14px 28px; border-radius: 999px;
  font-size: 20px; font-weight: 700; letter-spacing: 0.14em;
  color: #fff; z-index: 9998;
  background: linear-gradient(135deg, #59f2ff, #0a7fab);
  box-shadow: 0 8px 24px rgba(89, 242, 255, 0.3);
  transition: opacity 0.4s ease, background 0.5s ease;
}

.user-type-badge.girl-mode {
  background: linear-gradient(135deg, #ba55d3, #8b5cf6);
  box-shadow: 0 8px 24px rgba(186, 85, 211, 0.3);
}

/* ======== Girl Theme overrides ======== */
body.girl-theme .camera-preview {
  border-color: rgba(186, 85, 211, 0.35);
}

body.girl-theme .ai-analysis-card,
body.girl-theme .game-popup-card {
  border-color: rgba(186, 85, 211, 0.3);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.55), 0 0 50px rgba(186, 85, 211, 0.1);
}

body.girl-theme .ai-card-title,
body.girl-theme .ai-label,
body.girl-theme .ai-countdown,
body.girl-theme #popup-countdown-text {
  color: var(--purple);
}

body.girl-theme .ai-card-divider {
  background: linear-gradient(90deg, rgba(186, 85, 211, 0.28), transparent 80%);
}

body.girl-theme .standby-screen {
  background:
    radial-gradient(circle at 50% 38%, rgba(186, 85, 211, 0.07), transparent 55%),
    radial-gradient(circle at 30% 70%, rgba(255, 182, 193, 0.04), transparent 40%),
    linear-gradient(180deg, rgba(26, 16, 37, 0.96), rgba(12, 8, 18, 0.99));
}

/* ======== Responsive ======== */
@media (max-width: 900px) {
  .camera-preview { width: 220px; top: 12px; right: 12px; }
  .standby-title { font-size: 36px; }
  .ai-analysis-card { width: 480px; padding: 34px; }
  .game-popup-card { width: 460px; padding: 36px; }
}
