@import 'https://fonts.googleapis.com/css?family=Bungee';

/* Base styles */
body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background: #0F4D84;
    background-image:
        repeating-linear-gradient(120deg, rgba(255,255,255,.1), transparent 1px, transparent 10000px),
        repeating-linear-gradient(60deg, rgba(255,255,255,.1), rgba(255,255,255,.1) 1px, transparent 1px, transparent 10000px),
        linear-gradient(60deg,rgba(0,0,0,.1) 25%, transparent 25%, transparent 75%, rgba(0,0,0,.1) 75%, rgba(0,0,0,.1)),
        linear-gradient(120deg, rgba(0,0,0,.1) 25%, transparent 25%, transparent 75%, rgba(0,0,0,.1) 75%, rgba(0,0,0,.1));
    background-size: 180px 305px;
    font-family: system-ui, -apple-system, sans-serif;
    color: white;
}

/* Title styles */
h1, .battle-title {
    font-family: "Bungee", sans-serif;
    color: white;
    text-shadow: 
        -1px 0 1px #582E00, 
        1px 0 1px #582E00,
        0 -1px 1px #582E00,
        0 4px 1px #582E00,
        -2px 4px 1px #582E00,
        2px 3px 2px #582E00;
    text-align: center;
    margin-bottom: 2rem;
}

/* Card styles */
.card {
    background: linear-gradient(45deg, #162338 0%, #141c30 100%);
    border: 3px solid #f8b700;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 
        0 0 0 1px rgba(255, 255, 255, 0.1),
        0 2px 4px rgba(0, 0, 0, 0.7),
        inset 0 0 15px rgba(248, 183, 0, 0.1);
}

/* Stats cards */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 2rem;
}

/* Team colors */
.stats-card.blue-team {
    background: linear-gradient(45deg, #1e3a8a 0%, #2563eb 100%);
    border: 2px solid #60a5fa;
    box-shadow: 0 0 15px rgba(37, 99, 235, 0.3);
}

.stats-card.red-team {
    background: linear-gradient(45deg, #991b1b 0%, #dc2626 100%);
    border: 2px solid #f87171;
    box-shadow: 0 0 15px rgba(220, 38, 38, 0.3);
}

/* Player names */
#player1Name, #player2Name {
    font-family: "Bungee", sans-serif;
    font-size: 1.6rem;
    margin-bottom: 1rem;
}

.blue-team #player1Name {
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.red-team #player2Name {
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Button styles */
.button-container {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin: 2rem 0;
}

.compare-button {
    font-family: "Bungee", sans-serif;
    font-size: 1.2rem;
    padding: 1rem 2rem;
    background: linear-gradient(to bottom, #ffc000, #f8b700);
    border: 3px solid #000;
    border-radius: 8px;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    transition: transform 0.2s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    min-width: 200px;
}

.refresh-button {
    font-family: "Bungee", sans-serif;
    font-size: 1.2rem;
    padding: 1rem;
    background: linear-gradient(to bottom, #ffc000, #f8b700);
    border: 3px solid #000;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    transition: transform 0.2s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    min-width: 60px;
}

.compare-button:hover,
.refresh-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.3);
}

.compare-button:active,
.refresh-button:active {
    transform: translateY(1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Select styles */
select {
    font-family: system-ui, -apple-system, sans-serif;
    background: #1e293b;
    border: 2px solid #f8b700;
    border-radius: 8px;
    color: white;
    padding: 0.8rem;
    width: 100%;
    margin-bottom: 1rem;
}

/* Table styles */
.matches-table {
    margin-top: 2rem;
}

.matches-table th {
    font-family: "Bungee", sans-serif;
    background: rgba(248, 183, 0, 0.1);
    color: #f8b700;
    padding: 1rem;
    text-align: left;
}

.matches-table td {
    padding: 1rem;
    border-bottom: 1px solid rgba(248, 183, 0, 0.2);
}

.matches-table tr:hover td {
    background: rgba(248, 183, 0, 0.05);
}

/* Container and layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.logo-container {
    text-align: center;
    margin: 2rem auto;
    max-width: 300px;
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;

}

.logo-container img {
    width: 100%;
    height: auto;
    filter: drop-shadow(0 0 8px rgba(248, 183, 0, 0.3));

}

/* Selection grid */
.selection-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1rem;
    align-items: center;
    margin-bottom: 2rem;
}

.vs-icon {
    width: 48px;
    height: 48px;
    margin: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.vs-icon img {
    width: 100%;
    height: auto;
}

/* Form elements */
.select-container {
    position: relative;
}

.select-label {
    font-family: "Bungee", sans-serif;
    color: #f8b700;
    margin-bottom: 0.5rem;
    display: block;
}

select {
    width: 100%;
    padding: 1rem;
    background: rgba(30, 41, 59, 0.8);
    border: 2px solid #f8b700;
    border-radius: 8px;
    color: white;
    font-size: 1rem;
    appearance: none;
    cursor: pointer;
}

.game-mode-select {
    margin: 2rem 0;
}

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

    .vs-icon {
        margin: 1rem auto;
        transform: rotate(90deg);
    }

    .button-container {
        flex-direction: column;
    }

    .button-container button {
        width: 100%;
    }
}

/* Results section */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin: 2rem 0;
}

.stats-card {
    padding: 1.5rem;
    border-radius: 12px;
    position: relative;
    transition: all 0.3s ease;
    filter: brightness(0.8);
}

.stats-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    margin: 8px 0;
}

