:root {
    --brand-950: #06281f;
    --brand-900: #0a3a2c;
    --brand-800: #0f5b43;
    --brand-700: #117a57;
    --brand-600: #1b996b;
    --brand-500: #2fb982;
    --mint-100: #f3fbf5;
    --cream-100: #fff7e8;
    --cream-200: #f7ecd5;
    --stone-900: #1e3029;
    --stone-700: #51655f;
    --stone-500: #72857f;
    --stone-300: #c8d5ce;
    --white-strong: rgba(255, 255, 255, 0.96);
    --white-soft: rgba(255, 255, 255, 0.82);
    --shadow-strong: 0 24px 65px rgba(3, 22, 17, 0.38);
    --shadow-soft: 0 14px 30px rgba(7, 36, 28, 0.18);
    --border-soft: rgba(17, 91, 67, 0.16);
    --transition: 180ms ease;
    --marker-tm-icon: url("../Images/tmitem.png");
    --marker-entrance-icon: url("../Images/entrance.png");
    --marker-trainer-icon: url("../Images/trainer.webp");
}

[hidden] {
    display: none !important;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
}

body {
    overflow: hidden;
    font-family: "Trebuchet MS", "Gill Sans", "Segoe UI", sans-serif;
    color: var(--stone-900);
    background:
        radial-gradient(circle at top left, rgba(93, 192, 139, 0.28), transparent 35%),
        radial-gradient(circle at bottom right, rgba(255, 217, 133, 0.2), transparent 32%),
        linear-gradient(160deg, #021c15 0%, #07382b 48%, #0c5e45 100%);
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

#map {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100dvh;
    background:
        radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.08), transparent 28%),
        linear-gradient(180deg, rgba(5, 31, 23, 0.42), rgba(5, 31, 23, 0));
}

.control-panel {
    position: fixed;
    z-index: 1000;
    top: max(12px, env(safe-area-inset-top));
    left: max(12px, env(safe-area-inset-left));
    width: min(390px, calc(100vw - 24px));
    max-height: calc(100dvh - 50px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 14px;
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 26px;
    background:
        linear-gradient(180deg, rgba(255, 249, 237, 0.96), rgba(244, 252, 246, 0.94)),
        radial-gradient(circle at top right, rgba(53, 169, 112, 0.18), transparent 38%);
    box-shadow: var(--shadow-strong);
    backdrop-filter: blur(18px);
    overflow: hidden;
}

.control-panel::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.3), transparent 45%),
        radial-gradient(circle at bottom right, rgba(255, 214, 143, 0.24), transparent 30%);
}

.control-panel > * {
    position: relative;
}

.control-panel.is-collapsed {
    gap: 10px;
}

.control-panel.is-collapsed .panel-body {
    display: none;
}

.panel-handle {
    display: none;
    width: 60px;
    height: 6px;
    margin: 0 auto 2px;
    border-radius: 999px;
    background: rgba(17, 91, 67, 0.22);
}

.panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.panel-copy h1 {
    margin: 0;
    font-size: 1.85rem;
    line-height: 1.05;
    letter-spacing: -0.04em;
}

.panel-kicker {
    margin: 0 0 6px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--brand-700);
}

.panel-subtitle {
    margin: 8px 0 0;
    font-size: 0.95rem;
    line-height: 1.45;
    color: var(--stone-700);
}

.panel-toggle,
.utility-button,
.scope-button,
.filter-chip {
    transition:
        transform var(--transition),
        background-color var(--transition),
        color var(--transition),
        border-color var(--transition),
        box-shadow var(--transition);
}

.panel-toggle:hover,
.utility-button:hover,
.scope-button:hover,
.filter-chip:hover,
.result-card:hover {
    transform: translateY(-1px);
}

.panel-toggle,
.scope-button.is-active,
.filter-chip.is-active {
    color: #fff;
    background: linear-gradient(135deg, var(--brand-700), var(--brand-500));
    box-shadow: 0 10px 18px rgba(17, 122, 87, 0.24);
}

