/* Минималистичный дизайн в стиле "Башня Вампирра" */

/* Подключение шрифта PsyType */
@font-face {
    font-family: 'PsyType';
    src: url('/static/PsyType.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

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

/* Плавная прокрутка для элементов с прокруткой */
html {
    scroll-behavior: smooth;
}

/* Для элементов с overflow-y: auto добавляем дополнительные свойства плавности */
[style*="overflow-y: auto"],
[style*="overflow-y: scroll"] {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

:root {
    /* Цветовая палитра из дизайна заведения */
    --bg-primary: #0a0a0a;           /* Черный фон */
    --bg-secondary: #1a1a1a;         /* Темно-серый для карточек */
    --bg-accent: #2d1b3d;            /* Темно-фиолетовый */
    --red-primary: #8B0000;          /* Темно-красный (основной акцент) */
    --red-accent: #A52A2A;           /* Бордовый */
    --gold-primary: #D4AF37;         /* Золотой */
    --gold-light: #FFD700;           /* Светло-золотой */
    --text-primary: #eaeaea;         /* Белый текст */
    --text-secondary: #999;          /* Серый текст */
    --border-color: rgba(255, 255, 255, 0.1);
    --success-color: #4caf50;
    --error-color: #d32f2f;
    --notification-bg: var(--bg-secondary);
    --notification-border: var(--red-primary);
    --notification-shadow: rgba(139, 0, 0, 0.3);
}

html {
    height: 100%;
    overflow-x: hidden;
    overflow-y: hidden;
    margin: 0;
    padding: 0;
    width: 100%;
    max-width: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
    overflow-y: hidden;
    height: 100vh;
    height: 100dvh; /* Динамическая высота viewport для мобильных */
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

#app {
    height: 100%;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: hidden;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Экран входа */
.screen {
    display: none;
}

.screen.active {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    overflow-x: hidden;
    overflow-y: hidden;
    position: relative;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

#login-screen.active {
    background: var(--bg-primary);
}

#main-screen.active {
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    overflow-x: hidden;
    overflow-y: hidden;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.login-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow-x: hidden;
    overflow-y: auto;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    min-height: 0; /* Важно для flex-контейнера */
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.login-card {
    background: var(--bg-secondary);
    padding: clamp(24px, 5vh, 40px) clamp(20px, 4vw, 40px);
    border-radius: 12px;
    max-width: 420px;
    width: 100%;
    text-align: center;
    border: 1px solid var(--border-color);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-header {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: clamp(12px, 2vh, 20px);
}

.login-card h1 {
    font-size: clamp(24px, 6vw, 32px);
    margin: 0;
    color: var(--red-primary);
    font-weight: 600;
    letter-spacing: -0.5px;
    line-height: 1.2;
}

.login-card > p {
    margin: clamp(12px, 2vh, 20px) 0;
    font-size: clamp(13px, 3vw, 15px);
}

#telegram-login-container {
    margin: clamp(16px, 3vh, 30px) 0;
    display: flex;
    justify-content: center;
    min-height: 48px;
}

.login-footer {
    margin-top: clamp(24px, 4vh, 40px);
    text-align: center;
    padding-top: clamp(16px, 3vh, 24px);
    border-top: 1px solid var(--border-color);
}

.login-tagline {
    font-family: 'PsyType', sans-serif;
    font-size: clamp(18px, 4vw, 24px);
    color: var(--red-primary);
    margin: 0;
    letter-spacing: 1px;
}

.error-message {
    color: var(--error-color);
    margin-top: 20px;
    padding: 12px;
    background: rgba(211, 47, 47, 0.1);
    border-radius: 8px;
    display: none;
    border: 1px solid rgba(211, 47, 47, 0.3);
    font-size: 14px;
}

.error-message.show {
    display: block;
}

/* Заголовок */
.header {
    background: var(--bg-secondary);
    padding: clamp(10px, 1.5vh, 16px) clamp(12px, 3vw, 24px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

.header-user {
    display: flex;
    align-items: center;
    gap: clamp(8px, 2vw, 12px);
    min-width: 0;
    flex: 1;
}

.user-avatar {
    width: clamp(36px, 8vw, 44px);
    height: clamp(36px, 8vw, 44px);
    border-radius: 50%;
    border: 2px solid var(--red-primary);
    object-fit: cover;
    flex-shrink: 0;
}

.user-info {
    min-width: 0;
    flex: 1;
}

.user-info h2 {
    font-size: clamp(14px, 3.5vw, 16px);
    margin-bottom: 2px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: clamp(10px, 2.5vw, 11px);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Кнопка с иконкой */
.btn-icon {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
}

.btn-icon:hover {
    background: var(--bg-accent);
    border-color: var(--red-primary);
    color: var(--red-primary);
}

/* Иконка QR-кода */
.qr-code-icon {
    position: relative;
    width: 40px;
    height: 40px;
    padding: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23eaeaea'%3E%3Cpath d='M3 3h8v8H3V3zm2 2v4h4V5H5zm8-2h8v8h-8V3zm2 2v4h4V5h-4zM3 13h8v8H3v-8zm2 2v4h4v-4H5zm13-2h3v2h-3v-2zm0 4h3v2h-3v-2zm-2-4h2v2h-2v-2zm2 4h2v2h-2v-2zm-2 2h2v2h-2v-2zm-2-2h2v2h-2v-2zm2-2h2v2h-2v-2zm-2 0h2v2h-2v-2zm-2-2h2v2h-2v-2z'/%3E%3C/svg%3E");
    background-size: 24px 24px;
    background-position: center;
    background-repeat: no-repeat;
    transition: all 0.3s ease;
}

.qr-code-icon:hover {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%238B0000'%3E%3Cpath d='M3 3h8v8H3V3zm2 2v4h4V5H5zm8-2h8v8h-8V3zm2 2v4h4V5h-4zM3 13h8v8H3v-8zm2 2v4h4v-4H5zm13-2h3v2h-3v-2zm0 4h3v2h-3v-2zm-2-4h2v2h-2v-2zm2 4h2v2h-2v-2zm-2 2h2v2h-2v-2zm-2-2h2v2h-2v-2zm2-2h2v2h-2v-2zm-2 0h2v2h-2v-2zm-2-2h2v2h-2v-2z'/%3E%3C/svg%3E");
}

/* Навигация */
.tabs {
    display: flex;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1001; /* Выше модального окна, чтобы всегда быть видимым */
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 0;
    padding-bottom: max(0px, env(safe-area-inset-bottom)); /* Только если есть безопасная зона */
    flex-shrink: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.tab-btn {
    flex: 1;
    padding: clamp(10px, 2vh, 16px) clamp(4px, 1vw, 8px);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: clamp(20px, 5vw, 24px);
    transition: all 0.2s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: clamp(52px, 12vh, 64px);
    border-top: 2px solid transparent;
    touch-action: manipulation;
}

.tab-btn.active {
    border-top-color: var(--red-primary);
    color: var(--red-primary);
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(139, 0, 0, 0.05);
}

/* Контент */
.content {
    flex: 1;
    padding: clamp(12px, 2vh, 24px);
    padding-bottom: clamp(80px, 18vh, 100px); /* Отступ снизу для фиксированного меню */
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    min-height: 0; /* Важно для flex-контейнера */
    box-sizing: border-box;
}

/* Вкладка календаря */
#tab-calendar {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
    position: relative;
}

#tab-calendar > * {
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
    width: 100%;
}

.tab-content {
    display: none;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
    position: relative;
}

.tab-content.active {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

/* Профиль */
.profile-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: clamp(16px, 3vh, 32px);
    border: 1px solid var(--border-color);
}

.profile-header {
    display: flex;
    align-items: center;
    gap: clamp(12px, 3vw, 20px);
    margin-bottom: clamp(16px, 3vh, 32px);
    padding-bottom: clamp(12px, 2vh, 24px);
    border-bottom: 1px solid var(--border-color);
}

.profile-avatar-large {
    width: clamp(56px, 12vw, 72px);
    height: clamp(56px, 12vw, 72px);
    border-radius: 50%;
    border: 2px solid var(--red-primary);
    object-fit: cover;
    flex-shrink: 0;
}

.profile-card-number {
    color: var(--text-secondary);
    font-size: clamp(11px, 2.5vw, 13px);
    margin-top: 4px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(140px, calc(50% - 8px)), 1fr));
    gap: clamp(8px, 2vw, 16px);
    margin-bottom: clamp(16px, 3vh, 32px);
}

.stat-card {
    background: var(--bg-primary);
    padding: clamp(12px, 2.5vh, 20px);
    border-radius: 8px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.stat-label {
    font-size: clamp(10px, 2.5vw, 11px);
    color: var(--text-secondary);
    margin-bottom: clamp(4px, 1vh, 8px);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: clamp(20px, 5vw, 28px);
    font-weight: 600;
    color: var(--gold-primary);
    line-height: 1.2;
}

.currency-section {
    margin-top: clamp(16px, 3vh, 32px);
    padding-top: clamp(12px, 2vh, 24px);
    border-top: 1px solid var(--border-color);
}

.currency-section h4 {
    margin-bottom: clamp(8px, 2vh, 16px);
    font-size: clamp(14px, 3.5vw, 16px);
    font-weight: 500;
    color: var(--text-primary);
}

.currency-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(140px, calc(50% - 8px)), 1fr));
    gap: clamp(8px, 2vw, 16px);
}

.currency-card {
    background: var(--bg-primary);
    padding: clamp(12px, 2.5vh, 20px);
    border-radius: 8px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.currency-label {
    font-size: clamp(11px, 2.5vw, 13px);
    margin-bottom: clamp(4px, 1vh, 8px);
    color: var(--text-secondary);
}

.currency-value {
    font-size: clamp(20px, 5vw, 28px);
    font-weight: 600;
    color: var(--gold-primary);
    line-height: 1.2;
}

/* Игры */
.games-list {
    display: grid;
    gap: clamp(8px, 2vh, 12px);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding-bottom: clamp(20px, 4vh, 40px); /* Отступ снизу для последней карточки */
}

.game-card {
    background: var(--bg-secondary);
    padding: clamp(12px, 2.5vh, 20px);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s;
    touch-action: manipulation;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    word-wrap: break-word;
    overflow-wrap: break-word;
    overflow-x: hidden;
}

.game-card:hover {
    border-color: var(--red-primary);
    background: rgba(139, 0, 0, 0.05);
}

.game-card:active {
    transform: scale(0.98);
}

.game-card h3 {
    margin-bottom: clamp(4px, 1vh, 8px);
    font-size: clamp(16px, 4vw, 18px);
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.3;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.game-card p {
    margin: clamp(2px, 0.5vh, 4px) 0;
    font-size: clamp(12px, 3vw, 13px);
    color: var(--text-secondary);
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.game-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    margin-top: 12px;
    max-width: 100%;
    box-sizing: border-box;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.game-badge.closed {
    background: rgba(211, 47, 47, 0.15);
    color: var(--error-color);
    border: 1px solid rgba(211, 47, 47, 0.3);
}

.game-badge.open {
    background: rgba(76, 175, 80, 0.15);
    color: var(--success-color);
    border: 1px solid rgba(76, 175, 80, 0.3);
}

/* Календарь */
.calendar-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: clamp(12px, 2vh, 16px);
    padding: clamp(8px, 1.5vh, 12px);
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

.calendar-controls button {
    min-width: clamp(36px, 8vw, 44px);
    min-height: clamp(36px, 8vw, 44px);
    max-width: 100%;
    padding: 0;
    font-size: clamp(16px, 4vw, 20px);
    box-sizing: border-box;
    flex-shrink: 0;
}

#calendar-container {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: clamp(2px, 0.5vw, 6px);
    margin-bottom: clamp(12px, 2vh, 16px);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

.calendar-day {
    aspect-ratio: 1;
    padding: clamp(4px, 1vh, 10px);
    background: var(--bg-secondary);
    border-radius: 6px;
    text-align: center;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s;
    font-size: clamp(11px, 2.5vw, 13px);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    min-height: 0;
    min-width: 0;
    max-width: 100%;
    touch-action: manipulation;
    box-sizing: border-box;
    word-wrap: break-word;
    overflow-wrap: break-word;
    overflow: hidden;
}

.calendar-day:hover,
.calendar-day:active {
    border-color: var(--red-primary);
    background: rgba(139, 0, 0, 0.05);
}

.calendar-day.has-games {
    border-color: var(--red-primary);
    background: rgba(139, 0, 0, 0.1);
    color: var(--red-primary);
    font-weight: 500;
}

.calendar-day.has-games:hover,
.calendar-day.has-games:active {
    background: rgba(139, 0, 0, 0.15);
}

.calendar-day.today {
    border: 2px solid var(--gold-primary);
    background: rgba(212, 175, 55, 0.15);
    font-weight: 600;
    color: var(--gold-primary);
}

.calendar-day.today.has-games {
    border-color: var(--gold-primary);
    background: rgba(212, 175, 55, 0.2);
    color: var(--gold-primary);
}

.calendar-day.today:hover,
.calendar-day.today:active {
    background: rgba(212, 175, 55, 0.25);
}

.calendar-day.past {
    opacity: 0.5;
    cursor: default;
}

.calendar-day.past:hover {
    border-color: var(--border-color);
    background: var(--bg-secondary);
}

.calendar-day small {
    font-size: clamp(8px, 2vw, 10px);
    margin-top: clamp(2px, 0.5vh, 4px);
    line-height: 1.2;
    display: block;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    text-align: center;
}

.calendar-day-header {
    text-align: center;
    padding: clamp(8px, 1.5vh, 12px);
    font-weight: 500;
    color: var(--text-secondary);
    font-size: clamp(10px, 2.5vw, 12px);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Таймер */
.time-tracker {
    text-align: center;
    padding: clamp(24px, 5vh, 48px) clamp(12px, 3vw, 20px);
    min-height: calc(100vh - 200px);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.time-status {
    margin-bottom: clamp(24px, 5vh, 48px);
}

.time-display {
    font-size: clamp(40px, 12vw, 64px);
    font-weight: 600;
    margin-bottom: clamp(8px, 1.5vh, 12px);
    color: var(--gold-primary);
    letter-spacing: -2px;
    line-height: 1.1;
}

.time-mode {
    font-size: clamp(12px, 3vw, 14px);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.time-controls {
    display: flex;
    flex-direction: column;
    gap: clamp(8px, 2vh, 12px);
    max-width: min(280px, 90vw);
    margin: 0 auto;
    width: 100%;
}

/* Мастер */
.master-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

/* Кнопки */
.btn {
    padding: clamp(10px, 2.5vh, 12px) clamp(16px, 4vw, 24px);
    border: none;
    border-radius: 6px;
    font-size: clamp(14px, 3.5vw, 15px);
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    touch-action: manipulation;
    min-height: 44px; /* Минимальный размер для удобного нажатия */
    box-sizing: border-box;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
}

.btn-primary {
    background: var(--red-primary);
    color: white;
    width: 100%;
    max-width: 100%;
}

.btn-primary:hover {
    background: var(--red-accent);
}

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-primary);
    border-color: var(--red-primary);
    color: var(--red-primary);
}

.btn-danger {
    background: var(--error-color);
    color: white;
}

.btn-danger:hover {
    background: #b71c1c;
}

/* Формы */
.form-group {
    margin-bottom: 20px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 14px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    max-width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 15px;
    box-sizing: border-box;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--red-primary);
}

/* Модальные окна */
.modal {
    display: none;
    position: fixed;
    z-index: 1000; /* Ниже нижнего меню (1001), чтобы меню всегда было доступно */
    left: 0;
    top: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100%;
    /* Оставляем место для нижнего меню (примерно 70px + safe-area) */
    padding-bottom: calc(clamp(52px, 12vh, 64px) + max(0px, env(safe-area-inset-bottom)) + clamp(20px, 4vh, 40px));
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    overflow-x: hidden !important;
    overflow-y: auto;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    padding-left: clamp(10px, 2vw, 20px);
    padding-right: clamp(10px, 2vw, 20px);
    padding-top: clamp(10px, 2vh, 20px);
    box-sizing: border-box;
}

.modal.active {
    display: block;
}

.modal-content {
    background: var(--bg-secondary);
    margin: 0 auto;
    margin-bottom: calc(clamp(52px, 12vh, 64px) + max(0px, env(safe-area-inset-bottom)) + clamp(24px, 5vh, 48px)); /* Отступ снизу для меню + дополнительный отступ */
    padding: clamp(16px, 3vw, 32px);
    border-radius: 12px;
    max-width: 600px;
    width: 100%;
    max-width: calc(100vw - clamp(20px, 4vw, 40px)); /* Учитываем padding модального окна */
    position: relative;
    /* Ограничиваем высоту с учетом нижнего меню и padding */
    max-height: calc(100vh - clamp(52px, 12vh, 64px) - max(0px, env(safe-area-inset-bottom)) - clamp(48px, 10vh, 96px));
    overflow-x: hidden !important;
    overflow-y: auto;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    border: 1px solid var(--border-color);
    box-sizing: border-box;
}

.modal-content * {
    max-width: 100%;
    box-sizing: border-box;
}

.modal-content p,
.modal-content label,
.modal-content div {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.close {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 24px;
    font-weight: 300;
    cursor: pointer;
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.close:hover {
    color: var(--text-primary);
    background: var(--bg-primary);
}

.modal-content h2 {
    margin-bottom: 24px;
    font-size: 22px;
    font-weight: 500;
    color: var(--text-primary);
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

/* Стили для QR кода */
#qr-code-container {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px auto;
    padding: 20px;
    background: white;
    border-radius: 10px;
    min-height: 300px;
    min-width: 300px;
    max-width: 100%;
    box-sizing: border-box;
}

#qr-code-container #qrcode {
    display: flex;
    align-items: center;
    justify-content: center;
}

#qr-code-container #qrcode canvas {
    max-width: 100%;
    height: auto;
}

/* Контейнеры для биометрии и push-уведомлений */
#push-notifications-controls,
#biometric-status,
#push-status {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

#push-notifications-controls button {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* HR элементы в модальных окнах */
.modal-content hr {
    max-width: 100%;
    box-sizing: border-box;
    margin-left: 0;
    margin-right: 0;
}

/* Все элементы внутри модального окна */
.modal-content > * {
    max-width: 100%;
    box-sizing: border-box;
}

/* Элементы внутри game-details */
#game-details {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

#game-details * {
    max-width: 100%;
    box-sizing: border-box;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

#game-details h2,
#game-details h3,
#game-details p {
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

/* Game card внутри модального окна */
#game-details .game-card {
    width: 100%;
    max-width: 100%;
    margin-bottom: 12px;
    box-sizing: border-box;
}

#game-details .game-card h3,
#game-details .game-card p {
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Контейнер со списком игр в модальном окне */
#game-details > div {
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden !important;
    overflow-y: auto;
    word-wrap: break-word;
    overflow-wrap: break-word;
    position: relative;
}

/* Принудительное скрытие горизонтальной прокрутки для основных контейнеров */
html, body {
    overflow-x: hidden !important;
    max-width: 100vw !important;
    width: 100% !important;
}

#app, .screen, .content, .tab-content, .modal, .modal-content {
    overflow-x: hidden !important;
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

/* Адаптивность */
@media (max-width: 768px) {
    body {
        font-size: 14px;
    }
    
    .login-card {
        padding: clamp(20px, 4vh, 32px) clamp(16px, 4vw, 24px);
        max-height: 95vh;
    }
    
    .login-card h1 {
        font-size: clamp(22px, 6vw, 28px);
        margin-bottom: clamp(8px, 1.5vh, 16px);
    }
    
    .header {
        padding: clamp(8px, 1.5vh, 12px) clamp(10px, 3vw, 16px);
    }
    
    .tabs {
        flex-wrap: nowrap;
    }
    
    .tab-btn {
        font-size: clamp(18px, 4.5vw, 22px);
        padding: clamp(10px, 2vh, 14px) clamp(4px, 1vw, 6px);
        min-height: clamp(52px, 12vh, 60px);
    }
    
    .content {
        padding: clamp(10px, 2vh, 16px);
        padding-bottom: clamp(10px, 2vh, 16px); /* Убираем лишний отступ снизу */
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: clamp(6px, 1.5vw, 12px);
    }
    
    .stat-card {
        padding: clamp(10px, 2vh, 16px);
    }
    
    .time-display {
        font-size: clamp(36px, 10vw, 48px);
    }
    
    .time-tracker {
        padding: clamp(16px, 3vh, 32px) clamp(10px, 2vw, 16px);
    }
    
    .modal {
        padding-left: clamp(8px, 2vw, 16px);
        padding-right: clamp(8px, 2vw, 16px);
        padding-top: clamp(8px, 2vh, 16px);
        padding-bottom: calc(clamp(52px, 12vh, 64px) + max(0px, env(safe-area-inset-bottom)) + clamp(24px, 5vh, 48px));
    }
    
    .modal-content {
        margin: 0 auto;
        margin-bottom: calc(clamp(52px, 12vh, 64px) + max(0px, env(safe-area-inset-bottom)) + clamp(24px, 5vh, 48px));
        padding: clamp(16px, 3vh, 24px);
        max-width: calc(100vw - clamp(16px, 4vw, 32px));
        max-height: calc(100vh - clamp(52px, 12vh, 64px) - max(0px, env(safe-area-inset-bottom)) - clamp(48px, 10vh, 96px));
        width: 100%;
    }
    
    .profile-header {
        flex-direction: column;
        text-align: center;
        gap: clamp(8px, 2vw, 12px);
    }
    
    .profile-card {
        padding: clamp(12px, 2.5vh, 20px);
    }
    
    .game-card {
        padding: clamp(10px, 2vh, 16px);
    }
    
    .currency-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: clamp(6px, 1.5vw, 12px);
    }
    
    .currency-card {
        padding: clamp(10px, 2vh, 16px);
    }
    
    .calendar-controls {
        padding: clamp(6px, 1vh, 10px);
        margin-bottom: clamp(8px, 1.5vh, 12px);
    }
    
    .calendar-controls button {
        min-width: clamp(32px, 7vw, 40px);
        min-height: clamp(32px, 7vw, 40px);
        font-size: clamp(14px, 3.5vw, 18px);
    }
    
    #calendar-container {
        gap: clamp(3px, 0.8vw, 6px);
    }
    
    .calendar-day {
        padding: clamp(4px, 1vh, 8px);
        font-size: clamp(11px, 2.8vw, 13px);
    }
    
    .calendar-day small {
        font-size: clamp(8px, 2vw, 10px);
        margin-top: clamp(1px, 0.3vh, 3px);
    }
    
    .calendar-day-header {
        padding: clamp(6px, 1vh, 10px);
        font-size: clamp(9px, 2.2vw, 11px);
    }
}

/* Очень маленькие экраны */
@media (max-width: 360px) {
    .stats-grid,
    .currency-grid {
        grid-template-columns: 1fr;
    }
    
    .tab-btn {
        font-size: 18px;
        min-height: 56px;
    }
}

/* Высокие экраны (ландшафт) */
@media (max-height: 500px) and (orientation: landscape) {
    .login-card {
        padding: clamp(12px, 2vh, 20px) clamp(16px, 4vw, 24px);
        max-height: 90vh;
    }
    
    .login-card h1 {
        font-size: clamp(20px, 4vw, 24px);
        margin-bottom: clamp(6px, 1vh, 12px);
    }
    
    #telegram-login-container {
        margin: clamp(8px, 1.5vh, 16px) 0;
    }
    
    .header {
        padding: clamp(6px, 1vh, 10px) clamp(10px, 3vw, 16px);
    }
    
    .tab-btn {
        min-height: clamp(48px, 10vh, 56px);
        padding: clamp(8px, 1.5vh, 12px) clamp(4px, 1vw, 6px);
    }
    
        .content {
            padding: clamp(8px, 1.5vh, 12px);
            padding-bottom: clamp(8px, 1.5vh, 12px); /* Убираем лишний отступ снизу */
        }
    
    .time-tracker {
        padding: clamp(12px, 2vh, 24px) clamp(10px, 2vw, 16px);
    }
    
    .time-display {
        font-size: clamp(32px, 8vw, 40px);
    }
}

