/* --- Mobile Panel Toggle --- */
#panelToggleBtn {
    display: none;
}

.mobile-panel-header {
    display: none;
}

@media (max-width: 900px) {

    html,
    body {
        height: auto !important;
        min-height: 100%;
        overflow-y: auto !important;
    }

    body {
        position: relative;
    }

    #container {
        display: block;
        height: auto !important;
        margin: 0.25rem;
        overflow: visible !important;
    }

    #panelToggleBtn {
        width: 42px;
        height: 42px;
        border: 0;
        border-radius: 10px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
    }

    #panelToggleBtn ion-icon {
        font-size: 20px;
    }

    #controls {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 44;
        width: min(86vw, 320px) !important;
        height: 100dvh !important;
        max-height: 100dvh;
        padding-top: 1rem;
        transform: translateX(0);
        transition: transform 0.25s ease;
        box-shadow: 18px 0 36px rgba(0, 0, 0, 0.18);
    }

    #controls.panel-hidden {
        transform: translateX(-110%);
        pointer-events: none;
    }

    .mobile-panel-header {
        display: flex;
        justify-content: flex-end;
        margin-bottom: 0.5rem;
    }

    #panelCloseBtn {
        width: 32px;
        height: 32px;
        border: 0;
        border-radius: 10px;
        background: transparent;
        border: #3509b8 1px solid;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
    }

    #panelCloseBtn ion-icon {
        font-size: 20px;
        color: #3509b8;
    }

    #posterWrapper {
        height: auto !important;
        min-height: auto;
        padding: 0;
        background: #fff;
        border-radius: 0.75rem;
        overflow: visible !important;
    }

    #poster {
        width: 100%;
        max-width: 100%;
        max-height: none;
        margin-top: 1rem;
        margin-bottom: 1rem;
        border-radius: 0.75rem;
    }

    #mapContainer {
        min-height: 320px;
        max-height: none;
        overflow: visible;
        border-radius: 0.75rem;
    }
}

/* === INTRO MODAL === */
#introModal {
    animation: modalFadeIn 0.5s ease-out;
}

#introModal.closing {
    animation: modalFadeOut 0.4s ease-in forwards;
}

.intro-card {
    animation: cardSlideIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.intro-postcards-row {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    padding-bottom: 4px;
    box-sizing: border-box;
}

#introModal.closing .intro-card {
    animation: cardSlideOut 0.35s ease-in forwards;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes modalFadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

@keyframes cardSlideIn {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.96);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes cardSlideOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    to {
        opacity: 0;
        transform: translateY(12px) scale(0.97);
    }
}

#globeContainer canvas {
    border-radius: 50%;
}

/* Modern postcard city buttons */
.intro-city-btn.postcard {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0;
    border-radius: 16px;
    border: none;
    background: #fff;
    color: #333;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    width: 144px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 2px 12px rgba(68, 14, 223, 0.08), 0 0 0 1px rgba(68, 14, 223, 0.06);
    flex: 0 0 auto;
}

.intro-city-btn.postcard:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 32px rgba(68, 14, 223, 0.18), 0 0 0 3px #440edf;
}

.intro-city-btn.postcard:active {
    transform: translateY(-2px) scale(0.98);
}

.postcard-map {
    width: 100%;
    height: 90px;
    overflow: hidden;
    position: relative;
}

.postcard-map .maplibregl-canvas {
    border-radius: 0;
}

/* Hide all MapLibre controls in mini maps */
.postcard-map .maplibregl-ctrl-top-left,
.postcard-map .maplibregl-ctrl-top-right,
.postcard-map .maplibregl-ctrl-bottom-left,
.postcard-map .maplibregl-ctrl-bottom-right,
.postcard-map .maplibregl-ctrl-attrib {
    display: none !important;
}

.postcard-body {
    padding: 10px 12px;
    text-align: left;
    position: relative;
}

