/* ============================
   Base layout
   ============================ */

.aca-tournament-body {
    background: radial-gradient(circle at top left, #eef2ff 0, #f5f7fb 40%, #f9fafb 100%);
}

.aca-tournament-page {
    max-width: 100%;
    margin: 0;
    padding: 0;
}

.aca-tournament-tabs {
    width: 100%;
    max-width: none;
    margin: 24px 0 40px;
    padding: 0 24px 40px;
    box-sizing: border-box;
}

/* Hide radio buttons used as tabs */
.aca-tab-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

/* ============================
   Layout: sidebar + main
   ============================ */

.aca-tournament-layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 1.5rem;
    align-items: flex-start;
}

/* Sidebar: card-style, sticky */
.aca-tournament-sidebar {
    background: #f7f8ff;
    border-radius: 18px;
    padding: 1.5rem 1.25rem;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.05);
    border: 1px solid rgba(148, 163, 184, 0.25);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow-x: hidden;
    position: sticky;
    top: 24px;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
}

.aca-tournament-logo {
    text-align: center;
    margin-bottom: 24px;
}

.aca-tournament-logo img {
    max-width: 140px;
    height: auto;
}

/* ============================
   Sidebar menu
   ============================ */

.aca-tournament-menu {
    list-style: none;
    margin: 0;
    padding: 0;
}

.aca-tournament-menu-item + .aca-tournament-menu-item {
    margin-top: 6px;
}

.aca-tournament-menu-item label {
    display: block;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 17px;
    cursor: pointer;
    color: #111827;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.aca-tournament-menu-item label:hover {
    background-color: #f9f9f9;
    color: #e0b37e;
    transform: translateX(1px);
}

/* Active menu highlighting — single tournament */
#aca-tab-info:checked ~ .aca-tournament-layout .aca-menu-info label,
#aca-tab-register:checked ~ .aca-tournament-layout .aca-menu-register label,
#aca-tab-entries:checked ~ .aca-tournament-layout .aca-menu-entries label,
#aca-tab-pairings:checked ~ .aca-tournament-layout .aca-menu-pairings label,
#aca-tab-standings:checked ~ .aca-tournament-layout .aca-menu-standings label,
#aca-tab-live:checked ~ .aca-tournament-layout .aca-menu-live label,
#aca-tab-questions:checked ~ .aca-tournament-layout .aca-menu-questions label {
    background: #1a1a1a;
    color: #e0b37e;
    border-left: 4px solid #e0b37e;
}

/* Sidebar bottom */
.aca-tournament-bottom {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
}

.aca-tournament-back {
    margin-bottom: 8px;
}

.aca-tournament-back-link {
    font-size: 14px;
    text-decoration: none;
    color: #111827;
}

.aca-tournament-back-link:hover {
    text-decoration: underline;
}

.aca-tournament-copyright {
    font-size: 12px;
    color: #6b7280;
}

/* ============================
   Main column
   ============================ */

.aca-tournament-main {
    background: #ffffff;
    border-radius: 16px;
    padding: 24px 28px 32px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
    border: 1px solid #e5e7eb;
    font-size: 16px;
}

/* ============================
   Tables: site-safe horizontal scrolling
   ============================ */

.aca-tournament-main .wp-block-table,
.aca-tournament-main figure.wp-block-table,
.aca-tournament-main .elementor-widget-container,
.aca-tournament-main .aca-tournament-section,
.aca-tournament-main .aca-tournament-entries-table {
    max-width: 100%;
}

/* General non-entry tables */
.aca-tournament-main table:not(.aca-wpforms-entries) {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.aca-tournament-main table:not(.aca-wpforms-entries) th,
.aca-tournament-main table:not(.aca-wpforms-entries) td {
    white-space: nowrap;
}

/* WPForms entries table is handled by the entries wrapper */
.aca-tournament-main table.aca-wpforms-entries {
    display: table;
    width: max-content;
    max-width: none;
}

/* ============================
   Tab section visibility
   ============================ */

.aca-tournament-section {
    display: none;
}

/* Single tournament tabs */
#aca-tab-info:checked ~ .aca-tournament-layout #aca-info,
#aca-tab-register:checked ~ .aca-tournament-layout #aca-register,
#aca-tab-entries:checked ~ .aca-tournament-layout #aca-entries,
#aca-tab-pairings:checked ~ .aca-tournament-layout #aca-pairings,
#aca-tab-standings:checked ~ .aca-tournament-layout #aca-standings,
#aca-tab-live:checked ~ .aca-tournament-layout #aca-live,
#aca-tab-questions:checked ~ .aca-tournament-layout #aca-questions {
    display: block;
}

