:root {
    --ink: #f8fafc;
    --muted: #94a3b8;
    --line: rgba(255, 255, 255, 0.1);
    --paper: rgba(30, 41, 59, 0.6);
    --solid: #1e293b;
    --accent: #6366f1;
    --accent-deep: #4f46e5;
    --danger: #fb7185;
    --bg: #0f172a;
    --shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.5);
}

/* Для светлой темы (если переключат) */
:root[data-theme="light"] {
    --ink: #0f172a;
    --muted: #64748b;
    --line: rgba(0, 0, 0, 0.08);
    --paper: rgba(255, 255, 255, 0.75);
    --solid: #ffffff;
    --accent: #4f46e5;
    --accent-deep: #4338ca;
    --danger: #e11d48;
    --bg: #f1f5f9;
    --shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg);
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(79, 70, 229, 0.15), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(236, 72, 153, 0.15), transparent 25%);
    background-attachment: fixed;
    color: var(--ink);
    transition: background 0.4s, color 0.3s;
    overflow-x: hidden;
}

.shell {
    width: min(100%, 600px);
    margin: auto;
    padding: 24px;
    position: relative;
    z-index: 1;
}

/* ЭКРАНЫ */
.screen {
    display: none;
    min-height: 100vh;
    align-content: center;
    width: 100%;
}

.screen.active {
    display: grid;
    gap: 16px;
    animation: screenFadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes screenFadeIn {
    from { opacity: 0; transform: translateY(20px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* КАРТОЧКИ */
.hero-card, .login-card, .leaderboard-card, .info div {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 24px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
}

.hero-card, .login-card { padding: 32px 24px; }

/* ТЕКСТ */
.brand, .eyebrow {
    margin: 0;
    color: var(--accent);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
.eyebrow { margin-top: 16px; margin-bottom: 8px; }

h1 {
    margin: 0;
    font-size: clamp(28px, 6vw, 40px);
    line-height: 1.1;
    letter-spacing: -0.03em;
    font-weight: 800;
}

.lead { margin: 16px 0 24px; color: var(--muted); font-size: 16px; line-height: 1.5; }
.muted { color: var(--muted); font-size: 14px; }

/* КНОПКИ */
button, .filePick, .big-btn {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; min-height: 54px; padding: 0 20px;
    border: none; border-radius: 16px; font: inherit; font-weight: 600; font-size: 16px;
    cursor: pointer; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); user-select: none;
}

.primary, .btn-modern {
    background: var(--accent); color: #fff; box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
}
.primary:active, .btn-modern:active { transform: scale(0.96); }

.secondary, .icon, .theme-toggle {
    background: var(--solid); color: var(--ink); border: 1px solid var(--line);
}
.theme-toggle { width: auto; min-height: 54px; border-radius: 16px; padding: 0 20px; }
.theme-toggle.compact { min-height: 44px; width: 44px; padding: 0; border-radius: 12px; }

/* FAQ */
.faq-card { margin-top: 32px; padding: 24px; background: var(--solid); border-radius: 20px; border: 1px solid var(--line); }
.faq-title { margin: 0 0 20px; font-size: 18px; color: var(--ink); }
.step-item { display: flex; align-items: center; margin-bottom: 12px; padding: 12px; background: var(--bg); border-radius: 12px; }
.step-number { background: var(--accent); color: #fff; min-width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 50%; font-weight: 700; margin-right: 16px; }
.step-text { font-size: 14px; color: var(--muted); line-height: 1.4; }
.step-text b { color: var(--ink); }

/* ФОРМЫ */
.stack { display: grid; gap: 16px; }
.stack label { font-weight: 600; font-size: 14px; color: var(--muted); }
input, textarea { width: 100%; margin-top: 8px; padding: 16px; background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 14px; font: inherit; transition: border 0.3s; }
input:focus, textarea:focus { outline: none; border-color: var(--accent); }

/* ТОП */
.leaderboard-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.leaderboard-header h3 { margin: 0; font-size: 16px; font-weight: 800; }
.my-rank { background: var(--accent); color: #fff; padding: 4px 12px; border-radius: 999px; font-weight: 800; font-size: 12px; }
.leaderboard-list { display: grid; gap: 12px; }
.leaderboard-row { display: flex; align-items: center; gap: 12px; width: 100%; }
.lb-place { width: 24px; font-weight: 800; color: var(--muted); text-align: center; font-size: 14px; }
.leaderboard-row.me .lb-place { color: var(--accent); }
.lb-name { flex: 1; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-bar-track { width: 60px; height: 8px; background: rgba(128,128,128,0.2); border-radius: 4px; flex-shrink: 0;}
.lb-bar-fill { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.lb-count { width: 20px; text-align: right; font-size: 14px; color: var(--accent); font-weight: bold;}

/* ИНФО БЛОКИ */
.info { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.info div { padding: 16px; }
.info span { color: var(--muted); font-size: 13px; display: block; margin-bottom: 4px;}
.info strong { font-size: 16px; display: block; }

/* ОБЩЕЕ */
.hidden { display: none !important; }
.back { width: auto; min-height: auto; padding: 0; background: transparent; color: var(--muted); justify-content: start; margin-bottom: 16px; box-shadow: none;}
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px;}
.top-actions { display: flex; gap: 8px; }
.actions { display: grid; gap: 12px; margin-top: 16px; }
.notice { border-left: 4px solid var(--danger); background: var(--paper); padding: 12px; border-radius: 12px; font-size: 14px;}

/* УТИЛИТЫ (Старые, чтобы не сломалось) */
.petal { display: none !important; }
.preview { width: 100%; border-radius: 20px; margin-top: 16px;}
/* ======= ТОСТЫ УВЕДОМЛЕНИЙ ======= */
.toast-container {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    pointer-events: none;
    width: 90%;
    max-width: 400px;
}

.toast {
    padding: 16px 24px;
    border-radius: 16px;
    font-weight: 700;
    font-size: 15px;
    color: #fff;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(12px);
    animation: toastIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    pointer-events: auto;
    cursor: pointer;
    width: 100%;
    text-align: center;
    transition: opacity 0.3s, transform 0.3s;
}

.toast.success, .toast.info {
    background: rgba(22, 163, 74, 0.95);
}

.toast.error {
    background: rgba(225, 29, 72, 0.95);
}

.toast.warning {
    background: rgba(234, 179, 8, 0.95);
}

.toast.hide {
    animation: toastOut 0.3s ease-in forwards;
}

@keyframes toastIn {
    0% { opacity: 0; transform: translateY(40px) scale(0.9); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-20px) scale(0.9); }
}