/* Base Styles */
body {
    font-family: 'Roboto', 'Arial', sans-serif;
    background-color: #111;
    background-image: 
        linear-gradient(to right top, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.8)),
        url('https://www.dragonsports.eu/512925-verylarge_default/panel-for-mma-cage-with-door-ninestars.jpg');
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center top;
    height: 100vh;
    color: white;
    margin: 0;
    padding: 20px;
    overflow: hidden;
}

/* Advanced Chart Visual Effects */
@keyframes eventGlow {
    0% { 
        box-shadow: none; 
        transform: scale(1); 
    }
    50% { 
        box-shadow: 0 0 15px rgba(255, 255, 255, 0.8), 0 0 25px rgba(255, 255, 255, 0.5); 
        transform: scale(1.02); 
    }
    100% { 
        box-shadow: none; 
        transform: scale(1); 
    }
}

.event-glow-active {
    animation: eventGlow 0.6s ease-in-out infinite;
}

.event-clickable {
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.event-clickable:hover {
    opacity: 0.7;
}

/* Top Container */
.top-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    margin-top: 10px;
}

/* Score Section */
.score-section {
    display: flex;
    align-items: center;
}

.score-display {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Score Boxes */
.score-box {
    width: 100px;
    height: 80px;
    background-color: rgba(26, 26, 26, 0.9);
    border-radius: 10px;
    font-size: 4em;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;  /* Added for aggression indicator positioning */
    transition: all 0.3s ease; /* Added for smooth glow transitions */
}

.blue-score {
    border: 4px solid #2196F3;
    color: #2196F3;
}

.red-score {
    border: 4px solid #f44336;
    color: #f44336;
}

/* Aggression Indicators */
.aggression-indicator {
    font-size: .3em;
    font-weight: bold;
    position: absolute;
    top: -29px;
    right: 38px;
}

.blue-aggression {
    color: #2196F3;
}

.red-aggression {
    color: #f44336;
}

/* Fighter Names */
.fighter-name {
    min-width: 180px;
    padding: 15px;
    background-color: rgba(26, 26, 26, 0.9);
    font-size: 2em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    border-radius: 10px;
    text-align: center;
}

.blue-fighter {
    border: 3px solid #2196F3;
    color: #2196F3;
}

.red-fighter {
    border: 3px solid #f44336;
    color: #f44336;
}

.fighter-name:hover {
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.1);
}

/* Control Container */
#control-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

#timer {
    font-size: 2.5em;
    font-weight: bold;
    padding: 10px 20px;
    border-radius: 8px;
    min-width: 140px;
    text-align: center;
    background-color: #e0e0e0;
    color: #333;
    border: 3px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
}

#timer.running {
    background-color: #4CAF50;
    color: white;
}

#timer.paused {
    background-color: #FFD700;
    color: black;
}

#timer.ended {
    background-color: #FF0000;
    color: white;
}

#roundSelector {
    font-size: 1.5em;
    padding: 10px;
    border-radius: 8px;
    background-color: #333;
    color: white;
    border: 2px solid #666;
}

button {
    font-size: 1.5em;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    border: none;
    transition: background-color 0.3s;
}

#startPauseButton, #resetButton {
    background-color: #333;
    color: white;
    border: 2px solid #666;
}

#startPauseButton:hover, #resetButton:hover {
    background-color: #444;
    border-color: #888;
}

/* Swap Button Styles */
#swapButton {
    background-color: #333;
    color: white;
    border: 2px solid #666;
    padding: 5px 10px;
    font-size: 1.4em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    min-width: 70px;
}

#swapButton:hover {
    background-color: #444;
    border-color: #888;
}

.blue-arrow {
    color: #2196F3;
    font-weight: bold;
    font-size: 2em;
    text-shadow: 0 0 2px #2196F3;
}

.red-arrow {
    color: #f44336;
    font-weight: bold;
    font-size: 2em;
    text-shadow: 0 0 2px #f44336;
}

/* Add an arrow hint on hover */
#swapButton:hover .blue-arrow {
    transform: translateX(-2px);
    transition: transform 0.3s;
}

#swapButton:hover .red-arrow {
    transform: translateX(2px);
    transition: transform 0.3s;
}

/* Graph Container */
.graph-container {
    display: flex;
    justify-content: space-around;
    gap: 20px;
    margin-top: 20px;
    padding: 0 20px;
    width: 98%;
}

.bar-graph, .line-graph {
    width: 660px !important;
    height: 400px !important;
    background-color: rgba(51, 51, 51, 0.9);
    border: 1px solid #666;
    border-radius: 10px;
    padding: 10px;
    position: relative; /* Added for better chart positioning */
}

/* Enhanced Chart Styling */
.bar-graph {
    background-color: rgba(51, 51, 51, 0.9);
}

.line-graph {
    background-color: rgba(51, 51, 51, 0.9);
}

.chartjs-render-monitor {
    background: transparent !important;
}

/* CSV Button Container */
.csv-container {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

#exportCSVButton {
    background-color: #0099ff;
    color: white;
    padding: 10px 20px;
    font-size: 1.5em;
    border-radius: 8px;
    border: 2px solid #0077cc;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

#exportCSVButton:hover {
    background-color: #0077cc;
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.2);
}

/* Input styles for editable names */
.fighter-name input {
    background: transparent;
    border: none;
    color: inherit;
    font-size: inherit;
    font-family: inherit;
    width: 90%;
    outline: none;
    text-align: center;
}