/* Загрузка */
.loading {
    text-align: center;
    padding: 48px;
    color: var(--text-secondary);
}

.empty-state {
    text-align: center;
    padding: 48px;
    color: var(--text-secondary);
}

/* Кастомные уведомления */
#notifications-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 400px;
    width: calc(100% - 40px);
    pointer-events: none;
}

.notification {
    background: var(--notification-bg);
    border: 2px solid var(--notification-border);
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: 0 4px 20px var(--notification-shadow);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    pointer-events: auto;
    animation: slideInRight 0.3s ease-out;
    position: relative;
    overflow: hidden;
}

.notification::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--red-primary);
}

.notification.success {
    border-color: var(--success-color);
}

.notification.success::before {
    background: var(--success-color);
}

.notification.error {
    border-color: var(--error-color);
}

.notification.error::before {
    background: var(--error-color);
}

.notification-icon {
    font-size: 24px;
    flex-shrink: 0;
    margin-top: 2px;
}

.notification-content {
    flex: 1;
    min-width: 0;
}

.notification-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    line-height: 1.4;
}

.notification-body {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    word-wrap: break-word;
}

.notification-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.2s;
    margin-top: -2px;
    margin-right: -4px;
}

.notification-close:hover {
    color: var(--text-primary);
}

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

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.notification.hiding {
    animation: slideOutRight 0.3s ease-in forwards;
}