.postcard-city {
    display: block;
    font-size: 15px;
    font-weight: 700;
    color: #1a1a2e;
    letter-spacing: -0.2px;
    line-height: 1.2;
}

.postcard-country {
    display: block;
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #440edf;
    margin-top: 2px;
    opacity: 0.7;
}

.postcard-pin {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 26px;
    height: 26px;
    background: #440edf;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: #d2e823;
    box-shadow: 0 2px 8px rgba(68, 14, 223, 0.3);
    transition: transform 0.3s ease;
}

.intro-city-btn.postcard:hover .postcard-pin {
    transform: scale(1.15);
}

.intro-city-icon {
    font-size: 18px;
    line-height: 1;
}

@media (max-width: 640px) {
    .intro-copy {
        padding-left: 10px;
        padding-right: 10px;
    }

    .intro-postcards-row {
        overflow-x: auto;
        padding-left: 10px;
        padding-right: 10px;
    }

    .intro-card {
        border-radius: 20px;
    }

    .intro-city-btn.postcard {
        width: 132px;
    }
}

/* Theme Preview Styles */
.theme-swatch-large {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.theme-swatch-large::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--swatch-bg);
}

.theme-swatch-large::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 12px;
    background: var(--swatch-water);
}

.theme-swatch-large .roads {
    position: absolute;
    top: 6px;
    left: 6px;
    right: 6px;
    bottom: 16px;
    pointer-events: none;
}

/* Vertical line */
.theme-swatch-large .roads::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    width: 2px;
    height: 100%;
    background: var(--swatch-roads);
    transform: translateX(-50%);
}

/* Horizontal line */
.theme-swatch-large .roads::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--swatch-roads);
    transform: translateY(-50%);
}

.color-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.themes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(30px, 1fr));
    gap: 4px;
    max-height: 250px;
    overflow-y: auto;
    padding: 2px;
    transition: max-height 0.3s ease;
}

.themes-grid.collapsed {
    max-height: 72px;
    overflow: hidden;
}

.theme-swatch {
    width: 30px;
    height: 30px;
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    border: 2px solid transparent;
}

.theme-swatch:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    z-index: 1;
}

.theme-swatch.selected {
    border-color: #440edf;
    box-shadow: 0 0 0 2px rgba(68, 14, 223, 0.3);
}

.theme-swatch::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--swatch-bg);
}

.theme-swatch::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 8px;
    background: var(--swatch-water);
}

.theme-swatch .roads {
    position: absolute;
    top: 5px;
    left: 5px;
    right: 5px;
    bottom: 11px;
    pointer-events: none;
}

/* Vertical line */
.theme-swatch .roads::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    width: 1.5px;
    height: 100%;
    background: var(--swatch-roads);
    transform: translateX(-50%);
}

/* Horizontal line */
.theme-swatch .roads::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 1.5px;
    background: var(--swatch-roads);
    transform: translateY(-50%);
}

/* Poster Styles */
#poster {
    width: 100%;
    max-width: 1200px;
    max-height: calc(100vh - 150px);
    aspect-ratio: 5 / 8;
    background-color: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    transition: all 0.3s ease-out;
    margin-bottom: 48px;
    overflow: hidden;
}

#poster.landscape {
    aspect-ratio: 8 / 5;
    max-width: 1500px;
}

@media (max-width: 768px) {
    #poster {
        max-width: 95%;
        aspect-ratio: 5 / 7;
    }
}

/* Print Size Variations */
#poster.size-24x36 {
    aspect-ratio: 24 / 36;
    max-width: 1200px;
}

#poster.size-24x36.landscape {
    aspect-ratio: 36 / 24;
    max-width: 1800px;
}

#poster.size-a1 {
    aspect-ratio: 594 / 841;
    max-width: 1200px;
}

#poster.size-a1.landscape {
    aspect-ratio: 841 / 594;
    max-width: 1700px;
}

#poster.size-18x24 {
    aspect-ratio: 18 / 24;
    max-width: 1000px;
}

