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

:root {
    --primary-color: #4CAF50;
    --secondary-color: #2196F3;
    --danger-color: #f44336;
    --info-color: #17a2b8;
    --dark-color: #333;
    --light-color: #f5f5f5;
    --border-radius: 10px;
    --box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    --transition: all 0.3s ease;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--dark-color);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 15px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
    padding: 0 10px;
}

header h1 {
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    margin-bottom: 10px;
    word-wrap: break-word;
}

header p {
    font-size: clamp(1rem, 2vw, 1.2rem);
    opacity: 0.9;
}

/* Cards */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.card {
    background: white;
    padding: clamp(20px, 4vw, 30px);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    text-align: center;
    transition: var(--transition);
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
}

.card h2 {
    margin-bottom: 15px;
    color: var(--dark-color);
    font-size: clamp(1.3rem, 3vw, 1.5rem);
}

.card p {
    margin-bottom: 20px;
    color: #666;
    font-size: clamp(0.9rem, 2vw, 1rem);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: clamp(10px, 2vw, 12px) clamp(16px, 3vw, 24px);
    margin: 8px 4px;
    border: none;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-size: clamp(0.8rem, 2vw, 0.9rem);
    min-height: 44px; /* Минимальная высота для тач-интерфейса */
    text-align: center;
    white-space: nowrap;
}

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

.btn-primary:hover {
    background: #45a049;
    transform: translateY(-2px);
}

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

.btn-secondary:hover {
    background: #1976D2;
    transform: translateY(-2px);
}

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

.btn-info:hover {
    background: #138496;
    transform: translateY(-2px);
}

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

.btn-danger:hover {
    background: #da190b;
    transform: translateY(-2px);
}

.btn-small {
    padding: 6px 12px;
    font-size: clamp(0.7rem, 1.8vw, 0.8rem);
    min-height: 36px;
}

.btn-large {
    padding: clamp(12px, 3vw, 15px) clamp(20px, 4vw, 30px);
    font-size: clamp(1rem, 2.5vw, 1.1rem);
    min-height: 50px;
}

/* Кнопки для счета */
.btn-score {
    padding: clamp(8px, 2vw, 10px) clamp(12px, 2vw, 15px);
    font-size: clamp(14px, 3vw, 16px);
    font-weight: bold;
    min-width: clamp(40px, 8vw, 50px);
    min-height: 44px;
}

.btn-plus {
    background: var(--primary-color);
    color: white;
}

.btn-plus:hover {
    background: #45a049;
}

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

.btn-minus:hover {
    background: #da190b;
}

/* Login */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh; /* Для мобильных браузеров */
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-form {
    background: white;
    padding: clamp(25px, 6vw, 40px);
    border-radius: var(--border-radius);
    box-shadow: 0 15px 35px rgba(0,0,0,0.2);
    width: 100%;
    max-width: min(400px, 90vw);
}

.login-form h2 {
    text-align: center;
    margin-bottom: 30px;
    color: var(--dark-color);
    font-size: clamp(1.5rem, 4vw, 1.8rem);
}

.login-form input {
    width: 100%;
    padding: clamp(12px, 3vw, 15px);
    margin: 10px 0;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: clamp(14px, 3vw, 16px);
    min-height: 50px;
}

/* Admin Panel */
.admin-container {
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--light-color);
}

