/* Reset and Global Styles */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-sans);
  background: #000;
  color: var(--text-primary);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  user-select: none;
}

body.lang-zh {
  font-family: var(--font-cjk), var(--font-sans);
}

/* Phone Frame */
.phone-frame {
  position: relative;
  width: var(--phone-width);
  height: var(--phone-height);
  border-radius: 44px;
  background: var(--bg-primary);
  overflow: hidden;
  box-shadow: 0 0 0 3px #1a1a2e, 0 0 0 6px #0d0d15, var(--shadow-level3);
}

/* Subtle noise texture overlay */
.phone-frame::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
  pointer-events: none;
  z-index: 0;
  mix-blend-mode: overlay;
  opacity: 0.5;
}

/* Notch */
.phone-notch {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 150px;
  height: 30px;
  background: #000;
  border-radius: 0 0 20px 20px;
  z-index: 1000;
}

/* Status bar area */
.phone-status-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--safe-top);
  background: var(--bg-primary);
  z-index: 999;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 20px 4px;
}

.phone-status-bar .time {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.phone-status-bar .icons {
  display: flex;
  gap: 4px;
  align-items: center;
  font-size: 12px;
  color: var(--text-primary);
}

/* Home indicator */
.phone-home-indicator {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 134px;
  height: 5px;
  background: var(--text-secondary);
  border-radius: 999px;
  z-index: 1000;
}

/* App container - the scrollable area */
.app-container {
  position: absolute;
  top: var(--safe-top);
  left: 0;
  right: 0;
  bottom: var(--safe-bottom);
  overflow: clip;
}

/* Screen Management */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg-primary);
  opacity: 0;
  transform: translateX(100%);
  transition: opacity var(--ease-page), transform var(--ease-page);
  -webkit-overflow-scrolling: touch;
}

.screen.active {
  opacity: 1;
  transform: translateX(0);
  z-index: 10;
}

.screen.exiting-left {
  opacity: 0;
  transform: translateX(-30%);
  z-index: 5;
}

.screen.exiting-right {
  opacity: 0;
  transform: translateX(30%);
  z-index: 5;
}

.screen.entering-fade {
  transform: translateX(0);
}

/* Once a fade-in screen loses .active, move it off-screen to prevent compositing glitches */
.screen.entering-fade:not(.active) {
  transform: translateX(100%);
}

/* Scrollbar hiding */
.screen::-webkit-scrollbar { display: none; }
.screen { -ms-overflow-style: none; scrollbar-width: none; }

/* Typography Classes */
.type-display { font-size: 28px; font-weight: 700; line-height: 34px; letter-spacing: -0.5px; text-wrap: balance; }
.type-h1 { font-size: 22px; font-weight: 700; line-height: 28px; letter-spacing: -0.3px; text-wrap: balance; }
.type-h2 { font-size: 18px; font-weight: 600; line-height: 24px; letter-spacing: -0.2px; text-wrap: balance; }
.type-h3 { font-size: 15px; font-weight: 600; line-height: 20px; text-wrap: balance; }
.type-body { font-size: 15px; font-weight: 400; line-height: 22px; }
.type-body-small { font-size: 13px; font-weight: 400; line-height: 18px; }
.type-label { font-size: 11px; font-weight: 600; line-height: 14px; letter-spacing: 0.5px; text-transform: uppercase; }
.type-price-large { font-size: 24px; font-weight: 700; line-height: 28px; letter-spacing: -0.3px; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.type-price-medium { font-size: 17px; font-weight: 600; line-height: 22px; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.type-price-small { font-size: 13px; font-weight: 500; line-height: 16px; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Color utility classes */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-bullish { color: var(--bullish); }
.text-bearish { color: var(--bearish); }
.text-caution { color: var(--caution); }
.text-accent { color: var(--accent); }

/* Loading shimmer */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: var(--bg-surface-raised);
  background-image: linear-gradient(90deg, transparent 0%, #FFFFFF08 50%, transparent 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite ease-in-out;
  border-radius: var(--radius-small);
}

/* Pulse animation */
@keyframes pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* Breathing animation */
@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.005); }
}

/* Fade in */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Slide up */
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Spin */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Reduced motion: disable animations for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .screen {
    transition: none;
  }
}