.panel-toggle {
    border: none;
    border-radius: 999px;
    padding: 10px 14px;
    font-size: 0.92rem;
    font-weight: 700;
    white-space: nowrap;
}

.panel-body {
    min-height: 0;
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 12px;
}

.search-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
}

.search-field {
    display: flex;
    align-items: center;
    padding: 0 14px;
    border: 1px solid rgba(17, 91, 67, 0.16);
    border-radius: 18px;
    background: var(--white-strong);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.search-field:focus-within {
    border-color: rgba(17, 122, 87, 0.46);
    box-shadow:
        0 0 0 3px rgba(47, 185, 130, 0.14),
        inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

#searchBox {
    width: 100%;
    padding: 14px 0;
    border: none;
    background: transparent;
    color: var(--stone-900);
    font-size: 1rem;
    outline: none;
}

#searchBox::placeholder {
    color: var(--stone-500);
}

.utility-button {
    border: 1px solid rgba(17, 91, 67, 0.16);
    border-radius: 16px;
    padding: 11px 14px;
    background: rgba(255, 255, 255, 0.75);
    color: var(--stone-900);
    font-weight: 700;
    box-shadow: var(--shadow-soft);
}

.utility-button.is-active {
    border-color: rgba(17, 122, 87, 0.35);
    background: rgba(17, 122, 87, 0.12);
    color: var(--brand-900);
}

.utility-button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    transform: none;
    box-shadow: none;
}

.scope-switch {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    padding: 4px;
    border: 1px solid rgba(17, 91, 67, 0.12);
    border-radius: 999px;
    background: rgba(17, 91, 67, 0.08);
}

.scope-button {
    border: none;
    border-radius: 999px;
    padding: 10px 12px;
    background: transparent;
    color: var(--stone-700);
    font-weight: 700;
}

.panel-summary {
    display: grid;
    gap: 8px;
    padding: 12px 14px;
    border: 1px solid rgba(17, 91, 67, 0.12);
    border-radius: 18px;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.88), rgba(243, 251, 245, 0.9)),
        radial-gradient(circle at right, rgba(255, 214, 143, 0.16), transparent 38%);
}

.summary-heading {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 10px;
    align-items: baseline;
}

.summary-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--brand-700);
}

#currentMapLabel {
    font-size: 1rem;
}

#resultSummary {
    margin: 0;
    font-size: 0.93rem;
    line-height: 1.45;
    color: var(--stone-700);
}

.filter-grid,
.panel-actions,
.result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-chip {
    border: 1px solid rgba(17, 91, 67, 0.15);
    border-radius: 999px;
    padding: 9px 12px;
    background: rgba(255, 255, 255, 0.72);
    color: var(--stone-900);
    font-size: 0.9rem;
    font-weight: 700;
}

.results {
    min-height: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: auto;
    padding: 1px;
    border-radius: 18px;
}

.results::-webkit-scrollbar {
    width: 10px;
}

.results::-webkit-scrollbar-thumb {
    border: 2px solid transparent;
    border-radius: 999px;
    background: rgba(17, 91, 67, 0.22);
    background-clip: content-box;
}

.result-card,
.results-empty {
    border: 1px solid rgba(17, 91, 67, 0.12);
    border-radius: 18px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(247, 252, 247, 0.92)),
        radial-gradient(circle at top right, rgba(255, 214, 143, 0.14), transparent 30%);
    box-shadow: var(--shadow-soft);
}

.result-card {
    width: 100%;
    padding: 13px 14px;
    text-align: left;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 12px;
}

.result-card:focus-visible,
.panel-toggle:focus-visible,
.utility-button:focus-visible,
.scope-button:focus-visible,
.filter-chip:focus-visible,
#searchBox:focus-visible {
    outline: 3px solid rgba(47, 185, 130, 0.3);
    outline-offset: 2px;
}

.result-kicker {
    margin: 0 0 6px;
    font-size: 0.73rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--brand-700);
}

