/**
 * Canvas Match Player Styles
 * FA13 Production
 */

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

body {
    font-family: Arial, sans-serif;
    background-color: #1a1a1a;
    color: #ffffff;
    overflow-x: hidden; /* Предотвращаем горизонтальную прокрутку */
}

#match-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    width: 100%;
}

/* Header */
#match-header {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: justify;
    -webkit-justify-content: space-between;
    -ms-flex-pack: justify;
    justify-content: space-between;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background-color: #2a2a2a;
    border-radius: 8px;
}

#match-teams {
    font-size: 24px;
    font-weight: bold;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    line-height: 1.3;
}

#match-score {
    font-size: 32px;
    font-weight: bold;
    color: #4CAF50;
}

/* Canvas wrapper */
#canvas-wrapper {
    position: relative;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto 20px;
    background-color: #2a2a2a;
    border-radius: 8px;
    overflow: hidden;
    z-index: 1;
    /* Соотношение сторон 3:2 (1200:800) */
    aspect-ratio: 3 / 2;
}

#match-field,
#match-canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: pointer;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    position: relative;
    z-index: 10;
    pointer-events: auto;
    /* Обеспечиваем плавное масштабирование */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

#match-canvas:hover {
    opacity: 0.95;
}

/* Controls */
#match-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding: 15px;
    background-color: #2a2a2a;
    border-radius: 8px;
    margin-bottom: 20px;
}

.control-btn {
    padding: 10px 20px;
    font-size: 18px;
    background-color: transparent;
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 5px;
    cursor: pointer;
    -webkit-transition: all 0.3s;
    -moz-transition: all 0.3s;
    -o-transition: all 0.3s;
    transition: all 0.3s;
}

.control-btn:hover:not(:disabled) {
    border-color: rgba(255, 255, 255, 0.8);
    background-color: rgba(255, 255, 255, 0.1);
}

.control-btn:disabled {
    border-color: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.3);
    cursor: not-allowed;
    opacity: 0.5;
}

#speed-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

#speed-slider {
    width: 150px;
}

#time-display {
    font-size: 24px;
    font-weight: bold;
    min-width: 100px;
    text-align: center;
    padding: 5px 15px;
    background-color: #333;
    border-radius: 5px;
}

/* Timeline */
#match-timeline {
    padding: 15px;
    background-color: #2a2a2a;
    border-radius: 8px;
    margin-bottom: 20px;
}

#timeline-track {
    position: relative;
    height: 10px;
    background-color: #444;
    border-radius: 5px;
    cursor: pointer;
    margin-bottom: 10px;
}

#timeline-progress {
    position: absolute;
    height: 100%;
    background-color: #4CAF50;
    border-radius: 5px;
    width: 0%;
    -webkit-transition: width 0.1s linear;
    -moz-transition: width 0.1s linear;
    -o-transition: width 0.1s linear;
    transition: width 0.1s linear;
}

#timeline-handle {
    position: absolute;
    top: -5px;
    left: 0%;
    width: 20px;
    height: 20px;
    background-color: #4CAF50;
    border: 2px solid white;
    border-radius: 50%;
    cursor: grab;
    -webkit-transform: translateX(-50%);
    -moz-transform: translateX(-50%);
    -ms-transform: translateX(-50%);
    -o-transform: translateX(-50%);
    transform: translateX(-50%);
}

#timeline-handle:active {
    cursor: grabbing;
}

#timeline-events-toggle {
    margin-top: 10px;
    text-align: left;
}

#btn-toggle-events {
    padding: 8px 16px;
    font-size: 14px;
    background-color: transparent;
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 5px;
    cursor: pointer;
    -webkit-transition: all 0.3s;
    -moz-transition: all 0.3s;
    -o-transition: all 0.3s;
    transition: all 0.3s;
}

#btn-toggle-events:hover {
    border-color: rgba(255, 255, 255, 0.8);
    background-color: rgba(255, 255, 255, 0.1);
}