/* ============================
   Summary card
   ============================ */

.aca-tournament-summary-card {
    background: #eef3ff;
    border-radius: 18px;
    padding: 22px 26px 24px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.12);
    margin-bottom: 24px;
}

.aca-tournament-header {
    margin-bottom: 12px;
}

.aca-tournament-title {
    font-size: 28px;
    line-height: 1.25;
    margin: 0 0 10px;
}

.aca-tournament-status,
.aca-tournament-dates,
.aca-tournament-format,
.aca-tournament-circuit {
    margin: 0 0 4px;
    font-size: 15px;
}

.aca-tournament-status-label,
.aca-tournament-summary-label {
    font-weight: 600;
    color: #4b5563;
    margin-right: 4px;
}

.aca-tournament-status-value {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    background: #e0f2fe;
    color: #0369a1;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.aca-tournament-circuit-label {
    font-weight: 600;
}

/* Meta grid */
.aca-tournament-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 40px;
    margin-top: 10px;
}

.aca-tournament-meta-left,
.aca-tournament-meta-right {
    flex: 1 1 260px;
}

.aca-tournament-field {
    margin: 0 0 4px;
    font-size: 15px;
}

.aca-tournament-field strong {
    font-weight: 600;
    color: #374151;
}

.aca-register-refresh-note {
    margin: 0 0 14px;
    font-size: 0.9rem;
    color: #6b7280;
}

.aca-register-refresh-note #aca-register-timer {
    font-weight: 600;
    margin-left: 4px;
}

/* ============================
   Info tab sections
   ============================ */

.aca-tournament-brief,
.aca-tournament-regulations {
    margin-top: 24px;
}

.aca-tournament-brief h2,
.aca-tournament-section-register h2,
.aca-tournament-section-pairings h2,
.aca-tournament-section-standings h2,
.aca-tournament-section-live h2,
.aca-tournament-contact h2 {
    font-size: 22px;
    margin: 0 0 12px;
    color: #1a1a1a;
    border-left: 4px solid #e0b37e;
    padding-left: 8px;
}

.aca-tournament-regulations h2 {
    /* Reserved for future heading if needed */
}

.aca-tournament-brief-content,
.aca-tournament-regulations-content {
    font-size: 16px;
    line-height: 1.7;
}

.aca-tournament-regulations-content p:last-child {
    margin-bottom: 0;
}

/* Register tab heading */
.aca-tournament-register-heading {
    font-size: 24px;
    margin-bottom: 14px;
}

/* ============================
   Entries table
   ============================ */

.aca-tournament-entries-table {
    display: block !important;
    margin-top: 4px;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: visible !important;
    -webkit-overflow-scrolling: touch !important;
    padding-bottom: 10px !important;
}

/* Headings above entries table */
.aca-tournament-entries-table h2 {
    margin: 0 0 12px;
    font-size: 28px;
    line-height: 1.25;
}

.aca-tournament-entries-table h3 {
    margin: 0 0 18px;
    font-size: 20px;
    line-height: 1.35;
}

/* Force the entries table to be wider than the card */
.aca-tournament-main .aca-tournament-entries-table table.aca-wpforms-entries,
.aca-tournament-entries-table .aca-wpforms-entries {
    display: table !important;
    border-collapse: collapse !important;
    table-layout: fixed !important;
    width: 1375px !important;
    min-width: 1375px !important;
    max-width: none !important;
    margin: 0 !important;
    font-size: 15px !important;
    line-height: 1.45 !important;
}

/* Cells */
.aca-tournament-main .aca-tournament-entries-table table.aca-wpforms-entries th,
.aca-tournament-main .aca-tournament-entries-table table.aca-wpforms-entries td,
.aca-tournament-entries-table .aca-wpforms-entries th,
.aca-tournament-entries-table .aca-wpforms-entries td {
    box-sizing: border-box !important;
    padding: 10px 14px !important;
    border: 1px solid #e5e7eb !important;
    text-align: center !important;
    vertical-align: middle !important;
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
    hyphens: none !important;
}