.result-icon {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background:
        radial-gradient(circle at 35% 28%, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.36) 42%, transparent 44%),
        linear-gradient(145deg, rgba(17, 122, 87, 0.16), rgba(255, 214, 143, 0.18));
    border: 1px solid rgba(17, 91, 67, 0.12);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
    overflow: hidden;
    flex-shrink: 0;
}

.result-icon > div,
.result-icon > span {
    position: static !important;
    margin: 0 !important;
    transform: none !important;
}

.result-icon--sprite > div {
    width: 34px !important;
    height: 34px !important;
}

.result-icon--marker > span {
    width: 24px;
    height: 24px;
    background-size: 100% 100%;
}

.result-copy {
    min-width: 0;
}

.result-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.result-title {
    display: block;
    margin: 0;
    font-size: 1rem;
    line-height: 1.35;
}

.result-type {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 8px;
    border-radius: 999px;
    background: rgba(17, 122, 87, 0.12);
    color: var(--brand-900);
    font-size: 0.76rem;
    font-weight: 700;
}

.result-description {
    margin: 10px 0 0;
    color: var(--stone-700);
    font-size: 0.92rem;
    line-height: 1.45;
}

.result-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(10, 58, 44, 0.08);
    color: var(--stone-700);
    font-size: 0.78rem;
    font-weight: 700;
}

.results-empty {
    padding: 16px 14px;
}

.results-empty strong {
    display: block;
    margin-bottom: 4px;
    font-size: 0.98rem;
}

.results-empty p {
    margin: 0;
    font-size: 0.92rem;
    line-height: 1.45;
    color: var(--stone-700);
}

.berryIcon,
.tmitemIcon,
.entrance,
.trainer {
    will-change: transform;
}

.tmitemIcon {
    width: 24px;
    height: 24px;
    margin: -12px;
    background-image: var(--marker-tm-icon);
    background-size: 100% 100%;
}

.entrance {
    width: 24px;
    height: 24px;
    margin: -12px;
    background-image: var(--marker-entrance-icon);
    background-size: 100% 100%;
}

.trainer {
    width: 24px;
    height: 24px;
    margin: -12px;
    background-image: var(--marker-trainer-icon);
    background-size: 100% 100%;
}

.marker-editor-target {
    outline: 2px dashed #ffcf3f;
    outline-offset: 2px;
    border-radius: 6px;
    background-color: rgba(255, 207, 63, 0.22);
    cursor: grab;
}

.marker-editor-target.leaflet-drag-target {
    cursor: grabbing;
}

.marker-editor-target--trainer {
    background-image: url(https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQiSbJmaXq1oTsJeyJu_-3AHGqyWzjtatN85BrH2c7X_Q&s=10);
    background-size: 100% 100%;
}

.hidden {
    display: none;
}

.info {
    position: fixed;
    z-index: 900;
    top: max(12px, env(safe-area-inset-top));
    right: max(12px, env(safe-area-inset-right));
    max-width: min(360px, calc(100vw - 24px));
    max-height: calc(100dvh - 50px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 10px 12px;
    font: 14px/1.45 "Trebuchet MS", "Gill Sans", "Segoe UI", sans-serif;
    color: var(--stone-900);
    background: rgba(255, 252, 246, 0.95);
    box-shadow: var(--shadow-soft);
    border: 1px solid rgba(17, 91, 67, 0.16);
    border-radius: 18px;
    margin: 0 !important;
}

.trainer-table {
    width: 100%;
    margin-top: 8px;
    border-collapse: collapse;
}

.trainer-intro,
.marker-popup-text {
    margin-top: 6px;
    color: var(--stone-700);
    font-size: 0.9rem;
    line-height: 1.35;
}

.trainer-intro p,
.marker-popup-text p {
    margin: 0;
}

.trainer-intro p + p,
.marker-popup-text p + p {
    margin-top: 6px;
}

.trainer-table td {
    padding: 4px 6px;
    border: 1px solid rgba(17, 91, 67, 0.18);
}

.trainer-pokemon-sprite {
    width: 42px;
    min-width: 42px;
    text-align: center;
    vertical-align: middle;
}

.trainer-pokemon-sprite img {
    width: 100%;
    object-fit: contain;
}

.trainer-pokemon-name {
    text-align: left;
    font-weight: 700;
}

.trainer-pokemon-level {
    white-space: nowrap;
}

.trainer-pokemon-move {
    text-align: center;
    color: var(--stone-700);
}

.trainer-reward {
    margin-top: 8px;
}

.info-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.info-header h4 {
    margin: 0;
    color: var(--stone-900);
    font-size: 1rem;
}

.info-header button {
    margin-left: auto;
    border: 1px solid rgba(17, 91, 67, 0.16);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.85);
    padding: 7px 12px;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--stone-900);
}