#timeline-events {
    display: flex;
    gap: 5px;
    margin-top: 10px;
    flex-wrap: wrap;
    overflow-x: auto;
    padding-bottom: 5px;
}

.timeline-event {
    padding: 5px 10px;
    background-color: transparent;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    font-size: 12px;
    cursor: pointer;
    -webkit-transition: all 0.2s ease;
    -moz-transition: all 0.2s ease;
    -o-transition: all 0.2s ease;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.timeline-event:hover {
    -webkit-transform: translateY(-2px);
    -moz-transform: translateY(-2px);
    -ms-transform: translateY(-2px);
    -o-transform: translateY(-2px);
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.6);
    background-color: rgba(255, 255, 255, 0.1);
}

.timeline-event.active {
    border: 2px solid #fff;
    background-color: rgba(255, 255, 255, 0.15);
}

/* Убраны все цветные фоны - теперь все кнопки имеют прозрачный фон */
.timeline-event.goal,
.timeline-event.yellow-card,
.timeline-event.red-card,
.timeline-event.foul,
.timeline-event.whistle,
.timeline-event.event,
.timeline-event.danger,
.timeline-event.shot,
.timeline-event.offside,
.timeline-event.injury,
.timeline-event.substitution,
.timeline-event.corner,
.timeline-event.penalty,
.timeline-event.free-kick,
.timeline-event.halftime,
.timeline-event.end {
    background-color: transparent;
}

.event-icon {
    font-size: 14px;
}

.event-label {
    font-weight: bold;
}

.event-minute {
    opacity: 0.8;
    font-size: 11px;
}

/* Timeline markers on progress bar */
.timeline-marker {
    position: absolute;
    top: -3px;
    width: 6px;
    height: 16px;
    border-radius: 2px;
    -webkit-transform: translateX(-50%);
    -moz-transform: translateX(-50%);
    -ms-transform: translateX(-50%);
    -o-transform: translateX(-50%);
    transform: translateX(-50%);
    cursor: pointer;
    -webkit-transition: all 0.2s ease;
    -moz-transition: all 0.2s ease;
    -o-transition: all 0.2s ease;
    transition: all 0.2s ease;
    z-index: 10;
}

.timeline-marker:hover {
    -webkit-transform: translateX(-50%) scale(1.3);
    -moz-transform: translateX(-50%) scale(1.3);
    -ms-transform: translateX(-50%) scale(1.3);
    -o-transform: translateX(-50%) scale(1.3);
    transform: translateX(-50%) scale(1.3);
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
}

/* Info Panel */
#match-info {
    background-color: #2a2a2a;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

#info-toggle {
    text-align: left;
}

#btn-show-info {
    padding: 8px 16px;
    font-size: 14px;
    background-color: transparent;
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 5px;
    cursor: pointer;
    -webkit-transition: all 0.3s;
    -moz-transition: all 0.3s;
    -o-transition: all 0.3s;
    transition: all 0.3s;
}

#btn-show-info:hover {
    border-color: rgba(255, 255, 255, 0.8);
    background-color: rgba(255, 255, 255, 0.1);
}

#info-panel {
    padding: 15px;
    background-color: #333;
    border-radius: 5px;
    margin-top: 10px;
}

#info-keyboard-controls {
    margin-bottom: 20px;
    padding: 15px;
    background-color: #444;
    border-radius: 5px;
}

#info-keyboard-controls h3 {
    margin-bottom: 15px;
    color: #4CAF50;
    font-size: 16px;
}

.keyboard-shortcuts {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px 15px;
    font-size: 14px;
}

.keyboard-key {
    display: inline-block;
    padding: 4px 8px;
    background-color: #555;
    border: 1px solid #666;
    border-radius: 3px;
    font-family: monospace;
    font-weight: bold;
    text-align: center;
    min-width: 30px;
    box-shadow: 0 2px 3px rgba(0,0,0,0.3);
}

