* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-bg: #2a3f54;
    --secondary-bg: #1a2836;
    --nav-bg: #141d26;
    --card-bg: #1e2d3d;
    --text-color: #ffffff;
    --text-muted: #8b9cb5;
    --accent-color: #3498db;
    --nav-height: 70px;
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(180deg, var(--primary-bg) 0%, var(--secondary-bg) 100%);
    color: var(--text-color);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-width: 100%;
    overflow: hidden;
}

/* Основной контент */
.content {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    padding-bottom: calc(var(--nav-height) + 20px + var(--safe-area-bottom));
}

/* Страницы */
.page {
    display: none;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.page h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 12px;
}

.page p {
    color: var(--text-muted);
    font-size: 14px;
}

/* ========== ПРОФИЛЬ ========== */

/* Карточка профиля (верхний блок) */
.profile-card {
    background-color: var(--card-bg);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
    position: relative;
}

.profile-card-left {
    flex-shrink: 0;
}

.avatar-wrapper {
    position: relative;
    width: 100px;
    height: 100px;
}

.avatar {
    width: 100%;
    height: 100%;
    border-radius: 12px;
    background: linear-gradient(135deg, #3a4a5c, #2a3a4c);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.1);
    transition: border-color 0.2s;
}

.avatar:hover {
    border-color: rgba(255, 255, 255, 0.3);
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.rank-badge {
    position: absolute;
    bottom: -6px;
    left: -6px;
    background: var(--accent-color);
    color: white;
    font-size: 10px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 6px;
    white-space: nowrap;
}

.faceit-level {
    position: absolute;
    bottom: -6px;
    right: -6px;
    width: 28px;
    height: 28px;
    background: #e74c3c;
    color: white;
    font-size: 14px;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-card-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.profile-info {
    flex: 1;
}

.nickname {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 4px;
    cursor: pointer;
    transition: color 0.2s;
}

.nickname:hover {
    color: var(--accent-color);
}

.team-name {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.user-role {
    font-size: 13px;
    color: var(--text-muted);
}

.settings-btn {
    position: absolute;
    bottom: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 6px;
    border-radius: 8px;
    transition: all 0.2s;
}

.settings-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
}

.settings-btn svg {
    width: 100%;
    height: 100%;
}

/* Карточка статистики (средний блок) */
.stats-card {
    background-color: var(--card-bg);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 12px;
}

.stats-placeholder {
    text-align: center;
    padding: 30px 20px;
}

.stats-placeholder p {
    margin-bottom: 16px;
    color: var(--text-muted);
}

.link-faceit-btn {
    background: linear-gradient(135deg, #ff5500, #e64a00);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.link-faceit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 85, 0, 0.4);
}

.link-faceit-btn:active {
    transform: scale(0.98);
}

.stats-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.stat-icon {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    flex-shrink: 0;
}

.stat-value {
    font-size: 15px;
    font-weight: 500;
    min-width: 140px;
}

.stat-bar {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.stat-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease, background-color 0.3s;
}

/* Цвета статистики */
.stat-bar-fill.bad {
    background: linear-gradient(90deg, #e74c3c, #c0392b);
}

.stat-bar-fill.average {
    background: linear-gradient(90deg, #f1c40f, #f39c12);
}

.stat-bar-fill.good {
    background: linear-gradient(90deg, #2ecc71, #27ae60);
}

.stat-bar-fill.empty {
    background: rgba(255, 255, 255, 0.15);
}

/* Карточка трофеев (нижний блок) */
.trophies-card {
    background-color: var(--card-bg);
    border-radius: 16px;
    padding: 20px;
}

.trophies-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
}

.trophies-list {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.trophies-list::-webkit-scrollbar {
    height: 4px;
}

.trophies-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.trophy-item {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.trophy-item:hover {
    transform: scale(1.05);
}

.trophy-item.empty {
    border: 2px dashed rgba(255, 255, 255, 0.2);
    background: transparent;
}

.trophy-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 8px;
}

/* Нижняя навигация */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--nav-height) + var(--safe-area-bottom));
    padding-bottom: var(--safe-area-bottom);
    background-color: var(--nav-bg);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 12px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    min-width: 64px;
}

.nav-btn:active {
    transform: scale(0.95);
}

.nav-btn.active {
    color: var(--text-color);
}

.nav-icon {
    width: 24px;
    height: 24px;
}

.nav-btn span {
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}

/* Скроллбар для контента */
.content::-webkit-scrollbar {
    width: 4px;
}

.content::-webkit-scrollbar-track {
    background: transparent;
}

.content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

/* Безопасные области для мобильных устройств */
@supports (padding: max(0px)) {
    .bottom-nav {
        padding-bottom: max(var(--safe-area-bottom), 0px);
    }
}

/* ========== МОДАЛЬНЫЕ ОКНА ========== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    animation: modalFadeIn 0.2s ease;
}

.modal-overlay.closing {
    animation: modalFadeOut 0.2s ease forwards;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes modalFadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

.modal-content {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 24px;
    width: 100%;
    max-width: 320px;
    animation: modalSlideIn 0.2s ease;
}

.modal-overlay.closing .modal-content {
    animation: modalSlideOut 0.2s ease forwards;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes modalSlideOut {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(20px);
        opacity: 0;
    }
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    text-align: center;
}

.modal-description {
    font-size: 14px;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 20px;
}

.modal-input {
    width: 100%;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: var(--text-color);
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
}

.modal-input:focus {
    border-color: var(--accent-color);
}

.modal-input.error {
    border-color: #e74c3c;
}

.modal-input::placeholder {
    color: var(--text-muted);
}

.modal-error {
    color: #e74c3c;
    font-size: 13px;
    min-height: 20px;
    margin-top: 8px;
    text-align: center;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.modal-btn {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-btn:active {
    transform: scale(0.98);
}

.modal-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.modal-btn-cancel {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
}

.modal-btn-cancel:hover {
    background: rgba(255, 255, 255, 0.15);
}

.modal-btn-primary {
    background: linear-gradient(135deg, #ff5500, #e64a00);
    color: white;
}

.modal-btn-primary:hover {
    box-shadow: 0 4px 12px rgba(255, 85, 0, 0.4);
}

/* Увеличенное модальное окно для настроек */
.modal-content-large {
    max-width: 360px;
}

/* Секции настроек */
.settings-section {
    margin-bottom: 16px;
}

.settings-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.settings-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.settings-input-row .modal-input {
    flex: 1;
}

.settings-status {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.settings-status.connected {
    color: #2ecc71;
}

/* ========== СТРАНИЦА КОМАНДЫ ========== */

/* Экран "Нет команды" */
.no-team {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px;
    text-align: center;
}

.welcome-title {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 16px;
}

.welcome-text {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 40px;
}

.create-team-card {
    width: 100%;
    max-width: 280px;
    background: linear-gradient(135deg, #1a2836 0%, #2a3f54 100%);
    border-radius: 20px;
    padding: 40px 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.create-team-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.create-team-card:active {
    transform: scale(0.98);
}

.create-team-icon {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

.create-team-icon svg {
    width: 40px;
    height: 40px;
    color: var(--text-muted);
}

.create-team-text {
    font-size: 18px;
    font-weight: 600;
}

/* Экран "Есть команда" */
.has-team {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Шапка команды */
.team-header-card {
    background-color: var(--card-bg);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    gap: 16px;
    position: relative;
}

.team-logo {
    width: 80px;
    height: 80px;
    border-radius: 12px;
    background: linear-gradient(135deg, #3a4a5c, #2a3a4c);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
    color: var(--text-muted);
    flex-shrink: 0;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.team-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.team-header-info {
    flex: 1;
    min-width: 0;
}

.team-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
}

.team-info-block {
    margin-top: 4px;
}

.team-info-label {
    font-size: 14px;
    font-weight: 600;
    display: block;
    margin-bottom: 4px;
}

.team-description {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

.team-rank-badge {
    position: absolute;
    bottom: 12px;
    left: 24px;
    background: var(--accent-color);
    color: white;
    font-size: 10px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 6px;
}

/* Карточка с участниками */
.team-members-card {
    background-color: var(--card-bg);
    border-radius: 16px;
    padding: 20px;
}

.team-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.team-grid.collapsed .team-slot:nth-child(n+7) {
    display: none;
}

/* Слот участника */
.team-slot {
    aspect-ratio: 1;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
    overflow: hidden;
    border: 2px solid transparent;
}

.team-slot:hover {
    background: rgba(255, 255, 255, 0.08);
}

.team-slot:active {
    transform: scale(0.97);
}

/* Пустой слот */
.team-slot.empty {
    border: 2px dashed rgba(255, 255, 255, 0.15);
    background: transparent;
    justify-content: center;
}

.team-slot.empty .slot-add-icon {
    width: 32px;
    height: 32px;
    color: rgba(255, 255, 255, 0.3);
}

.team-slot.empty:hover {
    border-color: rgba(255, 255, 255, 0.3);
}

.team-slot.empty:hover .slot-add-icon {
    color: rgba(255, 255, 255, 0.5);
}

/* Заполненный слот */
.team-slot.filled {
    padding: 8px;
}

.slot-avatar {
    width: 100%;
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 6px;
    overflow: hidden;
}

.slot-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.slot-avatar span {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-muted);
}

.slot-info {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
}

.slot-name {
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.slot-role {
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Кнопка показать больше */
.show-more-btn {
    width: 100%;
    padding: 14px;
    margin-top: 16px;
    background: transparent;
    border: none;
    color: var(--accent-color);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s;
}

.show-more-btn:hover {
    color: #5dade2;
}

.show-more-btn:active {
    transform: scale(0.98);
}

/* ========== ДОПОЛНИТЕЛЬНЫЕ СТИЛИ МОДАЛОК ========== */

/* Список действий */
.modal-actions-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 20px 0;
}

.modal-action-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    border-radius: 10px;
    color: var(--text-color);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-action-btn svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.modal-action-btn:hover {
    background: rgba(255, 255, 255, 0.12);
}

.modal-action-btn:active {
    transform: scale(0.98);
}

.modal-action-btn.modal-action-danger {
    color: #e74c3c;
}

.modal-action-btn.modal-action-danger:hover {
    background: rgba(231, 76, 60, 0.15);
}

/* Кнопка на всю ширину */
.modal-btn-full {
    width: 100%;
    margin-top: 8px;
}

/* Select стили */
.modal-select {
    width: 100%;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: var(--text-color);
    font-size: 16px;
    outline: none;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%238b9cb5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 18px;
}

.modal-select:focus {
    border-color: var(--accent-color);
}

.modal-select option {
    background: var(--card-bg);
    color: var(--text-color);
}

/* Подсказка в модалке */
.modal-hint {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    margin-top: 8px;
}

/* Textarea */
.modal-textarea {
    min-height: 80px;
    resize: vertical;
    font-family: inherit;
}

/* Профиль игрока в модалке */
.player-profile-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.player-avatar {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.player-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.player-avatar span {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-muted);
}

.player-info {
    flex: 1;
}

.player-name {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
}

.player-role {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.player-faceit-level {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    color: white;
}

.player-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.player-stat {
    background: rgba(255, 255, 255, 0.08);
    padding: 12px;
    border-radius: 10px;
    text-align: center;
    font-size: 14px;
}

.player-stat span {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.player-no-stats {
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    padding: 20px;
}
