body { 
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 
    background: #f4f7f6; 
    padding: 0; 
    margin: 0; 
    color: #333; 
    /* Prevent accidental horizontal bounce */
    overflow-x: hidden; 
}

.container { 
    max-width: 600px; 
    margin: 0 auto; 
    background: white; 
    padding: 10px; 
    min-height: 100vh; 
    box-sizing: border-box; 
}

h2 { 
    text-align: center; 
    color: #1a73e8; 
    margin: 10px 0 5px 0; 
    font-size: 1.5rem; 
}

/* Paddle icon color - red by default, green when admin logged in */
.paddle-icon {
    display: inline-block;
    filter: grayscale(100%) brightness(0.4) sepia(100%) hue-rotate(-50deg) saturate(600%);
    transition: filter 0.3s ease;
}

.paddle-icon.admin-logged-in {
    filter: grayscale(100%) brightness(0.5) sepia(100%) hue-rotate(50deg) saturate(500%);
}

.status-msg { 
    padding: 12px; 
    margin-bottom: 15px; 
    border-radius: 6px; 
    text-align: center; 
    font-weight: bold; 
    font-size: 0.9em; 
    border: 1px solid transparent; 
}

.msg-success { background: #d4edda; color: #155724; border-color: #c3e6cb; }
.msg-info { background: #d1ecf1; color: #0c5460; border-color: #bee5eb; }
.msg-error { background: #f8d7da; color: #721c24; border-color: #f5c6cb; }

.form-box { 
    background: #eef2f7; 
    padding: 10px; 
    border-radius: 10px; 
    margin-top: 15px; 
    margin-bottom: 15px; 
    border: 1px solid #d1d9e6; 
}

.form-box h3 { 
    margin-top: 0px; 
    margin-bottom: 8px; 
    font-size: 1.05em; 
    color: #2c3e50; 
}

.input-flex-row { 
    display: flex; 
    gap: 10px; 
    margin-bottom: 10px; 
}

.input-flex-row div { flex: 1; }

.date-input, .score-input { 
    width: 100%; 
    padding: 8px; 
    border-radius: 6px; 
    border: 1px solid #ccc; 
    font-size: 15px; 
    box-sizing: border-box; 
}

.score-input { text-align: center; background: white; cursor: pointer; }
.score-input:disabled { background: #f5f5f5; cursor: not-allowed; color: #999; }

.form-group { margin-bottom: 10px; position: relative; }

.input-row { 
    display: flex; 
    align-items: flex-end; 
    gap: 8px; 
}

.search-input, select { 
    flex: 1; 
    padding: 8px; 
    border-radius: 6px; 
    border: 1px solid #ccc; 
    font-size: 15px; 
    width: 100%; 
    box-sizing: border-box; 
}

.search-container { 
    position: relative; 
    flex: 1; 
    display: flex; 
    align-items: center; 
}

.btn-clear { 
    position: absolute; 
    right: 10px; 
    background: #ccc; 
    color: white; 
    border: none; 
    border-radius: 50%; 
    width: 18px; 
    height: 18px; 
    font-size: 12px; 
    cursor: pointer; 
    display: none; 
    padding: 0; 
    z-index: 5; 
}

h1 { 
    font-size: 24px !important; 
    color: gray; 
    font-weight: 900 !important; 
    margin-bottom: 0px; 
}

.center-me { text-align: center; }

.search-results { 
    position: absolute; 
    width: 100%; 
    background: white; 
    border: 1px solid #ccc; 
    border-radius: 0 0 6px 6px; 
    max-height: 150px; 
    overflow-y: auto; 
    z-index: 100; 
    display: none; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.1); 
    top: 100%; 
}

.search-results div { 
    padding: 10px; 
    cursor: pointer; 
    border-bottom: 1px solid #eee; 
    font-size: 0.9em; 
}

.search-results div:hover { background-color: #f0f0f0; }

.check-group { 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: flex-end; 
    min-width: 60px; 
}

.check-group label { 
    font-size: 0.85em; 
    font-weight: bold; 
    color: #2c3e50; 
    margin-bottom: 2px; 
    line-height: 1; 
}

.win-check { 
    width: 28px; 
    height: 28px; 
    cursor: pointer; 
    margin-top: 4px; 
    appearance: none; 
    -webkit-appearance: none; 
    background-color: white; 
    border: 1px solid #ccc; 
    border-radius: 3px; 
    position: relative; 
    flex-shrink: 0; 
}

.win-check:checked { background-color: #1a73e8; border-color: #1a73e8; }
.win-check:checked::after { 
    content: '✓'; 
    position: absolute; 
    color: white; 
    font-size: 20px; 
    font-weight: bold; 
    left: 50%; 
    top: 50%; 
    transform: translate(-50%, -50%); 
}

.input-group { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
}

.input-group label { 
    font-size: 0.85em; 
    font-weight: bold; 
    color: #2c3e50; 
    margin-bottom: 2px; 
    line-height: 1; 
}

.about-link { color: #888; text-decoration: none; transition: color 0.2s; }
.about-link:hover { color: #1a73e8; text-decoration: underline; }

/* Fixed Buttons: Using margin: 10px auto and width 98% for safe centering */
.btn-submit, .btn-logout, .btn-history, .btn-rules, .btn-admin { 
    display: block; 
    width: 98%; 
    height: 50px; 
    line-height: 50px; 
    padding: 0 14px; 
    border-radius: 10px; 
    text-decoration: none; 
    font-weight: 700; 
    text-align: center; 
    font-size: 16px; 
    box-sizing: border-box; 
    cursor: pointer; 
    color: #fff; 
    border: 1px solid rgba(255,255,255,0.18); 
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease, background 0.2s ease;
    margin-left: auto;
    margin-right: auto;
}

button.btn-submit { appearance: none; -webkit-appearance: none; border: none; }
.btn-submit:hover, .btn-logout:hover, .btn-history:hover, .btn-rules:hover, .btn-admin:hover { 
    transform: translateY(-2px); 
    filter: brightness(1.03); 
}

.btn-submit { background: #22a06b; margin-top: 5px; }

.btn-history { 
    background: linear-gradient(135deg, #4f46e5 0%, #3730a3 100%); 
    box-shadow: 0 8px 18px rgba(79, 70, 229, 0.22); 
    margin-top: 10px; 
}

.btn-rules { 
    background: linear-gradient(135deg, #F97316 0%, #EA580C 100%); 
    box-shadow: 0 8px 18px rgba(249, 115, 22, 0.22); 
    margin-top: 10px; 
}

.btn-admin { 
    background: linear-gradient(135deg, #475569 0%, #334155 100%); 
    box-shadow: 0 8px 18px rgba(51, 65, 85, 0.22); 
    margin-top: 10px; 
}

.btn-logout { 
    background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%); 
    box-shadow: 0 8px 18px rgba(220, 38, 38, 0.22); 
    margin-top: 10px; 
}

/* FIXED Table Scroll: No more overflow-width */
.table-scroll { 
    border: 2px solid #d1d9e6; 
    border-radius: 8px; 
    margin-bottom: 15px; 
    margin-top: 5px; 
    overflow-x: auto; /* Allow internal scroll if needed, but not page scroll */
}

table { 
    width: 100%; 
    border-collapse: collapse; 
}

th { 
    background: #1a73e8; 
    color: white; 
    font-size: 0.75em; 
    text-transform: uppercase; 
    padding: 10px 8px; 
    position: sticky; 
    top: 0; 
    z-index: 10; 
    border: none; 
}

th:first-child { border-radius: 6px 0 0 0; }
th:last-child { border-radius: 0 6px 0 0; }

td { padding: 10px 5px; border-bottom: 1px solid #eee; }

.rank-badge { 
    background: #6c757d; 
    color: white; 
    padding: 4px 8px; 
    border-radius: 12px; 
    font-weight: bold; 
    font-size: 0.85em; 
    display: inline-block; 
    min-width: 20px; 
    text-align: center; 
}

tr:nth-child(1) .rank-badge { background: #FFD700; color: #000; }
tr:nth-child(2) .rank-badge { background: #C0C0C0; color: #000; }
tr:nth-child(3) .rank-badge { background: #CD7F32; color: #fff; }

.status-badge { 
    padding: 3px 8px; 
    border-radius: 10px; 
    font-weight: bold; 
    font-size: 0.75em; 
    display: inline-block; 
    text-transform: uppercase; 
}

.status-active { background: #d4edda; color: #155724; }
.status-inactive { background: #f8d7da; color: #721c24; }
.status-challenge-pending { background: #fff3cd; color: #856404; }

.player-row-inactive { opacity: 0.5; }

.history-box { 
    margin-top: 15px; 
    border: 1px solid #d1d9e6; 
    border-radius: 8px; 
    padding: 15px 10px 10px 10px; 
    width: calc(100% ); /* Adjusted to fit within container padding */
    box-sizing: border-box;
}

.history-item { 
    font-size: 0.85em; 
    padding: 8px 0; 
    border-bottom: 1px solid #f9f9f9; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
}

.winner-name { color: #28a745; font-weight: bold; }
.score-pill { 
    background: #eee; 
    padding: 2px 6px; 
    border-radius: 4px; 
    font-weight: bold; 
    font-size: 0.9em; 
    margin-left: 4px; 
}

/* Status Legend Styles */
.legend-box { 
    display: flex; 
    justify-content: space-around; 
    padding: 12px; 
    background: #f9f9f9; 
    border: 1px solid #ddd; 
    border-radius: 8px; 
    margin: 10px 0 20px 0; 
    flex-wrap: wrap; 
    gap: 10px; 
}

.legend-item { 
    display: flex; 
    align-items: center; 
    font-size: 0.8em; 
    font-weight: bold; 
}

.legend-dot { 
    width: 12px; 
    height: 12px; 
    border-radius: 50%; 
    margin-right: 6px; 
    border: 1px solid rgba(0,0,0,0.1); 
}

/* Custom confirm modal */
#confirmModal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

#confirmBox {
    background: #ffffff;
    padding: 16px 18px 14px 18px;
    border-radius: 10px;
    max-width: 90%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    font-size: 0.95rem;
}

#confirmMessage {
    white-space: pre-line;
    margin: 0 0 12px 0;
    color: #111827;
}

#confirmButtons {
    text-align: right;
}

#confirmButtons button {
    padding: 8px 14px;
    margin-left: 6px;
    border-radius: 6px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.95rem;
}

#confirmCancel {
    background: #e5e7eb;
    color: #111827;
}

#confirmOk {
    background: #22a06b;
    color: #ffffff;
}
