:root {
    --cell-margin: 0.1rem;
    --match-cell-height: auto;
    --players-font-multiplier: 1.2;
    --status-font-multiplier: 0.5;
    --category-font-multiplier: 1;
    --court-header-font-multiplier: 1;
    --time-cell-font-multiplier: 1;
    --court-col-min-width: auto;
}

html,
body {
    height: 100%;
    margin: 0;
    background-color: #1a1a1a;
    overflow: hidden;
    font-size: 10px;
}

body {
    font-family: 'Roboto', Arial, sans-serif;
    color: #f0f0f0;
}

#schedule-container {
    height: 100vh;
    width: 100vw;
    overflow: auto;
    scroll-behavior: smooth;
}

#schedule-table {
    width: 100%;
    border-collapse: collapse;
    background-color: #212121;
}

th,
td {
    border: 0.1rem solid #4a4a4a;
    padding: 0;
    text-align: center;
    vertical-align: middle;
}

#schedule-table thead tr {
    position: sticky;
    top: 0;
    z-index: 4;
}

th.court-col {
    background-color: #2c2c2c;
    font-weight: 900;
    font-size: calc(1.6em * var(--court-header-font-multiplier));
    padding: 1.2rem 0.5rem;
    color: #FFD700;
    border-bottom: 0.2rem solid #FFD700;
    cursor: grab;
    min-width: var(--court-col-min-width);
}

th.court-col:active {
    cursor: grabbing;
}

th.court-col.over {
    background-color: #444;
}

th.time-header {
    width: 3rem !important;
    background-color: #2c2c2c;
}

/* REEMPLAZA TU REGLA "td.time-cell" ANTIGUA CON ESTA */
td.time-cell {
    background-color: #2c2c2c;
    font-weight: 700;
    font-size: calc(1.8em * var(--time-cell-font-multiplier));
    width: 4rem; /* Mantenemos el ancho extra para seguridad */
    min-width: 4rem;
    position: sticky;
    left: 0;
    z-index: 2;
    padding: 0.5rem 0; /* Añadimos un poco de padding vertical */
}

/* AÑADE ESTA NUEVA REGLA JUSTO DEBAJO */
td.time-cell > span {
    display: block;
    transform: rotate(-90deg);
    white-space: nowrap; /* Evita que el texto se parta en dos líneas */
}

.day-separator-row td {
    background-color: #000;
    color: #FFD700;
    font-size: 1.8em;
    font-weight: 900;
    padding: 1rem;
    border-top: 3px solid #FFD700;
    border-bottom: 3px solid #FFD700;
    position: sticky;
    top: 57px;
    z-index: 3;
    opacity: 0;
    height: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-width: 0;
    transition: opacity 0.3s ease-out, height 0.3s ease-out, padding 0.3s ease-out, border-width 0.3s ease-out;
}

.day-separator-row.visible td {
    opacity: 1;
    height: auto;
    padding: 1rem;
    border-width: 3px 0;
}

.match-cell {
    height: var(--match-cell-height);
    padding: 0;
}

.match-wrapper {
    width: 100%;
    height: 100%;
    border-radius: 0.8rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem;
    box-sizing: border-box;
    position: relative;
    transition: box-shadow 0.5s ease-in-out;
    background-color: var(--match-bg-color);
    /* Usamos una variable para el color de fondo */
}

.match-players {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    font-size: calc(2.2em * var(--players-font-multiplier));
    line-height: 1.1;
    font-weight: 900;
}

.player-name {
    flex-grow: 1;
    text-align: center;
    color: #000;
    text-shadow: 0 0 3px #fff, 0 0 5px #fff;
    transition: color 0.3s;
}

.player-name.loser {
    color: #666;
    text-shadow: 0 0 2px #fff;
}

.vs-separator,
.match-score,
.match-live {
    font-weight: 900;
    font-size: calc(1.6em * var(--status-font-multiplier));
}

