/* ==========================================
   Tab Navigation Styles
   ========================================== */
.tab {
    display: flex;
    background: linear-gradient(135deg, #f8f9ff 0%, #e8eaf6 100%);
    border-bottom: 2px solid rgba(102, 126, 234, 0.1);
}

.tablinks {
    flex: 1;
    padding: 1rem;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: var(--font-family);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: var(--transition-normal);
    position: relative;
}

.tablinks::after {
    content: "";
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--primary-gradient);
    transform: scaleX(0);
    transition: transform var(--transition-normal);
}

.tablinks:hover {
    color: var(--primary-color);
    background: rgba(102, 126, 234, 0.05);
}

.tablinks.active {
    color: var(--primary-color);
    background: rgba(102, 126, 234, 0.08);
}

.tablinks.active::after {
    transform: scaleX(1);
}

.tab-icon {
    font-size: 1.1rem;
}

/* ==========================================
   Game Setup Section
   ========================================== */
#gameSetup {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-dark);
    padding: 1.25rem 1.5rem 0.75rem;
    display: block;
}

#allFields {
    padding: 0 1rem 1rem;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}

/* ==========================================
   Fieldset Styles
   ========================================== */
fieldset {
    border: 2px solid rgba(102, 126, 234, 0.2);
    border-radius: var(--border-radius-md);
    padding: 1.25rem;
    margin-bottom: 1rem;
    background: linear-gradient(
        135deg,
        rgba(102, 126, 234, 0.03) 0%,
        rgba(240, 147, 251, 0.03) 100%
    );
    transition: var(--transition-normal);
}

fieldset:hover {
    border-color: rgba(102, 126, 234, 0.4);
    box-shadow: var(--shadow-sm);
}

legend {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-color);
    padding: 0 0.75rem;
    background: var(--bg-card);
    border-radius: var(--border-radius-sm);
}

/* ==========================================
   Form Elements
   ========================================== */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
}

#nameInput,
#dimensionList {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid rgba(102, 126, 234, 0.2);
    border-radius: var(--border-radius-sm);
    font-family: var(--font-family);
    font-size: 1rem;
    color: var(--text-dark);
    background: var(--bg-card);
    transition: var(--transition-normal);
}

#nameInput:focus,
#dimensionList:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

#nameInput::placeholder {
    color: var(--text-light);
}

#dimensionList {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23667eea' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1.25rem;
    padding-right: 2.5rem;
}

/* ==========================================
   Button Styles
   ========================================== */
.button-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-top: 1rem;
}

.btn {
    padding: 0.85rem 1rem;
    border: none;
    border-radius: var(--border-radius-sm);
    font-family: var(--font-family);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    transition: var(--transition-slow);
}

.btn:not(:disabled):hover::before {
    left: 100%;
}

.btn-play {
    background: var(--success-gradient);
    color: var(--text-white);
    box-shadow: 0 4px 15px rgba(56, 239, 125, 0.3);
}

.btn-play:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(56, 239, 125, 0.4);
}

.btn-cancel {
    background: var(--danger-gradient);
    color: var(--text-white);
    box-shadow: 0 4px 15px rgba(244, 92, 67, 0.3);
}

.btn-cancel:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(244, 92, 67, 0.4);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn-icon {
    font-size: 1rem;
}

/* Legacy button IDs for compatibility */
#greenButton {
    background: var(--success-gradient);
    color: var(--text-white);
    box-shadow: 0 4px 15px rgba(56, 239, 125, 0.3);
}

#redButton {
    background: var(--danger-gradient);
    color: var(--text-white);
    box-shadow: 0 4px 15px rgba(244, 92, 67, 0.3);
}

/* ==========================================
   Progress Grid
   ========================================== */
.progress-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

.progress-item {
    text-align: center;
}

.progress-item label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-light);
    margin-bottom: 0.4rem;
}

.progress-item input {
    width: 100%;
    padding: 0.5rem;
    border: 2px solid rgba(102, 126, 234, 0.2);
    border-radius: var(--border-radius-sm);
    font-family: var(--font-family);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-color);
    text-align: center;
    background: linear-gradient(
        135deg,
        rgba(102, 126, 234, 0.05) 0%,
        rgba(240, 147, 251, 0.05) 100%
    );
}

/* ==========================================
   Leaderboard Styles
   ========================================== */
#leaderboards {
    display: none;
    padding: 1rem;
    animation: fadeIn 0.3s ease-out;
}

#leaderboards[hidden] {
    display: none !important;
}

.leaderboard-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 1rem;
    text-align: center;
}

.table-container {
    border-radius: var(--border-radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

#leaderboardsTable {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

#leaderboardsTable thead {
    background: var(--primary-gradient);
    color: var(--text-white);
}

#leaderboardsTable th {
    padding: 0.85rem 0.5rem;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

#leaderboardsTable tbody tr {
    background: var(--bg-card);
    transition: var(--transition-fast);
}

#leaderboardsTable tbody tr:nth-child(even) {
    background: rgba(102, 126, 234, 0.03);
}

#leaderboardsTable tbody tr:hover {
    background: rgba(102, 126, 234, 0.08);
}

#leaderboardsTable td {
    padding: 0.75rem 0.5rem;
    text-align: center;
    border-bottom: 1px solid rgba(102, 126, 234, 0.1);
}

.stats-row {
    animation: slideInRow 0.3s ease-out;
}

@keyframes slideInRow {
    0% {
        opacity: 0;
        transform: translateX(-20px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

.status-success {
    color: #11998e;
    font-weight: 600;
}

.status-cancelled {
    color: #eb3349;
    font-weight: 600;
}

.empty-state {
    text-align: center;
    color: var(--text-light);
    font-size: 0.95rem;
    padding: 2rem 1rem;
    background: rgba(102, 126, 234, 0.05);
    border-radius: var(--border-radius-md);
    margin-top: 1rem;
}

/* ==========================================
   Responsive Adjustments
   ========================================== */
@media (max-width: 480px) {
    .progress-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .button-group {
        grid-template-columns: 1fr;
    }

    #leaderboardsTable {
        font-size: 0.8rem;
    }

    #leaderboardsTable th,
    #leaderboardsTable td {
        padding: 0.5rem 0.25rem;
    }
}