.keyboard-description {
    display: flex;
    align-items: center;
    color: #ddd;
}

#info-teams {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.team-info {
    padding: 15px;
    background-color: #444;
    border-radius: 5px;
}

.team-info h3 {
    margin-bottom: 10px;
    color: #4CAF50;
}

.player-item {
    padding: 5px 0;
    border-bottom: 1px solid #555;
}

.player-item:last-child {
    border-bottom: none;
}

#info-stats {
    padding: 15px;
    background-color: #444;
    border-radius: 5px;
}

/* Events Settings */
#events-settings {
    padding: 15px;
    background-color: #2a2a2a;
    border-radius: 8px;
}

#settings-toggle {
    text-align: left;
}

#btn-toggle-settings {
    padding: 8px 16px;
    font-size: 14px;
    background-color: transparent;
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 5px;
    cursor: pointer;
    -webkit-transition: all 0.3s;
    -moz-transition: all 0.3s;
    -o-transition: all 0.3s;
    transition: all 0.3s;
}

#btn-toggle-settings:hover {
    border-color: rgba(255, 255, 255, 0.8);
    background-color: rgba(255, 255, 255, 0.1);
}

#settings-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 15px;
    margin-top: 10px;
    background-color: #333;
    border-radius: 5px;
}

#settings-panel label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background-color: #333;
    border-radius: 5px;
    cursor: pointer;
    -webkit-transition: background-color 0.2s;
    -moz-transition: background-color 0.2s;
    -o-transition: background-color 0.2s;
    transition: background-color 0.2s;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

#settings-panel label:hover {
    background-color: #3a3a3a;
}

#settings-panel input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

#settings-panel input[type="checkbox"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Стили для отключенных чекбоксов - применяются через JavaScript, так как :has() не поддерживается старыми браузерами */
#settings-panel label.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#settings-panel label.disabled:hover {
    background-color: #333;
}

/* Messages */
#error-message,
#loading-message {
    padding: 20px;
    text-align: center;
    font-size: 18px;
    background-color: #333;
    border-radius: 8px;
    margin: 20px 0;
}

#error-message {
    background-color: #F44336;
}

#loading-message {
    background-color: #2196F3;
}

/* Responsive Design - Mobile First */

/* Экраны шириной до 600px */
@media (max-width: 600px) {
    #match-teams {
        font-size: 14px;
        text-align: center;
        max-width: 100%;
    }

    #match-score {
        font-size: 24px;
    }

    .keyboard-shortcuts {
        font-size: 12px;
        gap: 8px 10px;
    }

    .keyboard-key {
        font-size: 12px;
        padding: 3px 6px;
        min-width: 25px;
    }
}

/* Очень маленькие экраны (телефоны в портретной ориентации) */
@media (max-width: 480px) {
    body {
        font-size: 14px;
    }

    #match-container {
        padding: 10px;
    }

    #match-header {
        flex-direction: column;
        gap: 10px;
        padding: 10px;
    }

    #match-teams {
        font-size: 13px;
        text-align: center;
        max-width: 100%;
        padding: 0 5px;
    }

    #match-score {
        font-size: 20px;
    }

    #match-controls {
        flex-wrap: wrap;
        gap: 6px;
        padding: 8px;
        justify-content: center;
    }

    .control-btn {
        padding: 8px 10px;
        font-size: 16px;
        flex: 0 1 auto;
        min-width: 50px;
        border-width: 1px;
    }

    /* Первый ряд: кнопки управления */
    #btn-play,
    #btn-pause,
    #btn-restart,
    #btn-rewind-1min {
        flex: 1 1 calc(25% - 6px);
        max-width: calc(25% - 6px);
    }

    #speed-control {
        width: 100%;
        flex-basis: 100%;
        justify-content: center;
        gap: 8px;
        order: 1;
        margin-top: 4px;
    }

    #speed-control label {
        font-size: 12px;
    }

    #speed-slider {
        width: 100%;
        max-width: 150px;
        flex: 1;
    }

    #speed-value {
        font-size: 14px;
        min-width: 25px;
    }

    #time-display {
        font-size: 16px;
        min-width: 70px;
        padding: 6px 10px;
        order: 2;
        margin-top: 4px;
        flex-basis: 100%;
    }

    #info-teams {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .team-info {
        padding: 10px;
    }

    #timeline-events {
        gap: 3px;
    }

    .timeline-event {
        padding: 4px 8px;
        font-size: 11px;
    }

    #canvas-wrapper {
        border-radius: 4px;
        margin-bottom: 10px;
    }

    #match-timeline,
    #match-info,
    #events-settings {
        padding: 10px;
        margin-bottom: 10px;
    }

    #info-keyboard-controls h3 {
        font-size: 14px;
        margin-bottom: 10px;
    }

    .keyboard-shortcuts {
        font-size: 11px;
        gap: 6px 8px;
    }

    .keyboard-key {
        font-size: 10px;
        padding: 2px 5px;
        min-width: 22px;
    }
}

