* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #0a0e27 0%, #1a1f3a 50%, #0f1419 100%);
    color: #e8eaed;
    min-height: 100vh;
    padding: 20px;
    overflow-x: hidden;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

h1 {
    text-align: center;
    margin-bottom: 20px;
    color: #fff;
    font-size: 2.5em;
    font-weight: 700;
    letter-spacing: -0.02em;
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    background: linear-gradient(135deg, #fff 0%, #e0e0e0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.instructions {
    background: linear-gradient(135deg, rgba(230, 0, 0, 0.08) 0%, rgba(255, 24, 1, 0.05) 100%);
    border-left: 3px solid #e10600;
    padding: 16px 24px;
    margin-bottom: 30px;
    border-radius: 12px;
    text-align: center;
    color: #f0f0f0;
    box-shadow: 0 2px 8px rgba(225, 6, 0, 0.15);
    backdrop-filter: blur(10px);
}

.tables-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 30px;
    margin-bottom: 40px;
}

@media (max-width: 500px) {
    .tables-container {
        grid-template-columns: 1fr;
    }
}

.table-wrapper {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.03) 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(20px);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.table-wrapper:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), 0 4px 12px rgba(0, 0, 0, 0.3);
}

.table-wrapper h2 {
    color: #fff;
    margin-bottom: 18px;
    font-size: 1.3em;
    font-weight: 600;
    letter-spacing: -0.01em;
    border-bottom: 2px solid #e10600;
    padding-bottom: 12px;
    background: linear-gradient(90deg, #e10600 0%, transparent 100%);
    background-size: 100% 2px;
    background-position: bottom;
    background-repeat: no-repeat;
}

.standings-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95em;
    table-layout: fixed;
}

/* Consistent column widths across tables */
.standings-table th:first-child,
.standings-table td:first-child {
    width: 50px;
}

#finalGPTable th:first-child,
#finalGPTable td:first-child {
    width: 40px;
}

#finalGPTable th:nth-child(2),
#finalGPTable td:nth-child(2) {
    width: 50px;
}

.standings-table thead {
    background: linear-gradient(135deg, rgba(225, 6, 0, 0.15) 0%, rgba(225, 6, 0, 0.08) 100%);
}

.standings-table th {
    padding: 14px 8px;
    text-align: center;
    font-weight: 600;
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #fff;
    border-bottom: 2px solid #e10600;
    white-space: nowrap;
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
}

.standings-table td {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    height: 48px;
    white-space: nowrap;
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

.standings-table tbody tr {
    transition: all 0.15s ease;
    border-radius: 4px;
    height: 48px;
}

.standings-table tbody tr:hover {
    background: linear-gradient(90deg, rgba(225, 6, 0, 0.1) 0%, transparent 100%);
    transform: translateX(2px);
}

.standings-table tbody tr:last-child td {
    border-bottom: none;
}

.drag-handle-header {
    width: 40px;
    padding: 12px 8px !important;
}

.drag-handle {
    cursor: grab;
    user-select: none;
    text-align: center;
    font-size: 1.4em;
    color: #999;
    padding: 0;
    width: 40px;
    height: 48px;
    line-height: 48px;
    opacity: 0.5;
    transition: all 0.2s ease;
    vertical-align: middle;
}

.drag-handle:hover {
    opacity: 1;
    color: #e10600;
    transform: scale(1.1);
}

.drag-handle:active {
    cursor: grabbing;
}

.draggable-tbody tr {
    user-select: none;
}

.draggable-tbody tr.dragging {
    opacity: 0.4;
    background: linear-gradient(90deg, rgba(225, 6, 0, 0.25) 0%, rgba(225, 6, 0, 0.15) 100%);
    transform: scale(0.98);
}

.draggable-tbody tr.drag-over {
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.12) 0%, transparent 100%);
    border-top: 2px solid #ffd700;
    box-shadow: 0 -2px 8px rgba(255, 215, 0, 0.2);
}

.position {
    font-weight: 700;
    color: #fff;
    text-align: center;
    width: 50px;
    font-size: 0.95em;
    background: linear-gradient(135deg, rgba(225, 6, 0, 0.15) 0%, transparent 100%);
    border-radius: 4px;
    height: 48px;
    line-height: 48px;
    padding: 0 !important;
}

.points {
    font-weight: 700;
    color: #ffd700;
    font-size: 1.05em;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

.empty-state p {
    margin: 10px 0;
}

@media (max-width: 1200px) {
    .tables-container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    h1 {
        font-size: 1.8em;
        margin-bottom: 15px;
    }

    .instructions {
        padding: 12px 15px;
        margin-bottom: 20px;
        font-size: 0.9em;
    }

    .tables-container {
        gap: 20px;
    }

    .table-wrapper {
        padding: 15px;
    }

    .table-wrapper h2 {
        font-size: 1.1em;
        margin-bottom: 12px;
    }

    .standings-table {
        font-size: 0.85em;
        min-width: 100%;
    }

    .standings-table th,
    .standings-table td {
        padding: 10px 8px;
    }

    /* Make tables scrollable horizontally on small screens */
    .standings-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    .standings-table thead,
    .standings-table tbody {
        display: table;
        width: 100%;
        table-layout: fixed;
    }

    .standings-table thead {
        width: calc(100% - 1em);
    }

    /* Increase touch target size for draggable rows */
    .draggable-tbody tr {
        min-height: 44px;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.5em;
        line-height: 1.2;
    }

    .instructions {
        padding: 10px;
        font-size: 0.85em;
    }

    .table-wrapper {
        padding: 10px;
        border-radius: 6px;
    }

    .table-wrapper h2 {
        font-size: 1em;
        margin-bottom: 10px;
        padding-bottom: 8px;
    }

    .standings-table {
        font-size: 0.75em;
    }

    .standings-table th,
    .standings-table td {
        padding: 8px 4px;
    }

    .position {
        width: 35px;
    }

    .drag-handle-header {
        width: 35px;
        padding: 8px 4px !important;
    }

    .drag-handle {
        width: 35px;
        padding: 8px 4px;
        font-size: 1.2em;
    }

    /* Ensure readable text on very small screens */
    #currentStandingsTable td:nth-child(2),
    #currentStandingsTable th:nth-child(2),
    #finalStandingsTable td:nth-child(2),
    #finalStandingsTable th:nth-child(2) {
        min-width: 120px;
    }

    #finalGPTable td:nth-child(3),
    #finalGPTable th:nth-child(3) {
        min-width: 120px;
    }

    #currentStandingsTable td:nth-child(3),
    #currentStandingsTable th:nth-child(3),
    #finalStandingsTable td:nth-child(3),
    #finalStandingsTable th:nth-child(3),
    #finalGPTable td:nth-child(4),
    #finalGPTable th:nth-child(4) {
        min-width: 100px;
    }
}
