/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Remove any browser default highlighting or selection styles */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Allow text selection for content areas */
p, span, h1, h2, h3, h4, h5, h6, input, textarea {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a4c35 0%, #2d5a3d 50%, #1a3f2e 100%);
    min-height: 100vh;
    color: #333;
}

/* Header Styles */
header {
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 3px solid #ffd700;
    padding: 0.5rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

nav {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    min-height: 50px;
    flex-wrap: nowrap;
    position: relative;
}

.nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 30px;
    position: relative;
    z-index: 1000;
}

.hamburger-line {
    width: 25px;
    height: 3px;
    background: #ffd700;
    border-radius: 2px;
    transition: all 0.3s ease;
    transform-origin: center;
}

.mobile-menu-toggle.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.mobile-menu-toggle.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

nav h1 {
    color: #ffd700;
    font-size: 1.4rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.nav-links {
    display: flex;
    gap: 1rem;
    align-items: center;
}

/* Ensure navigation is visible on desktop */
@media (min-width: 769px) {
    .nav-header {
        width: auto;
    }
    
    .mobile-menu-toggle {
        display: none !important;
    }
    
    .nav-links {
        display: flex !important;
        position: static !important;
        background: none !important;
        backdrop-filter: none !important;
        padding: 0 !important;
        border: none !important;
        box-shadow: none !important;
        z-index: auto !important;
        flex-direction: row !important;
        width: auto !important;
    }
    
    nav {
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
    }
    
    nav h1 {
        text-align: left !important;
        flex: none !important;
    }
}

#guestNav,
#userNav {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.nav-btn {
    padding: 0.4rem 0.8rem;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    font-size: 0.9rem;
    min-width: fit-content;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.nav-btn.active {
    background: rgba(255, 255, 255, 0.4);
    font-weight: 600;
}

/* Main Content */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Tournament page gets special wider treatment */
#tournamentPage {
    max-width: 95%;
    width: 95%;
    margin: 0 auto;
}

/* Override main container width for tournament page */
body.viewing-tournament main {
    max-width: 100%;
    width: 100%;
    padding: 1rem;
}

.page {
    display: none;
    animation: fadeIn 0.5s ease-in-out;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Hero Section */
.hero {
    text-align: center;
    background: rgba(255, 255, 255, 0.9);
    padding: 3rem 2rem;
    border-radius: 15px;
    margin-bottom: 2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.hero h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: #333;
}

.hero p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    color: #666;
}

