/* Custom Color Palette */
:root {
    --primary: #006ffd;
    --primary-dark: #0056cc;
    --primary-light: #3e90f8;
    --secondary: #5294e8;
    --secondary-dark: #3e90f8;
    --secondary-light: #eaf2ff;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --background: #f8fafc;
    --surface: #ffffff;
    --surface-secondary: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --gold: #eab308;
    --silver: #94a3b8;
    --bronze: #ea580c;
}

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

body {
    font-family:
        -apple-system, BlinkMacSystemFont, "SF Pro Display",
        "Helvetica Neue", sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 428px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--background);
    position: relative;
}

.container.hidden {
    display: none;
}

/* Tournament Listing Styles */

.tournaments-list h1 {
    margin: 0;
    font-size: 24px;
    color: var(--text);
}

.tournaments-list {
    padding: 0 20px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state h2 {
    margin: 0 0 10px 0;
    color: var(--text);
}

.registration-status {
    font-size: 12px;
    font-weight: 500;
    margin: 8px 0;
    padding: 3px 6px;
    border-radius: 3px;
    display: inline-block;
}

.registration-status.registered {
    background-color: #e8f5e8;
    color: #2d5a2d;
    border: 1px solid #c3e6c3;
}

.registration-status.not-registered {
    background-color: #f5f5f5;
    color: #666666;
    border: 1px solid #dddddd;
}

.tournament-location {
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    margin-top: 4px;
    opacity: 0.9;
}

.tournament-description {
    color: var(--text-muted);
    font-size: 14px;
    margin: 10px 0;
    font-style: italic;
}

.tournament-actions {
    margin-top: 15px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.tournament-roster {
    margin-top: 15px;
    border-top: 1px solid var(--border);
    padding-top: 15px;
}

.roster-header h4 {
    margin: 0 0 10px 0;
    font-size: 16px;
    color: var(--text);
}

.roster-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    margin-bottom: 6px;
    background-color: var(--card);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.player-name {
    font-weight: 500;
    color: var(--text);
}

.player-status {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.player-status.status-host {
    background-color: #dc3545;
    color: #ffffff;
    border: 1px solid #dc3545;
}

.player-status.status-registered {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #b8daff;
}

.roster-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
}

/* Status Bar */
.status-bar {
    height: 44px;
    background: var(--surface);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-light);
}

.status-item {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Navigation Header */
.nav-header {
    background: var(--surface);
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
}

.nav-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.nav-button {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    padding: 8px;
}

/* Screen Container */
.screen {
    padding: 16px 14px 100px 14px;
    display: none;
    min-height: calc(100vh - 100px);
}

.screen.active {
    display: block;
}

/* Card Components */
.card {
    background: var(--surface);
    border-radius: 12px;
    margin-bottom: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
}

.card-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.card-content {
    padding: 20px;
}

/* Buttons */
.button {
    border-radius: 10px;
    border: none;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 50px;
    width: 100%;
    margin-bottom: 12px;
}

.button-primary {
    background: var(--primary);
    color: white;
}

.button-primary:hover {
    background: var(--primary-dark);
}

.button-secondary {
    background: var(--surface-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.button-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}

.button-outline:hover {
    background: var(--secondary-light);
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    height: 44px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0 16px;
    font-size: 16px;
    color: var(--text-primary);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--secondary-light);
}

.form-textarea {
    height: auto;
    min-height: 80px;
    padding: 12px 16px;
    resize: vertical;
}

/* Tournament Items */
.tournament-card {
    background: var(--surface);
    border-radius: 12px;
    margin-bottom: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.tournament-header {
    padding: 16px 20px;
    background: linear-gradient(
        135deg,
        var(--primary) 0%,
        var(--secondary) 100%
    );
    color: white;
}

.tournament-name {
    font-size: 18px;
    font-weight: 700;
    text-align: center;
}

.tournament-date {
    font-size: 14px;
    opacity: 0.9;
    margin-top: 4px;
    font-weight: 600;
}

.tournament-body {
    padding: 20px;
}

.tournament-stats {
    display: flex;
    justify-content: space-between;
    margin-bottom: 16px;
}

.stat-item {
    text-align: center;
    flex: 1;
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

/* Player List */
.player-grid {
    background: var(--surface);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.player-item {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
}

.player-item:last-child {
    border-bottom: none;
}

.player-avatar {
    width: 44px;
    height: 44px;
    border-radius: 22px;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    margin-right: 16px;
}

.player-details {
    flex: 1;
}

.player-name {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
}

.player-skill {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.status-badge {
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
}

.status-registered {
    background: var(--success);
    color: white;
}
.status-pending {
    background: var(--warning);
    color: white;
}
.status-host {
    background: var(--primary);
    color: white;
}

/* Score Interface */
.score-header {
    background: linear-gradient(
        135deg,
        var(--primary) 0%,
        var(--secondary) 100%
    );
    color: white;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    margin-bottom: 16px;
}

.round-info {
    font-size: 14px;
    opacity: 0.9;
}

.court-info {
    font-size: 20px;
    font-weight: 700;
    margin-top: 4px;
}

.game-timer {
    background: var(--warning);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 16px;
    font-weight: 600;
    margin-top: 12px;
    display: none;
}

.game-timer.active {
    display: inline-block;
}

.score-container {
    background: var(--surface);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.team-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-light);
}

.team-row:last-child {
    border-bottom: none;
}

.team-names {
    flex: 1;
}

.team-name {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
}

.team-name.you {
    color: var(--primary);
    font-weight: 600;
}

.score-input-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.score-input {
    width: 60px;
    height: 44px;
    background: var(--surface-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    text-align: center;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.score-controls {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.score-button {
    width: 36px;
    height: 36px;
    border: 1px solid var(--primary);
    border-radius: 8px;
    background: var(--surface);
    color: var(--primary);
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    display: none;
}

.score-button:hover {
    background: var(--secondary-light);
}

.timed-mode .score-button {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Mode Toggle */
.mode-selector {
    background: var(--surface-secondary);
    border-radius: 10px;
    padding: 4px;
    display: flex;
    margin-bottom: 16px;
}

.mode-option {
    flex: 1;
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mode-option.active {
    background: var(--primary);
    color: white;
    font-weight: 600;
}

/* Leaderboard */
.leaderboard-item {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border-light);
}

.leaderboard-item:first-child {
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

.leaderboard-item:last-child {
    border-bottom: none;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
}

.position-badge {
    width: 36px;
    height: 36px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    margin-right: 16px;
    font-size: 16px;
}

.position-1 {
    background: var(--gold);
    color: white;
}
.position-2 {
    background: var(--silver);
    color: white;
}
.position-3 {
    background: var(--bronze);
    color: white;
}
.position-other {
    background: var(--border-light);
    color: var(--text-secondary);
}

.player-info {
    flex: 1;
}

/* Admin Styles */
.nav-item.admin-nav-item {
    display: none;
}

.admin-user .admin-nav-item {
    display: flex;
}

.pending-user-item {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 8px;
    border-radius: 12px;
}

.pending-user-info {
    flex: 1;
    margin-right: 16px;
}

.pending-user-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.pending-user-email {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.pending-user-details {
    font-size: 12px;
    color: var(--text-secondary);
}

.admin-actions {
    display: flex;
    gap: 8px;
}

.admin-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.approve-btn {
    background: var(--success);
    color: white;
}

.approve-btn:hover {
    background: var(--success-dark);
}

.reject-btn {
    background: var(--error);
    color: white;
}

.reject-btn:hover {
    background: var(--error-dark);
}

.admin-stats {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.admin-stat {
    text-align: center;
    padding: 12px;
    background: var(--surface);
    border-radius: 12px;
    flex: 1;
    margin: 0 4px;
}

.admin-stat-number {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.admin-stat-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.user-status-badge {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-admin {
    background: var(--primary);
    color: white;
}

.status-standard {
    background: var(--success);
    color: white;
}

.status-pending {
    background: var(--warning);
    color: var(--text);
}

.logout-item {
    cursor: pointer;
    transition: opacity 0.2s ease;
    display: flex;
    align-items: center;
    padding: 4px 8px !important;
    border-radius: 4px;
}

.logout-item:hover {
    opacity: 0.7;
    background: rgba(255, 255, 255, 0.1);
}

.logout-item svg {
    width: 14px;
    height: 14px;
}

.nav-user-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logout-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    transition: all 0.2s ease;
    color: var(--text);
    display: flex;
    align-items: center;
}

.logout-button:hover {
    background: rgba(0, 0, 0, 0.1);
    opacity: 0.8;
}

#userProfileStatus {
    font-weight: 600;
    color: var(--text);
}

.player-stats {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.player-score {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
}

/* Match History */
.match-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.match-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.match-round {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.match-result {
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
}

.result-won {
    background: var(--success);
    color: white;
}
.result-lost {
    background: var(--error);
    color: white;
}

.match-teams {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.team-display {
    text-align: center;
    flex: 1;
}

.team-players {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.team-score {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    margin-top: 4px;
}

.vs-divider {
    padding: 0 16px;
    color: var(--text-tertiary);
    font-size: 14px;
}

/* Statistics */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.stat-number {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
}

.stat-description {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Partner Performance */
.partner-item {
    margin-bottom: 16px;
}

.partner-item:last-child {
    margin-bottom: 0;
}

.partner-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-weight: 500;
}

.partner-percentage {
    color: var(--primary);
    font-weight: 600;
}

.progress-bar {
    height: 8px;
    background: var(--surface-secondary);
    border-radius: 8px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: 8px;
    transition: width 0.3s ease;
}

/* Court Status */
.court-status-grid {
    background: var(--surface);
    border-radius: 12px;
    padding: 16px;
    margin-top: 16px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.court-status-header {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.court-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    font-size: 14px;
}

.court-name {
    font-weight: 600;
    color: var(--text-primary);
}

.court-match {
    color: var(--text-primary);
    display: flex;
    align-items: center;
    font-weight: 500;
}

/* Status Indicators */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 4px;
    margin-left: 8px;
    display: inline-block;
}

.status-completed {
    background: var(--success);
}
.status-active {
    background: var(--warning);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 428px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 8px 0 34px 0;
    display: flex;
    justify-content: space-around;
}

.bottom-nav.hidden {
    display: none;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px;
    color: var(--text-tertiary);
    text-decoration: none;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-item.active {
    color: var(--primary);
}

.nav-icon {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
}

/* Authentication Screens */
.auth-container {
    display: none;
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 428px;
    height: 100vh;
    background: var(--background);
    z-index: 1000;
    padding: 40px 20px;
}

.auth-container.active {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.auth-header {
    text-align: center;
    margin-bottom: 40px;
}

.auth-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.auth-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
}

.auth-form {
    background: var(--surface);
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.auth-switch {
    text-align: center;
    margin-top: 24px;
    color: var(--text-secondary);
}

.auth-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
}

.auth-link:hover {
    text-decoration: underline;
}
