/* Modern CSS Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Modern Color Palette */
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --secondary: #06b6d4;
    --accent: #f59e0b;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    
    /* Neutral Colors */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    
    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
}

body {
    font-family: var(--font-sans);
    color: var(--gray-900);
    line-height: 1.6;
    min-height: 100vh;
    padding: var(--space-lg);
}

.container {
    max-width: 1440px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

/* Header */
.subtitle {
    text-align: center;
    color: var(--gray-600);
    font-size: 1.125rem;
    font-weight: 500;
    margin-bottom: var(--space-xl);
}

#map-section {
    margin-bottom: 30px;
}

/* Map Container */
.map-container {
    position: relative;
    /* Allow horizontal scrolling */
    overflow-x: auto;
    overflow-y: hidden;
    /* Smooth scrolling */
    scroll-behavior: smooth;
    /* Touch scrolling support */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    /* Prevent text selection during scrolling */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    /* Scrollbar styling */
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: #cbd5e0 transparent; /* Firefox */
    /* Ensure proper scrolling area */
    width: 100%;
    max-width: 100%;
}

/* Custom scrollbar for webkit browsers */
.map-container::-webkit-scrollbar {
    height: 8px;
}

.map-container::-webkit-scrollbar-track {
    background: transparent;
}

.map-container::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 4px;
}

.map-container::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Map Section */
#map-grid {
    display: grid;
    grid-template-columns: repeat(13, 1fr);
    gap: 0;
    margin: 0;
    position: relative;
    width: fit-content;
    min-width: max-content;
    padding: 1px;
}

#map-grid::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        repeating-linear-gradient(
            to right,
            transparent 0,
            transparent calc(100% / 13 - 0.5px),
            #f0f0f0 calc(100% / 13 - 0.5px),
            #f0f0f0 calc(100% / 13 + 0.5px),
            transparent calc(100% / 13 + 0.5px),
            transparent calc(100% / 13)
        ),
        repeating-linear-gradient(
            to bottom,
            transparent 0,
            transparent calc(100% / 13 - 0.5px),
            #f0f0f0 calc(100% / 13 - 0.5px),
            #f0f0f0 calc(100% / 13 + 0.5px),
            transparent calc(100% / 13 + 0.5px),
            transparent calc(100% / 13)
        );
    pointer-events: none;
    z-index: 0;
    background-size: calc(100% / 13) calc(100% / 13);
}

#map-grid::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 1px solid #d1d5db;
    pointer-events: none;
    z-index: 0;
}

/* Zone Styling */
.zone {
    position: relative;
    width: 80px;
    height: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #f8f9fa;
    overflow: visible;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    z-index: 2;
    border: 1px solid #e0e0e0;
    margin: 0;
    box-sizing: border-box;
}

.zone.alliance-controlled::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255,255,255,0.1) 50%, transparent 70%);
    pointer-events: none;
}

/* Alliance Overlay Elements */
.alliance-overlay {
    display: none !important;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 10;
}

.claims-badge {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    pointer-events: none;
    z-index: 10;
}

.alliance-dots {
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-items: flex-end;
    transition: all 0.2s ease;
}

.alliance-dot {
    transition: all 0.2s ease;
    cursor: pointer;
}

.alliance-dot:hover {
    transform: scale(1.3);
    box-shadow: 0 0 4px rgba(0,0,0,0.6);
    z-index: 15;
}

.claims-count {
    font-family: var(--font-sans);
    font-weight: 600;
    text-align: center;
    line-height: 1;
    min-width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

/* Gradient support indicators */
.zone.alliance-controlled[style*="linear-gradient"] {
    position: relative;
}

/* Enhanced tooltip support */
.zone[title] {
    position: relative;
}

/* Enhanced accessibility for color-blind users */
.alliance-dot::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border: 2px solid transparent;
    border-radius: 50%;
    transition: border-color 0.2s ease;
}

.alliance-dot:hover::after {
    border-color: rgba(255,255,255,0.8);
}

/* Enhanced zone info styling */
.zone-info {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    z-index: 1000;
    max-width: 350px;
    max-height: 80vh;
    overflow-y: auto;
    border: 1px solid var(--gray-200);
}

.zone-info::before {
    content: '';
    position: absolute;
    top: -8px;
    right: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid white;
}