.info-placeholder strong {
    display: block;
    margin-bottom: 6px;
}

.info-placeholder p {
    margin: 0;
    color: var(--stone-700);
}

#pkmn-list {
    display: grid;
    grid-template-columns: 50px minmax(0, 1.4fr) repeat(3, minmax(56px, 1fr));
    gap: 1px;
    background-color: rgba(17, 91, 67, 0.45);
    border: 1px solid rgba(17, 91, 67, 0.22);
    border-radius: 14px;
    overflow: hidden;
}

.pkmn-nodata {
    text-align: center;
    padding: 12px;
}

.pkmn-list-row {
    width: 100%;
    grid-column: 1 / -1;
    text-align: center;
    background-color: rgba(247, 252, 247, 0.96);
    padding: 6px 0;
    font-weight: 700;
}

.pkmn-list-column {
    min-width: 0;
    text-align: center;
    background-color: rgba(255, 255, 255, 0.96);
    padding: 0px 5px;
    font-size: 0.82rem;
}

.pkmn-list-column img {
    width: 40px;
    height: 40px;
}

.pkmn-list-column--games {
    padding: 0;
}

.pkmn-list-column-game {
    min-height: 100%;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(28px, 1fr);
}

.pkmn-game-pill {
    display: grid;
    place-items: center;
    min-width: 28px;
    border-left: 1px solid rgba(17, 91, 67, 0.22);
    background: rgba(10, 58, 44, 0.06);
    color: rgba(81, 101, 95, 0.65);
}

.pkmn-game-pill.is-active {
    background: var(--pkmn-version-color, var(--brand-600));
    color: #fff;
}

.pkmn-game-pill:first-child {
    border-left: 0;
}

.pkmn-game-pill p {
    margin: 0;
    padding: 0;
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1.6;
}

.leaflet-popup-content-wrapper {
    border-radius: 16px;
    box-shadow: var(--shadow-soft);
}

.leaflet-popup-content {
    margin: 12px 14px;
    text-align: center;
    font: 14px/1.45 "Trebuchet MS", "Gill Sans", "Segoe UI", sans-serif;
}

.leaflet-control-zoom {
    border: none !important;
    box-shadow: var(--shadow-soft) !important;
    overflow: hidden;
    border-radius: 18px !important;
}

.leaflet-control-zoom a {
    width: 34px !important;
    height: 34px !important;
    line-height: 34px !important;
    border: none !important;
    color: var(--stone-900) !important;
}

.tile-location-control {
    min-width: 122px;
    padding: 8px 10px;
    border: 1px solid rgba(8, 60, 45, 0.2) !important;
    border-radius: 14px;
    color: var(--brand-950);
    background: rgba(255, 250, 239, 0.94);
    box-shadow: 0 10px 24px rgba(3, 22, 17, 0.18);
    backdrop-filter: blur(12px);
    pointer-events: none;
}

.tile-location-control .tile-location-label {
    display: block;
    margin-bottom: 2px;
    color: var(--stone-700);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    line-height: 1;
    text-transform: uppercase;
}