.vs-separator {
    font-weight: 500;
    opacity: 0.8;
    color: #fff;
}

.match-score,
.match-live {
    padding: 0.2rem 1.2rem;
    border-radius: 0.6rem;
}

.match-score {
    background-color: rgba(255, 255, 255, 0.95);
    color: #000;
}

.match-live {
    background-color: #d90429;
    color: #fff;
    animation: pulse 1.5s infinite;
    font-weight: bold;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(217, 4, 41, 0.7);
    }

    70% {
        box-shadow: 0 0 0 1rem rgba(217, 4, 41, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(217, 4, 41, 0);
    }
}

.match-category-stage-line {
    font-size: calc(1.1em * var(--category-font-multiplier));
    font-weight: bold;
    color: #000;
    text-shadow: 0 0 4px #fff, 0 0 2px #fff;
    width: 100%;
    text-align: center;
}

.live-match .match-wrapper {
    outline: 0.4rem solid #d90429 !important;
    outline-offset: -0.4rem;
}

.match-wrapper.updated {
    box-shadow: 0 0 1.5rem 0.5rem rgba(255, 255, 0, 0.5);
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1002;
}

.modal-overlay.hidden {
    display: none;
}

.modal-content {
    background-color: #2c2c2c;
    color: #e0e0e0;
    padding: 2rem;
    border-radius: 0.8rem;
    width: 90%;
    max-width: 50rem;
    position: relative;
    text-align: center;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-close-btn {
    position: sticky;
    top: -1rem;
    right: -1rem;
    float: right;
    font-size: 2.5rem;
    font-weight: bold;
    cursor: pointer;
    color: #aaa;
    z-index: 1004;
    background: #2c2c2c;
    border-radius: 50%;
    width: 3rem;
    height: 3rem;
    line-height: 3rem;
}

.analyze-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    width: 3rem;
    height: 3rem;
    cursor: pointer;
    font-size: 1.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.analyze-btn:hover {
    background: rgba(255, 255, 255, 0.4);
}

#tournament-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.tournament-card {
    background-color: #3a3a3a;
    border-radius: 0.8rem;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.tournament-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 1rem 2rem rgba(0, 0, 0, 0.3);
}

.tournament-card img {
    width: 100%;
    height: 12rem;
    object-fit: cover;
    display: block;
}

.tournament-card-title {
    padding: 1rem;
    font-size: 1.4rem;
    font-weight: bold;
}

.custom-card {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    background-color: #1a1a1a;
    border: 2px dashed #444;
}

.custom-card:hover {
    border-color: #FFD700;
    color: #FFD700;
}

.custom-card .plus-icon {
    font-size: 4rem;
    font-weight: bold;
}

#floating-clock {
    position: fixed;
    top: 1rem;
    right: 1.5rem;
    background-color: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 0.5rem 1.5rem;
    font-family: 'Roboto', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    border-radius: 0.8rem;
    z-index: 1001;
    display: flex;
    align-items: center;
    gap: 1rem;
}

#clock-spinner {
    width: 1.6rem;
    height: 1.6rem;
    border: 0.2rem solid #555;
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

#clock-spinner.hidden {
    display: none;
}

#settings-modal .modal-content {
    max-width: 40rem;
    font-size: 0.8em;
    padding: 1.5rem;
}

#settings-modal .modal-content h4 {
    font-size: 1.2em;
    color: #FFD700;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #555;
    text-align: left;
}

.settings-single-column {
    display: flex;
    flex-direction: column;
}

.settings-section {
    border-top: 1px solid #444;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    text-align: left;
}

.settings-section:first-child {
    border-top: none;
    margin-top: 0;
    padding-top: 0;
}

.label-control-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.label-control {
    padding: 0.6rem 1rem;
}

.label-control>label {
    font-size: 1.1em;
    margin-bottom: 0.6rem;
}

.control-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 1rem;
}