.zone-info h3 {
    color: var(--gray-900);
    margin-bottom: var(--space-md);
    font-size: 1.25rem;
    font-weight: 600;
    border-bottom: 2px solid var(--primary);
    padding-bottom: var(--space-sm);
}

.zone-info .close-btn {
    background: var(--error);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    margin-top: 15px;
    width: 100%;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.zone-info .close-btn:hover {
    background: #c53030;
}

.zone:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-color: #d0d0d0;
    background: #f0f0f0;
}

.zone.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1), var(--shadow-lg);
    transform: scale(1.15);
    z-index: 10;
    overflow: visible;
}

/* Ensure normal zones have hidden overflow for clean appearance */
.zone:not(.selected) {
    overflow: hidden;
}

/* Zone Content */
.zone-type {
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: #6c757d;
    margin-bottom: 3px;
    text-align: center;
    line-height: 1.1;
}

.zone-level {
    background: #6c757d;
    color: white;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    font-family: var(--font-mono);
    margin: 3px 0;
    border: none;
    border-radius: 100%;
    position: relative;
    overflow: hidden;
    letter-spacing: 0.02em;
}

.zone-level::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.zone:hover .zone-level::before {
    left: 100%;
}

.zone-icon {
    font-size: 1.4rem;
    margin-top: 3px;
    filter: grayscale(0.3) contrast(1.05);
    opacity: 0.9;
}

/* Sleek Zone Styling - Pastel Colors for Zone Types */
.zone.village { 
    background: #e8f5e8;
    border-color: #c8e6c9;
}

.zone.city { 
    background: #fff3e0;
    border-color: #ffcc80;
}

.zone.factory { 
    background: #f3e5f5;
    border-color: #ce93d8;
}

.zone.train { 
    background: #e3f2fd;
    border-color: #90caf9;
}

.zone.launch { 
    background: #e8f5e8;
    border-color: #a5d6a7;
}

.zone.palace { 
    background: #fce4ec;
    border-color: #f48fb1;
}

.zone.furnace { 
    background: #fff8e1;
    border-color: #ffd54f;
}

.zone.digsite { 
    background: #f8f9fa;
    border-color: #e0e0e0;
}

.zone.digsite .zone-icon {
    display: none;
}

/* Pastel Level Badge Colors for Each Zone Type */
.zone.village .zone-level {
    background: #4caf50;
}

.zone.city .zone-level {
    background: #ff9800;
}

.zone.factory .zone-level {
    background: #9c27b0;
}

.zone.train .zone-level {
    background: #2196f3;
}

.zone.launch .zone-level {
    background: #4caf50;
}

.zone.palace .zone-level {
    background: #e91e63;
}

.zone.furnace .zone-level {
    background: #ffc107;
}

.zone.digsite .zone-level {
    background: #6c757d;
}

/* Display-only zones (no map_id) - using existing styles.css system */
.zone.display-only {
    cursor: default;
}

.zone.display-only:hover {
    transform: none;
    box-shadow: none;
}

.zone.display-only:hover .zone-level::before {
    display: none;
}

/* Display-only info text */
.display-only-info {
    text-align: center;
    margin-top: 20px;
    padding: 15px;
    background: var(--gray-50);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--secondary);
}

.display-only-info .info-text {
    margin: 0;
    color: var(--gray-600);
    font-size: 0.9rem;
}

.display-only-info .info-text a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.display-only-info .info-text a:hover {
    text-decoration: underline;
}

/* Legend */
.legend {
    background: #fafafa;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border: 1px solid #e8e8e8;
}

.legend h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: var(--space-lg);
    text-align: center;
    position: relative;
}

.legend h3::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: 2px;
}

.legend-items {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--space-md);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    border-radius: 6px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    transition: all 0.2s ease;
    cursor: pointer;
}

.legend-item:hover {
    background: #f0f0f0;
    border-color: #d0d0d0;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.legend-icon {
    font-size: 1.5rem;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: white;
    box-shadow: var(--shadow-sm);
}

.legend-item span:last-child {
    font-weight: 500;
    color: var(--gray-700);
}

/* Alliance Legend Main */
.alliance-legend-main {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: white;
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--gray-200);
    max-width: 300px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    transition: all 0.3s ease;
}

.alliance-legend-main h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: var(--space-md);
    text-align: left;
    position: relative;
    margin: 0;
}