.aca-tournament-main .aca-tournament-entries-table table.aca-wpforms-entries th,
.aca-tournament-entries-table .aca-wpforms-entries th {
    background: #f3f4f6 !important;
    color: #111827 !important;
    font-weight: 600 !important;
}

.aca-tournament-main .aca-tournament-entries-table table.aca-wpforms-entries tr:nth-child(even),
.aca-tournament-entries-table .aca-wpforms-entries tr:nth-child(even) {
    background: #f9fafb !important;
}

.aca-tournament-main .aca-tournament-entries-table table.aca-wpforms-entries a,
.aca-tournament-entries-table .aca-wpforms-entries a {
    color: #2563eb !important;
    text-decoration: none !important;
}

.aca-tournament-main .aca-tournament-entries-table table.aca-wpforms-entries a:hover,
.aca-tournament-entries-table .aca-wpforms-entries a:hover {
    text-decoration: underline !important;
}

/* Exact entries column widths */
.aca-tournament-main .aca-tournament-entries-table .aca-wpforms-col-fide-title {
    width: 90px !important;
    min-width: 90px !important;
    max-width: 90px !important;
}

.aca-tournament-main .aca-tournament-entries-table .aca-wpforms-col-name {
    width: 190px !important;
    min-width: 190px !important;
    max-width: 190px !important;
    text-align: left !important;
}

.aca-tournament-main .aca-tournament-entries-table .aca-wpforms-col-fide-id {
    width: 125px !important;
    min-width: 125px !important;
    max-width: 125px !important;
}

.aca-tournament-main .aca-tournament-entries-table .aca-wpforms-col-fide-rating {
    width: 115px !important;
    min-width: 115px !important;
    max-width: 115px !important;
}

.aca-tournament-main .aca-tournament-entries-table .aca-wpforms-col-federation {
    width: 115px !important;
    min-width: 115px !important;
    max-width: 115px !important;
}

.aca-tournament-main .aca-tournament-entries-table .aca-wpforms-col-birth-year {
    width: 110px !important;
    min-width: 110px !important;
    max-width: 110px !important;
}

.aca-tournament-main .aca-tournament-entries-table .aca-wpforms-col-gender {
    width: 90px !important;
    min-width: 90px !important;
    max-width: 90px !important;
}

.aca-tournament-main .aca-tournament-entries-table .aca-wpforms-col-would-you-like-to-request-a-0-5-point-bye {
    width: 250px !important;
    min-width: 250px !important;
    max-width: 250px !important;
}

.aca-tournament-main .aca-tournament-entries-table .aca-wpforms-col-uscf-id {
    width: 125px !important;
    min-width: 125px !important;
    max-width: 125px !important;
}

.aca-tournament-main .aca-tournament-entries-table .aca-wpforms-col-uscf-expiration-date {
    width: 165px !important;
    min-width: 165px !important;
    max-width: 165px !important;
}

/* Numeric values */
.aca-tournament-main .aca-tournament-entries-table .aca-wpforms-col-fide-id,
.aca-tournament-main .aca-tournament-entries-table .aca-wpforms-col-uscf-id,
.aca-tournament-main .aca-tournament-entries-table .aca-wpforms-col-fide-rating,
.aca-tournament-main .aca-tournament-entries-table .aca-wpforms-col-birth-year,
.aca-tournament-main .aca-tournament-entries-table .aca-wpforms-col-uscf-expiration-date {
    font-variant-numeric: tabular-nums !important;
}

/* Do not split FIDE ID / USCF ID links */
.aca-tournament-main .aca-tournament-entries-table .aca-wpforms-col-fide-id a,
.aca-tournament-main .aca-tournament-entries-table .aca-wpforms-col-uscf-id a {
    white-space: nowrap !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
}

/* ============================
   USCF lookup problem badges
   ============================ */

.aca-uscf-id-problem,
.aca-uscf-exp-date-problem {
    background: #fff3cd;
}

td.aca-uscf-exp-date-problem {
    position: relative;
}

td.aca-uscf-exp-date-problem::before {
    content: "!";
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.15em;
    height: 1.15em;
    margin-right: 0.4em;
    border-radius: 999px;
    background: #b91c1c;
    color: #ffffff;
    font-weight: 800;
    font-size: 0.8em;
    line-height: 1;
    box-shadow: 0 1px 0 rgba(0,0,0,.08);
    transform: translateY(-0.03em);
    cursor: help;
}