/* Средние экраны (телефоны в альбомной, планшеты в портретной) */
@media (min-width: 481px) and (max-width: 768px) {
    #match-container {
        padding: 15px;
    }

    #match-teams {
        font-size: 16px;
    }

    #match-score {
        font-size: 26px;
    }

    #match-controls {
        flex-wrap: wrap;
        gap: 10px;
    }

    .control-btn {
        padding: 9px 14px;
        font-size: 15px;
    }

    #speed-control {
        flex-basis: 100%;
        justify-content: center;
        order: 1;
    }

    #time-display {
        font-size: 18px;
        order: 2;
        flex-basis: 100%;
        margin-top: 8px;
    }

    #info-teams {
        grid-template-columns: 1fr;
    }
}

/* Узкие десктопные окна (как на скриншоте) */
@media (min-width: 769px) and (max-width: 900px) {
    #match-teams {
        font-size: 18px;
    }

    #match-score {
        font-size: 28px;
    }

    .control-btn {
        padding: 9px 15px;
        font-size: 16px;
    }

    #speed-slider {
        width: 120px;
    }

    #time-display {
        font-size: 20px;
        min-width: 90px;
    }
}

/* Планшеты в альбомной ориентации */
@media (min-width: 769px) and (max-width: 1024px) {
    #match-container {
        padding: 18px;
    }

    #match-teams {
        font-size: 20px;
    }

    #match-score {
        font-size: 28px;
    }

    #info-teams {
        grid-template-columns: 1fr 1fr;
        gap: 15px;
    }
}

/* Поддержка touch устройств */
@media (hover: none) and (pointer: coarse) {
    /* Увеличиваем размеры кнопок для удобного нажатия пальцем */
    .control-btn {
        min-height: 44px;
        min-width: 44px;
    }

    #timeline-handle {
        width: 30px;
        height: 30px;
        top: -10px;
    }

    .timeline-event {
        min-height: 40px;
        padding: 8px 12px;
    }

    /* Убираем hover эффекты на touch устройствах */
    .control-btn:hover:not(:disabled),
    #btn-toggle-events:hover,
    #btn-show-info:hover,
    .timeline-event:hover {
        transform: none;
        background-color: transparent;
    }
}

/* Ориентация экрана */
@media (orientation: landscape) and (max-width: 768px) {
    /* Для альбомной ориентации на маленьких экранах */
    #match-container {
        padding: 10px;
    }

    #match-header {
        padding: 10px;
    }

    #match-controls {
        padding: 8px;
        gap: 8px;
    }
}

/* Высокие DPI экраны (Retina) */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    #match-field,
    #match-canvas {
        /* Canvas автоматически обрабатывается в JS с учетом devicePixelRatio */
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Очень большие экраны */
@media (min-width: 1400px) {
    #match-container {
        max-width: 1600px;
    }

    #canvas-wrapper {
        max-width: 1400px;
    }
}