#poster.size-18x24.landscape {
    aspect-ratio: 24 / 18;
    max-width: 1300px;
}

#poster.size-16x20 {
    aspect-ratio: 16 / 20;
    max-width: 950px;
}

#poster.size-16x20.landscape {
    aspect-ratio: 20 / 16;
    max-width: 1200px;
}

#poster.size-a2 {
    aspect-ratio: 420 / 594;
    max-width: 1000px;
}

#poster.size-a2.landscape {
    aspect-ratio: 594 / 420;
    max-width: 1400px;
}

#poster.size-a3 {
    aspect-ratio: 297 / 420;
    max-width: 850px;
}

#poster.size-a3.landscape {
    aspect-ratio: 420 / 297;
    max-width: 1200px;
}

#poster.size-11x14 {
    aspect-ratio: 11 / 14;
    max-width: 850px;
}

#poster.size-11x14.landscape {
    aspect-ratio: 14 / 11;
    max-width: 1100px;
}

/* Map Container */
#mapContainer {
    width: 100%;
    height: 100%;
    flex: 1;
    min-height: 0;
    position: relative;
}

#mapContainer .maplibregl-canvas {
    position: absolute;
}

/* Poster Footer Base */
#posterFooter {
    text-align: center;
    padding: 16px 18px 20px;
    background-color: inherit;
    color: inherit;
    flex-shrink: 0;
}

#cityTitle {
    font-size: 1.5rem;
    letter-spacing: 4px;
    text-transform: uppercase;
    margin-bottom: 6px;
    font-weight: 800;
    line-height: 1.2;
}

#citySubtitle {
    font-size: 11px;
    letter-spacing: 0.1em;
    margin-bottom: 2px;
    font-weight: 500;
    font-style: italic;
    opacity: 0.85;
    line-height: 1.3;
}

#coordinates {
    font-size: 10px;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    opacity: 0.7;
    font-weight: 500;
    margin-top: 6px;
    line-height: 1.2;
}

/* Poster Layout Styles - Minimal Luxury */
.poster-style-minimal #posterFooter {
    padding: 0;
    padding-top: 0.5%;
    padding-bottom: 2.5%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.poster-style-minimal #cityTitle {
    position: relative;
    top: 0;
    font-size: clamp(28px, 6.5vw, 52px);
    letter-spacing: clamp(1px, 0.6vw, 8px);
    text-transform: uppercase;
    font-weight: 100;
    line-height: 1;
    margin: 0;
    margin-bottom: 0.35em;
}

.poster-style-minimal #citySubtitle {
    font-size: clamp(11px, 1.6vw, 14px);
    letter-spacing: clamp(2px, 0.5vw, 4px);
    text-transform: uppercase;
    font-weight: 500;
    line-height: 1;
    opacity: 0.75;
    margin: 0;
    margin-bottom: 0.5em;
}

.poster-style-minimal #coordinates {
    font-size: clamp(9px, 1.4vw, 11px);
    opacity: 0.6;
    font-weight: 500;
    line-height: 1;
    margin: 0;
}

/* Vertical Edge */
.poster-style-vertical {
    display: block;
}

.poster-style-vertical #mapContainer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.poster-style-vertical #posterFooter {
    position: absolute;
    inset: 0;
    padding: 0;
    text-align: left;
    background-color: transparent;
    pointer-events: none;
    display: block;
}

.poster-style-vertical #cityTitle {
    font-size: clamp(24px, 3.5vw, 38px);
    padding: clamp(18px, 3vw, 28px);
    position: absolute;
    left: clamp(14px, 2.4vw, 22px);
    bottom: clamp(20px, 3vw, 32px);
    text-transform: uppercase;
    font-weight: 900;
    margin: 0;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-start;
    gap: clamp(6px, 1.6vw, 10px);
    letter-spacing: 0;
    line-height: 1;
    text-align: left;
    max-height: 70%;
}

.poster-style-vertical #cityTitle span {
    display: block;
    line-height: 0.9em;
    text-align: center;
    width: 100%;
}