.alliance-legend-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.legend-controls {
    display: flex;
    gap: var(--space-xs);
}

.toggle-legend-btn,
.close-legend-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--space-xs);
    border-radius: var(--radius-sm);
    color: var(--gray-600);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.toggle-legend-btn:hover,
.close-legend-btn:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

.toggle-legend-btn .toggle-icon {
    font-size: 1.2rem;
    font-weight: bold;
    line-height: 1;
}

.close-legend-btn .close-icon {
    font-size: 1.4rem;
    font-weight: bold;
    line-height: 1;
}

.alliance-legend-main.collapsed {
    max-height: 60px;
    overflow: hidden;
}

.alliance-legend-main.collapsed .toggle-icon {
    transform: rotate(180deg);
}

#alliance-legend-items {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.alliance-legend-main-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    padding: var(--space-sm);
    border-radius: var(--radius-md);
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    transition: all 0.2s ease;
}

.alliance-legend-main-item:hover {
    background: var(--gray-100);
    border-color: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.alliance-legend-main-info {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex: 1;
}

.alliance-legend-main-color {
    width: 16px;
    height: 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-300);
    flex-shrink: 0;
}

.alliance-legend-main-name {
    font-weight: 500;
    color: var(--gray-700);
    font-size: 0.875rem;
}

.alliance-legend-main-copy-btn {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.2s;
}

.alliance-legend-main-copy-btn:hover {
    background-color: #0056b3;
}

.alliance-legend-main-copy-btn.copied {
    background-color: #28a745;
}

.alliance-legend-main-no-access {
    color: #6c757d;
    font-size: 12px;
    font-style: italic;
    padding: 5px 10px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background-color: #f8f9fa;
}

.alliance-no-access {
    color: #6c757d;
    font-size: 12px;
    font-style: italic;
    padding: 10px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background-color: #f8f9fa;
    text-align: center;
    margin: 10px 0;
}

/* Responsive styles for alliance legend */
@media (max-width: 768px) {
    .alliance-legend-main {
        bottom: 10px;
        left: 10px;
        right: 10px;
        max-width: none;
        max-height: 300px;
    }
    
    .alliance-legend-main-item {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-xs);
    }
    
    .alliance-legend-main-copy-btn {
        align-self: stretch;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .alliance-legend-main {
        bottom: 5px;
        left: 5px;
        right: 5px;
        padding: var(--space-sm);
        max-height: 250px;
    }
    
    .alliance-legend-main h3 {
        font-size: 0.875rem;
    }
    
    .alliance-legend-main-name {
        font-size: 0.8rem;
    }
    
    .alliance-legend-main-copy-btn {
        font-size: 0.7rem;
        padding: var(--space-xs);
    }
}

/* Loading State */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Create Map Button */
.create-map-section {
    text-align: center;
    margin-bottom: var(--space-xl);
}

/* Error Display */
.error-display {
    display: none; /* Hidden by default */
    background: var(--error);
    color: white;
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-bottom: var(--space-lg);
    box-shadow: var(--shadow-md);
    animation: slideDown 0.3s ease-out;
}

.error-content {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.error-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

#error-message {
    flex: 1;
    font-weight: 500;
}

.dismiss-error-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: background-color 0.2s ease;
}

.dismiss-error-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.create-map-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    border: none;
    padding: var(--space-md) var(--space-xl);
    border-radius: var(--radius-lg);
    font-size: 1.125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-md);
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
}

.create-map-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
}

.create-map-btn:active {
    transform: translateY(0);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: var(--radius-2xl);
    padding: var(--space-2xl);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--gray-200);
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-xl);
    padding-bottom: var(--space-md);
    border-bottom: 2px solid var(--gray-100);
}

.modal-header h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0;
}

.close-btn {
    background: var(--gray-100);
    border: none;
    border-radius: var(--radius-md);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--gray-600);
    cursor: pointer;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: var(--gray-200);
    color: var(--gray-900);
    transform: scale(1.05);
}

/* Form Styles */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-group label {
    display: block;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: var(--space-sm);
    font-size: 1rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: var(--space-md);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: all 0.2s ease;
    background: white;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

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

.info-text {
    margin-bottom: var(--space-sm);
    padding: var(--space-sm);
    background: var(--gray-50);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--primary);
}