td.aca-uscf-exp-date-problem::after {
    content: "Your USCF membership will expire before the tournament begins or during the event. Please renew it unless you are a GM/IM/WGM/WIM whose FIDE federation is outside the USA.";
    position: absolute;
    left: 50%;
    top: 0;
    transform: translate(-50%, -120%);
    max-width: 320px;
    width: max-content;
    padding: 8px 10px;
    border-radius: 10px;
    background: #111827;
    color: #ffffff;
    font-size: 12px;
    line-height: 1.35;
    text-align: left;
    box-shadow: 0 10px 25px rgba(0,0,0,.18);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .15s ease, transform .15s ease, visibility .15s ease;
    z-index: 50;
}

td.aca-uscf-exp-date-problem:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -135%);
}

/* ============================
   Contact section
   ============================ */

.aca-tournament-contact p {
    font-size: 16px;
}

/* ==========================================
   Circuit pages
   ========================================== */

#aca-circuit-tab-info:checked ~ .aca-tournament-layout #aca-circuit-info,
#aca-circuit-tab-scoring:checked ~ .aca-tournament-layout #aca-circuit-scoring,
#aca-circuit-tab-prizes:checked ~ .aca-tournament-layout #aca-circuit-prizes,
#aca-circuit-tab-standings:checked ~ .aca-tournament-layout #aca-circuit-standings,
#aca-circuit-tab-questions:checked ~ .aca-tournament-layout #aca-circuit-questions {
    display: block;
}

/* Active menu highlighting — circuit */
#aca-circuit-tab-info:checked ~ .aca-tournament-layout .aca-circuit-menu-info label,
#aca-circuit-tab-scoring:checked ~ .aca-tournament-layout .aca-circuit-menu-scoring label,
#aca-circuit-tab-prizes:checked ~ .aca-tournament-layout .aca-circuit-menu-prizes label,
#aca-circuit-tab-standings:checked ~ .aca-tournament-layout .aca-circuit-menu-standings label,
#aca-circuit-tab-questions:checked ~ .aca-tournament-layout .aca-circuit-menu-questions label {
    background: #1a1a1a;
    color: #e0b37e;
    border-left: 4px solid #e0b37e;
}

/* Sidebar tournaments list for circuits */
.aca-circuit-tournaments-block {
    margin-top: 18px;
}

.aca-circuit-tournaments-heading {
    margin: 0 0 6px;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #4b5563;
}

.aca-circuit-tournaments-list {
    max-height: 260px;
    overflow-y: auto;
    padding-right: 4px;
}

.aca-circuit-events {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 14px;
}

.aca-circuit-tournament + .aca-circuit-tournament {
    margin-top: 10px;
}

.aca-circuit-tournament-main {
    line-height: 1.4;
}

.aca-circuit-line-title {
    font-weight: 600;
}

.aca-circuit-tournament-title {
    color: #111827;
    text-decoration: none;
}

.aca-circuit-tournament-title:hover {
    text-decoration: underline;
}

.aca-circuit-line-meta {
    font-size: 13px;
    color: #6b7280;
    margin-top: 2px;
}

.aca-circuit-dates,
.aca-circuit-venue {
    font-size: 13px;
    color: #4b5563;
}

.aca-circuit-links {
    font-size: 13px;
    margin-top: 3px;
}

.aca-circuit-links a {
    color: #2563eb;
    text-decoration: none;
}

.aca-circuit-links a:hover {
    text-decoration: underline;
}

.aca-circuit-no-events {
    font-size: 13px;
    color: #6b7280;
}

/* Prevent included-tournaments list from spilling out */
#aca-circuit-tab-info ~ .aca-tournament-layout .aca-circuit-tournaments-list {
    max-width: 100%;
    overflow-x: hidden;
}

#aca-circuit-tab-info ~ .aca-tournament-layout .aca-circuit-tournament-main,
#aca-circuit-tab-info ~ .aca-tournament-layout .aca-circuit-line-meta,
#aca-circuit-tab-info ~ .aca-tournament-layout .aca-circuit-links {
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
}

/* ============================
   Responsive
   ============================ */

