/* ============================================
   LANGY — GLOBAL STYLES
   Reset, typography, base utilities
   ============================================ */

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font);
    font-size: var(--fs-base);
    font-weight: var(--fw-regular);
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
    overflow-x: hidden;
    min-height: 100vh;
    min-height: 100dvh;
    transition: background-color 0.4s var(--ease-out), color 0.4s var(--ease-out);
}

*, *::before, *::after {
    transition: background-color 0.4s var(--ease-out), border-color 0.4s var(--ease-out), outline-color 0.4s var(--ease-out), box-shadow 0.4s var(--ease-out);
}


#app {
    width: 100%;
    max-width: var(--app-max-width);
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    position: relative;
    overflow: hidden;
    background: var(--bg);
}

#screen-container {
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    position: relative;
}

/* ---- Screen base ---- */
.screen {
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    padding: var(--sp-6);
    padding-bottom: calc(var(--sp-8) + var(--safe-bottom));
    display: flex;
    flex-direction: column;
}

.screen--no-pad {
    padding: 0;
}

.screen--center {
    justify-content: center;
    align-items: center;
}

/* ---- Typography ---- */
h1, h2, h3, h4, h5, h6 {
    font-weight: var(--fw-bold);
    line-height: 1.2;
    color: var(--text);
}

h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }

p { line-height: 1.6; }

.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-primary { color: var(--primary); }
.text-accent { color: var(--accent-dark); }
.text-center { text-align: center; }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.text-md { font-size: var(--fs-md); }
.text-lg { font-size: var(--fs-lg); }

/* ---- Links ---- */
a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--duration-fast) var(--ease-out);
}
a:hover { color: var(--primary-dark); }

/* ---- Images ---- */
img, svg { display: block; max-width: 100%; }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius-full);
}

/* ---- Selection ---- */
::selection {
    background: var(--primary);
    color: var(--text-inverse);
}

/* ---- Utilities ---- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.gap-6 { gap: var(--sp-6); }
.gap-8 { gap: var(--sp-8); }
.w-full { width: 100%; }
.relative { position: relative; }
.overflow-hidden { overflow: hidden; }
.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }

/* ---- Animations ---- */
@keyframes screenFadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

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

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

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-24px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-24px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(24px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.9); }
    to   { opacity: 1; transform: scale(1); }
}

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

@keyframes glow {
    0%, 100% { box-shadow: 0 0 8px rgba(16, 185, 129, 0.3); }
    50%      { box-shadow: 0 0 24px rgba(16, 185, 129, 0.6); }
}

@keyframes glowGold {
    0%, 100% { box-shadow: 0 0 8px rgba(245, 158, 11, 0.3); }
    50%      { box-shadow: 0 0 24px rgba(245, 158, 11, 0.6); }
}

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

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

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

@keyframes countUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes flyOut {
    to { opacity: 0; transform: scale(0.5) translateX(var(--fly-x, 100px)); }
}

@keyframes streakFire {
    0%, 100% { transform: scaleY(1) scaleX(1); opacity: 1; }
    25% { transform: scaleY(1.2) scaleX(0.9); }
    50% { transform: scaleY(0.9) scaleX(1.1); opacity: 0.8; }
    75% { transform: scaleY(1.1) scaleX(0.95); }
}

@keyframes ripple {
    0% { transform: scale(0); opacity: 0.5; }
    100% { transform: scale(4); opacity: 0; }
}

.animate-delay-1 { animation-delay: 100ms; }
.animate-delay-2 { animation-delay: 200ms; }
.animate-delay-3 { animation-delay: 300ms; }
.animate-delay-4 { animation-delay: 400ms; }
.animate-delay-5 { animation-delay: 500ms; }

/* ---- Overlay ---- */
.overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: var(--z-overlay);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: fadeIn var(--duration-normal) var(--ease-out);
}

.overlay__sheet {
    width: 100%;
    max-width: var(--app-max-width);
    max-height: 90vh;
    background: var(--surface);
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    padding: var(--sp-6);
    padding-bottom: calc(var(--sp-8) + var(--safe-bottom));
    overflow-y: auto;
    animation: slideUp var(--duration-slow) var(--ease-spring);
}

.overlay__handle {
    width: 40px;
    height: 4px;
    background: var(--border);
    border-radius: var(--radius-full);
    margin: 0 auto var(--sp-5);
}

/* ---- Animate In (Widget Entry) ---- */
.animate-in {
    animation: slideUp 0.4s var(--ease-out) forwards;
}

/* ---- AI Loader ---- */
.ai-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--sp-4);
}

.ai-loader__orb {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    animation: aiPulse 1.5s ease-in-out infinite;
}

@keyframes aiPulse {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.3); opacity: 1; box-shadow: 0 0 30px rgba(16, 185, 129, 0.5); }
}

/* ---- Scroll Y ---- */
.scroll-y {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ---- Circle Button (base) ---- */
.circle-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s;
    user-select: none;
}

.circle-btn:hover {
    border-color: var(--primary);
    transform: scale(1.05);
}

.circle-btn:active {
    transform: scale(0.95);
}

