/* Brill Bridge Challenge - Styles */

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --secondary-hover: #475569;
    --success-color: #16a34a;
    --error-color: #dc2626;
    --warning-color: #ca8a04;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --radius-lg: 12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.app-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-link:hover {
    color: var(--primary-color);
}

.user-display {
    color: var(--text-primary);
    font-weight: 500;
}

/* User Profile Button in Nav */
.user-profile-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius);
    transition: background-color 0.2s;
}

.user-profile-btn:hover {
    background: var(--background);
}

.nav-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

/* Profile Modal Styles */
.profile-avatar-section {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.avatar-preview {
    position: relative;
    width: 80px;
    height: 80px;
}

.avatar-large {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
}

.avatar-placeholder {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.75rem;
    font-weight: 600;
}

.avatar-upload {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.modal-divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 1.5rem 0;
}

#change-password-form h4 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.danger-zone {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 1rem;
}

.danger-zone h4 {
    color: #dc2626;
    margin: 0 0 0.5rem 0;
}

.modal-small {
    max-width: 400px;
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
    width: 100%;
}

/* Footer */
.app-footer {
    background: var(--surface);
    border-top: 1px solid var(--border-color);
    padding: 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 500;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: var(--secondary-hover);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-danger {
    background: var(--error-color);
    color: white;
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.btn-full {
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.375rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: border-color 0.2s;
    font-family: inherit;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-hint {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .form-group {
    flex: 1;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 500;
}

.checkbox-label input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    cursor: pointer;
}

/* PBN File Upload */
.file-upload-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.file-name {
    color: var(--text-muted);
    font-size: 0.875rem;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.validation-results {
    background: var(--bg-secondary);
    border-radius: 6px;
    padding: 0.75rem;
    margin-top: 0.5rem;
    border: 1px solid var(--border-color);
}

.validation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.validation-messages {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.8rem;
    max-height: 120px;
    overflow-y: auto;
}

.validation-messages li {
    padding: 0.25rem 0;
}

.validation-messages li.error {
    color: var(--error-color);
}

.validation-messages li.warning {
    color: #d97706;
}

.validation-messages li.success {
    color: var(--success-color);
}

.badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 4px;
}

.badge.success {
    background-color: #dcfce7;
    color: #166534;
}

.badge.warning {
    background-color: #fef3c7;
    color: #92400e;
}

.badge.error {
    background-color: #fef2f2;
    color: #991b1b;
}

/* Validation errors */
.input-error {
    border-color: var(--error-color) !important;
    background-color: #fef2f2;
}

.input-error:focus {
    outline-color: var(--error-color);
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.2);
}

.validation-error {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--error-color);
    font-weight: 500;
}

/* Auth Page */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.auth-container {
    background: var(--surface);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 400px;
    width: 100%;
}

.auth-container h2 {
    text-align: center;
    margin-bottom: 0.5rem;
}

.auth-container .subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.auth-tabs {
    display: flex;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    flex: 1;
    padding: 0.75rem;
    background: none;
    border: none;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.error-message {
    color: var(--error-color);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

.success-message {
    color: var(--success-color);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

.forgot-link {
    display: block;
    text-align: center;
    margin-top: 12px;
    color: var(--primary-color);
    font-size: 0.9em;
    text-decoration: none;
}

.forgot-link:hover {
    text-decoration: underline;
}

/* Hub Page */
.hub-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.challenge-sections {
    display: grid;
    gap: 2rem;
}

.challenge-section h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.challenge-list {
    display: grid;
    gap: 1rem;
}

.challenge-card {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem;
    transition: box-shadow 0.2s;
}

.challenge-card:hover {
    box-shadow: var(--shadow);
}

/* Compact one-liner challenge cards */
.challenge-card.compact {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 1rem;
}

.challenge-card.compact .challenge-name {
    font-weight: 600;
    font-size: 0.9375rem;
    min-width: 150px;
    flex-shrink: 0;
}

.challenge-card.compact .challenge-info {
    color: var(--text-secondary);
    font-size: 0.8125rem;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.challenge-card.compact .challenge-time {
    color: var(--text-secondary);
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0.7;
}

.challenge-card.compact .challenge-scoring {
    color: var(--text-secondary);
    font-size: 0.75rem;
    white-space: nowrap;
}

.challenge-card.compact .challenge-status {
    flex-shrink: 0;
}

.challenge-card.compact .card-actions {
    display: flex;
    gap: 0.375rem;
    flex-shrink: 0;
    margin-left: auto;
}

.challenge-card.compact .card-actions .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.challenge-card.compact .card-actions .waiting,
.challenge-card.compact .card-actions .result {
    font-size: 0.75rem;
    white-space: nowrap;
}

/* Icon-only buttons for compact cards */
.btn-icon {
    padding: 0.25rem 0.375rem !important;
    min-width: 28px;
}

.btn-icon svg {
    width: 14px;
    height: 14px;
}

/* Pending invites section */
.challenge-section.pending-invites {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.challenge-section.pending-invites h3 {
    margin-bottom: 0.75rem;
    color: #92400e;
}

.challenge-card.invite-card {
    background: white;
    border: 1px solid #fcd34d;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.challenge-name {
    font-weight: 600;
    font-size: 1.125rem;
}

.badge {
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.badge.pending {
    background: #fef3c7;
    color: #92400e;
}

.badge.in_progress,
.badge.created {
    background: #dbeafe;
    color: #1e40af;
}

.badge.completed {
    background: #dcfce7;
    color: #166534;
}

.card-body {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}

.card-body p {
    margin-bottom: 0.25rem;
}

.card-actions {
    display: flex;
    gap: 0.5rem;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

.modal-content {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    max-width: 450px;
    width: 90%;
}

.modal-content h3 {
    margin-bottom: 1rem;
}

.modal-buttons {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    justify-content: flex-end;
}

/* Generation Progress Bar */
.generation-progress {
    margin: 1rem 0;
    padding: 1rem;
    background: var(--surface-alt, #f5f5f5);
    border-radius: 8px;
    text-align: center;
}

.generation-progress.hidden {
    display: none;
}

.generation-progress .progress-label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.generation-progress .progress-bar-container {
    height: 8px;
    background: var(--border-color, #ddd);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.generation-progress .progress-bar {
    height: 100%;
    background: var(--primary, #4CAF50);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.generation-progress .progress-status {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Play Page */
.play-page {
    max-width: 100%;
    padding: 0;
}

.play-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
}

.play-info {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

#challenge-title {
    font-weight: 600;
}

#board-progress {
    color: var(--text-secondary);
}

/* Board Results Table */
.board-results-container {
    max-width: 800px;
    margin: 0 auto 1rem;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.board-results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.board-results-table th,
.board-results-table td {
    padding: 0.5rem 0.75rem;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

.board-results-table th {
    background: #2d5a2d;
    color: white;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

.board-results-table th.player-header {
    border-bottom: 1px solid rgba(255,255,255,0.3);
}

.board-results-table th.you-header {
    background: #1e4620;
}

.board-results-table th.opponent-header {
    background: #4a2020;
}

.board-results-table th.sub-header {
    font-size: 0.6875rem;
    padding: 0.25rem 0.5rem;
    font-weight: 500;
}

.board-results-table tbody tr {
    transition: background-color 0.2s;
}

.board-results-table tbody tr:hover {
    background: var(--background);
}

.board-results-table .board-num {
    font-weight: 700;
    color: var(--primary-color);
}

.board-results-table .board-contract {
    font-weight: 600;
    font-family: 'Segoe UI Symbol', 'Apple Color Emoji', sans-serif;
}

/* Suit colors for contracts */
.suit-spade {
    color: #000080; /* Navy blue for spades */
}

.suit-heart {
    color: #cc0000; /* Red for hearts */
}

.suit-diamond {
    color: #ff8c00; /* Orange for diamonds */
}

.suit-club {
    color: #228b22; /* Green for clubs */
}

.board-results-table .you-score,
.board-results-table .opponent-score {
    font-weight: 600;
}

.board-results-table .opponent-result .clickable-contract {
    text-decoration: underline;
    text-decoration-style: dotted;
}

.board-results-table .opponent-result:hover .clickable-contract {
    color: var(--primary);
    text-decoration-style: solid;
}

.board-results-table .board-imp {
    font-weight: 700;
}

.board-results-table .board-imp.positive {
    color: var(--success-color);
}

.board-results-table .board-imp.negative {
    color: var(--error-color);
}

/* Board row states */
.board-row.current {
    background: #fff3cd;
    animation: pulse 2s ease-in-out infinite;
}

.board-row.you-complete {
    background: linear-gradient(90deg, #d4edda 0%, #d4edda 50%, #f8f9fa 50%, #f8f9fa 100%);
}

.board-row.both-complete {
    background: #d4edda;
}

@keyframes pulse {
    0%, 100% { background: #fff3cd; }
    50% { background: #ffe69c; }
}

/* Status dots */
.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 4px;
}

.status-dot.pending {
    background: #94a3b8;
}

/* Not played yet marker */
.not-played {
    color: #94a3b8;
    font-style: italic;
}

/* Waiting message on results page */
.waiting-message {
    color: var(--text-secondary);
    font-style: italic;
}

.status-dot.playing {
    background: #f59e0b;
    animation: blink 1s ease-in-out infinite;
}

.status-dot.complete {
    background: #22c55e;
}

.status-dot.waiting {
    background: #e2e8f0;
    border: 1px dashed #94a3b8;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.status-badge.pending {
    background: #e2e8f0;
    color: #64748b;
}

.status-badge.playing {
    background: #fef3c7;
    color: #92400e;
}

.status-badge.completed {
    background: #dcfce7;
    color: #166534;
}

.status-badge.rejected {
    background: #fecaca;
    color: #991b1b;
}

.rejected-text {
    color: var(--error-color);
    font-size: 0.85rem;
    font-style: italic;
}

/* Total row */
.board-total-row {
    background: #f1f5f9;
    font-size: 0.9375rem;
}

.board-total-row td {
    border-bottom: none;
    padding: 0.75rem;
}

.you-total {
    background: rgba(34, 197, 94, 0.1);
}

.opponent-total {
    background: rgba(239, 68, 68, 0.1);
}

.imp-total {
    font-weight: 700;
}

.widget-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    min-height: 600px;
    width: 100%;
}

.widget-container bridge-widget {
    width: 100%;
    max-width: 1000px;
    height: 700px;
}

/* Results Page */
.results-page {
    max-width: 800px;
    margin: 0 auto;
}

.results-page h2 {
    text-align: center;
    margin-bottom: 2rem;
}

.challenge-type-badge {
    text-align: center;
    margin-bottom: 1rem;
}

.challenge-type-badge .badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--primary-color);
    color: white;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
}

.challenge-type-badge .badge.declare-only {
    background: #2563eb; /* Blue for declarer mode */
}

.challenge-type-badge .badge.defend-only {
    background: #dc2626; /* Red for defender mode */
}

.results-summary {
    background: var(--surface);
    padding: 2rem;
    border-radius: var(--radius-lg);
    text-align: center;
    margin-bottom: 2rem;
}

.results-summary .winner {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--success-color);
}

.results-summary .score {
    font-size: 1.25rem;
    margin-top: 0.5rem;
}

.results-comparison {
    background: var(--surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 2rem;
}

.comparison-header {
    display: grid;
    grid-template-columns: 80px 1fr 1fr 100px 60px;
    padding: 1rem;
    background: var(--background);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
}

.comparison-row {
    display: grid;
    grid-template-columns: 80px 1fr 1fr 100px 60px;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.comparison-row:last-child {
    border-bottom: none;
}

.comparison-row .board-num {
    font-weight: 600;
}

.comparison-row .board-num a {
    color: var(--primary-color);
    text-decoration: none;
}

.comparison-row .board-num a:hover {
    text-decoration: underline;
}

.comparison-row span > a {
    color: inherit;
    text-decoration: none;
}

.comparison-row span > a:hover {
    text-decoration: underline;
}

.comparison-row .score-positive {
    color: var(--success-color);
}

.comparison-row .score-negative {
    color: var(--error-color);
}

.comparison-row .board-contract {
    font-weight: 600;
    font-size: 0.85em;
    margin-right: 0.5em;
    font-family: 'Segoe UI Symbol', 'Apple Color Emoji', sans-serif;
}

.autoplay-btn {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.2s;
}

.autoplay-btn:hover {
    background: var(--primary-dark, #0056b3);
}

.autoplay-btn:disabled {
    opacity: 0.6;
    cursor: wait;
}

.results-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* Leaderboard Page */
.leaderboard-page h2 {
    text-align: center;
    margin-bottom: 2rem;
}

.leaderboard-table {
    background: var(--surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.leaderboard-header,
.leaderboard-row {
    display: grid;
    grid-template-columns: 60px 1fr 80px 80px 80px;
    padding: 1rem;
}

.leaderboard-header {
    background: var(--background);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
}

.leaderboard-row {
    border-bottom: 1px solid var(--border-color);
}

.leaderboard-row:last-child {
    border-bottom: none;
}

.leaderboard-row .rank {
    font-weight: 700;
    color: var(--primary-color);
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.loading {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
}

/* Responsive */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }

    .nav-menu {
        flex-wrap: wrap;
        justify-content: center;
    }

    .hub-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .comparison-header,
    .comparison-row {
        grid-template-columns: 60px 1fr 1fr 80px 50px;
        font-size: 0.875rem;
    }

    .leaderboard-header,
    .leaderboard-row {
        grid-template-columns: 40px 1fr 60px 60px 60px;
        font-size: 0.875rem;
    }
}

/* ========================================
   Tournament Styles
   ======================================== */

/* Tournament Hub */
.tournaments-page {
    max-width: 1000px;
    margin: 0 auto;
}

.tournaments-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.tournament-sections {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.tournament-section h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.tournament-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

/* Tournament Card */
.tournament-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.tournament-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.tournament-card .card-header {
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.tournament-card .tournament-name {
    font-weight: 600;
    font-size: 1rem;
}

.tournament-card .card-body {
    padding: 1rem;
}

.tournament-card .card-body p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.tournament-card .card-actions {
    padding: 1rem;
    background: var(--background);
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* Tournament Status Badges */
.badge.status-registration {
    background: #dbeafe;
    color: #1e40af;
}

.badge.status-in_progress {
    background: #dcfce7;
    color: #166534;
}

.badge.status-completed {
    background: #f3f4f6;
    color: #4b5563;
}

.badge.status-cancelled {
    background: #fee2e2;
    color: #991b1b;
}

.badge.status-active {
    background: #dcfce7;
    color: #166534;
}

.badge.status-eliminated {
    background: #fee2e2;
    color: #991b1b;
}

.badge.status-registered {
    background: #dbeafe;
    color: #1e40af;
}

.badge.status-withdrawn {
    background: #fef3c7;
    color: #92400e;
}

/* Tournament Detail Page */
.tournament-page {
    max-width: 1000px;
    margin: 0 auto;
}

.tournament-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.tournament-title {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.tournament-title h2 {
    margin: 0;
}

.tournament-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tournament-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.info-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
}

.info-card h4 {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.info-card p {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Tournament Tabs */
.tournament-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.tournament-tabs .tab-btn {
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius) var(--radius) 0 0;
    transition: all 0.2s;
}

.tournament-tabs .tab-btn:hover {
    background: var(--background);
    color: var(--text-primary);
}

.tournament-tabs .tab-btn.active {
    background: var(--primary-color);
    color: white;
}

.tab-content {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.tab-content.hidden {
    display: none;
}

/* Standings Table */
.standings-header,
.standings-row {
    display: grid;
    grid-template-columns: 50px 1fr 80px 80px 100px 80px;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    align-items: center;
}

.standings-header {
    background: var(--background);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    border-radius: var(--radius);
}

.standings-row {
    border-bottom: 1px solid var(--border-color);
}

.standings-row:last-child {
    border-bottom: none;
}

.standings-row.eliminated {
    opacity: 0.5;
    background: #fee2e2;
}

.standings-row .rank {
    font-weight: 700;
    color: var(--primary-color);
}

.standings-row .player-name {
    font-weight: 500;
}

.standings-row .vp {
    font-weight: 700;
    color: var(--success-color);
}

/* Rounds List */
.rounds-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.round-card {
    background: var(--background);
    border-radius: var(--radius);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.round-header {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.round-number {
    font-weight: 700;
    font-size: 1.1rem;
}

.round-type {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.round-info {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Matches Grid */
.matches-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.match-card {
    background: var(--background);
    border-radius: var(--radius);
    padding: 1rem;
    border-left: 4px solid var(--border-color);
}

.match-card.completed {
    border-left-color: var(--success-color);
}

.match-card.pending {
    border-left-color: var(--warning-color);
}

.match-players {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.match-players .player {
    flex: 1;
    font-weight: 500;
    text-align: center;
}

.match-players .player.winner {
    color: var(--success-color);
    font-weight: 700;
}

.match-players .vs {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.match-result {
    text-align: center;
    font-weight: 600;
}

.match-result .vp {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: block;
}

.match-status {
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* My Matches */
.matches-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.my-match-card {
    background: var(--background);
    border-radius: var(--radius);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.my-match-card .match-round {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.my-match-card .match-opponent {
    font-weight: 500;
}

.my-match-card .match-result {
    font-weight: 700;
}

.my-match-card .match-result.won {
    color: var(--success-color);
}

.my-match-card .match-result.lost {
    color: var(--error-color);
}

/* Players List */
.players-header,
.player-row {
    display: grid;
    grid-template-columns: 50px 1fr 120px 120px;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    align-items: center;
}

.players-header {
    background: var(--background);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    border-radius: var(--radius);
}

.player-row {
    border-bottom: 1px solid var(--border-color);
}

.player-row:last-child {
    border-bottom: none;
}

.player-row .number {
    font-weight: 700;
    color: var(--text-secondary);
}

.player-row .name {
    font-weight: 500;
}

/* Modal Large */
.modal-large {
    max-width: 900px;
}

/* Modal Header with Close Button */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.modal-header h3 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text);
}

/* Board Review Modal */
.table-switcher {
    display: flex;
    gap: 0;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--border);
}

.table-tab {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-muted);
    transition: all 0.2s ease;
}

.table-tab:hover {
    color: var(--text);
    background: var(--background-alt);
}

.table-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.table-switcher.hidden {
    display: none;
}

.board-review-content {
    display: flex;
    flex-direction: row;
    gap: 1.5rem;
    max-height: 65vh;
    overflow-y: auto;
}

.review-left-column {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

.board-review-content > .play-section {
    flex: 0 0 auto;
    width: 220px;
}

.review-section h4 {
    margin: 0 0 0.25rem 0;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Deal Diagram */
.deal-info {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.deal-info .dealer,
.deal-info .vul {
    color: var(--text-muted);
}

.deal-grid {
    display: grid;
    grid-template-areas:
        ".     north ."
        "west  .     east"
        ".     south .";
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.5rem;
    max-width: 400px;
    margin: 0 auto;
}

.deal-grid .hand {
    background: var(--surface-elevated);
    padding: 0.75rem;
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 0.875rem;
}

.deal-grid .hand.north { grid-area: north; }
.deal-grid .hand.south { grid-area: south; }
.deal-grid .hand.east { grid-area: east; }
.deal-grid .hand.west { grid-area: west; }

.position-label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.suit-row {
    white-space: nowrap;
}

.suit.spades,
.suit.clubs {
    color: #1a1a2e;
}

.suit.hearts,
.suit.diamonds {
    color: #dc2626;
}

/* Auction Table */
.auction-table {
    width: 100%;
    max-width: 300px;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 0.875rem;
}

.auction-table th {
    background: var(--surface-elevated);
    padding: 0.1rem 0.3rem;
    font-weight: 600;
    font-size: 0.8rem;
    border-bottom: 1px solid var(--border);
}

.auction-table td {
    padding: 0.05rem 0.3rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

/* Result Display */
.result-display {
    display: flex;
    gap: 2rem;
    align-items: center;
    font-size: 1.125rem;
}

.result-contract {
    font-weight: 600;
    font-size: 1.25rem;
}

.result-score {
    color: var(--text-muted);
}

/* Play Display */
.play-display {
    overflow-y: auto;
}

.play-tricks {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.trick {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.1rem 0.4rem;
    background: var(--surface-elevated);
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    line-height: 1.1;
}

.trick-number {
    font-weight: 600;
    color: var(--text-muted);
    min-width: 1.25rem;
    text-align: right;
}

.trick-cards {
    display: flex;
    gap: 0.5rem;
}

.trick-card {
    display: inline-flex;
    align-items: center;
    gap: 0.05rem;
    min-width: 1.8rem;
}

.trick-card .card-suit {
    font-size: 0.8rem;
}

.trick-card .card-suit.spade {
    color: #000080;
}

.trick-card .card-suit.heart {
    color: #cc0000;
}

.trick-card .card-suit.diamond {
    color: #ff8c00;
}

.trick-card .card-suit.club {
    color: #228b22;
}

/* Clickable board rows */
.board-row {
    transition: background-color 0.15s ease;
}

.board-row.completed {
    cursor: pointer;
}

.board-row.completed:hover {
    background-color: var(--surface-elevated);
}

.no-data {
    color: var(--text-muted);
    font-style: italic;
}

/* Tournament Type Specific Styles */
.tournament-type-bam_swiss {
    border-top: 3px solid #9333ea;
}

.tournament-type-imp_swiss {
    border-top: 3px solid #2563eb;
}

.tournament-type-brill_challenge {
    border-top: 3px solid #dc2626;
}

/* Responsive adjustments for tournaments */
@media (max-width: 768px) {
    .tournaments-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .tournament-header {
        flex-direction: column;
        text-align: center;
    }

    .tournament-actions {
        justify-content: center;
    }

    .standings-header,
    .standings-row {
        grid-template-columns: 40px 1fr 60px 60px;
        font-size: 0.8rem;
    }

    .standings-header span:nth-child(5),
    .standings-header span:nth-child(6),
    .standings-row span:nth-child(5),
    .standings-row span:nth-child(6) {
        display: none;
    }

    .players-header,
    .player-row {
        grid-template-columns: 40px 1fr 100px;
        font-size: 0.8rem;
    }

    .players-header span:nth-child(4),
    .player-row span:nth-child(4) {
        display: none;
    }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 12px 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 280px;
    max-width: 400px;
    animation: slideInRight 0.3s ease;
    pointer-events: auto;
}

.toast.toast-success {
    border-left: 4px solid #28a745;
    background: #d4edda;
}

.toast.toast-error {
    border-left: 4px solid #dc3545;
    background: #f8d7da;
}

.toast.toast-warning {
    border-left: 4px solid var(--warning-color);
}

.toast.toast-info {
    border-left: 4px solid var(--primary-color);
}

.toast-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.toast-success .toast-icon {
    color: var(--success-color);
}

.toast-error .toast-icon {
    color: var(--error-color);
}

.toast-warning .toast-icon {
    color: var(--warning-color);
}

.toast-info .toast-icon {
    color: var(--primary-color);
}

.toast-message {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.toast.hiding {
    animation: slideOutRight 0.3s ease forwards;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}