/* Buttons */
.primary-btn {
    background: linear-gradient(45deg, #ffd700, #ffed4e);
    color: #1a4c35;
    border: 2px solid #ffd700;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 215, 0, 0.4);
    background: linear-gradient(45deg, #ffed4e, #ffd700);
}

.secondary-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.secondary-btn:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.warning-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.warning-btn:hover {
    background: #c82333;
    transform: translateY(-2px);
}

/* Tournament Lists */
.active-tournaments {
    background: rgba(255, 255, 255, 0.95);
    padding: 3rem 2rem;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    border: 2px solid #ffd700;
    text-align: center;
}

.active-tournaments h3 {
    margin-bottom: 2rem;
    color: #1a4c35;
    font-size: 2rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 3px solid #ffd700;
    display: inline-block;
    padding-bottom: 0.5rem;
}

.tournaments-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    justify-items: center;
    max-width: 1000px;
    margin: 0 auto;
}

.tournaments-grid .empty-state {
    grid-column: 1 / -1;
    width: 100%;
    max-width: 600px;
    justify-self: center;
}

.tournament-card {
    background: white;
    padding: 2rem 1.5rem;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    cursor: pointer;
    border: 2px solid transparent;
    width: 100%;
    max-width: 350px;
}

.tournament-card:hover {
    transform: translateY(-8px);
    border-color: #ffd700;
    box-shadow: 0 12px 35px rgba(255, 215, 0, 0.2);
}

.tournament-card h4 {
    color: #1a4c35;
    margin-bottom: 1rem;
    font-size: 1.3rem;
    font-weight: 700;
}

.tournament-card p {
    color: #2d5a3d;
    font-size: 1rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.tournament-status {
    display: inline-block;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    margin-top: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-active {
    background: linear-gradient(45deg, #ffd700, #ffed4e);
    color: #1a4c35;
    border: 1px solid #ffd700;
}

.status-completed {
    background: linear-gradient(45deg, #1a4c35, #2d5a3d);
    color: #ffd700;
    border: 1px solid #ffd700;
}

/* Authentication Styles */
.auth-container {
    max-width: 500px;
    margin: 2rem auto;
    padding: 3rem;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    border: 2px solid #ffd700;
}

.auth-container h2 {
    text-align: center;
    color: #1a4c35;
    margin-bottom: 2rem;
    font-size: 2rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.auth-switch {
    text-align: center;
    margin-top: 1rem;
    color: #2d5a3d;
    font-size: 0.9rem;
}

.link-btn {
    background: none;
    border: none;
    color: #ffd700;
    text-decoration: underline;
    cursor: pointer;
    font-weight: 600;
    font-size: inherit;
}

.link-btn:hover {
    color: #ffed4e;
}

.user-welcome {
    color: #ffd700;
    font-weight: 600;
    font-size: 0.85rem;
    margin: 0 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    flex-shrink: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.logout-btn {
    background: linear-gradient(45deg, #d32f2f, #f44336) !important;
    color: white !important;
    border: 2px solid #d32f2f !important;
}

.logout-btn:hover {
    background: linear-gradient(45deg, #b71c1c, #d32f2f) !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(211, 47, 47, 0.3);
}

/* Create Tournament Form */
.create-tournament {
    background: rgba(255, 255, 255, 0.9);
    padding: 3rem;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.create-tournament h2 {
    margin-bottom: 2rem;
    color: #333;
    text-align: center;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: #333;
    font-weight: 600;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
}

/* Tournament Bracket */
.tournament-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.95);
    padding: 1.5rem;
    border-radius: 15px;
    margin-bottom: 1.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    border: 2px solid #ffd700;
    width: 100%;
}

.tournament-header h2 {
    color: #1a4c35;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.tournament-actions {
    display: flex;
    gap: 1rem;
}

.bracket-container {
    background: rgba(255, 255, 255, 0.95);
    padding: 2rem 1.5rem;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    overflow-x: auto;
    border: 2px solid #ffd700;
    width: 100%;
    min-height: 450px;
    scrollbar-width: thin;
    scrollbar-color: #ffd700 rgba(255, 255, 255, 0.3);
}

.bracket-container::-webkit-scrollbar {
    height: 8px;
}

.bracket-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

.bracket-container::-webkit-scrollbar-thumb {
    background: linear-gradient(90deg, #ffd700, #ffed4e);
    border-radius: 4px;
    border: 1px solid #1a4c35;
}

.bracket-container::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(90deg, #ffed4e, #ffd700);
}

/* Scroll indicator for touch devices */
@media (hover: none) and (pointer: coarse) {
    .bracket-container::before {
        content: '← Swipe to see more rounds →';
        position: absolute;
        bottom: 1rem;
        left: 50%;
        transform: translateX(-50%);
        background: rgba(26, 76, 53, 0.9);
        color: #ffd700;
        padding: 0.5rem 1rem;
        border-radius: 20px;
        font-size: 0.8rem;
        font-weight: 600;
        z-index: 10;
        opacity: 0.8;
        pointer-events: none;
        animation: fadeInOut 3s ease-in-out;
    }
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; }
    20%, 80% { opacity: 0.8; }
}

.bracket {
    display: flex;
    align-items: center;
    gap: 2.5rem;
    min-width: fit-content;
    width: 100%;
    padding: 1.5rem 0.5rem;
    position: relative;
    justify-content: space-evenly;
}

.bracket-round {
    display: flex;
    flex-direction: column;
    min-width: 220px;
    flex: 1;
    position: relative;
    justify-content: center;
}

.bracket-round:not(:last-child) {
    position: relative;
}

.bracket-round:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 50%;
    right: -1.25rem;
    width: 2.5rem;
    height: 3px;
    background: linear-gradient(90deg, #ffd700, #ffed4e);
    z-index: 1;
    border-radius: 2px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.bracket-round.final-round {
    margin-left: 2rem;
    align-self: center;
    justify-content: center;
    min-width: 250px;
}

.round-title {
    text-align: center;
    font-weight: 700;
    color: #1a4c35;
    margin-bottom: 1.2rem;
    padding: 0.7rem 1rem;
    background: linear-gradient(45deg, #ffd700, #ffed4e);
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    border: 2px solid #1a4c35;
    font-size: 0.85rem;
    box-shadow: 0 3px 10px rgba(255, 215, 0, 0.3);
    position: relative;
    z-index: 2;
}

.bracket-round.final-round .round-title {
    background: linear-gradient(45deg, #1a4c35, #2d5a3d);
    color: #ffd700;
    border-color: #ffd700;
    font-size: 1rem;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    padding: 0.8rem 1.5rem;
}

.match {
    background: white;
    border-radius: 10px;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    margin-bottom: 1.2rem;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    position: relative;
}

.match:hover {
    border-color: #ffd700;
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.2);
    transform: translateY(-2px);
}

.bracket-round.final-round .match {
    border: 3px solid #ffd700;
    box-shadow: 0 8px 25px rgba(255, 215, 0, 0.3);
    background: linear-gradient(135deg, #ffffff 0%, #fffef7 100%);
    margin-bottom: 0;
}

.bracket-round.final-round .match:hover {
    box-shadow: 0 12px 35px rgba(255, 215, 0, 0.4);
    transform: translateY(-3px);
}

.bracket-round.semi-final-round {
    justify-content: center;
    gap: 3rem;
}

.bracket-round.quarter-final-round {
    gap: 1.5rem;
}

.bracket-round:nth-child(2) {
    margin-top: 1rem;
}

.bracket-round:nth-child(3) {
    margin-top: 2.5rem;
}

.bracket-round:nth-child(4) {
    margin-top: 3.5rem;
}

/* Additional responsive spacing */
@media (max-width: 1200px) {
    .bracket-round:nth-child(2) {
        margin-top: 1.5rem;
    }
    
    
}

@media (max-width: 992px) {
    .bracket-round:nth-child(2) {
        margin-top: 1rem;
    }
    
    .bracket-round:nth-child(3) {
        margin-top: 2rem;
    }
    
    .bracket-round:nth-child(4) {
        margin-top: 3rem;
    }
}

.player {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #eee;
    cursor: pointer !important;
    transition: all 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: auto !important;
    -webkit-user-select: none;
    user-select: none;
}

.player:last-child {
    border-bottom: none;
}

.player:hover {
    background: #f8f9fa;
}

.player.winner {
    background: linear-gradient(45deg, #28a745, #20c997);
    color: white;
    font-weight: 600;
    cursor: pointer !important;
    pointer-events: auto !important;
    text-decoration: none !important;
}

.player.loser {
    background: #f8f9fa;
    color: #6c757d;
    text-decoration: line-through;
    cursor: pointer !important;
    pointer-events: auto !important;
}

.player.bye {
    background: #fff3cd;
    color: #856404;
    font-style: italic;
}

.player-name {
    flex: 1;
}

.player-status {
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.3);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 15px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content h3 {
    color: #333;
    margin-bottom: 1rem;
}

.modal-content p {
    color: #666;
    margin-bottom: 2rem;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* History Section */
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.95);
    padding: 1.5rem 2rem;
    border-radius: 15px;
    margin-bottom: 2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    border: 2px solid #ffd700;
}

.history-header h2 {
    color: #1a4c35;
    font-size: 1.5rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.history-container {
    background: rgba(255, 255, 255, 0.95);
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    border: 2px solid #ffd700;
}

.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
}

.history-item {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.history-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(45deg, #ffd700, #ffed4e);
}

.history-item:hover {
    transform: translateY(-3px);
    border-color: #ffd700;
    box-shadow: 0 8px 25px rgba(255, 215, 0, 0.2);
}

.history-item-header {
    text-align: center;
    margin-bottom: 1rem;
}

.history-item h4 {
    color: #1a4c35;
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.history-winner-compact {
    background: linear-gradient(45deg, #ffd700, #ffed4e);
    color: #1a4c35;
    padding: 0.75rem;
    margin-bottom: 1rem;
    border-radius: 8px;
    border: 2px solid #1a4c35;
    text-align: center;
}

.history-winner-label-compact {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.history-winner-name-compact {
    font-size: 1.4rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.history-details-compact {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.history-detail-compact {
    text-align: center;
    flex: 1;
    padding: 0.5rem;
    background: rgba(26, 76, 53, 0.05);
    border-radius: 6px;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.history-detail-label-compact {
    display: block;
    font-size: 0.7rem;
    color: #2d5a3d;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 0.25rem;
}

.history-detail-value-compact {
    display: block;
    font-size: 1rem;
    color: #1a4c35;
    font-weight: 700;
}

.history-status-container {
    text-align: center;
}

.history-status-compact {
    display: inline-block;
    padding: 0.3rem 0.6rem;
    border-radius: 15px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.winner-highlight {
    background: linear-gradient(45deg, #ffd700, #ffed4e);
    color: #1a4c35;
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid #1a4c35;
    display: inline-block;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

/* Large Tablets and Small Desktops */
@media (max-width: 1200px) {
    #tournamentPage {
        max-width: 98%;
        width: 98%;
    }
    
    .bracket {
        min-width: fit-content;
        gap: 2rem;
    }
    
    .bracket-round {
        min-width: 200px;
    }
    
    .bracket-round.final-round {
        min-width: 230px;
        margin-left: 1.5rem;
    }
    
    .round-title {
        font-size: 0.8rem;
        padding: 0.6rem 0.8rem;
    }
    
    .bracket-round.final-round .round-title {
        font-size: 0.9rem;
    }
}

/* Tablets */
@media (max-width: 992px) {
    #tournamentPage {
        max-width: 99%;
        width: 99%;
        padding: 1rem;
    }
    
    .bracket {
        min-width: fit-content;
        gap: 2rem;
    }
    
    .bracket-round {
        min-width: 180px;
    }
    
    .bracket-round.final-round {
        min-width: 220px;
        margin-left: 1rem;
    }
    
    .round-title {
        font-size: 0.8rem;
        padding: 0.6rem 0.9rem;
    }
    
    .bracket-round.final-round .round-title {
        font-size: 0.9rem;
        padding: 0.7rem 1.2rem;
    }
    
    .tournament-header {
        padding: 1.2rem;
    }
    
    .bracket-container {
        padding: 1.5rem 1rem;
    }
}

/* Mobile Devices */


/* Loading Animation */
.loading {
    text-align: center;
    padding: 2rem;
    color: #666;
}

.loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #ccc;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: #1a4c35;
    max-width: 600px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    border: 2px dashed #ffd700;
}

.empty-state h3 {
    margin-bottom: 1.5rem;
    font-size: 2.2rem;
    font-weight: 700;
    color: #1a4c35;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.empty-state p {
    margin-bottom: 2.5rem;
    font-size: 1.2rem;
    color: #2d5a3d;
    font-weight: 500;
    line-height: 1.4;
}

.empty-state .primary-btn {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.3);
}

/* Ensure no browser default styles interfere */
.empty-state * {
    background: none !important;
    border: none !important;
    outline: none !important;
}

.empty-state h3 {
    background: none !important;
    border: none !important;
    padding: 0 !important;
    margin-bottom: 1.5rem !important;
    font-size: 2.2rem !important;
    font-weight: 700 !important;
    color: #1a4c35 !important;
    text-transform: uppercase !important;
    letter-spacing: 1px !important;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1) !important;
}

.empty-state p {
    background: none !important;
    border: none !important;
    padding: 0 !important;
    margin-bottom: 2.5rem !important;
    font-size: 1.2rem !important;
    color: #2d5a3d !important;
    font-weight: 500 !important;
    line-height: 1.4 !important;
}

.empty-state .primary-btn {
    background: linear-gradient(45deg, #ffd700, #ffed4e) !important;
    color: #1a4c35 !important;
    border: 2px solid #ffd700 !important;
}

/* Mobile and Tablet Responsive Design */

/* iPhone 14 Pro Max and similar large phones */
@media (max-width: 430px) and (min-width: 391px) {
    header {
        padding: 1rem 0.8rem;
    }
    
    nav {
        flex-direction: column;
        padding: 0 0.8rem;
        align-items: stretch;
    }
    
    .nav-header {
        width: 100%;
        justify-content: space-between;
        align-items: center;
    }
    
    nav h1 {
        font-size: 1.2rem;
        flex: 1;
    }
    
    .mobile-menu-toggle {
        display: flex;
    }
    
    .nav-links {
        display: none;
        flex-direction: column;
        gap: 0.8rem;
        width: 100%;
        align-items: stretch;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: rgba(0, 0, 0, 0.95);
        backdrop-filter: blur(10px);
        padding: 1rem;
        border-top: 2px solid #ffd700;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
        z-index: 999;
    }
    
    .nav-links.active {
        display: flex;
        animation: slideDown 0.3s ease;
    }
    
    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
    
    /* Prevent body scroll when mobile menu is open */
    body.mobile-menu-open {
        overflow: hidden;
    }
    
    #guestNav, #userNav {
        display: flex;
        flex-direction: column;
        gap: 0.8rem;
        width: 100%;
        align-items: stretch;
    }
    
    .nav-btn {
        width: 100%;
        padding: 1rem;
        text-align: center;
        font-size: 1rem;
        min-height: 44px;
        border-radius: 8px;
        flex-shrink: 0;
        background: rgba(255, 255, 255, 0.25);
        border: 1px solid rgba(255, 255, 255, 0.3);
        font-weight: 600;
        transition: all 0.2s ease;
    }
    
    .nav-btn:hover,
    .nav-btn:active {
        background: rgba(255, 255, 255, 0.35);
        border-color: rgba(255, 255, 255, 0.5);
        transform: none;
    }
    
    .nav-btn.active {
        background: rgba(255, 215, 0, 0.3);
        border-color: #ffd700;
        color: #ffd700;
        font-weight: 700;
    }
    
    .logout-btn {
        background: rgba(220, 53, 69, 0.3) !important;
        border-color: #dc3545 !important;
        color: #ff6b6b !important;
    }
    
    .logout-btn:hover,
    .logout-btn:active {
        background: rgba(220, 53, 69, 0.5) !important;
        border-color: #dc3545 !important;
        color: white !important;
        transform: none !important;
    }
    
    .user-welcome {
        order: -1;
        text-align: center;
        font-size: 0.9rem;
        padding: 0.8rem;
        background: rgba(255, 215, 0, 0.15);
        border-radius: 8px;
        color: #ffd700;
        border: 1px solid rgba(255, 215, 0, 0.3);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }
}

/* iPhone SE and small devices */
@media (max-width: 390px) {
    header {
        padding: 0.8rem 0.5rem;
    }
    
    nav {
        flex-direction: column;
        padding: 0 0.5rem;
        align-items: stretch;
    }
    
    .nav-header {
        width: 100%;
        justify-content: space-between;
        align-items: center;
    }
    
    nav h1 {
        font-size: 1.1rem;
        flex: 1;
    }
    
    .mobile-menu-toggle {
        display: flex;
    }
    
    .nav-links {
        display: none;
        flex-direction: column;
        gap: 0.8rem;
        width: 100%;
        align-items: stretch;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: rgba(0, 0, 0, 0.95);
        backdrop-filter: blur(10px);
        padding: 1rem;
        border-top: 2px solid #ffd700;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
        z-index: 999;
    }
    
    .nav-links.active {
        display: flex;
        animation: slideDown 0.3s ease;
    }
    
    #guestNav, #userNav {
        display: flex;
        flex-direction: column;
        gap: 0.8rem;
        width: 100%;
        align-items: stretch;
    }
    
    .nav-btn {
        width: 100%;
        padding: 0.9rem;
        text-align: center;
        font-size: 0.9rem;
        min-height: 44px;
        border-radius: 8px;
        flex-shrink: 0;
        background: rgba(255, 255, 255, 0.25);
        border: 1px solid rgba(255, 255, 255, 0.3);
        font-weight: 600;
        transition: all 0.2s ease;
    }
    
    .nav-btn:hover,
    .nav-btn:active {
        background: rgba(255, 255, 255, 0.35);
        border-color: rgba(255, 255, 255, 0.5);
        transform: none;
    }
    
    .nav-btn.active {
        background: rgba(255, 215, 0, 0.3);
        border-color: #ffd700;
        color: #ffd700;
        font-weight: 700;
    }
    
    .logout-btn {
        background: rgba(220, 53, 69, 0.3) !important;
        border-color: #dc3545 !important;
        color: #ff6b6b !important;
    }
    
    .logout-btn:hover,
    .logout-btn:active {
        background: rgba(220, 53, 69, 0.5) !important;
        border-color: #dc3545 !important;
        color: white !important;
        transform: none !important;
    }
    
    .user-welcome {
        order: -1;
        text-align: center;
        font-size: 0.85rem;
        padding: 0.6rem;
        background: rgba(255, 215, 0, 0.1);
        border-radius: 6px;
        color: #ffd700;
        border: 1px solid rgba(255, 215, 0, 0.3);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }
    
    main {
        padding: 0.5rem;
    }
    
    .auth-container {
        padding: 1.5rem;
        margin: 1rem;
    }
    
    .auth-container h2 {
        font-size: 1.5rem;
    }
    
    .form-group input,
    .form-group textarea {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .hero {
        padding: 1.5rem 1rem;
    }
    
    .hero h2 {
        font-size: 1.5rem;
    }
    
    .hero p {
        font-size: 1rem;
    }
    
    .primary-btn, .secondary-btn, .warning-btn {
        width: 100%;
        padding: 0.8rem;
        font-size: 0.9rem;
    }
    
    .empty-state {
        padding: 2rem 1rem;
    }
    
    .empty-state h3 {
        font-size: 1.5rem;
    }
    
    .empty-state p {
        font-size: 1rem;
    }
}

/* Standard iPhone and small tablets */
@media (max-width: 768px) {
    header {
        padding: 1rem 0.8rem;
    }
    
    nav {
        flex-direction: column;
        padding: 0 0.8rem;
        align-items: stretch;
    }
    
    .nav-header {
        width: 100%;
        justify-content: space-between;
        align-items: center;
    }
    
    nav h1 {
        font-size: 1.2rem;
        flex: 1;
    }
    
    .mobile-menu-toggle {
        display: flex;
    }
    
    .nav-links {
        display: none;
        flex-direction: column;
        gap: 1rem;
        width: 100%;
        align-items: stretch;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: rgba(0, 0, 0, 0.95);
        backdrop-filter: blur(10px);
        padding: 1rem;
        border-top: 2px solid #ffd700;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
        z-index: 999;
    }
    
    .nav-links.active {
        display: flex;
        animation: slideDown 0.3s ease;
    }
    
    #guestNav, #userNav {
        display: flex;
        flex-direction: column;
        gap: 1rem;
        width: 100%;
        align-items: stretch;
    }
    
    .nav-btn {
        width: 100%;
        padding: 1rem;
        text-align: center;
        font-size: 1rem;
        min-height: 44px;
        border-radius: 8px;
        flex-shrink: 0;
        font-weight: 600;
        background: rgba(255, 255, 255, 0.25);
        border: 1px solid rgba(255, 255, 255, 0.3);
        transition: all 0.2s ease;
    }
    
    .nav-btn:hover,
    .nav-btn:active {
        background: rgba(255, 255, 255, 0.35);
        border-color: rgba(255, 255, 255, 0.5);
        transform: none;
    }
    
    .nav-btn.active {
        background: rgba(255, 215, 0, 0.3);
        border-color: #ffd700;
        color: #ffd700;
        font-weight: 700;
    }
    
    .logout-btn {
        background: rgba(220, 53, 69, 0.3) !important;
        border-color: #dc3545 !important;
        color: #ff6b6b !important;
    }
    
    .logout-btn:hover,
    .logout-btn:active {
        background: rgba(220, 53, 69, 0.5) !important;
        border-color: #dc3545 !important;
        color: white !important;
        transform: none !important;
    }
    
    .user-welcome {
        order: -1;
        text-align: center;
        font-size: 0.9rem;
        padding: 0.8rem;
        width: 100%;
        background: rgba(255, 215, 0, 0.15);
        border-radius: 8px;
        color: #ffd700;
        border: 1px solid rgba(255, 215, 0, 0.3);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    main {
        padding: 1rem;
    }
    
    .auth-container {
        padding: 2rem;
        margin: 1rem 0;
        max-width: 100%;
    }
    
    .form-group {
        margin-bottom: 1.5rem;
    }
    
    .form-group input,
    .form-group textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.8rem;
        min-height: 44px; /* Apple's recommended touch target size */
    }
    
    .form-group textarea {
        min-height: 200px;
    }
    
    .hero {
        padding: 2rem 1rem;
    }
    
    .hero h2 {
        font-size: 2rem;
    }
    
    .tournament-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
        padding: 1rem;
    }
    
    .tournament-actions {
        flex-direction: column;
        gap: 0.8rem;
    }
    
    .tournament-actions button {
        width: 100%;
        min-height: 44px;
    }
    
    #tournamentPage {
        max-width: 100%;
        width: 100%;
        padding: 0.5rem;
    }
    
    .bracket-container {
        padding: 1rem 0.5rem;
        min-height: auto;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    }
    
    .bracket {
        gap: 1rem;
        padding: 0.8rem 0.5rem;
        flex-direction: column;
        align-items: stretch;
        min-width: auto;
        width: 100%;
        justify-content: flex-start;
    }
    
    .bracket-round {
        min-width: auto;
        margin-top: 0 !important;
        flex: none;
        width: 100%;
    }
    
    .bracket-round:not(:last-child)::after {
        display: none;
    }
    
    .bracket-round.final-round {
        margin-left: 0;
        order: -1;
        min-width: auto;
        background: rgba(26, 76, 53, 0.1);
        padding: 1rem;
        border-radius: 10px;
        border: 2px solid #ffd700;
    }
    
    .round-title {
        font-size: 0.9rem;
        padding: 0.8rem;
        margin-bottom: 1rem;
        letter-spacing: 0.8px;
        text-align: center;
    }
    
    .bracket-round.final-round .round-title {
        font-size: 1rem;
        padding: 0.8rem;
    }
    
    .match {
        margin-bottom: 1rem;
    }
    
    .player {
        padding: 0.8rem;
        min-height: 44px; /* Apple's recommended touch target size */
        font-size: 0.9rem;
        cursor: pointer;
        pointer-events: auto;
        transition: all 0.3s ease;
    }
    
    .player:hover {
        background: #f8f9fa !important;
    }
    
    .player.winner {
        background: linear-gradient(45deg, #28a745, #20c997) !important;
        color: white !important;
        font-weight: 600 !important;
        text-decoration: none !important;
    }
    
    .player.loser {
        background: #f8f9fa !important;
        color: #6c757d !important;
        text-decoration: line-through !important;
    }
    
    .form-actions {
        flex-direction: column;
        gap: 0.8rem;
    }
    
    .form-actions button {
        width: 100%;
        min-height: 44px;
    }
    
    .modal-content {
        width: 95%;
        max-width: 400px;
        margin: 0 auto;
        padding: 1.5rem;
    }
    
    .modal-actions {
        flex-direction: column;
        gap: 0.8rem;
    }
    
    .modal-actions button {
        width: 100%;
        min-height: 44px;
    }
    
    .history-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
        padding: 1rem;
    }
    
    .history-header button {
        width: 100%;
        min-height: 44px;
    }
    
    .history-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .history-details-compact {
        flex-direction: column;
        gap: 0.8rem;
    }
    
    .history-winner-name-compact {
        font-size: 1.2rem;
    }
    
    .history-item h4 {
        font-size: 1.1rem;
    }
    
    .history-item {
        padding: 1.5rem;
    }
}

/* iPad and larger tablets */
@media (min-width: 768px) and (max-width: 1024px) {
    header {
        padding: 1rem;
    }
    
    .nav-header {
        width: auto;
    }
    
    .mobile-menu-toggle {
        display: none;
    }
    
    nav {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 0 1rem;
    }
    
    nav h1 {
        font-size: 1.3rem;
        flex-shrink: 0;
    }
    
    .nav-links {
        display: flex !important;
        position: static !important;
        background: none !important;
        backdrop-filter: none !important;
        padding: 0 !important;
        border: none !important;
        box-shadow: none !important;
        z-index: auto !important;
        flex-direction: row;
        gap: 1rem;
        flex-wrap: wrap;
        justify-content: flex-end;
        width: auto;
    }
    
    #userNav {
        display: flex;
        flex-direction: row;
        gap: 0.8rem;
        align-items: center;
        flex-wrap: wrap;
    }
    
    .nav-btn {
        min-height: 44px;
        padding: 0.8rem 1rem;
        flex-shrink: 0;
    }
    
    .user-welcome {
        order: initial;
        margin-right: 1rem;
        max-width: 150px;
        font-size: 0.8rem;
    }
    
    main {
        padding: 1.5rem;
    }
    
    .auth-container {
        max-width: 500px;
        margin: 2rem auto;
        padding: 2.5rem;
    }
    
    .form-group input,
    .form-group textarea {
        font-size: 16px;
        min-height: 44px;
    }
    
    .hero {
        padding: 3rem 2rem;
    }
    
    .tournament-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 1.5rem;
    }
    
    .tournament-actions {
        flex-direction: row;
        gap: 1rem;
    }
    
    .tournament-actions button {
        min-height: 44px;
        width: auto;
    }
    
    #tournamentPage {
        width: 95%;
        padding: 1rem;
    }
    
    .bracket-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 1.5rem;
    }
    
    .bracket {
        flex-direction: row;
        gap: 2rem;
        min-width: 800px;
    }
    
    .bracket-round {
        min-width: 180px;
    }
    
    .bracket-round:not(:last-child)::after {
        display: block;
    }
    
    .bracket-round.final-round {
        order: initial;
        margin-left: 1rem;
        min-width: 200px;
    }
    
    .player {
        min-height: 44px;
        font-size: 0.9rem;
        cursor: pointer;
        pointer-events: auto;
        transition: all 0.3s ease;
    }
    
    .player:hover {
        background: #f8f9fa !important;
    }
    
    .player.winner {
        background: linear-gradient(45deg, #28a745, #20c997) !important;
        color: white !important;
        font-weight: 600 !important;
        text-decoration: none !important;
    }
    
    .player.loser {
        background: #f8f9fa !important;
        color: #6c757d !important;
        text-decoration: line-through !important;
    }
    
    .form-actions {
        flex-direction: row;
        justify-content: center;
        gap: 1rem;
    }
    
    .form-actions button {
        width: auto;
        min-height: 44px;
    }
    
    .modal-content {
        width: 80%;
        max-width: 500px;
    }
    
    .modal-actions {
        flex-direction: row;
        gap: 1rem;
    }
    
    .modal-actions button {
        width: auto;
        min-height: 44px;
    }
    
    .history-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 1.5rem;
    }
    
    .history-header button {
        width: auto;
        min-height: 44px;
    }
    
    .history-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    
    .history-details-compact {
        flex-direction: row;
        gap: 1rem;
    }
}

/* iOS-specific optimizations */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari specific styles */
    .nav-btn, .primary-btn, .secondary-btn, .warning-btn {
        -webkit-appearance: none;
        border-radius: 8px;
    }
    
    .form-group input,
    .form-group textarea {
        -webkit-appearance: none;
        border-radius: 8px;
    }
    
    .player {
        -webkit-tap-highlight-color: rgba(255, 215, 0, 0.2);
        cursor: pointer;
        pointer-events: auto;
    }
    
    .player:active {
        -webkit-tap-highlight-color: rgba(255, 215, 0, 0.3);
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
    
    /* Prevent text selection on interactive elements */
    .nav-btn, .primary-btn, .secondary-btn, .warning-btn, .tournament-card {
        -webkit-user-select: none;
        user-select: none;
        -webkit-touch-callout: none;
    }
    
    /* Allow players to be interactive */
    .player {
        -webkit-user-select: none;
        user-select: none;
        cursor: pointer;
        pointer-events: auto;
    }
    
    /* Improve touch scrolling */
    .bracket-container, .history-container {
        -webkit-overflow-scrolling: touch;
        overflow-x: auto;
    }
    
    /* Fix iOS input zoom and improve accessibility */
    .form-group input,
    .form-group textarea {
        font-size: max(16px, 1rem);
        -webkit-text-size-adjust: 100%;
    }
    
    /* Better button touch feedback */
    .nav-btn:active,
    .primary-btn:active,
    .secondary-btn:active,
    .warning-btn:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
    
    /* Mobile navigation improvements */
    @media (max-width: 768px) {
        .nav-btn:active {
            background: rgba(255, 255, 255, 0.4) !important;
            border-color: rgba(255, 255, 255, 0.6) !important;
        }
        
        .nav-btn.active:active {
            background: rgba(255, 215, 0, 0.5) !important;
            border-color: #ffd700 !important;
        }
        
        .logout-btn:active {
            background: rgba(220, 53, 69, 0.6) !important;
            border-color: #dc3545 !important;
            color: white !important;
        }
    }
    
    /* Improve modal on iOS */
    .modal {
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
    }
    
    .modal-content {
        -webkit-transform: translate3d(0, 0, 0);
        transform: translate3d(0, 0, 0);
    }
}

/* Landscape orientation improvements */
@media (orientation: landscape) and (max-height: 500px) {
    .hero {
        padding: 1.5rem;
    }
    
    .auth-container {
        padding: 1.5rem;
    }
    
    .tournament-header {
        padding: 1rem;
    }
    
    .bracket-container {
        padding: 1rem;
    }
}

/* High DPI displays (Retina) */
@media (-webkit-min-device-pixel-ratio: 2) {
    .round-title,
    .player-name,
    .history-winner-name-compact,
    nav h1,
    .nav-btn,
    .user-welcome {
        text-rendering: optimizeLegibility;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* iPhone X and newer with notch/Dynamic Island support */
@supports (padding: max(0px)) {
    header {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
        padding-top: max(0.5rem, env(safe-area-inset-top));
    }
    
    main {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
    
    .modal-content {
        margin-left: max(1rem, env(safe-area-inset-left));
        margin-right: max(1rem, env(safe-area-inset-right));
    }
    
    /* Enhanced mobile navigation for devices with notches */
    @media (max-width: 768px) {
        nav {
            padding-left: max(0.8rem, env(safe-area-inset-left));
            padding-right: max(0.8rem, env(safe-area-inset-right));
        }
    }
}

/* Performance optimizations for mobile */
@media (max-width: 768px) {
    * {
        will-change: auto;
    }
    
    .bracket-round,
    .modal-content {
        will-change: transform;
    }
    
    .player {
        will-change: transform;
        cursor: pointer !important;
        pointer-events: auto !important;
        -webkit-user-select: none;
        user-select: none;
    }
    
    .bracket-container {
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
    }
    
    /* Ensure proper header layout */
    header {
        min-height: auto;
    }
    
    nav {
        min-height: auto;
        width: 100%;
        box-sizing: border-box;
    }
    
    .nav-links {
        min-width: 0;
        flex: 1;
    }
    
    #guestNav, #userNav {
        min-width: 0;
        flex: 1;
    }
    
    .nav-btn {
        box-sizing: border-box;
        display: block;
        text-align: center;
    }
    
    .user-welcome {
        display: block;
        box-sizing: border-box;
    }
    
    /* Reduce animations on lower-end devices */
    @media (prefers-reduced-motion: reduce) {
        *,
        *::before,
        *::after {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
        }
    }
} 