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

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

#galleryScreen {
    min-height: 100vh;
    padding: 20px;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

#galleryHeader {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 25px 30px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-icon {
    font-size: 32px;
    color: #64b5f6;
}

#galleryHeader h1 {
    font-size: 32px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
}

.header-right {
    display: flex;
    gap: 15px;
}

button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

button:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.btn-secondary {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    box-shadow: 0 4px 15px rgba(245, 87, 108, 0.4);
}

.btn-secondary:hover {
    box-shadow: 0 6px 20px rgba(245, 87, 108, 0.6);
}

.btn-icon {
    padding: 12px;
    min-width: 44px;
    justify-content: center;
}

.btn-back {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    box-shadow: 0 4px 15px rgba(79, 172, 254, 0.4);
}

.btn-back:hover {
    box-shadow: 0 6px 20px rgba(79, 172, 254, 0.6);
}

#mapGallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 25px;
    padding: 20px;
}

.map-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.18);
    position: relative;
}

.map-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.2) 0%, rgba(118, 75, 162, 0.2) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.map-card:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
}

.map-card:hover::before {
    opacity: 1;
}

.map-card-image {
    width: 100%;
    height: 220px;
    object-fit: cover;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    transition: transform 0.4s ease;
}

.map-card:hover .map-card-image {
    transform: scale(1.1);
}

.map-card-info {
    padding: 20px;
    position: relative;
    z-index: 1;
}

.map-card-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 15px;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.map-card-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.map-card-actions button {
    flex: 1;
    padding: 10px;
    font-size: 13px;
}

.btn-edit {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    box-shadow: 0 4px 15px rgba(240, 147, 251, 0.4);
}

.btn-edit:hover {
    box-shadow: 0 6px 20px rgba(240, 147, 251, 0.6);
}

.btn-delete {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    box-shadow: 0 4px 15px rgba(250, 112, 154, 0.4);
}

.btn-delete:hover {
    box-shadow: 0 6px 20px rgba(250, 112, 154, 0.6);
}

#viewerScreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #1a1a2e;
}

#controls {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(26, 26, 46, 0.95);
    backdrop-filter: blur(10px);
    padding: 15px 20px;
    display: flex;
    gap: 15px;
    align-items: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.controls-divider {
    width: 1px;
    height: 30px;
    background: rgba(255, 255, 255, 0.2);
    margin: 0 5px;
}

.input-group {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 12px;
    border-radius: 8px;
}

.input-group label {
    font-size: 13px;
    color: #b8c5d6;
    font-weight: 600;
}

.input-group input,
.input-group select {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    transition: all 0.3s ease;
}

.input-group input:focus,
.input-group select:focus {
    background: rgba(255, 255, 255, 0.2);
    border-color: #667eea;
}

#zoomInput {
    width: 70px;
}

#zoomInfo {
    color: white;
    font-size: 14px;
    margin-left: auto;
    padding: 10px 20px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.3) 0%, rgba(118, 75, 162, 0.3) 100%);
    border-radius: 8px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

#canvas {
    position: fixed;
    top: 70px;
    left: 0;
    right: 0;
    bottom: 0;
    cursor: grab;
    background: #16213e;
}

#canvas:active {
    cursor: grabbing;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    padding: 0;
    border-radius: 20px;
    min-width: 450px;
    max-width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    position: relative;
    z-index: 1;
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: modalSlideIn 0.3s ease;
}

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

.modal-header {
    padding: 25px 30px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    color: #fff;
    font-size: 22px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-close {
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 12px;
    min-width: auto;
    box-shadow: none;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.modal-body {
    padding: 30px;
}

.input-field {
    margin-bottom: 20px;
}

.input-field label {
    display: block;
    margin-bottom: 10px;
    color: #b8c5d6;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.input-field input[type="text"] {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    color: white;
    font-size: 15px;
    outline: none;
    transition: all 0.3s ease;
}

.input-field input[type="text"]:focus {
    border-color: #667eea;
    background: rgba(255, 255, 255, 0.1);
}

.file-input-wrapper {
    position: relative;
}

.file-input-wrapper input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.file-input-display {
    padding: 14px 16px;
    border: 2px dashed rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    color: #b8c5d6;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.file-input-wrapper:hover .file-input-display {
    border-color: #667eea;
    background: rgba(255, 255, 255, 0.1);
}

.modal-footer {
    padding: 20px 30px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    gap: 15px;
    justify-content: flex-end;
}

.modal-footer button {
    min-width: 120px;
}

#uploadStatus {
    margin: 20px 30px 0;
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    animation: statusSlideIn 0.3s ease;
}

@keyframes statusSlideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

#uploadStatus.success {
    background: linear-gradient(135deg, rgba(46, 204, 113, 0.2) 0%, rgba(52, 211, 153, 0.2) 100%);
    color: #2ecc71;
    border: 1px solid rgba(46, 204, 113, 0.5);
}

#uploadStatus.error {
    background: linear-gradient(135deg, rgba(231, 76, 60, 0.2) 0%, rgba(239, 68, 68, 0.2) 100%);
    color: #e74c3c;
    border: 1px solid rgba(231, 76, 60, 0.5);
}

#loadingMaps {
    text-align: center;
    padding: 60px 40px;
    font-size: 18px;
    color: #b8c5d6;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.no-maps {
    text-align: center;
    padding: 80px 40px;
    font-size: 20px;
    color: #b8c5d6;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    border: 2px dashed rgba(255, 255, 255, 0.2);
}

.file-preview {
    margin-top: 20px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: fadeInPreview 0.3s ease;
}

