/* Base styles */
body {
    font-family: 'Arial', sans-serif;
    background-color: black;
    color: white;
    margin: 0;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    box-sizing: border-box;
    overflow-x: hidden;
}

.scoreboard {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 1000px;
    background-color: black;
    border: 3px solid white;
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
    box-sizing: border-box;
}

/* Timer section */
.timer-section {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 72px;
    font-weight: bold;
    margin-bottom: 15px;
    background-color: #111;
    padding: 10px;
    border-radius: 10px;
    position: relative;
}

.timer-buttons {
    position: absolute;
    right: 20px;
    display: flex;
    gap: 10px;
}

/* New competitors container for better organization */
.competitors-container {
    display: flex;
    flex-direction: row;
    gap: 15px;
    width: 100%;
    box-sizing: border-box;
}

/* Competitor block includes both competitor and deduct sections */
.competitor-block {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Competitor sections */
.competitor {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px;
    border-radius: 10px;
    position: relative;
    box-sizing: border-box;
    width: 100%;
}

.red {
    background-color: rgba(139, 0, 0, 0.3);
    border: 2px solid #8B0000;
}

.blue {
    background-color: rgba(0, 0, 139, 0.3);
    border: 2px solid #00008B;
}

.name {
    font-size: 36px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 10px;
}

.score {
    font-size: 100px;
    font-weight: bold;
    margin: 10px 0;
}

/* Category indicators */
.category {
    font-size: 24px;
    margin-bottom: 5px;
}

/* Penalties */
.penalties {
    display: flex;
    gap: 15px;
    margin: 10px 0;
}

.penalty-light {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: #333;
    border: 2px solid white;
}

.penalty-active {
    background-color: yellow;
}

/* P Button (in a circle) */
.penalty-btn {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    cursor: pointer;
    background-color: #333;
    color: white;
    font-size: 16px;
    z-index: 10;
}

.red .penalty-btn:hover {
    background-color: #A52A2A;
}

.blue .penalty-btn:hover {
    background-color: #0000CD;
}

/* Deduct controls section */
.deduct-section {
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding: 10px 0;
    box-sizing: border-box;
}

.red-deducts button {
    background-color: #5B0000;
}

.blue-deducts button {
    background-color: #00005B;
}

/* Controls */
.controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
}

.points-buttons {
    display: flex;
    justify-content: space-around;
    gap: 10px;
    margin-bottom: 5px;
}

button {
    padding: 10px 15px;
    border: none;
    border-radius: 5px;
    color: white;
    font-size: 18px;
    cursor: pointer;
    min-width: 60px;
    transition: background-color 0.2s;
}

button:hover {
    opacity: 0.9;
}

.point-button {
    font-weight: bold;
    font-size: 24px;
}

.red-button {
    background-color: #8B0000;
}

.red-button:hover {
    background-color: #A52A2A;
}

.blue-button {
    background-color: #00008B;
}

.blue-button:hover {
    background-color: #0000CD;
}

.deduct {
    background-color: #222;
    border: 1px solid #555;
}

.reset-button {
    background-color: #333;
    margin-top: 10px;
}

.reset-section {
    display: flex;
    justify-content: center;
    margin-top: 15px;
    gap: 10px;
    flex-wrap: wrap;
}

/* Senshu indicator */
.senshu-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    cursor: pointer;
    background-color: #333;
}

.senshu-active {
    background-color: gold;
    color: black;
}