/* Keyboard Instructions */
.keyboard-instructions {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 10px 20px;
    border-radius: 5px;
    color: #666;
    font-size: 0.9em;
}

/* Help Button */
#helpButton {
    background-color: #4CAF50; 
    color: white;
    padding: 10px 20px;
    font-size: 1.5em;
    border-radius: 8px;
    border: 2px solid #388E3C;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-left: 15px;
}

#helpButton:hover {
    background-color: #388E3C;
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.2);
}

/* Help Modal */
.help-modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    overflow: auto;
}

.help-content {
    background-color: #222;
    margin: 5% auto;
    padding: 25px;
    border: 1px solid #444;
    max-width: 80%;
    max-height: 80vh;
    overflow-y: auto;
    border-radius: 10px;
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.5);
    position: relative;
}

.help-close {
    color: #aaa;
    position: absolute;
    top: 15px;
    right: 25px;
    font-size: 38px;
    font-weight: bold;
    cursor: pointer;
}

.help-close:hover {
    color: white;
}

.help-sections {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.help-section {
    background-color: #333;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.help-section h3 {
    margin-top: 0;
    padding-bottom: 10px;
    border-bottom: 1px solid #555;
    color: #4CAF50;
}

.help-section ul,
.help-section ol {
    padding-left: 25px;
    margin-bottom: 10px;
}

.help-section li {
    margin-bottom: 8px;
    line-height: 1.5;
}

.dismiss-help {
    background-color: #4CAF50;
    color: white;
    padding: 10px 20px;
    font-size: 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    display: block;
    margin: 20px auto 0;
}

.dismiss-help:hover {
    background-color: #388E3C;
}

/* Username Modal */
.username-modal {
    display: none;
    position: fixed;
    z-index: 200;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    overflow: auto;
}

.username-content {
    background-color: #222;
    margin: 15% auto;
    padding: 30px;
    border: 1px solid #444;
    max-width: 500px;
    border-radius: 15px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.7);
    text-align: center;
}

.username-content h2 {
    color: #4CAF50;
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 2em;
}

.username-content p {
    margin-bottom: 25px;
    font-size: 1.2em;
    color: #ccc;
}

#usernameInput {
    width: 100%;
    max-width: 300px;
    padding: 15px;
    font-size: 1.3em;
    border: 2px solid #666;
    border-radius: 8px;
    background-color: #333;
    color: white;
    margin-bottom: 25px;
    box-sizing: border-box;
    text-align: center;
}

#usernameInput:focus {
    outline: none;
    border-color: #4CAF50;
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.3);
}

#usernameInput::placeholder {
    color: #999;
}

.save-username {
    background-color: #4CAF50;
    color: white;
    padding: 12px 30px;
    font-size: 1.3em;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s;
    min-width: 150px;
}

.save-username:hover {
    background-color: #388E3C;
}

.save-username:disabled {
    background-color: #666;
    cursor: not-allowed;
}

/* Enhanced Visual Effects for Charts */
.chart-threshold-annotation {
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.chart-threshold-annotation:hover {
    opacity: 1;
}

/* Score Box Glow Effects */
.score-box.blue-score.event-glow-active {
    box-shadow: 0 0 20px rgba(33, 150, 243, 0.8), 0 0 30px rgba(33, 150, 243, 0.5);
    border-color: #64B5F6;
}

.score-box.red-score.event-glow-active {
    box-shadow: 0 0 20px rgba(244, 67, 54, 0.8), 0 0 30px rgba(244, 67, 54, 0.5);
    border-color: #EF5350;
}

/* Responsive adjustments for mobile/smaller screens */
@media (max-width: 1000px) {
    .graph-container {
        flex-direction: column;
        align-items: center;
    }

    .bar-graph, .line-graph {
        width: 95% !important;
    }
}

@media (max-width: 1000px) {
    .top-container {
        flex-direction: column;
        gap: 20px;
    }

    #control-container {
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* Additional responsive styles for enhanced features */
@media (max-width: 768px) {
    .score-box {
        width: 90px;
        height: 70px;
        font-size: 3.5em;
    }
    
    .aggression-indicator {
        font-size: 0.25em;
        top: -25px;
        right: 32px;
    }
    
    .fighter-name {
        min-width: 160px;
        font-size: 1.8em;
    }
    
    .bar-graph, .line-graph {
        height: 300px !important;
    }

    .username-content {
        margin: 10% auto;
        padding: 20px;
        max-width: 90%;
    }

    .username-content h2 {
        font-size: 1.8em;
    }

    #usernameInput {
        font-size: 1.1em;
        padding: 12px;
    }

    .save-username {
        font-size: 1.1em;
        padding: 10px 25px;
    }
}

/* Chart Animation Enhancements */
.chart-flash-blue {
    animation: flashBlue 0.6s ease-in-out;
}

.chart-flash-red {
    animation: flashRed 0.6s ease-in-out;
}

@keyframes flashBlue {
    0%, 100% { opacity: 1; }
    50% { 
        opacity: 0.7; 
        filter: brightness(1.3) saturate(1.2);
    }
}

@keyframes flashRed {
    0%, 100% { opacity: 1; }
    50% { 
        opacity: 0.7; 
        filter: brightness(1.3) saturate(1.2);
    }
}