.stats-item:has(.progress-container) {
    display: block;
    padding: 8px;
}

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

/* Table improvements */
.matches-table {
    overflow-x: auto;
    margin: 2rem 0;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
}

.matches-table table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.matches-table th {
    padding: 1.2rem 1rem;
    background: rgba(248, 183, 0, 0.15);
    font-family: "Bungee", sans-serif;
    font-size: 0.9rem;
}

.matches-table td {
    padding: 1rem;
    border-bottom: 1px solid rgba(248, 183, 0, 0.1);
}

.matches-table tr:last-child td {
    border-bottom: none;
}

/* Message states */
.hidden {
    display: none !important;
}

/* Results section header */
.results-header {
    position: relative;
    text-align: center;
    margin: 3rem 0;
    padding: 2rem 0;
}

.crown-ribbon {
    position: relative;
    background: linear-gradient(to right, transparent, #f8b700, transparent);
    height: 3px;
    margin: 2rem 0;
}

.crown-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    background: #162338;
    border-radius: 50%;
    padding: 8px;
    border: 2px solid #f8b700;
}

.crown-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Load more button */
.load-more {
    display: block;
    width: 200px;
    margin: 2rem auto;
    font-family: "Bungee", sans-serif;
    background: rgba(248, 183, 0, 0.1);
    border: 2px solid #f8b700;
    border-radius: 8px;
    color: #f8b700;
    padding: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.load-more:hover {
    background: rgba(248, 183, 0, 0.2);
}

/* Player stats improvements */
.stats-card h3 {
    font-family: "Bungee", sans-serif;
    font-size: 1.5rem;
    margin: 0;
    color: white !important;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    text-align: center;
}

.blue-team h3 {
    color: white !important;
}

.red-team h3 {
    color: white !important;
}

/* Winner card animation */
@keyframes winner-glow {
    0% { box-shadow: 0 0 5px rgba(248, 183, 0, 0.5); }
    50% { box-shadow: 0 0 20px rgba(248, 183, 0, 0.8); }
    100% { box-shadow: 0 0 5px rgba(248, 183, 0, 0.5); }
}

@keyframes crown-float {
    0% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0); }
}

.winner-card {
    animation: shimmer 2s infinite;
    border: 2px solid #f8b700;
    box-shadow: 0 0 15px rgba(248, 183, 0, 0.3);
    opacity: 1;
    filter: brightness(1.1);
}

.winner-crown {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    animation: crown-float 2s infinite ease-in-out;
}