/* Sound controls */
.sound-settings {
    margin-top: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.toggle-sound {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Alert message for end of time */
.time-up-alert {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.alert-content {
    font-size: 120px;
    color: red;
    font-weight: bold;
    text-align: center;
    animation: blink 1s infinite;
}

@keyframes blink {
    0% { opacity: 1; }
    50% { opacity: 0.3; }
    100% { opacity: 1; }
}

/* Responsive design */
/* Tablet layout */
@media (max-width: 900px) and (min-width: 481px) {
    .scoreboard {
        padding: 10px;
    }
    
    .timer-section {
        font-size: 60px;
        margin-bottom: 10px;
    }
    
    .name {
        font-size: 30px;
    }
    
    .score {
        font-size: 80px;
    }
    
    .category {
        font-size: 20px;
    }
    
    .penalties {
        gap: 10px;
    }
    
    .penalty-light {
        width: 25px;
        height: 25px;
    }
    
    .point-button {
        font-size: 20px;
        padding: 8px 12px;
    }
    
    .reset-button {
        font-size: 16px;
    }
    
    .alert-content {
        font-size: 80px;
    }
    
    .penalty-btn {
        width: 24px;
        height: 24px;
        font-size: 14px;
    }
}

/* Mobile layout */
@media (max-width: 480px) {
    body {
        padding: 5px;
    }
    
    .scoreboard {
        padding: 5px;
        border-width: 2px;
    }
    
    .timer-section {
        font-size: 40px;
        margin-bottom: 5px;
        padding: 5px;
    }
    
    .timer-buttons {
        position: static;
        margin-top: 5px;
    }
    
    /* Stack competitor blocks in mobile view */
    .competitors-container {
        flex-direction: column;
        gap: 5px;
    }
    
    .competitor {
        padding: 5px;
    }
    
    .name {
        font-size: 22px;
        margin-bottom: 2px;
    }
    
    .category {
        font-size: 18px;
        margin-bottom: 2px;
    }
    
    .score {
        font-size: 50px;
        margin: 2px 0;
    }
    
    .penalties {
        gap: 8px;
        margin: 5px 0;
    }
    
    .penalty-light {
        width: 20px;
        height: 20px;
    }
    
    .penalty-btn {
        width: 20px;
        height: 20px;
        font-size: 12px;
        top: 5px;
        left: 5px;
    }
    
    .controls {
        gap: 5px;
    }
    
    .points-buttons {
        margin-bottom: 2px;
        gap: 5px;
    }
    
    .deduct-section {
        padding: 5px 0;
    }
    
    button {
        padding: 6px 10px;
        font-size: 14px;
        min-width: 40px;
    }
    
    .point-button {
        font-size: 16px;
    }
    
    .reset-section {
        margin-top: 5px;
        gap: 5px;
    }
    
    .reset-button {
        padding: 5px 8px;
        font-size: 12px;
        margin-top: 5px;
    }
    
    .sound-settings {
        margin-top: 5px;
        font-size: 14px;
    }
    
    .senshu-indicator {
        width: 22px;
        height: 22px;
        top: 5px;
        right: 5px;
        font-size: 12px;
    }
    
    .alert-content {
        font-size: 50px;
    }
    
    .toggle-sound label {
        font-size: 14px;
    }
}

/* Very small phones/portrait mode */
@media (max-width: 360px) {
    .timer-section {
        font-size: 32px;
    }
    
    .score {
        font-size: 40px;
    }
    
    .name, .category {
        font-size: 16px;
    }
    
    .point-button {
        font-size: 14px;
        padding: 4px 8px;
    }
    
    .penalty-light {
        width: 16px;
        height: 16px;
    }
    
    .reset-button {
        font-size: 11px;
        padding: 4px 6px;
    }
    
    .senshu-indicator, .penalty-btn {
        width: 18px;
        height: 18px;
        font-size: 10px;
    }
}

/* Landscape mode adjustments */
@media (max-height: 500px) and (orientation: landscape) {
    .scoreboard {
        padding: 5px;
    }
    
    .timer-section {
        font-size: 36px;
        margin-bottom: 5px;
        padding: 5px;
    }
    
    .competitors-container {
        flex-direction: row;
    }
    
    .competitor {
        padding: 5px;
    }
    
    .name {
        font-size: 20px;
        margin-bottom: 2px;
    }
    
    .score {
        font-size: 40px;
        margin: 2px 0;
    }
    
    .category {
        font-size: 16px;
        margin-bottom: 2px;
    }
    
    .penalties {
        gap: 5px;
        margin: 3px 0;
    }
    
    .penalty-light {
        width: 16px;
        height: 16px;
    }
    
    .point-button {
        font-size: 14px;
        padding: 4px 8px;
    }
    
    .reset-section {
        margin-top: 5px;
    }
    
    .reset-button {
        padding: 4px 6px;
        font-size: 11px;
    }
}

/* Timer control buttons */
.timer-buttons button {
    background-color: #444;
    color: white;
    border: 1px solid #888;
    transition: background-color 0.3s, color 0.3s;
}

.timer-buttons button:hover {
    background-color: #666;
}

/* Start button - green when idle, red when running */
#startTimer.start-mode {
    background-color: #006400; /* dark green */
}

#startTimer.pause-mode {
    background-color: #8B0000; /* dark red */
}

/* Responsive Layout Adjustments */

/* Desktop and Laptop: Landscape Left/Right */
@media (min-width: 901px) {
    .competitors-container {
        flex-direction: row;
    }
}

/* Tablet Portrait: Stacked (Top/Bottom) */
@media (max-width: 900px) and (orientation: portrait) {
    .competitors-container {
        flex-direction: column;
    }
}

/* Phone: Stacked layout (Top/Bottom) */
@media (max-width: 480px) {
    .competitors-container {
        flex-direction: column;
    }
}

/* Landscape-mode on smaller screens (like phones turned sideways) */
@media (max-height: 500px) and (orientation: landscape) {
    .competitors-container {
        flex-direction: row;
    }
}

/* Fix desktop layout to evenly spread competitor blocks */
.competitors-container {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    gap: 20px;
}

.competitor-block {
    flex: 1;
    min-width: 0;
}