.control-row span {
    font-size: 1.1em;
    min-width: 30px;
    text-align: right;
}

.setting-input,
.setting-slider,
.setting-toggle {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1.2rem;
    margin-bottom: 1rem;
    align-items: center;
}

.setting-input label,
.setting-slider label,
.setting-toggle label {
    font-size: 1.1em;
}

.setting-input select,
.setting-input input {
    padding: 0.5rem;
    font-size: 1.1em;
}

.toggle-switch {
    transform: scale(0.8);
}

#change-tournament-btn,
#reset-all-btn,
#toggle-court-names-btn {
    width: 100%;
    color: white;
    border: none;
    padding: 0.8rem;
    border-radius: .5rem;
    cursor: pointer;
    margin-top: 1rem;
    font-size: 1.1em;
    font-weight: bold;
}

#change-tournament-btn {
    background-color: #d90429;
}

#reset-all-btn {
     background-color: #dc3545;
}

#toggle-court-names-btn {
    background-color: #6c757d;
}

#court-filters {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-top: 1rem;
}

.court-filter-item {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 1.2rem;
    background-color: rgba(0, 0, 0, 0.2);
    padding: 0.8rem;
    border-radius: 4px;
}

.court-name-span {
    flex-grow: 1;
    outline: none;
    font-size: 1.2em;
}

.court-name-span[contenteditable="true"] {
    background-color: #555;
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
}

.court-filter-item .icon-btn {
    cursor: pointer;
    font-size: 1.4em;
    background: none;
    border: none;
    color: #fff;
    padding: 0.5rem;
}

.court-filter-item .icon-btn:hover {
    background-color: #555;
    border-radius: 50%;
}

.hidden-icon {
    display: none;
}

#modal-scroll-controls {
    position: absolute;
    top: 1.5rem;
    left: 1.5rem;
    z-index: 1005;
    display: none;
    flex-direction: row;
    gap: 1rem;
}

#settings-modal.has-scroll #modal-scroll-controls {
    display: flex;
}

#modal-scroll-controls button {
    width: 3rem;
    height: 3rem;
    font-size: 1.5rem;
    line-height: 1;
    background-color: rgba(255, 215, 0, 0.8);
    color: #1a1a1a;
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
}

#fire-tv-fab {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    background-color: #ff9900;
    color: white;
    border: none;
    padding: 0.8rem 1.2rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: bold;
}

#fire-tv-widget {
    position: fixed;
    bottom: 2.5rem;
    left: 2.5rem;
    width: 340px;
    background-color: rgba(15, 23, 42, 0.9);
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 1.5rem;
    z-index: 2000;
    color: white;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    transform: translateX(-150%);
    transition: transform 0.4s ease-in-out;
}

#fire-tv-widget.visible {
    transform: translateX(0);
}

#fire-tv-widget .video-container {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

#fire-tv-widget .video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#fire-tv-widget .button-group {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

#fire-tv-widget .button-group button {
    flex-grow: 1;
    background-color: #007bff;
    color: white;
    border: none;
    padding: 1rem;
    font-size: 1.4rem;
    font-weight: bold;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
}

#settings-fab,
#fullscreen-fab {
    position: fixed;
    bottom: 1.5rem;
    width: 4.5rem;
    height: 4.5rem;
    color: white;
    border: none;
    border-radius: 50%;
    box-shadow: 0 0.4rem 1rem rgba(0, 0, 0, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

#settings-fab {
    right: 1.5rem;
    background-color: #0d6efd;
}

#fullscreen-fab {
    left: 1.5rem;
    background-color: #343a40;
}

#custom-url-modal input {
    width: 100%;
    padding: 1rem;
    margin-top: 1rem;
    font-size: 1.4rem;
    box-sizing: border-box;
}

.custom-url-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.5rem;
}

.custom-url-buttons button {
    padding: 1rem 1.5rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
}

#custom-url-load {
    background-color: #0d6efd;
    color: white;
}