.winner-crown img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Shimmer effect */
@keyframes shimmer {
    0% {
        box-shadow: 0 0 0 2px rgba(248, 183, 0, 0.3);
    }
    70% {
        box-shadow: 0 0 0 4px rgba(248, 183, 0, 0.6);
    }
    100% {
        box-shadow: 0 0 0 2px rgba(248, 183, 0, 0.3);
    }
}

.winner-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.1),
        transparent
    );
    background-size: 200% 100%;
    animation: shimmer 3s infinite;
    border-radius: inherit;
    pointer-events: none;
}

/* Stats items styling */
.stats-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.stats-item span:first-child {
    color: rgba(255, 255, 255, 0.8);
}

.stats-item span:last-child {
    font-weight: bold;
}

/* Table row highlighting */
.blue-team-win {
    background: rgba(37, 99, 235, 0.1);
}

.red-team-win {
    background: rgba(220, 38, 38, 0.1);
}

/* Improved table styling */
.matches-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 2rem 0;
}

.matches-table th,
.matches-table td {
    padding: 1rem;
    text-align: left;
}

.matches-table th {
    background: rgba(248, 183, 0, 0.1);
    font-family: "Bungee", sans-serif;
    color: #f8b700;
}

.matches-table td {
    border-bottom: 1px solid rgba(248, 183, 0, 0.1);
}

.matches-table tr:hover td {
    background: rgba(248, 183, 0, 0.05);
}

/* Pagination and view controls */
.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin: 2rem 0;
}

.pagination-button {
    font-family: "Bungee", sans-serif;
    padding: 0.5rem 1rem;
    background: linear-gradient(to bottom, #ffc000, #f8b700);
    border: 2px solid #000;
    border-radius: 4px;
    color: white;
    cursor: pointer;
}

.pagination-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#pageInfo {
    color: #f8b700;
    font-family: "Bungee", sans-serif;
}

.view-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin: 1rem 0;
}

.view-button {
    font-family: "Bungee", sans-serif;
    padding: 0.5rem 1rem;
    background: transparent;
    border: 2px solid #f8b700;
    border-radius: 4px;
    color: #f8b700;
    cursor: pointer;
}

.view-button.active {
    background: #f8b700;
    color: white;
}

/* Winner crown styling */
.winner-crown {
    position: static;
    top: -15px;
    right: 10px;
    width: 30px;
    height: 30px;
}

.winner-crown img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Date summary styling */
.date-summary {
    background: rgba(248, 183, 0, 0.1);
    font-family: "Bungee", sans-serif;
    color: #f8b700;
}

.date-summary td {
    padding: 1rem;
    text-align: center;
    color: #f8b700;
    font-family: "Bungee", sans-serif;
    font-size: 1.2rem;
    text-shadow: 0 0 5px rgba(248, 183, 0, 0.5);
}

/* Logo animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: .8;
        transform: scale(1.05);
    }
}

/* Progress bar styles */
.progress-container {
    width: 100%;
    padding: 2px;
    height: 21px;
    border-radius: 5px;
    border: solid 3px rgba(248, 183, 0, 0.3);
    background-color: rgba(0, 0, 0, 0.2);
    position: relative;
}

.progress-track {
    position: relative;
    width: 100%;
    height: 21px;
    overflow: hidden;
}

.progress-bars {
    height: 100%;
    display: flex;
    gap: 2px;
    transition: width 1s ease-in-out;
}

.progress-segment {
    height: 15px;
    width: 24px;
    background-color: #f8b700;
    position: relative;
    border-radius: 2px;
    box-shadow: 0px 0px 5px #f8b700;
    margin: 3px 2px;
}

.progress-text {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: white;
    font-weight: bold;
    text-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
    z-index: 1;
}

/* Player name and crown container */
.player-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.winner-crown {
    width: 24px;
    height: 24px;
    display: inline-block;
    vertical-align: middle;
}

.winner-crown img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Remove crown from battle list */
.matches-table .winner-crown {
    display: none;
}

.stats-card h3 {
    margin: 0;
}

.blue-team {
    background: linear-gradient(to bottom, rgba(59, 130, 246, 0.5), rgba(37, 99, 235, 0.3));
}