.admin-header {
    background: white;
    padding: clamp(15px, 3vw, 20px);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.admin-header h1 {
    font-size: clamp(1.5rem, 4vw, 2rem);
    color: var(--dark-color);
    text-align: center;
}

.header-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.admin-content {
    max-width: 1000px;
    margin: 0 auto;
    padding: clamp(15px, 3vw, 20px);
}

.section {
    background: white;
    padding: clamp(20px, 4vw, 25px);
    margin: clamp(15px, 3vw, 20px) 0;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

.section h2 {
    margin-bottom: clamp(15px, 3vw, 20px);
    color: var(--dark-color);
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
    font-size: clamp(1.2rem, 3vw, 1.5rem);
}

/* Score Editor */
.score-editor {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    margin: 20px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: var(--border-radius);
    border: 2px dashed #dee2e6;
}

.score-team {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    width: 100%;
    max-width: 300px;
}

.team-label {
    font-weight: bold;
    color: #555;
    font-size: clamp(16px, 3vw, 18px);
    text-align: center;
    min-height: 24px;
    word-break: break-word;
}

.score-controls-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    justify-content: center;
}

.score-input {
    width: clamp(70px, 20vw, 80px);
    padding: clamp(12px, 3vw, 15px);
    font-size: clamp(20px, 4vw, 24px);
    font-weight: bold;
    text-align: center;
    border: 3px solid var(--secondary-color);
    border-radius: 8px;
    background: white;
    min-height: 60px;
}

.score-vs {
    font-size: clamp(20px, 4vw, 24px);
    font-weight: bold;
    color: #6c757d;
    padding: 10px 0;
}

.score-actions {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 15px;
    flex-wrap: wrap;
    width: 100%;
}

/* Form Controls */
.form-group {
    margin: clamp(12px, 3vw, 15px) 0;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
    font-size: clamp(0.9rem, 2vw, 1rem);
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="color"] {
    width: 100%;
    padding: clamp(10px, 2vw, 12px);
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: clamp(14px, 3vw, 16px);
    min-height: 46px;
}

.form-group input[type="color"] {
    height: 50px;
    cursor: pointer;
    min-height: 50px;
}

.color-input-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.color-input-group input[type="color"] {
    flex: 0 0 60px;
    min-width: 60px;
}

.color-input-group input[type="text"] {
    flex: 1;
    min-width: 0; /* Для правильного сжатия в flex */
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    min-width: 20px;
}

.checkbox-group label {
    margin: 0;
    font-size: clamp(0.9rem, 2vw, 1rem);
}

.team-controls,
.score-controls,
.display-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr));
    gap: clamp(12px, 3vw, 15px);
}

/* Preview */
.preview {
    display: flex;
    justify-content: center;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 8px;
    overflow: hidden;
}

.preview iframe {
    width: 100%;
    max-width: 700px;
    height: clamp(180px, 40vw, 250px);
    border: 1px solid #ccc;
    background: white;
    border-radius: 6px;
}

/* URL Box */
.url-box {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
    border-left: 4px solid var(--secondary-color);
}

.url-box code {
    display: block;
    background: #e9ecef;
    padding: 10px;
    border-radius: 4px;
    margin: 10px 0;
    font-family: monospace;
    word-break: break-all;
    font-size: clamp(0.8rem, 2vw, 0.9rem);
}

.btn-copy {
    background: #6c757d;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    min-height: 36px;
}

.btn-copy:hover {
    background: #5a6268;
}

/* Server Info */
.server-info {
    text-align: left;
}

.server-info p {
    margin: 10px 0;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 5px;
    font-size: clamp(0.9rem, 2vw, 1rem);
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: #666;
    font-size: clamp(0.75rem, 2vw, 0.8rem);
}

/* Modal */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background-color: white;
    border-radius: var(--border-radius);
    width: 100%;
    max-width: min(600px, 95vw);
    max-height: 90vh;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: clamp(15px, 3vw, 20px);
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.modal-header h2 {
    margin: 0;
    color: var(--dark-color);
    font-size: clamp(1.3rem, 3vw, 1.5rem);
}

.close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    padding: 5px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close:hover {
    color: #333;
}

.modal-body {
    padding: clamp(15px, 3vw, 20px);
    overflow-y: auto;
    flex: 1;
}

/* History */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-item {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 15px;
    border: 1px solid #eee;
    border-radius: 8px;
    background: #f9f9f9;
}

.history-preview {
    font-weight: bold;
    font-size: clamp(0.9rem, 2vw, 1rem);
    word-break: break-word;
}

.history-time {
    color: #666;
    font-size: clamp(0.8rem, 2vw, 0.9rem);
}

.history-item .btn {
    align-self: flex-start;
}

/* Footer */
footer {
    text-align: center;
    color: white;
    margin-top: 30px;
    padding: 20px 10px;
    font-size: clamp(0.9rem, 2vw, 1rem);
}

