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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #ffffff;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    border: 1px solid #e5e7eb;
}

.header {
    background: #f8f9fa;
    color: #1f2937;
    padding: 30px;
    text-align: center;
    border-bottom: 2px solid #e5e7eb;
}

.header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    font-weight: 700;
}

.progress-container {
    margin-top: 20px;
    background: #e5e7eb;
    border-radius: 8px;
    padding: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 28px;
    background: #10b981;
    border-radius: 6px;
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 1em;
}

.content {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 0;
}

#map {
    height: 700px;
    width: 100%;
}

.sidebar {
    background: #ffffff;
    padding: 30px;
    overflow-y: auto;
    max-height: 700px;
    border-left: 1px solid #e5e7eb;
}

.sidebar h2 {
    color: #1f2937;
    margin-bottom: 20px;
    font-size: 1.6em;
    font-weight: 600;
}

.controls {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
}

.btn {
    padding: 10px 15px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    transition: all 0.3s ease;
    width: 100%;
}

.btn-reset {
    background: #ef4444;
    color: white;
}

.btn-reset:hover {
    background: #dc2626;
}

.btn[href="rankings.html"]:hover {
    background: #2563eb !important;
}

.arena-list {
    list-style: none;
}

.arena-item {
    position: relative;
    background: #f9fafb;
    margin-bottom: 10px;
    padding: 14px;
    padding-right: 60px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    transition: all 0.2s ease;
}

.arena-item:hover {
    border-color: #d1d5db;
    background: #f3f4f6;
}

.arena-item.visited {
    background: #d1fae5;
    border-color: #10b981;
}

.arena-item.dragging {
    opacity: 0.5;
}

.arena-item.drag-over {
    border-top: 3px solid #3b82f6;
}

.drag-handle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    cursor: grab;
    color: #6b7280;
    background: #e5e7eb;
    font-size: 24px;
    font-weight: bold;
    padding: 8px 10px;
    border-radius: 6px;
    user-select: none;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.drag-handle:hover {
    background: #d1d5db;
    color: #374151;
}

.drag-handle:active {
    cursor: grabbing;
    background: #9ca3af;
}

.arena-item label {
    display: flex;
    align-items: flex-start;
    cursor: pointer;
    gap: 12px;
    width: 100%;
    padding-top: 2px;
}

.arena-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #10b981;
}

.arena-info {
    flex: 1;
}

.arena-name {
    font-weight: 600;
    color: #1f2937;
    font-size: 0.95em;
    margin-bottom: 3px;
}

.team-name {
    color: #6b7280;
    font-size: 0.85em;
}

.ranking-container {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.ranking-label {
    font-size: 0.8em;
    color: #6b7280;
    font-weight: 500;
}

.star-rating {
    display: flex;
    gap: 4px;
}

.star {
    font-size: 26px;
    cursor: pointer;
    color: #d1d5db;
    user-select: none;
    position: relative;
    display: inline-block;
}

.star.filled {
    color: #fbbf24;
}

.star.half-filled {
    background: linear-gradient(90deg, #fbbf24 50%, #d1d5db 50%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.star.hover-preview {
    color: #fbbf24;
    opacity: 0.7;
}

.star.hover-preview.half-filled {
    background: linear-gradient(90deg, #fbbf24 50%, rgba(209, 213, 219, 0.7) 50%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.star:hover {
    transform: none;
}

.ranking-number {
    font-size: 0.85em;
    color: #fbbf24;
    font-weight: 600;
    min-width: 35px;
}

.rating-count {
    font-size: 0.75em;
    color: #9ca3af;
    font-weight: 500;
    margin-left: 4px;
}

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

.stat {
    text-align: center;
    padding: 14px;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.stat-value {
    font-size: 1.8em;
    font-weight: 700;
    color: #1f2937;
}

.stat-label {
    font-size: 0.85em;
    color: #6b7280;
    margin-top: 5px;
}

@media (max-width: 1024px) {
    .content {
        grid-template-columns: 1fr;
    }

    .sidebar {
        max-height: none;
    }
}

.leaflet-popup-content-wrapper {
    border-radius: 10px;
}

.custom-marker {
    background: transparent !important;
    border: none !important;
}

.popup-content {
    text-align: center;
    padding: 8px;
    min-width: 220px;
}

.popup-team {
    font-weight: 600;
    color: #1f2937;
    font-size: 1em;
    margin-bottom: 4px;
}

.popup-arena {
    color: #6b7280;
    font-size: 0.88em;
    margin-bottom: 12px;
}

.popup-checkbox {
    margin-top: 8px;
    padding: 8px 16px;
    background: #10b981;
    color: white;
    border: 1.5px solid #10b981;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9em;
    width: 100%;
    transition: all 0.2s ease;
}

.popup-checkbox:hover {
    background: #059669;
    border-color: #059669;
}

.popup-checkbox.visited {
    background: #ef4444;
    border-color: #ef4444;
    color: white;
}

.popup-checkbox.visited:hover {
    background: #dc2626;
    border-color: #dc2626;
}

.footer {
    background: #f8f9fa;
    padding: 20px;
    text-align: center;
    border-top: 1px solid #e5e7eb;
    margin-top: 20px;
}

.footer p {
    color: #6b7280;
    font-size: 0.9em;
    margin: 0 0 8px 0;
}

.footer-disclaimer {
    font-size: 0.7em !important;
    color: #9ca3af !important;
    margin-top: 8px !important;
}

.footer a {
    color: #3b82f6;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}

.footer a:hover {
    color: #2563eb;
    text-decoration: underline;
}

/* ========== Phones ========== */
@media (max-width: 640px) {
    body {
        padding: 0;
    }

    .container {
        border-radius: 0;
        border-left: none;
        border-right: none;
        box-shadow: none;
    }

    .header {
        padding: 14px 16px;
        gap: 12px;
    }

    .header h1 {
        font-size: 1.4em;
        text-align: left;
        line-height: 1.2;
    }

    #auth {
        flex-shrink: 0;
    }

    #btnShowSignIn {
        white-space: nowrap;
    }

    /* Email is too long for a phone header; the photo and settings stay */
    #who {
        display: none !important;
    }

    /* Shorter map so there's always room to scroll past it */
    #map {
        height: 50vh;
        min-height: 300px;
    }

    .sidebar {
        padding: 16px;
        border-left: none;
        border-top: 1px solid #e5e7eb;
    }

    .sidebar h2 {
        font-size: 1.3em;
        margin-bottom: 14px;
    }

    .arena-item {
        padding: 12px;
        padding-right: 56px;
    }

    /* Let the stars drop to their own line instead of running under the handle */
    .ranking-container {
        flex-wrap: wrap;
        gap: 4px 8px;
    }

    .star {
        font-size: 28px;
    }

    .drag-handle {
        right: 8px;
        touch-action: none;
    }

    .arena-item.touch-dragging {
        opacity: 0.6;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }

    #signInModal > div {
        padding: 28px 20px !important;
    }

    #signInModal h2 {
        font-size: 1.5em !important;
    }

    #closeModal {
        top: 12px !important;
        right: 12px !important;
    }

    .footer {
        margin-top: 0;
    }
}