@media (max-width: 1024px) {
    .aca-tournament-tabs {
        padding: 0 16px 32px;
    }

    #aca-circuit-tab-info ~ .aca-tournament-layout .aca-tournament-sidebar {
        flex-direction: column;
        align-items: stretch;
        flex-wrap: nowrap;
        gap: 10px;
    }

    #aca-circuit-tab-info ~ .aca-tournament-layout .aca-tournament-logo {
        margin: 0 0 10px;
        text-align: center;
    }

    #aca-circuit-tab-info ~ .aca-tournament-layout .aca-tournament-menu {
        display: grid;
        grid-template-columns: repeat(1, 1fr);
        gap: 8px;
    }

    #aca-circuit-tab-info ~ .aca-tournament-layout .aca-tournament-menu-item + .aca-tournament-menu-item {
        margin-top: 0;
    }

    #aca-circuit-tab-info ~ .aca-tournament-layout .aca-tournament-menu-item label {
        width: 100%;
        text-align: center;
    }
}

@media (max-width: 900px) {
    .aca-tournament-layout {
        grid-template-columns: 1fr;
    }

    .aca-tournament-sidebar {
        position: static !important;
        flex-direction: column;
        max-height: none;
        overflow-y: visible;
        overflow-x: hidden;
    }

    .aca-circuit-tournaments-list {
        max-height: none;
    }

    .aca-tournament-main .aca-tournament-entries-table table.aca-wpforms-entries,
    .aca-tournament-entries-table .aca-wpforms-entries {
        width: 1375px !important;
        min-width: 1375px !important;
        font-size: 14px !important;
    }

    .aca-tournament-main .aca-tournament-entries-table table.aca-wpforms-entries th,
    .aca-tournament-main .aca-tournament-entries-table table.aca-wpforms-entries td,
    .aca-tournament-entries-table .aca-wpforms-entries th,
    .aca-tournament-entries-table .aca-wpforms-entries td {
        padding: 8px 10px !important;
    }

    .aca-tournament-entries-table h2 {
        font-size: 24px;
    }

    .aca-tournament-entries-table h3 {
        font-size: 17px;
    }
}

@media (max-width: 768px) {
    .aca-tournament-tabs {
        margin: 16px 0 24px;
        padding: 0 10px 24px;
    }

    .aca-tournament-layout {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .aca-tournament-sidebar {
        height: auto;
        flex-direction: row;
        position: static !important;
        align-items: flex-start;
        flex-wrap: wrap;
        gap: 8px 10px;
        padding: 12px 12px;
    }

    .aca-tournament-logo {
        margin: 0 12px 0 0;
    }

    .aca-tournament-menu {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        flex: 1 1 0;
        min-width: 0;
        justify-content: flex-start;
    }

    .aca-tournament-menu-item + .aca-tournament-menu-item {
        margin-top: 0;
    }

    .aca-tournament-menu-item label {
        font-size: 15px;
        padding: 6px 10px;
    }

    .aca-tournament-bottom {
        flex: 0 0 100%;
        width: 100%;
        margin-left: 0 !important;
        margin-top: 8px;
        text-align: center;
        padding-top: 10px;
        border-top: 1px solid #e5e7eb;
    }

    .aca-tournament-back-link {
        display: inline-block;
        max-width: 100%;
        white-space: normal;
        word-break: break-word;
        line-height: 1.25;
        font-size: 13px;
    }

    .aca-tournament-copyright {
        font-size: 11px;
        line-height: 1.3;
    }

    .aca-tournament-main {
        padding: 18px 14px 22px;
        overflow: visible !important;
    }

    .aca-tournament-summary-card {
        padding: 16px 16px 18px;
    }

    .aca-tournament-title {
        font-size: 24px;
    }

    .aca-tournament-meta {
        gap: 6px 18px;
    }

    /* Mobile entries table: use almost full screen width for the scroll area */
    .aca-tournament-main .aca-tournament-entries-table {
        width: calc(100vw - 20px) !important;
        max-width: calc(100vw - 20px) !important;
        margin-left: -14px !important;
        margin-right: -14px !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        padding-bottom: 12px !important;
        overflow-x: auto !important;
        overflow-y: visible !important;
        -webkit-overflow-scrolling: touch !important;
        touch-action: pan-x !important;
    }

    .aca-tournament-main .aca-tournament-entries-table table.aca-wpforms-entries {
        width: 1375px !important;
        min-width: 1375px !important;
        max-width: none !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    .aca-tournament-main .aca-tournament-entries-table::after {
        content: "";
        display: block;
        width: 12px;
        height: 1px;
    }
}