/* style.css */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-tap-highlight-color: transparent;
}

body {
    /* Dynamic properties set in index.php's <style> block */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    padding: 5px;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    overflow: hidden;
    background-color: var(--app-bg-color, inherit); /* Use body's bg by default */
    border-radius: var(--card-border-radius); /* Rounded corners for the app container itself */
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid #333;
    flex-shrink: 0;
    /* Removed top-left/right radius, app-container now has it */
}

.page-title {
    font-size: clamp(1.5rem, 5vw, 2rem);
    font-weight: normal;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    margin: 0;
}

.settings-button {
    font-size: 1.8rem;
    padding: 5px 8px;
    border: 1px solid #000000; /* Black outline */
    cursor: pointer;
    line-height: 1;
    transition: background-color 0.2s ease, transform 0.1s ease;
    /* background-color & color set by inline style from PHP */
    border-radius: var(--button-border-radius);
}
.settings-button:hover {
    background-color: #7FB3D5 !important; /* Ensure hover overrides inline if !important is needed */
}
.settings-button:active {
    transform: scale(0.95);
}

.teams-container {
    display: grid;
    gap: 10px;
    padding: 10px;
    overflow-y: auto;
    flex-grow: 1;
    align-content: flex-start;
    grid-template-columns: repeat(2, 1fr);
}

.teams-container.teams-1 { grid-template-columns: 1fr; }
.teams-container.teams-2 { grid-template-columns: repeat(2, 1fr); }
.teams-container.teams-3 { grid-template-columns: repeat(3, 1fr); }
.teams-container.teams-4 { grid-template-columns: repeat(2, 1fr); }
.teams-container.teams-5, .teams-container.teams-6 {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}
@media (max-width: 400px) {
  .teams-container.teams-3 { grid-template-columns: repeat(2, 1fr); }
}


.team-card {
    color: #FFFFFF; /* Default text, JS can override with data-text-color */
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    text-align: center;
    min-height: 150px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: box-shadow 0.3s ease, transform 0.3s ease;
    position: relative; /* For neon glow */
    border-radius: var(--card-border-radius); /* Use CSS variable */
    /* background-color set by JS */
}

/* Neon Glow Styling */
.team-card.highest-score::before {
    content: '';
    position: absolute;
    /* Make it slightly larger than the card to form a border */
    top: -4px;   /* Adjust thickness of glow border */
    left: -4px;
    right: -4px;
    bottom: -4px;
    background: var(--glow-color); /* Team's color, set by JS */
    border-radius: calc(var(--card-border-radius) + 4px); /* Ensure rounded corners match and expand */
    z-index: -1; /* Behind the card content */
    filter: blur(8px); /* The blur effect - adjust strength */
    opacity: 0; /* Start transparent for animation */
    animation: neonGlow 1.5s infinite alternate;
}

@keyframes neonGlow {
    from {
        opacity: 0.6; /* Start opacity */
        transform: scale(1);
    }
    to {
        opacity: 1;   /* Full opacity at peak */
        transform: scale(1.01); /* Slight pulse outwards */
    }
}

.team-name {
    font-size: clamp(1rem, 4vw, 1.3rem);
    font-weight: bold;
    margin-bottom: 8px;
    word-break: break-word;
}

.team-score {
    font-size: clamp(2.5rem, 10vw, 4rem);
    font-weight: bold;
    margin: 5px 0;
    line-height: 1;
}

.score-controls {
    display: flex;
    justify-content: space-around;
    width: 100%;
    margin-top: 10px;
}

.score-button {
    font-size: 1.5rem;
    font-weight: bold;
    padding: 10px 0;
    flex-grow: 1;
    margin: 0 5px;
    border: 1px solid #000000; /* Black outline */
    color: white;
    cursor: pointer;
    border-radius: var(--button-border-radius); /* Use CSS variable */
    transition: transform 0.1s ease, box-shadow 0.2s ease;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.6); /* Text shadow for +1 / -1 */
    /* background-color set by inline style from PHP */
}
.score-button:active {
    transform: translateY(2px) scale(0.98);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}


/* Settings Modal */
#modal-backdrop {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.6);
    z-index: 999;
}

.settings-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: clamp(300px, 90vw, 500px);
    max-height: 85vh;
    overflow-y: auto;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s 0.2s;
    /* background-color, color, border-radius set by inline style from PHP */
}

.settings-modal.visible {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
    transition-delay: 0s;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #444;
    padding-bottom: 10px;
    margin-bottom: 15px;
}
.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
}
.modal-close-button {
    font-size: 1.8rem;
    border: 1px solid #000000; /* Black outline */
    background: none; /* Overridden by inline style from PHP, but good for base */
    cursor: pointer;
    padding: 0 5px;
    color: var(--modal-text-color, #E0E0E0); /* Use text color from PHP */
    border-radius: var(--button-border-radius);
}
.modal-close-button:hover {
    background-color: #7FB3D5 !important; /* Ensure hover overrides inline */
    color: #FFFFFF !important;
}


.setting-item {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}
.setting-item label {
    margin-bottom: 5px;
    font-size: 0.9rem;
}
.setting-item input[type="text"],
.setting-item input[type="color"],
.setting-item select {
    padding: 8px 10px;
    border-radius: 5px;
    border: 1px solid #555;
    background-color: #2C3E50;
    color: #ECF0F1;
    font-size: 1rem;
    width: 100%;
}
.setting-item input[type="color"] {
    height: 40px;
    padding: 2px;
}

#team-settings-editors .team-editor {
    border: 2px solid white; /* Thicker white line around team editor */
    padding: 10px;
    margin-bottom: 10px;
    border-radius: var(--button-border-radius); /* Match other small radius */
}
#team-settings-editors .team-editor h4 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

#save-settings-button, #reset-scores-button {
    display: block;
    width: 100%;
    padding: 12px;
    font-size: 1.1rem;
    font-weight: bold;
    border: 1px solid #000000; /* Black outline */
    cursor: pointer;
    margin-top: 10px; /* Default margin, reset button might have more */
    transition: background-color 0.2s ease, transform 0.1s ease;
    border-radius: var(--button-border-radius);
    /* background-color & color set by inline style from PHP or specific ID styles */
}
#save-settings-button:active, #reset-scores-button:active {
    transform: scale(0.98);
}

#reset-scores-button {
    background-color: #c0392b; /* Specific red for reset, matches PHP var */
    color: #FFFFFF; /* Ensure text is white */
}
#reset-scores-button:hover {
    background-color: #e74c3c !important;
}


/* Debug Indicator */
#debug-indicator {
    position: fixed;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    background-color: red;
    color: white;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 10px;
    z-index: 10001;
}

.team-card[data-text-color="dark"] .team-name,
.team-card[data-text-color="dark"] .team-score {
    color: #2c3e50;
}
.team-card[data-text-color="light"] .team-name,
.team-card[data-text-color="light"] .team-score {
    color: #FFFFFF;
}

@media (max-width: 360px), (min-width: 400px) and (max-width: 600px) and (max-teams >= 5) {
    .teams-container.teams-5, .teams-container.teams-6 {
        grid-template-columns: repeat(2, 1fr);
    }
    .team-score {
        font-size: clamp(2rem, 8vw, 3rem);
    }
    .team-name {
        font-size: clamp(0.9rem, 3.5vw, 1.1rem);
    }
}
/* style.css */