.info-text small {
    color: var(--gray-600);
    font-size: 0.875rem;
    line-height: 1.4;
}

/* Alliance Rows */
.alliance-row {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
    padding: var(--space-md);
    background: var(--gray-50);
    border-radius: var(--radius-md);
    border: 1px solid var(--gray-200);
}

.alliance-name {
    flex: 1;
    margin: 0;
}

.color-picker {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
    max-width: 300px;
}

.color-swatch {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-md);
    border: 2px solid var(--gray-300);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    flex-shrink: 0;
}

.color-swatch:hover {
    transform: scale(1.1);
    border-color: var(--gray-600);
}

.color-swatch.selected {
    border-color: var(--gray-900);
    box-shadow: 0 0 0 2px white, 0 0 0 4px var(--gray-900);
}

.color-swatch.selected::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-weight: bold;
    font-size: 12px;
    text-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
}

.remove-alliance-btn {
    background: var(--error);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.remove-alliance-btn:hover {
    background: #dc2626;
    transform: scale(1.05);
}

.add-alliance-btn {
    background: var(--success);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-md);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-top: var(--space-sm);
}

.add-alliance-btn:hover {
    background: #059669;
    transform: translateY(-1px);
}

.add-alliance-btn:disabled {
    background: var(--gray-400);
    cursor: not-allowed;
    transform: none;
}

.form-actions {
    margin-top: var(--space-xl);
    text-align: center;
}

.submit-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    padding: var(--space-md) var(--space-2xl);
    border-radius: var(--radius-lg);
    font-size: 1.125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-md);
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
}

.submit-btn:disabled {
    background: var(--gray-400);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Success Modal */
.success-content {
    max-width: 600px;
}

.success-content h3 {
    color: var(--success);
    margin-bottom: var(--space-md);
    font-size: 1.25rem;
}

.map-links,
.alliances-section,
.legend-section {
    margin-bottom: var(--space-xl);
    padding: var(--space-lg);
    background: var(--gray-50);
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-200);
}

.link-group {
    margin-bottom: var(--space-md);
}

.link-group label {
    display: block;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: var(--space-sm);
}

.link-input-group {
    display: flex;
    gap: var(--space-sm);
}

.link-input-group input {
    flex: 1;
    background: white;
    font-family: var(--font-mono);
    font-size: 0.875rem;
}

.copy-btn {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-md);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.copy-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.copy-btn.copied {
    background: var(--success);
}

/*.alliance-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    padding: var(--space-md);
    background: white;
    border-radius: var(--radius-md);
    border: 1px solid var(--gray-200);
    margin-bottom: var(--space-sm);
}*/

.alliance-info {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.alliance-color-display {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-300);
}

.alliance-links {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.edit-link-group,
.token-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.edit-link-group label,
.token-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-700);
    margin: 0;
}

.alliance-token {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--gray-600);
    background: var(--gray-100);
    padding: var(--space-sm);
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-200);
    word-break: break-all;
}

.alliance-legend-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm);
    background: white;
    border-radius: var(--radius-md);
    border: 1px solid var(--gray-200);
    margin-bottom: var(--space-sm);
}

.warning {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: var(--radius-md);
    padding: var(--space-md);
    color: #92400e;
    font-weight: 500;
    text-align: center;
}

/* Copy Feedback */
.copy-feedback {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--success);
    color: white;
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-lg);
    font-weight: 600;
    z-index: 10001;
    box-shadow: var(--shadow-lg);
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .container {
        gap: var(--space-xl);
    }
    
    .map-container, .legend {
        padding: var(--space-xl);
    }
}

@media (max-width: 1100px) {
    body {
        padding: var(--space-md);
    }
    
    .container {
        gap: var(--space-lg);
    }
    
    .map-container, .legend {
        padding: var(--space-lg);
    }
    
    /* Keep zones at 80px on all screen sizes */
    .zone {
        width: 80px;
        height: 80px;
    }
    
    .zone-type {
        font-size: 0.8rem;
    }
    
    .zone-level {
        width: 28px;
        height: 20px;
        font-size: 0.8rem;
    }
    
    .zone-icon {
        font-size: 1.3rem;
    }
    
    .map-container {
        padding: var(--space-lg);
        /* Ensure horizontal scrolling works on mobile */
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    #map-grid {
        /* Remove centering transform on mobile for better scrolling */
        transform: none;
        margin: 0;
        /* Add some padding for better touch experience */
        padding: 10px;
    }
    
    .legend-items {
        grid-template-columns: 1fr;
        gap: var(--space-sm);
    }
    
    .legend-item {
        padding: var(--space-sm);
    }
}

