* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

/* Telegram Animated Emoji Global Tokens */
.tg-emoji {
  display: inline-block;
  aspect-ratio: 1/1;
  object-fit: contain;
  vertical-align: middle;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.25));
}

@media (prefers-reduced-motion: reduce) {
  .tg-emoji {
    animation: none !important;
    transition: none !important;
  }
}

/* =========================================================
   Apple Color Emoji Integration (https://github.com/samuelngs/apple-emoji-ttf)
   ========================================================= */
@font-face {
  font-family: 'Apple Color Emoji';
  src: local('Apple Color Emoji'),
       local('AppleColorEmoji'),
       local('Apple Color Emoji-Linux'),
       local('AppleColorEmoji-Windows'),
       url('../fonts/AppleColorEmoji.ttf') format('truetype');
  font-display: swap;
}

.emoji, .tg-emoji-fallback {
  display: inline-block;
  vertical-align: middle;
  line-height: 1;
  font-family: var(--font-emoji);
  font-variant-emoji: emoji;
}

.apple-emoji {
  display: inline-block;
  vertical-align: middle;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}

.apple-emoji-flag {
  display: inline-block;
  vertical-align: -1px;
  line-height: 1;
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
  font-size: 1.1em;
  letter-spacing: normal;
  user-select: none;
  -webkit-user-select: none;
  margin-right: 4px;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--app-bg);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 16px;
  line-height: 1.4;
  overscroll-behavior: none;
  transition: background-color 0.25s ease, color 0.25s ease;
}

#app-root {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  height: 100dvh;
  position: relative;
  overflow: hidden;
  padding: 0;
}

/* App Header */
.app-header {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 20;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.brand-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

/* Screens */
.screens-container {
  flex: 1;
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  perspective: 1200px;
}

.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  opacity: 0;
  pointer-events: none;
  background: var(--app-bg);
  transform: translate3d(0, 0, 0);
  will-change: transform, opacity;
}

.screen.active {
  display: flex;
  opacity: 1;
  pointer-events: auto;
  transform: translate3d(0, 0, 0);
}

.screen.entering-right {
  display: flex;
  animation: screenSlideInRight var(--duration-screen) cubic-bezier(0.25, 1, 0.5, 1) forwards;
  z-index: 3;
}

.screen.entering-left {
  display: flex;
  animation: screenSlideInLeft var(--duration-screen) cubic-bezier(0.25, 1, 0.5, 1) forwards;
  z-index: 2;
}

.screen.leaving-left {
  display: flex;
  animation: screenSlideOutLeft var(--duration-screen) cubic-bezier(0.25, 1, 0.5, 1) forwards;
  z-index: 1;
}

.screen.leaving-right {
  display: flex;
  animation: screenSlideOutRight var(--duration-screen) cubic-bezier(0.25, 1, 0.5, 1) forwards;
  z-index: 3;
}

@keyframes screenSlideInRight {
  from {
    opacity: 1;
    transform: translate3d(100%, 0, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes screenSlideInLeft {
  from {
    opacity: 1;
    transform: translate3d(-24%, 0, 0) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}

@keyframes screenSlideOutLeft {
  from {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    opacity: 0.8;
    transform: translate3d(-24%, 0, 0) scale(0.98);
  }
}

@keyframes screenSlideOutRight {
  from {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
  to {
    opacity: 0;
    transform: translate3d(100%, 0, 0);
  }
}