/* Адаптивность для уведомлений */
@media (max-width: 480px) {
    #notifications-container {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
        width: auto;
    }
    
    .notification {
        padding: 14px 16px;
    }
    
    .notification-title {
        font-size: 15px;
    }
    
    .notification-body {
        font-size: 13px;
    }
}

/* Кастомные модальные окна (замена alert, confirm, prompt) */
.custom-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.custom-modal.active {
    display: flex;
}

.custom-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
}

.custom-modal-content {
    position: relative;
    background: var(--bg-secondary);
    border: 2px solid var(--red-primary);
    border-radius: 16px;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 8px 32px rgba(139, 0, 0, 0.4);
    animation: modalSlideIn 0.3s ease-out;
    overflow: hidden;
}

@keyframes modalSlideIn {
    from {
        transform: scale(0.9) translateY(-20px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.custom-modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.custom-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.custom-modal-body {
    padding: 24px;
}

.custom-modal-body p {
    margin: 0;
    font-size: 16px;
    color: var(--text-primary);
    line-height: 1.5;
    word-wrap: break-word;
}

.custom-prompt-input {
    width: 100%;
    padding: 12px;
    margin-top: 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 16px;
    font-family: inherit;
    box-sizing: border-box;
}

.custom-prompt-input:focus {
    outline: none;
    border-color: var(--red-primary);
    box-shadow: 0 0 0 3px rgba(139, 0, 0, 0.2);
}

.custom-modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.custom-modal-footer .btn {
    min-width: 100px;
    padding: 10px 20px;
    font-size: 15px;
}

.custom-modal-footer .btn-secondary {
    background: var(--bg-accent);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.custom-modal-footer .btn-secondary:hover {
    background: var(--bg-primary);
    border-color: var(--red-primary);
}

/* Блокирующее модальное окно для установки PWA */
.pwa-install-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    z-index: 10000; /* Максимальный z-index для блокировки всего контента */
    overflow: hidden;
    padding: 20px;
    box-sizing: border-box;
}

.pwa-install-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}

.pwa-install-content {
    background: var(--bg-secondary);
    border: 2px solid var(--red-primary);
    border-radius: 16px;
    padding: 32px 24px;
    max-width: 500px;
    width: 100%;
    text-align: center;
    box-shadow: 0 8px 32px rgba(139, 0, 0, 0.4);
}

.pwa-install-icon {
    font-size: 64px;
    margin-bottom: 24px;
    animation: pulse 2s ease-in-out infinite;
}

.pwa-install-content h2 {
    color: var(--text-primary);
    font-size: 24px;
    margin-bottom: 16px;
    font-weight: 600;
}

.pwa-install-content > p {
    color: var(--text-secondary);
    font-size: 16px;
    line-height: 1.6;
    margin-bottom: 24px;
}

.pwa-install-instructions {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
    text-align: left;
}

.pwa-install-instructions ol {
    margin: 0;
    padding-left: 20px;
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.8;
}

.pwa-install-instructions li {
    margin-bottom: 12px;
}

.pwa-install-instructions li:last-child {
    margin-bottom: 0;
}

.pwa-install-instructions strong {
    color: var(--red-primary);
}

.pwa-install-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pwa-install-actions .btn {
    width: 100%;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
}

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

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

/* Адаптивность для модальных окон */
@media (max-width: 480px) {
    .custom-modal {
        padding: 10px;
    }
    
    .custom-modal-content {
        max-width: 100%;
    }
    
    .custom-modal-header,
    .custom-modal-body,
    .custom-modal-footer {
        padding: 16px;
    }
    
    .custom-modal-header h3 {
        font-size: 16px;
    }
    
    .custom-modal-body p {
        font-size: 15px;
    }
    
    .custom-modal-footer {
        flex-direction: column-reverse;
    }
    
    .custom-modal-footer .btn {
        width: 100%;
    }
    
    .pwa-install-content {
        padding: 24px 20px;
        max-width: 100%;
    }
    
    .pwa-install-content h2 {
        font-size: 20px;
    }
    
    .pwa-install-content > p {
        font-size: 15px;
    }
    
    .pwa-install-instructions {
        padding: 16px;
    }
    
    .pwa-install-instructions ol {
        font-size: 14px;
    }
}