@media (max-width: 480px) {
    /* Keep zones at 80px on all screen sizes */
    .zone {
        width: 80px;
        height: 80px;
    }
    
    .zone-type {
        font-size: 0.8rem;
        margin-bottom: 2px;
    }
    
    .zone-level {
        width: 28px;
        height: 20px;
        font-size: 0.8rem;
        margin: 2px 0;
    }
    
    .zone-icon {
        font-size: 1.3rem;
        margin-top: 2px;
    }
    
    .map-container, .legend {
        padding: var(--space-md);
    }
    
    .map-container {
        padding: var(--space-md);
        /* Ensure horizontal scrolling works on small mobile */
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    #map-grid {
        margin: 0;
    }
}

/* Alliance-specific styles for alliance.html */
.alliance-page .container {
    max-width: none;
    width: 100%;
    margin: 0;
}

.alliance-page .map-container {
    margin: 20px auto;
    max-width: none;
    width: 100%;
    padding: 0 20px;
    box-sizing: border-box;
}

/* Ensure alliance page works on all screen sizes */
.alliance-page .map-container {
    /* Always allow horizontal scrolling for alliance page */
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.alliance-page .legend {
    background: white;
    border-radius: 10px;
    padding: 25px;
    margin: 30px;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    width: calc(100% - 60px);
    box-sizing: border-box;
}

.alliance-page .legend h3 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.3em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alliance-page .legend-items {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.alliance-page .legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.alliance-page .legend-icon {
    font-size: 1.2em;
}

/* Responsive adjustments for alliance overlays */
@media (max-width: 768px) {
    .alliance-dot {
        width: 6px;
        height: 6px;
    }
    
    .claims-count {
        font-size: 8px;
        min-width: 14px;
        height: 14px;
    }
}

@media (max-width: 480px) {
    .alliance-dot {
        width: 5px;
        height: 5px;
    }
    
    .claims-count {
        font-size: 7px;
        min-width: 12px;
        height: 12px;
    }
}

/* Admin Alliance Management Modal Styles */
#admin-alliance-modal {
    display: none;
}

#admin-alliance-modal .modal-content {
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
}

#admin-alliance-modal .modal-header {
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: white;
    padding: 20px;
    border-radius: 8px 8px 0 0;
}

#admin-alliance-modal .modal-header h2 {
    margin: 0;
    font-size: 1.5em;
}

#admin-alliance-modal .modal-header .close {
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: white;
    opacity: 0.8;
}

#admin-alliance-modal .modal-header .close:hover {
    opacity: 1;
}

#admin-alliance-modal .modal-body {
    padding: 20px;
}

#admin-alliance-modal .admin-section {
    margin-bottom: 30px;
    padding: 20px;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    background: #f8f9fa;
}

#admin-alliance-modal .admin-section h3 {
    margin-top: 0;
    color: #495057;
    border-bottom: 2px solid #dc3545;
    padding-bottom: 10px;
}

#admin-alliance-modal .form-group {
    margin-bottom: 15px;
}

#admin-alliance-modal .form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #495057;
}

#admin-alliance-modal .form-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}

#admin-alliance-modal .form-group input[type="color"] {
    width: 60px;
    height: 40px;
    padding: 2px;
    border: 2px solid #ced4da;
    border-radius: 4px;
    cursor: pointer;
}

#admin-alliance-modal .btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
}

#admin-alliance-modal .btn-primary {
    background: #007bff;
    color: white;
}

#admin-alliance-modal .btn-primary:hover {
    background: #0056b3;
}

#admin-alliance-modal .btn-secondary {
    background: #6c757d;
    color: white;
    margin-right: 8px;
}

#admin-alliance-modal .btn-secondary:hover {
    background: #545b62;
}

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

#admin-alliance-modal .btn-danger:hover {
    background: #c82333;
}

#admin-alliance-modal .btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

#admin-alliance-modal .alliance-admin-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    margin-bottom: 10px;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