.red-team {
    background: linear-gradient(to bottom, rgba(239, 68, 68, 0.5), rgba(185, 28, 28, 0.3));
}

@keyframes shimmer {
    0% {
        box-shadow: 0 0 0 2px rgba(248, 183, 0, 0.3);
    }
    70% {
        box-shadow: 0 0 0 4px rgba(248, 183, 0, 0.6);
    }
    100% {
        box-shadow: 0 0 0 2px rgba(248, 183, 0, 0.3);
    }
}

.winner-card {
    animation: shimmer 2s infinite;
    border: 2px solid #f8b700;
    box-shadow: 0 0 15px rgba(248, 183, 0, 0.3);
    filter: brightness(1);
}

/* Remove any existing border from inner elements when card is winner */
.winner-card .stats-item,
.winner-card .progress-container {
    border-color: rgba(248, 183, 0, 0.2);
}

/* Ensure the stats container doesn't have its own border */
#player1Stats,
#player2Stats {
    border: none;
}

.date-navigation {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    width: 100%;
    touch-action: pan-y pinch-zoom;
}

.date-summary-content {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem;
    text-align: center;
    width: 100%;
}

.date-text {
    color: white;
    margin: 0 1rem;
    white-space: nowrap;
}

.red-team-text,
.blue-team-text {
    white-space: nowrap;
}

.nav-button {
    background: none;
    border: none;
    color: #f8b700;
    cursor: pointer;
    padding: 0.5rem;
    font-size: 1.2rem;
    transition: opacity 0.3s ease;
}

.nav-button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.nav-button:not(:disabled):hover {
    color: white;
}

/* Mobile optimization */
@media (max-width: 768px) {
    .date-summary-content {
        gap: 0.5rem;
        font-size: 0.9rem;
    }
    
    .date-text {
        margin: 0 0.5rem;
    }
    
    .nav-button {
        padding: 0.25rem;
    }
}

/* Prevent text selection during swipe */
.date-navigation {
    user-select: none;
    -webkit-user-select: none;
}

/* Mobile responsive layout */
@media (max-width: 768px) {
    /* Container width */
    .container {
        width: 100%;
        padding: 0rem;
        max-width: 100vw;
        overflow-x: hidden;
    }

    /* Stats grid for player cards - stack them vertically */
    .stats-grid {
        display: grid;
        grid-template-columns: 1fr;  /* Changed to single column */
        gap: 0.5rem;
        margin: 1rem 0;
        width: 100%;
    }

    /* Player cards */
    .stats-card {
        padding: 0.75rem;
        font-size: 0.9rem;
        width: 90%;
        margin-bottom: 0.5rem;
    }

    /* Move controls to top */
    .view-controls,
    .pagination-controls {
        order: -1;  /* Move to top */
        margin-bottom: 1rem;
    }

    /* Reduce table padding */
    .matches-table td,
    .matches-table th {
        padding: 0.5rem;
    }

    

    /* Make buttons more touch-friendly */
    .view-button,
    .pagination-button {
        padding: 0.75rem 1rem;
        min-width: 44px; /* Minimum touch target size */
    }

    /* Compact table styles */
    .matches-table td,
    .matches-table th {
        padding: 0.5rem;
        font-size: 0.8rem;
    }

    /* Make the date column more compact */
    .matches-table td:first-child {
        font-size: 0.75rem;
        white-space: nowrap;
    }

    /* Game mode column */
    .matches-table td:nth-child(2) {
        font-size: 0.75rem;
    }

    /* Score and winner columns */
    .matches-table td:nth-child(3),
    .matches-table td:nth-child(4) {
        font-size: 0.8rem;
        white-space: nowrap;
    }

    /* Adjust table width */
    .matches-table {
        width: 100%;
        table-layout: fixed;
    }

    /* Column widths */
    .matches-table th:nth-child(1) { width: 25%; } /* Date */
    .matches-table th:nth-child(2) { width: 30%; } /* Game Mode */
    .matches-table th:nth-child(3) { width: 25%; } /* Winner */
    .matches-table th:nth-child(4) { width: 20%; } /* Score */
}

