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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    min-height: 100vh;
    color: #333;
}

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

/* Navigation */
nav {
    background: rgba(255, 255, 255, 0.95);
    padding: 1rem 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    font-size: 1.5rem;
    font-weight: bold;
    color: #1e3c72;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    list-style: none;
}

.nav-links a {
    color: #333;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    transition: all 0.3s;
}

.nav-links a:hover,
.nav-links a.active {
    background: #1e3c72;
    color: white;
}

.auth-status {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.btn {
    padding: 0.5rem 1.5rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s;
}

.btn-primary {
    background: #1e3c72;
    color: white;
}

.btn-primary:hover {
    background: #2a5298;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

/* Main Content Area */
.content {
    background: white;
    border-radius: 10px;
    padding: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.page {
    display: none;
}

.page.active {
    display: block;
}

/* Dashboard */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.stat-card h3 {
    font-size: 0.9rem;
    opacity: 0.9;
    margin-bottom: 0.5rem;
}

.stat-card .value {
    font-size: 2.5rem;
    font-weight: bold;
}

.stat-card.green {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

.stat-card.orange {
    background: linear-gradient(135deg, #ee0979 0%, #ff6a00 100%);
}

.stat-card.blue {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

/* Recent Games */
.recent-games {
    margin-top: 2rem;
}

.recent-games h2 {
    margin-bottom: 1rem;
    color: #1e3c72;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    position: relative;
}

th, td {
    padding: 0.5rem;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
    white-space: nowrap;
    overflow: visible;
    text-overflow: ellipsis;
}

tbody tr {
    position: relative;
    z-index: 1;
}

tbody tr:hover:not(.highlighted) {
    z-index: 2;
}

tbody td {
    overflow: visible;
}

th {
    background: #f8f9fa;
    font-weight: 600;
    color: #1e3c72;
    font-size: 0.9rem;
}

tr:hover {
    background: #f8f9fa;
}

tr.highlighted {
    background: #a8e6a1 !important;
    position: relative;
    z-index: 1;
}

.game-history-table td {
    font-size: 0.85rem;
    max-width: 180px;
}

.game-history-table td:first-child {
    max-width: 50px;
}

.notes-icon, .turnorder-icon {
    cursor: pointer;
    background: #1e3c72;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: bold;
    position: relative;
}

.notes-icon:hover, .turnorder-icon:hover {
    background: #2a5298;
}

.notes-icon.no-notes {
    opacity: 0.3;
    cursor: default;
}

.notes-icon.no-notes:hover {
    background: #1e3c72;
}

.turnorder-icon {
    background: #28a745;
}

.turnorder-icon:hover {
    background: #218838;
}

.notes-popup {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border: 2px solid #1e3c72;
    border-radius: 10px;
    padding: 1.5rem;
    max-width: 90%;
    max-height: 90vh;
    overflow: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 1000;
}

#turnorder-popup {
    max-width: 95vw;
    width: fit-content;
    min-width: 400px;
}

#notes-popup {
    max-width: 500px;
}

.notes-popup.show {
    display: block;
}

.notes-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.notes-overlay.show {
    display: block;
}

.notes-popup h3 {
    margin-top: 0;
    color: #1e3c72;
}

.notes-popup .close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
}

.notes-popup .close-btn:hover {
    color: #1e3c72;
}

.turnorder-table {
    width: auto;
    border-collapse: collapse;
    margin-top: 1rem;
}

.turnorder-table th,
.turnorder-table td {
    padding: 0.75rem 1rem;
    text-align: center;
    border: 1px solid #ddd;
    white-space: nowrap;
}

.turnorder-table th {
    background: #1e3c72;
    color: white;
    font-weight: 600;
}

.turnorder-table td {
    background: #f8f9fa;
}

.player-name {
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 3px;
}

/* PLAYER COLORS - All player colors defined here. Used everywhere: scoreboard, filters, tables, etc. */
/* Set to #1A1A1A (jet black) for players you want displayed in black */
.player-michael { color: #1565c0; }     /* Blue */
.player-david { color: #d32f2f; }       /* Red */
.player-bryan-w { color: #2e7d32; }     /* Green */
.player-nick { color: #9c27b0; }        /* Purple */
.player-jc { color: #c2185b; }          /* Purple */
.player-matt { color: #00838f; }        /* Cyan */
.player-casey { color: #f57f17; }       /* Amber */
.player-brian-m { color: #1A1A1A; }     /* Jet Black */
.player-doc { color: #1A1A1A; }         /* Jet Black */
.player-evan { color: #1A1A1A; }        /* Jet Black */
.player-diego { color: #1A1A1A; }       /* Jet Black */
.player-easy { color: #1A1A1A; }        /* Jet Black */
.player-kaylee { color: #1A1A1A; }      /* Jet Black */
.player-megan { color: #1A1A1A; }       /* Jet Black */
.player-mike { color: #880e4f; }        /* Dark Pink */
.player-jeannette { color: #1A1A1A; }   /* Jet Black */
.player-dave { color: #33dce2; }        /* Bright Teal */

.placement-tooltip {
    display: none;
    position: fixed;
    background: white;
    color: #333;
    padding: 0.75rem;
    border-radius: 5px;
    border: 2px solid #1e3c72;
    z-index: 100000;
    white-space: nowrap;
    font-size: 0.85rem;
    line-height: 1.6;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    pointer-events: none;
}

.placement-cell {
    position: relative;
    cursor: help;
}

/* Scryfall card image tooltip */
.card-image-tooltip {
    display: none;
    position: fixed;
    background: rgba(0, 0, 0, 0.9);
    padding: 0.5rem;
    border-radius: 8px;
    border: 2px solid #1e3c72;
    z-index: 100001;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    pointer-events: none;
    max-width: 90vw;
}

.card-image-tooltip img {
    display: block;
    max-width: 250px;
    max-height: 350px;
    width: auto;
    height: auto;
    border-radius: 5px;
}

.card-image-tooltip.loading {
    padding: 1rem;
    color: white;
    font-size: 0.9rem;
}

.card-image-tooltip .card-images {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

#deck-stats-table tbody td:first-child {
    cursor: pointer;
}

.placement-cell:hover .placement-tooltip {
    display: block;
}

.filter-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.filter-container select {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 0.9rem;
}

.filter-container select option {
    font-weight: 600;
}

.filter-container .btn {
    padding: 0.5rem 1rem;
}

.actions-column {
    display: none;
}

body.authenticated .actions-column {
    display: table-cell;
}

.auth-required {
    display: none;
}

body.authenticated .auth-required {
    display: list-item;
}

/* All player colors defined in one place - filters will inherit from .player- classes */

.placement-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: bold;
}

.place-1 {
    background: #ffd700;
    color: #333;
}

.place-2 {
    background: #c0c0c0;
    color: #333;
}

.place-3 {
    background: #cd7f32;
    color: white;
}

.place-4 {
    background: #666;
    color: white;
}

/* Scoreboard */
.scoreboard-section {
    margin-bottom: 3rem;
}

.scoreboard-section h2 {
    color: #1e3c72;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #1e3c72;
}

.scoreboard-layout {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

.scoreboard-layout .deck-stats-container {
    flex: 0 0 50%;
}

.scoreboard-layout .side-stats {
    flex: 1;
}

#thursday-stats-tbody td {
    padding: 0.4rem;
    font-size: 0.85rem;
}

#thursday-stats-table td:nth-child(4),
#thursday-stats-table thead tr:first-child th:nth-child(4),
#thursday-stats-table thead tr:nth-child(2) th:nth-child(4) {
    position: relative;
}

#thursday-stats-table td:nth-child(4)::before,
#thursday-stats-table thead tr:first-child th:nth-child(4)::before,
#thursday-stats-table thead tr:nth-child(2) th:nth-child(4)::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #1e3c72;
    z-index: 1;
}

.sortable-header {
    cursor: pointer;
    user-select: none;
}

.sortable-header:hover {
    background: #e0e0e0;
}

.sortable-header::after {
    content: ' ⇅';
    opacity: 0.3;
}

.sortable-header.asc::after {
    content: ' ▲';
    opacity: 1;
}

.sortable-header.desc::after {
    content: ' ▼';
    opacity: 1;
}

.leaderboard {
    display: grid;
    gap: 1rem;
}

.leaderboard-item {
    display: grid;
    grid-template-columns: 50px 2fr 1fr 1fr 1fr;
    align-items: center;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #1e3c72;
}

.leaderboard-item:nth-child(1) {
    border-left-color: #ffd700;
    background: linear-gradient(to right, #fff9e6, #f8f9fa);
}

.leaderboard-item:nth-child(2) {
    border-left-color: #c0c0c0;
}

.leaderboard-item:nth-child(3) {
    border-left-color: #cd7f32;
}

.rank {
    font-size: 1.5rem;
    font-weight: bold;
    color: #666;
}

.deck-name {
    font-weight: 600;
}

.player-tag {
    color: #666;
    font-size: 0.9rem;
}

/* Add Game Form */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #333;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.player-row {
    display: grid;
    grid-template-columns: 2fr 2fr 1.5fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
}

/* Turn Order Stats */
.turn-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-top: 2rem;
}

.turn-stat {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 8px;
    text-align: center;
}

.turn-stat h4 {
    color: #666;
    margin-bottom: 0.5rem;
}

.turn-stat .percentage {
    font-size: 2rem;
    font-weight: bold;
    color: #1e3c72;
}

.turn-stat .count {
    color: #666;
    font-size: 0.9rem;
}

/* Sol Ring Stats */
.sol-ring-stats {
    background: #fff9e6;
    border: 2px solid #ffd700;
    border-radius: 10px;
    padding: 2rem;
    margin-top: 2rem;
}

.sol-ring-stats h3 {
    color: #1e3c72;
    margin-bottom: 1rem;
}

.sol-ring-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.sol-ring-stat {
    text-align: center;
}

.sol-ring-stat .label {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.5rem;
}

.sol-ring-stat .value {
    font-size: 1.8rem;
    font-weight: bold;
    color: #1e3c72;
}

/* Head to Head */
.player-selector {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.h2h-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.h2h-card {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 8px;
    text-align: center;
}

.h2h-card .player-name {
    font-weight: bold;
    color: #1e3c72;
    margin-bottom: 0.5rem;
}

.h2h-card .wins {
    font-size: 2rem;
    font-weight: bold;
}

.h2h-card .winrate {
    color: #666;
}

/* Login Modal */
.login-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 10px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    min-width: 400px;
}

.login-modal.show {
    display: block;
}

.login-modal h2 {
    color: #1e3c72;
    margin-top: 0;
    margin-bottom: 1.5rem;
}

.login-modal .form-group {
    margin-bottom: 1.5rem;
}

.login-modal input[type="password"] {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}

.login-modal input[type="password"]:focus {
    outline: none;
    border-color: #1e3c72;
}

.login-modal .button-group {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.login-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
}

.login-modal-overlay.show {
    display: block;
}

/* Toast Notifications */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10001;
    display: none;
    min-width: 300px;
    animation: slideIn 0.3s ease-out;
}

.toast.show {
    display: block;
}

.toast.success {
    border-left: 4px solid #28a745;
}

.toast.error {
    border-left: 4px solid #dc3545;
}

.toast-header {
    font-weight: bold;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toast.success .toast-header {
    color: #28a745;
}

.toast.error .toast-header {
    color: #dc3545;
}

.toast-message {
    color: #666;
    font-size: 0.9rem;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

/* Delete Confirmation Modal */
.confirm-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 10px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 10003;
    min-width: 400px;
}

.confirm-modal.show {
    display: block;
}

.confirm-modal h2 {
    color: #dc3545;
    margin-top: 0;
    margin-bottom: 1rem;
}

.confirm-modal p {
    color: #666;
    margin-bottom: 1.5rem;
}

.confirm-modal .button-group {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

/* Edit Game Modal */
.edit-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 10px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 10003;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.edit-modal.show {
    display: block;
}

.edit-modal h2 {
    color: #1e3c72;
    margin-top: 0;
    margin-bottom: 1.5rem;
}

.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10002;
}

.modal-overlay.show {
    display: block;
}

/* Mobile Responsive Styles */
@media screen and (max-width: 768px) {
    /* Header adjustments */
    header {
        padding: 0.5rem;
    }

    header h1 {
        font-size: 1.25rem;
    }

    /* Navigation - mobile layout */
    nav {
        display: flex;
        flex-direction: column;
        gap: 0.3rem !important;
        padding: 0.4rem !important;
    }

    .nav-brand {
        font-size: 2rem;
        text-align: center;
        margin-bottom: 0;
    }

    .content {
    background: white;
    border-radius: 10px;
    padding: 0rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    }

    /* Main navigation links - one row */
    .nav-links {
        display: flex;
        flex-direction: row;
        gap: 1rem !important;
        justify-content: space-between;
        flex-wrap: nowrap;
        padding: 0 !important;
    }

    .nav-links li {
        flex: 1;
        min-width: 0;
    }

    /* Hide Add Game from nav-links on mobile - it goes in auth-status instead */
    .nav-links li.auth-required {
        display: none;
    }

    .nav-link {
        padding: 0.5rem 0.1rem !important;
        min-width: 100px;
        font-size: 1rem !important;
        white-space: nowrap;
        text-align: center;
        display: block;
        overflow: visible !important;
        text-overflow: clip !important;
        line-height: 1.1;
    }

    /* Auth status section - one row with Add Game button */
    .auth-status {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 0.3rem;
        font-size: 0.7rem;
        flex-wrap: nowrap;
        padding: 0 !important;
    }

    .auth-status .left-section {
        display: flex;
        align-items: center;
        gap: 0.3rem;
    }

    .auth-status .right-section {
        display: flex;
        align-items: center;
        gap: 0.3rem;
    }

    .auth-status span {
        white-space: nowrap;
        font-size: 1rem;
    }

    .auth-status button,
    #auth-btn,
    #mobile-add-game {
        font-size: 1rem;
        padding: 0.35rem 0.5rem;
        white-space: nowrap;
    }

    /* Add Game button in auth-status (mobile only) */
    #mobile-add-game {
        display: none;
    }

    body.authenticated #mobile-add-game {
        display: inline-block;
    }

    /* Auth-required items (Add Game button) - hidden by default, shown when authenticated */
    /* Note: Desktop CSS uses body.authenticated .auth-required */

    /* Container */
    .container {
        padding: 0.1rem;
        margin: 0.5rem 0.25rem;
    }

    /* Reduce padding around page content */
    .page {
        padding: 0.5rem;
    }

    .page.active {
        display: block;
        padding: 0.5rem;
    }

    .page h1 {
        margin-bottom: 0.75rem;
        font-size: 1.25rem;
    }

    .recent-games,
    .scoreboard-section {
        margin-top: 1rem;
    }

    .recent-games h2,
    .scoreboard-section h2 {
        font-size: 1.1rem;
        margin-bottom: 0.5rem;
    }

    /* Tables */
    table {
        font-size: 0.75rem;
    }

    th, td {
        padding: 0.4rem 0rem;
    }

    /* Make tables horizontally scrollable */
    .game-history-table-wrapper,
    div[style*="overflow-x: auto"] {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Stats cards - inline format */
    .stats-grid {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .stat-card {
        padding: 0.5rem 0.75rem;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .stat-card h3 {
        font-size: 0.85rem;
        margin: 0;
        opacity: 0.95;
    }

    .stat-card .value {
        font-size: 1.25rem;
        font-weight: bold;
        margin: 0;
    }

    /* Scoreboard layout */
    .scoreboard-layout {
        flex-direction: column;
    }

    .scoreboard-layout .deck-stats-container {
        flex: 1 1 100%;
        width: 100%;
    }

    .scoreboard-section {
        margin-bottom: 1rem;
    }

    .scoreboard-section h2,
    .scoreboard-section h3 {
        margin-bottom: 0.5rem;
    }

    /* Turn order stats */
    .turn-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    /* Buttons */
    .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }

    /* Forms */
    .form-group {
        margin-bottom: 0.75rem;
    }

    .form-group label {
        font-size: 0.85rem;
        margin-bottom: 0.3rem;
    }

    /* Add Game page specific */
    #add-game h3 {
        font-size: 1rem;
        margin-top: 1rem;
        margin-bottom: 0.75rem;
    }

    /* Player rows on mobile - SWAP order: placement first, then deck */
    .player-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
        margin-bottom: 1rem;
    }

    .player-row .form-group {
        margin-bottom: 0;
    }

    /* Order the children: player, placement, deck */
    .player-row .form-group:nth-child(1) {
        order: 1; /* Player name stays first */
    }

    .player-row .form-group:nth-child(2) {
        order: 3; /* Deck/Commander goes last */
        grid-column: 1 / -1; /* Span full width */
    }

    .player-row .form-group:nth-child(3) {
        order: 2; /* Placement goes second */
    }

    /* Placement rows on mobile */
    .placement-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
        margin-bottom: 1rem;
    }

    .placement-row .form-group {
        margin-bottom: 0;
    }

    /* Sol Ring section */
    #add-game h4 {
        font-size: 0.9rem;
        margin-top: 1rem;
        margin-bottom: 0.5rem;
    }

    .solring-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    /* Notes section */
    #add-game textarea {
        min-height: 80px;
    }

    /* Modals */
    .login-modal,
    .edit-modal,
    .confirm-modal {
        width: 95%;
        max-width: 95%;
        padding: 1.5rem;
        max-height: 90vh;
        overflow-y: auto;
    }

    .notes-popup,
    #turnorder-popup {
        width: 95%;
        max-width: 95%;
        padding: 1rem;
    }

    /* Toast notifications */
    .toast {
        width: 90%;
        left: 5%;
        right: 5%;
    }

    /* Filter container */
    .filter-container {
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
    }

    .filter-container select,
    .filter-container button {
        width: 100%;
        font-size: 0.85rem;
        padding: 0.6rem 0.5rem;
    }

    /* Specific filter dropdowns - make them larger */
    #player-filter,
    #deck-player-filter {
        max-width: 100%;
        min-width: 100%;
        font-size: 0.85rem;
    }

    #reset-deck-filter {
        font-size: 0.75rem;
        padding: 0.5rem;
    }

    /* Action buttons in table */
    .actions-column button {
        padding: 0.25rem 0.4rem !important;
        font-size: 0.7rem !important;
        margin-right: 0.15rem !important;
    }

    /* Thursday stats table */
    #thursday-stats-table {
        font-size: 0.7rem !important;
    }

    #thursday-stats-table th,
    #thursday-stats-table td {
        padding: 0.3rem 0.2rem;
        font-size: 0.65rem !important;
    }

    /* Deck stats and player stats tables */
    #deck-stats-table,
    #player-stats-table {
        font-size: 0.8rem;
    }

    /* Login button */
    .login-btn {
        font-size: 0.85rem;
        padding: 0.4rem 0.75rem;
    }

    /* Form inputs */
    input[type="text"],
    input[type="date"],
    input[type="password"],
    select,
    textarea {
        font-size: 0.85rem;
        padding: 0.5rem;
        width: 100%;
    }

    /* Add new player section */
    #add-game .form-group > div[style*="display: flex"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.5rem !important;
    }

    #add-game .form-group > div[style*="display: flex"] > div {
        flex: 1 !important;
    }

    #add-game .form-group > div[style*="display: flex"] button {
        width: 100%;
    }

    /* Button groups */
    .button-group {
        flex-direction: column;
        gap: 0.5rem;
    }

    .button-group button {
        width: 100%;
    }

    /* Recent games table in dashboard */
    #recent-games-tbody td {
        font-size: 0.65rem;
        padding: 0.3rem 0.15rem;
        white-space: nowrap;
    }

    /* Dashboard recent games specific column widths */
    #dashboard table th:nth-child(1),
    #dashboard table td:nth-child(1) {
        width: 60px;
        min-width: 60px;
    }

    #dashboard table th:nth-child(2),
    #dashboard table td:nth-child(2),
    #dashboard table th:nth-child(3),
    #dashboard table td:nth-child(3),
    #dashboard table th:nth-child(4),
    #dashboard table td:nth-child(4),
    #dashboard table th:nth-child(5),
    #dashboard table td:nth-child(5) {
        width: 70px;
        min-width: 70px;
    }

    /* Game History table - adjust date and placement columns */
    .game-history-table th:nth-child(1),
    .game-history-table td:nth-child(1) {
        width: 70px;
        min-width: 70px;
        font-size: 0.7rem;
    }

    .game-history-table th:nth-child(2),
    .game-history-table td:nth-child(2),
    .game-history-table th:nth-child(3),
    .game-history-table td:nth-child(3),
    .game-history-table th:nth-child(4),
    .game-history-table td:nth-child(4),
    .game-history-table th:nth-child(5),
    .game-history-table td:nth-child(5) {
        min-width: 80px;
        font-size: 0.65rem;
    }

    /* Player Statistics - wrap Games Played header */
    #player-stats-table th:nth-child(2) {
        white-space: normal;
        line-height: 1.2;
        padding: 0.3rem 0.2rem;
    }

    /* Deck Statistics - make more compact */
    #deck-stats-table {
        font-size: 0.65rem;
    }

    #deck-stats-table th,
    #deck-stats-table td {
        padding: 0.25rem 0.1rem;
        font-size: 0.65rem;
        line-height: 1.2;
    }

    #deck-stats-table th:nth-child(1),
    #deck-stats-table td:nth-child(1) {
        min-width: 100px;
        max-width: 150px;
        padding-left: 0.2rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    #deck-stats-table th:nth-child(2),
    #deck-stats-table td:nth-child(2),
    #deck-stats-table th:nth-child(3),
    #deck-stats-table td:nth-child(3),
    #deck-stats-table th:nth-child(4),
    #deck-stats-table td:nth-child(4) {
        width: 45px;
        min-width: 45px;
        text-align: center;
    }

    /* Deck filter section on mobile */
    .deck-stats-container > div:first-child {
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.5rem;
    }

    .deck-stats-container h2 {
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }

    /* Additional adjustments for very small screens */
    @media screen and (max-width: 400px) {
        /* Turn stats single column */
        .turn-stats {
            grid-template-columns: 1fr;
        }

        /* Even smaller text for some tables */
        #thursday-stats-table {
            font-size: 0.6rem !important;
        }

        #thursday-stats-table th,
        #thursday-stats-table td {
            padding: 0.2rem 0.1rem;
            font-size: 0.55rem !important;
        }

        /* Smaller modal text */
        .login-modal h2,
        .edit-modal h2,
        .confirm-modal h2 {
            font-size: 1.15rem;
        }

        /* Tighter navigation */
        .nav-link {
            padding: 0.35rem 0.25rem;
            font-size: 0.7rem;
        }
    }
}

/* Desktop - hide mobile Add Game button, show in nav-links instead */
@media screen and (min-width: 769px) {
    #mobile-add-game {
        display: none !important;
    }
}

/* Tablet adjustments */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    .container {
        padding: 1.5rem;
    }

    .stats-container {
        grid-template-columns: repeat(2, 1fr);
    }

    .scoreboard-layout {
        flex-direction: column;
    }
}