@keyframes fadeInPreview {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.preview-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 15px;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(79, 172, 254, 0.2) 0%, rgba(0, 242, 254, 0.2) 100%);
    border-radius: 8px;
    border: 1px solid rgba(79, 172, 254, 0.3);
}

.preview-info i {
    color: #4facfe;
    font-size: 20px;
}

.preview-info span {
    color: #fff;
    font-size: 14px;
}

.preview-info .file-size {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: #4facfe;
}

.preview-image {
    width: 100%;
    max-height: 300px;
    object-fit: contain;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.3);
}

#zoomInput {
    width: 80px;
    -moz-appearance: textfield;
    appearance: textfield;
}

#zoomInput::-webkit-outer-spin-button,
#zoomInput::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Стилизация select (уровень) */
#quadLevelSelect {
    cursor: pointer;
    min-width: 130px;
    font-weight: 600;
}

#quadLevelSelect option {
    background: #2c3e50;
    color: white;
    padding: 10px;
}

/* Улучшенные кнопки zoom */
.btn-icon {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    position: relative;
    overflow: hidden;
}

.btn-icon::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-icon:hover::before {
    width: 100px;
    height: 100px;
}

.btn-icon i {
    position: relative;
    z-index: 1;
    font-size: 16px;
}

/* Анимация для иконок */
.btn-icon:hover i {
    animation: iconPulse 0.6s ease;
}

@keyframes iconPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* Улучшенный input-group */
.input-group {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    transition: all 0.3s ease;
}

.input-group:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(102, 126, 234, 0.5);
}

.input-group label {
    font-size: 13px;
    color: #b8c5d6;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-group input,
.input-group select {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    outline: none;
    transition: all 0.3s ease;
}

.input-group input:focus,
.input-group select:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.input-group input:hover,
.input-group select:hover {
    background: rgba(255, 255, 255, 0.12);
}

/* Стили для zoomInfo */
#zoomInfo {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.25) 0%, rgba(118, 75, 162, 0.25) 100%);
    border: 1px solid rgba(102, 126, 234, 0.4);
    padding: 12px 24px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

#zoomInfo i {
    color: #667eea;
    font-size: 16px;
}

#zoomInfo span {
    font-family: 'Courier New', monospace;
    letter-spacing: 0.5px;
}

/* Улучшение file-input-display */
.file-input-display {
    transition: all 0.3s ease;
}

.file-input-display i {
    font-size: 20px;
    color: #4facfe;
    transition: transform 0.3s ease;
}

.file-input-wrapper:hover .file-input-display i {
    transform: scale(1.2) rotate(10deg);
}

/* Разделитель в controls */
.controls-divider {
    width: 2px;
    height: 35px;
    background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.3), transparent);
    margin: 0 10px;
}

.settings-panel {
    position: fixed;
    top: 70px;
    right: 20px;
    width: 400px;
    max-height: calc(100vh - 100px);
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 1500;
    overflow: hidden;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.settings-header {
    padding: 20px 25px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.settings-header h3 {
    color: #fff;
    font-size: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
}

.settings-header h3 i {
    color: #667eea;
    font-size: 22px;
}

.settings-close {
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 12px;
    min-width: auto;
    box-shadow: none;
    border: none;
    cursor: pointer;
    border-radius: 8px;
    color: white;
    transition: all 0.3s ease;
}

.settings-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.settings-body {
    padding: 25px;
    max-height: calc(100vh - 180px);
    overflow-y: auto;
}

.settings-body::-webkit-scrollbar {
    width: 8px;
}

.settings-body::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.settings-body::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    gap: 20px;
}

.setting-label {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #b8c5d6;
    font-size: 14px;
    font-weight: 600;
    flex: 1;
}

.setting-label i {
    color: #667eea;
    font-size: 18px;
    min-width: 20px;
}

.setting-value {
    margin-left: auto;
    color: #4facfe;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    min-width: 40px;
    text-align: right;
}

/* Переключатель (toggle) */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 30px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    transition: all 0.4s;
    border-radius: 30px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 2px;
    bottom: 2px;
    background: white;
    transition: all 0.4s;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.toggle-switch input:checked + .toggle-slider {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(30px);
}

/* Color picker */
input[type="color"] {
    width: 60px;
    height: 40px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    padding: 2px;
    transition: all 0.3s ease;
}

input[type="color"]:hover {
    border-color: #667eea;
    transform: scale(1.05);
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 6px;
}

/* Range slider */
input[type="range"] {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.5);
    transition: all 0.3s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.7);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
    border-radius: 50%;
    border: none;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.5);
}

.settings-divider {
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.2), transparent);
    margin: 20px 0;
}

.btn-reset {
    width: 100%;
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    color: white;
    border: none;
    padding: 14px 20px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 700;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(250, 112, 154, 0.4);
    margin-top: 10px;
}

.btn-reset:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(250, 112, 154, 0.6);
}

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

@media (max-width: 768px) {
    #galleryHeader {
        flex-direction: column;
        gap: 15px;
    }
    
    .header-left, .header-right {
        width: 100%;
        justify-content: center;
    }
    
    #mapGallery {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        min-width: 90%;
    }
    
    #controls {
        flex-wrap: wrap;
        padding: 10px;
    }

    .preview-image {
        max-height: 200px;
    }
    
    #zoomInput {
        width: 60px;
    }
    
    #quadLevelSelect {
        min-width: 100px;
    }

    .settings-panel {
        width: calc(100% - 40px);
        left: 20px;
        right: 20px;
        top: 80px;
    }
    
    .setting-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .setting-label {
        width: 100%;
    }
    
    input[type="color"],
    .toggle-switch {
        align-self: flex-end;
    }
}