#admin-alliance-modal .alliance-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

#admin-alliance-modal .alliance-color-display {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

#admin-alliance-modal .alliance-name {
    font-weight: 600;
    color: #495057;
}

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

/* Zone Information Popup */
.zone-info-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.zone-info-content {
    background: white;
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    position: relative;
}

.zone-info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 2px solid var(--primary);
}

.zone-info-header h3 {
    margin: 0;
    color: var(--gray-900);
    font-size: 1.25rem;
}

.zone-info-popup .close-btn {
    background: var(--error);
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.zone-info-popup .close-btn:hover {
    background: #c53030;
    transform: scale(1.1);
}

#zone-info-body {
    color: var(--gray-700);
    line-height: 1.6;
}

/* Desktop centering for index page */
@media (min-width: 1101px) {
    .index-page .map-container {
        display: flex;
        justify-content: center;
        align-items: flex-start;
    }
    
    .index-page #map-grid {
        margin: 0 auto;
    }
    
    .index-page #display-only-map-grid {
        margin: 0 auto;
    }
}

/* Desktop centering for alliance page */
@media (min-width: 1101px) {
    .alliance-page .map-container {
        display: flex;
        justify-content: center;
        align-items: flex-start;
    }
    
    .alliance-page #map-grid {
        margin: 0 auto;
    }
}

/* Desktop zone sizing for index page */
@media (min-width: 1101px) {
    .index-page .zone {
        width: 80px;
        height: 80px;
    }
    
    .index-page .zone-type {
        font-size: 0.8rem;
        margin-bottom: 4px;
    }
    
    .index-page .zone-level {
        width: 28px;
        height: 20px;
        font-size: 0.8rem;
        margin: 3px 0;
    }
    
    .index-page .zone-icon {
        font-size: 1.3rem;
        margin-top: 3px;
    }
}

/* Desktop zone sizing for alliance page */
@media (min-width: 1101px) {
    .alliance-page .zone {
        width: 80px;
        height: 80px;
    }
    
    .alliance-page .zone-type {
        font-size: 0.8rem;
        margin-bottom: 4px;
    }
    
    .alliance-page .zone-level {
        width: 28px;
        height: 20px;
        font-size: 0.8rem;
        margin: 3px 0;
    }
    
    .alliance-page .zone-icon {
        font-size: 1.3rem;
        margin-top: 3px;
    }
}

/* Mobile-specific map improvements */
@media (max-width: 1100px) {
    .map-container {
        /* Ensure the container takes full width and allows horizontal scrolling */
        width: 100%;
        max-width: 100vw;
        margin: 0;
        padding: var(--space-md);
        /* Smooth scrolling for touch devices */
        scroll-behavior: smooth;
        /* Ensure proper scroll area */
        min-height: 100vh;
    }
    
    #map-grid {
        /* Ensure the grid is properly sized for mobile */
        min-width: max-content;
        margin: 0;
        /* Add some padding for better touch experience */
        padding: 10px;
    }
    
    /* Alliance page specific overrides for mobile */
    .alliance-page .map-container {
        /* Keep alliance page specific styling */
        margin: 20px auto;
        padding: 0 20px;
    }
    
    .alliance-page #map-grid {
        /* Ensure alliance page grid works properly on mobile */
        min-width: max-content;
        margin: 0;
        padding: 5px;
    }
    
    /* Add visual indicator that map is scrollable */
    .map-container::after {
        content: '← Scroll to see full map →';
        position: absolute;
        bottom: -30px;
        left: 50%;
        transform: translateX(-50%);
        background: rgba(0, 0, 0, 0.7);
        color: white;
        padding: 8px 16px;
        border-radius: 20px;
        font-size: 0.8rem;
        white-space: nowrap;
        z-index: 10;
        opacity: 0.8;
    }
    
    /* Hide scroll indicator after first scroll */
    .map-container.scrolled::after {
        display: none;
    }
}

/* Touch-friendly improvements for all devices */
.map-container {
    /* Enable momentum scrolling on touch devices */
    -webkit-overflow-scrolling: touch;
    /* Prevent text selection during scrolling */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Ensure zones are touch-friendly */
.zone {
    /* Prevent text selection on zones */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    /* Ensure zones are properly sized for touch */
    min-width: 50px;
    min-height: 50px;
}