.tile-location-control strong {
    display: block;
    font-family: "Courier New", monospace;
    font-size: 0.95rem;
    line-height: 1.15;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media only screen and (max-width: 980px) {
    .control-panel {
        top: auto;
        right: max(10px, env(safe-area-inset-right));
        bottom: max(10px, env(safe-area-inset-bottom));
        left: max(10px, env(safe-area-inset-left));
        width: auto;
        max-height: min(72dvh, 560px);
        gap: 10px;
        padding: 8px 12px 12px;
        border-top-left-radius: 24px;
        border-top-right-radius: 24px;
        border-bottom-left-radius: 24px;
        border-bottom-right-radius: 24px;
        overflow-y: hidden;
        overflow-x: hidden;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        transform: translateY(0);
        transition: transform 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
        touch-action: pan-x;
    }

    .control-panel.is-collapsed {
        transform: translateY(calc(100% - 28px));
        padding-top: 6px;
        padding-bottom: 6px;
    }

    .control-panel.is-collapsed .panel-body {
        display: flex;
        visibility: hidden;
        pointer-events: none;
    }

    .control-panel.is-collapsed .panel-header {
        display: none;
    }

    .control-panel.is-dragging {
        transition: none;
    }

    .panel-handle {
        display: block;
        flex: 0 0 auto;
        width: 54px;
        height: 5px;
        margin-bottom: 4px;
        touch-action: none;
        cursor: grab;
    }

    .panel-header {
        align-items: center;
        min-height: 44px;
        gap: 10px;
        cursor: grab;
        touch-action: none;
        user-select: none;
    }

    .panel-kicker,
    .panel-toggle {
        display: none;
    }

    .panel-copy h1 {
        font-size: 1.22rem;
        letter-spacing: -0.03em;
    }

    .panel-subtitle {
        margin-top: 5px;
        font-size: 0.82rem;
        line-height: 1.3;
    }

    .panel-body {
        min-height: 0;
        flex: 1 1 auto;
        overflow-y: auto;
        padding-right: 2px;
        overscroll-behavior: contain;
    }

    .results {
        min-height: 400px;
        flex: 1 1 auto;
        overflow: auto;
        padding-right: 0;
    }

    .info {
        z-index: 950;
        top: max(8px, env(safe-area-inset-top));
        right: max(8px, env(safe-area-inset-right));
        bottom: auto;
        left: max(8px, env(safe-area-inset-left));
        width: auto;
        max-width: none;
        max-height: 30dvh;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        padding: 8px 10px;
        border-radius: 16px;
        font-size: 13px;
    }

    .info-placeholder strong {
        display: none;
    }

    .info-placeholder p {
        display: block;
        color: var(--stone-900);
    }
}

@media only screen and (max-width: 720px) {
    .search-row {
        grid-template-columns: 1fr;
    }

    .panel-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .panel-actions .utility-button {
        width: 100%;
    }

    .result-header {
        gap: 8px;
    }

    #pkmn-list {
        grid-template-columns: 42px minmax(0, 1.25fr) repeat(3, minmax(48px, 1fr));
    }

    .pkmn-list-column {
        font-size: 0.74rem;
        padding: 5px 4px;
    }

    .pkmn-list-column img {
        width: 22px;
        height: 22px;
    }
}

@media only screen and (max-width: 520px) {
    .control-panel {
        gap: 12px;
    }

    .panel-subtitle {
        margin-top: 6px;
        font-size: 0.85rem;
    }

    .filter-chip,
    .utility-button,
    .scope-button {
        font-size: 0.86rem;
    }

    .results {
        gap: 8px;
    }

    .info {
        max-width: none;
        font-size: 12px;
    }

    #pkmn-list {
        grid-template-columns: 36px minmax(0, 1fr) repeat(3, minmax(42px, 0.9fr));
    }

    .pkmn-list-column {
        font-size: 0.68rem;
        padding: 4px 3px;
    }

    .pkmn-list-column img {
        width: 18px;
        height: 18px;
    }
}