/* Desktop Styles */
@media (min-width: 768px) {
    .container {
        padding: 20px;
    }

    .admin-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .admin-header h1 {
        text-align: left;
    }

    .header-actions {
        justify-content: flex-end;
    }

    .score-editor {
        flex-direction: row;
        justify-content: center;
        gap: 30px;
    }

    .score-vs {
        padding: 0 20px;
    }

    .score-team {
        max-width: 200px;
    }

    .history-item {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .history-item .btn {
        align-self: center;
    }

    .color-input-group {
        flex-direction: row;
    }
}

/* Large Desktop Styles */
@media (min-width: 1200px) {
    .container {
        padding: 30px;
    }

    .cards {
        gap: 30px;
    }

    .admin-content {
        padding: 30px;
    }
}

/* Small Mobile Styles */
@media (max-width: 480px) {
    .btn {
        width: 100%;
        margin: 5px 0;
    }

    .score-actions .btn-small {
        width: calc(50% - 10px);
        min-width: auto;
    }

    .header-actions {
        width: 100%;
    }

    .header-actions .btn {
        flex: 1;
        min-width: 120px;
    }

    .color-input-group {
        flex-direction: column;
    }

    .color-input-group input[type="color"] {
        align-self: flex-start;
    }

    .team-controls,
    .score-controls,
    .display-controls {
        grid-template-columns: 1fr;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .btn:hover {
        transform: none;
    }

    .card:hover {
        transform: none;
    }

    .btn:active {
        transform: scale(0.98);
    }

    /* Увеличиваем зоны клика для тач-устройств */
    .checkbox-group label {
        padding: 10px 0;
    }

    .form-group label {
        padding: 5px 0;
    }
}

/* High DPI Screens */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .btn {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .btn:hover,
    .card:hover {
        transform: none;
    }
}

/* Dark Mode Support */
/* @media (prefers-color-scheme: dark) {
    .card,
    .section,
    .admin-header,
    .login-form,
    .modal-content {
        background: #2d3748;
        color: #e2e8f0;
    }

    .card h2,
    .section h2,
    .admin-header h1,
    .login-form h2,
    .modal-header h2 {
        color: #f7fafc;
    }

    .form-group label {
        color: #cbd5e0;
    }

    .form-group input {
        background: #4a5568;
        border-color: #718096;
        color: #e2e8f0;
    }

    .url-box,
    .server-info p {
        background: #4a5568;
        color: #e2e8f0;
    }

    .url-box code {
        background: #2d3748;
        color: #e2e8f0;
    }
} */

/* Стили для сетки матчей */
.matches-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.match-card {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
}

.match-card:hover {
    transform: translateY(-5px);
}

.match-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.match-header h3 {
    margin: 0;
    color: #333;
}

.match-actions {
    display: flex;
    gap: 5px;
}

.match-preview {
    text-align: center;
    margin-bottom: 15px;
}

.match-preview .score {
    font-size: 24px;
    font-weight: bold;
    color: #333;
    margin-bottom: 10px;
}

.match-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.match-info small {
    color: #666;
}

.match-urls {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 5px;
    border-left: 4px solid #2196F3;
}

.match-urls code {
    display: block;
    background: #e9ecef;
    padding: 8px;
    border-radius: 4px;
    margin: 8px 0;
    font-size: 12px;
    word-break: break-all;
}

/* Адаптивность */
@media (max-width: 768px) {
    .matches-grid {
        grid-template-columns: 1fr;
    }
    
    .match-header {
        flex-direction: column;
        gap: 10px;
    }
    
    .match-actions {
        width: 100%;
        justify-content: space-between;
    }
}

.default-badge {
    background: #ffd700;
    color: #333;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
    margin-left: 10px;
}

.default-note {
    color: #666;
    font-size: 12px;
    font-style: italic;
}

/* Стили для редактора матча */
.match-editor .section {
    margin: 15px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #007bff;
}

.match-editor .section h3 {
    margin-bottom: 15px;
    color: #333;
    font-size: 1.2em;
}

.match-editor .form-group {
    margin: 10px 0;
}

.match-editor .team-controls,
.match-editor .score-controls,
.match-editor .display-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
}

.match-editor .score-editor {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin: 20px 0;
    padding: 20px;
    background: white;
    border-radius: 10px;
    border: 2px dashed #dee2e6;
}

.match-editor .score-team {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.match-editor .score-controls-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.match-editor .score-vs {
    font-size: 20px;
    font-weight: bold;
    color: #6c757d;
    padding: 0 15px;
}

.match-editor .score-actions {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.match-editor .preview {
    display: flex;
    justify-content: center;
    padding: 15px;
    background: white;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.match-editor .color-input-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.match-editor .color-input-group input[type="color"] {
    width: 60px;
    height: 40px;
    padding: 2px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.match-editor .color-input-group input[type="text"] {
    flex: 1;
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
    .match-editor .score-editor {
        flex-direction: column;
        gap: 15px;
    }
    
    .match-editor .team-controls,
    .match-editor .score-controls,
    .match-editor .display-controls {
        grid-template-columns: 1fr;
    }
    
    .match-editor .score-actions .btn {
        flex: 1;
        min-width: 120px;
    }
}