.poster-style-vertical #citySubtitle {
    bottom: clamp(20px, 3vw, 28px);
    left: clamp(90px, 12vw, 120px);
    font-size: clamp(10px, 1.5vw, 14px);
    position: absolute;
    opacity: 0.8;
    text-transform: uppercase;
    font-weight: 500;
    max-width: 60%;
    pointer-events: auto;
    margin: 0;
}

.poster-style-vertical #coordinates {
    top: clamp(24px, 4vw, 36px);
    right: clamp(24px, 4vw, 36px);
    font-size: clamp(9px, 1.4vw, 11px);
    position: absolute;
    opacity: 0.8;
    font-weight: 500;
    margin: 0;
    pointer-events: auto;
}

/* Corner Grid */
.poster-style-corner {
    display: block;
}

.poster-style-corner #mapContainer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.poster-style-corner #posterFooter {
    position: absolute;
    inset: 0;
    padding: 0;
    background-color: transparent;
    pointer-events: none;
}

.poster-style-corner #cityTitle {
    top: clamp(20px, 3vw, 28px);
    left: clamp(24px, 4vw, 36px);
    font-size: clamp(24px, 3.5vw, 38px);
    position: absolute;
    text-transform: uppercase;
    font-weight: 800;
    margin: 0;
    text-align: left;
    pointer-events: auto;
    line-height: 1;
}

.poster-style-corner #citySubtitle {
    bottom: clamp(20px, 3vw, 28px);
    left: clamp(24px, 4vw, 36px);
    font-size: clamp(10px, 1.5vw, 14px);
    position: absolute;
    opacity: 0.8;
    font-weight: 500;
    margin: 0;
    text-align: left;
    text-transform: uppercase;
    pointer-events: auto;
}

.poster-style-corner #coordinates {
    top: clamp(28px, 3vw, 38px);
    right: clamp(24px, 4vw, 36px);
    font-size: clamp(9px, 1.4vw, 11px);
    position: absolute;
    opacity: 0.7;
    font-weight: 500;
    margin: 0;
    text-align: right;
    pointer-events: auto;
    line-height: 1;
}

/* Oversized Drama */
.poster-style-oversized #posterFooter {
    padding: 0;
    padding-top: 0.5%;
    padding-bottom: 2.5%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.poster-style-oversized #cityTitle {
    position: relative;
    top: 0;
    font-size: clamp(28px, 6.5vw, 52px);
    letter-spacing: clamp(0.5px, 0.2vw, 1.5px);
    text-transform: uppercase;
    font-weight: 900;
    line-height: 1;
    margin: 0;
    margin-bottom: 0.35em;
}

.poster-style-oversized #citySubtitle {
    font-size: clamp(11px, 1.6vw, 14px);
    letter-spacing: clamp(2px, 0.5vw, 4px);
    text-transform: uppercase;
    font-weight: 500;
    line-height: 1;
    opacity: 0.75;
    margin: 0;
    margin-bottom: 0.5em;
}

.poster-style-oversized #coordinates {
    font-size: clamp(9px, 1.4vw, 11px);
    opacity: 0.6;
    font-weight: 500;
    line-height: 1;
    margin: 0;
}

/* Responsive */
@media (max-width: 768px) {
    .poster-style-minimal #cityTitle {
        letter-spacing: 8px;
    }

    .poster-style-oversized #cityTitle {
        font-size: clamp(36px, 8vw, 56px);
    }
}

/* Left Panel Scrollbar Styling */
#controls::-webkit-scrollbar {
    width: 8px;
}

#controls::-webkit-scrollbar-track {
    background: transparent;
}

#controls::-webkit-scrollbar-thumb {
    background: #440edf;
    border-radius: 4px;
}

#controls::-webkit-scrollbar-thumb:hover {
    background: #3509b8;
}

/* Firefox scrollbar styling */
#controls {
    scrollbar-width: thin;
    scrollbar-color: #440edf transparent;
}