:root {
    --direction-widget-gap: clamp(0.75rem, 2vw, 1.3rem);
    --direction-widget-border: 1px solid rgba(148, 163, 184, 0.45);
    --direction-widget-radius: 18px;
}

.direction-widget {
    width: min(960px, 100%);
    padding: clamp(1rem, 4vw, 1.75rem);
    border-radius: var(--direction-widget-radius);
    border: var(--direction-widget-border);
    background: #ffffff;
    box-shadow: 0 24px 48px rgba(15, 23, 42, 0.08);
    display: flex;
    flex-direction: column;
    gap: var(--direction-widget-gap);
}

@media (max-width: 640px) {
    .direction-widget {
        padding: 1rem;
        border-radius: 16px;
        box-shadow: 0 16px 38px rgba(15, 23, 42, 0.08);
    }

    .direction-widget .leaflet-control-zoom {
        display: none !important;
    }
}

.direction-widget__title {
    margin: 0;
    font-size: clamp(1.2rem, 4vw, 1.6rem);
    font-weight: 700;
    color: #0f172a;
}

.direction-widget__note {
    margin: 0;
    min-height: 1.5em;
    font-size: 0.95rem;
    line-height: 1.5;
}

.direction-widget__form {
    display: grid;
    gap: 0.85rem;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.direction-widget__field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.direction-widget__map {
    position: relative;
    width: 100%;
    min-height: 280px;
    height: clamp(280px, 55vh, 520px);
    border-radius: calc(var(--direction-widget-radius) - 4px);
    overflow: hidden;
    background: #dbeafe;
}

.direction-widget__map .leaflet-container {
    width: 100%;
    height: 100%;
}

@media (min-width: 768px) {
    .direction-widget__map {
        height: clamp(360px, 50vh, 560px);
    }
}

@media (min-width: 1280px) {
    .direction-widget__map {
        height: clamp(420px, 45vh, 640px);
    }
}

.direction-map__locate {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: clamp(4rem, 5vw, 5rem);
    display: block;
    width: min(420px, calc(80% - clamp(1.5rem, 4vw, 3rem)));
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    text-align: center;
    z-index: 401;
}

.direction-map__locate img {
    display: block;
    width: 100%;
    height: auto;
    pointer-events: none;
    filter: drop-shadow(0 12px 24px rgba(15, 23, 42, 0.4));
}

.direction-map__locate:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.75);
    outline-offset: 3px;
    border-radius: 999px;
}

.direction-map__locate:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.direction-map__locate--fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 48px;
    padding: 0.65rem 1.5rem;
    border-radius: 999px;
    border: none;
    background-color: #2563eb;
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: 'RocknRoll One', "Hiragino Sans", "Yu Gothic", sans-serif;
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.35);
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.direction-map__locate--fallback:hover,
.direction-map__locate--fallback:focus {
    background-color: #1d4ed8;
    outline: none;
    box-shadow: 0 6px 20px rgba(29, 78, 216, 0.35);
}

.direction-map__locate--fallback:disabled {
    background-color: #93c5fd;
    cursor: not-allowed;
    box-shadow: none;
}

[data-direction-legend] {
    margin-top: 0.5rem;
    padding: 1rem;
    border-radius: calc(var(--direction-widget-radius) - 4px);
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    font-size: 0.9rem;
    line-height: 1.6;
}

[data-direction-legend] dl {
    margin: 0;
    display: grid;
    gap: 0.95rem;
}

[data-direction-legend] dt {
    font-weight: 700;
    color: #0f172a;
    margin: 0;
}

[data-direction-legend] dd {
    margin: 0;
    color: #475569;
}

.legend-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.65rem;
    margin: 0.25rem 0.4rem 0.25rem 0;
    border-radius: 999px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    white-space: nowrap;
}

.legend-color {
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 50%;
    border: 1px solid rgba(15, 23, 42, 0.15);
}

.direction-good-table {
    margin-top: 1rem;
    border: 1px solid #e2e8f0;
    border-radius: calc(var(--direction-widget-radius) - 6px);
    overflow: hidden;
    background: #fff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.direction-good-table__title {
    margin: 0;
    padding: 0.75rem 1rem;
    font-weight: 600;
    font-size: 0.95rem;
    color: #0f172a;
    background: linear-gradient(90deg, #e0f2fe, #dbeafe);
}

.direction-good-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.direction-good-table td {
    padding: 0.65rem 1rem;
    border-top: 1px solid #e2e8f0;
    color: #1f2937;
    word-break: break-word;
}

.direction-good-table tr:nth-child(even) td {
    background: #f8fafc;
}

.direction-widget__attribution {
    margin-top: 0.75rem;
    font-size: 0.75rem;
    color: #4b5563;
    text-align: right;
}

.direction-widget__attribution a {
    color: inherit;
    text-decoration: underline;
}

.location-permission-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(17, 24, 39, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.location-permission-modal__dialog {
    background: #ffffff;
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.25);
    max-width: 420px;
    width: 100%;
    padding: 1.5rem;
    color: #1f2937;
    line-height: 1.6;
}

.location-permission-modal__title {
    margin: 0 0 0.75rem;
    font-size: 1.1rem;
    font-weight: 700;
}

.location-permission-modal__body p {
    margin: 0 0 0.75rem;
    font-size: 0.95rem;
}

.location-permission-modal__footer {
    margin-top: 1.25rem;
    text-align: right;
}

.location-permission-modal__close {
    padding: 0.45rem 1rem;
    border-radius: 6px;
    border: none;
    background: #2563eb;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

.location-permission-modal__close:hover,
.location-permission-modal__close:focus {
    background: #1d4ed8;
    outline: none;
}
