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

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

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    /*overflow: hidden; КЛИПАЕТ ХОВЕР НА ТОЧКАХ, НО ЕСЛИ ОФФНУТЬ ТО УБИРАЕТ БОРДЕР РАДИУС*/
}


.header {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    padding: 30px;
    text-align: center;
    color: white;
}

.header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.header p {
    font-size: 1.1em;
    opacity: 0.9;
}

.controls {
    padding: 30px;
    background: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 15px;
    max-width: 500px;
    margin: 0 auto;
}

.control-group label {
    font-size: 1.1em;
    font-weight: 600;
    color: #495057;
}

.control-group select {
    flex: 1;
    padding: 12px 20px;
    font-size: 1em;
    border: 2px solid #dee2e6;
    border-radius: 10px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.control-group select:hover {
    border-color: #667eea;
}

.control-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.legend {
    display: flex;
    justify-content: center;
    gap: 30px;
    padding: 20px 30px;
    background: white;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.legend-dot.win {
    background: #28a745;
}

.legend-dot.loss {
    background: #dc3545;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 24px;
    padding: 30px;
    align-items: start;
}

/* Chart wrapper and container */
.chart-wrapper {
    position: relative;
    width: 100%;
}

.chart-container {
    position: relative;
    height: 500px;
    width: 100%;
}

#battleChart {
    width: 100% !important;
    height: 100% !important;
}

/* Custom hover tooltip */
#customHover {
    position: absolute;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.92);
    color: white;
    padding: 15px;
    border-radius: 10px;
    display: none;
    font-family: 'Segoe UI', sans-serif;
    font-size: 13px;
    z-index: 1000;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

#customHover .tooltip-header {
    margin-bottom: 12px;
}

#customHover .tooltip-header > div {
    margin-bottom: 6px;
}

#customHover .tooltip-header strong {
    color: #aaa;
    font-weight: 600;
}

#customHover .tooltip-header .win {
    color: #4caf50;
    font-weight: 700;
}

#customHover .tooltip-header .loss {
    color: #f44336;
    font-weight: 700;
}

#customHover hr {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    margin: 10px 0;
}

#customHover .battle-layout {
    display: flex;
    align-items: center;
    gap: 12px;
}

#customHover .deck-column {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

#customHover .deck-label {
    font-size: 11px;
    color: #bbb;
    font-weight: 600;
    text-align: center;
}

#customHover .deck-stats {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 6px;
    text-align: center;
}

#customHover .stat-item {
    font-size: 10px;
    color: #999;
}

#customHover .score-divider {
    display: flex;
    align-items: center;
    padding: 0 8px;
}

#customHover .score {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
}

#customHover .player-cards,
#customHover .enemy-cards {
    display: grid;
    grid-template-columns: repeat(4, min-content);
    grid-template-rows: repeat(2, min-content);
    gap: 2px;
}

#customHover .card-wrapper {
    position: relative;
    display: inline-block;
}

#customHover .player-cards img,
#customHover .enemy-cards img {
    display: block;
    max-height: 80px !important;
    width: auto !important;
    height: auto !important;
}

#customHover .card-level {
    position: absolute;
    bottom: 2px;
    right: 2px;
    background: rgba(0, 0, 0, 0.7);
    color: #4dabf7;
    font-size: 13px;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 3px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.1s;
}

#customHover .card-wrapper.loaded .card-level {
    opacity: 1;
}

/* Last battles sidebar */
.last-battles {
    background: #ffffff;
    border-radius: 14px;
    padding: 18px 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
    position: sticky;
    top: 20px;
    max-height: 600px;
    overflow-y: auto;
}

.last-battles h3 {
    margin-bottom: 14px;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.last-battles ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.battle-row {
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

.battle-row:last-child {
    border-bottom: none;
}

.battle-main {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.battle-time {
    margin-top: 4px;
    font-size: 12px;
    color: #9aa0a6;
}

.player {
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.trophies {
    color: #6c757d;
    font-variant-numeric: tabular-nums;
    font-size: 13px;
}

.change {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    font-size: 14px;
}

.change.win {
    color: #28a745;
}

.change.loss {
    color: #dc3545;
}

.stats-info {
    padding: 20px 30px;
    background: #f8f9fa;
    border-top: 2px solid #e9ecef;
    text-align: center;
    color: #6c757d;
    font-size: 0.9em;
}

/* Responsive design */
@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .last-battles {
        position: static;
        max-height: none;
    }

    #customHover {
        min-width: 320px;
    }

    #customHover .battle-layout {
        flex-direction: column;
        gap: 8px;
    }

    #customHover .score-divider {
        padding: 4px 0;
    }

    #customHover .player-cards,
    #customHover .enemy-cards {
        display: grid;
        grid-template-columns: repeat(4, min-content);
        grid-template-rows: repeat(2, min-content);
        gap: 2px;
    }

    #customHover .battle-cards img {
        display: block;
        max-width: 40px !important;
        max-height: 40px !important;
    }
}

@media (max-width: 768px) {
    .header h1 {
        font-size: 1.8em;
    }

    .control-group {
        flex-direction: column;
        align-items: stretch;
    }

    .chart-container {
        height: 400px;
    }

    .main-content {
        padding: 15px;
    }
}