:root {
    --bg: #f5f8fb;
    --panel: #ffffff;
    --ink: #182033;
    --muted: #667085;
    --line: #dce5ee;
    --accent: #0f9f7a;
    --accent-strong: #087a5c;
    --coral: #f05d5e;
    --sun: #ffd166;
    --shadow: 0 18px 55px rgba(24, 32, 51, 0.11);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--ink);
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(18px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    width: fit-content;
    font-weight: 800;
    font-size: 1.1rem;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--sun);
    box-shadow: inset 0 -3px 0 rgba(24, 32, 51, 0.14);
}

.nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
}

.nav a,
.logout-form button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 12px;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--muted);
    background: transparent;
    cursor: pointer;
    white-space: nowrap;
}

.nav a.active,
.logout-form button:hover,
.nav a:hover {
    color: var(--ink);
    border-color: var(--line);
    background: var(--panel);
}

.nav .nav-cta {
    color: #ffffff;
    background: var(--ink);
}

.logout-form {
    margin: 0;
}

.page {
    width: min(1180px, calc(100% - 28px));
    margin: 0 auto;
    padding: 22px 0 40px;
}

.flash {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--panel);
    font-weight: 700;
}

.flash.success {
    color: var(--accent-strong);
    border-color: rgba(15, 159, 122, 0.26);
}

.flash.error {
    color: #b42318;
    border-color: rgba(240, 93, 94, 0.34);
}

.hero,
.place-hero,
.profile-hero {
    display: grid;
    gap: 18px;
    align-items: end;
    padding: 24px 0;
}

.hero h1,
.place-hero h1,
.profile-hero h1,
.content-panel h1,
.create-shell h1,
.not-found h1 {
    margin: 0;
    font-size: clamp(2.1rem, 9vw, 4.9rem);
    line-height: 0.96;
    letter-spacing: 0;
}

.hero p,
.place-hero p,
.profile-hero p,
.auth-copy p,
.not-found p {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 1rem;
    line-height: 1.6;
}

.eyebrow {
    margin: 0 0 7px;
    color: var(--accent-strong);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0;
}

.hero-actions,
.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.button {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-weight: 800;
    cursor: pointer;
    transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.button:hover {
    transform: translateY(-1px);
}

.button.primary {
    border-color: var(--accent);
    background: var(--accent);
    color: #ffffff;
    box-shadow: 0 12px 30px rgba(15, 159, 122, 0.2);
}

.button.ghost {
    background: var(--panel);
    color: var(--ink);
}

.button.full {
    width: 100%;
}

.button.compact {
    min-height: 38px;
    padding: 0 12px;
}

.stats-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 10px 0 22px;
}

.stats-strip div {
    display: grid;
    gap: 3px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.stats-strip strong {
    font-size: clamp(1.35rem, 5vw, 2rem);
    line-height: 1;
}

.stats-strip span {
    color: var(--muted);
    font-size: 0.8rem;
}

.home-grid,
.place-grid,
.auth-shell,
.create-shell {
    display: grid;
    gap: 18px;
}

.map-panel,
.side-panel,
.content-panel,
.review-panel,
.form-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.map-panel,
.side-panel,
.content-panel,
.review-panel {
    padding: 14px;
}

.map {
    width: 100%;
    height: min(68vh, 560px);
    min-height: 390px;
    border-radius: 8px;
    border: 1px solid var(--line);
    overflow: hidden;
    background: #dce8ef;
    position: relative;
    isolation: isolate;
}

.map.small {
    height: 360px;
    min-height: 320px;
}

.map .maplibregl-canvas {
    outline: none;
}

.map .maplibregl-control-container {
    font-family: inherit;
}

.map .maplibregl-ctrl-group {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 10px 22px rgba(24, 32, 51, 0.14);
}

.map .maplibregl-ctrl button {
    width: 34px;
    height: 34px;
}

.map-marker {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 2px solid rgba(255, 255, 255, 0.92);
    border-radius: 999px;
    background: var(--sun);
    box-shadow: 0 12px 26px rgba(24, 32, 51, 0.3);
    cursor: pointer;
    font-size: 1.22rem;
}

.map-marker:hover {
    transform: translateY(-2px);
}

.map .maplibregl-popup-content {
    border-radius: 8px;
    padding: 0;
    box-shadow: 0 16px 38px rgba(24, 32, 51, 0.2);
}

.map .maplibregl-popup-tip {
    border-top-color: #ffffff;
}

.map-fallback {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--muted);
    font-weight: 800;
}

.section-title {
    margin-bottom: 12px;
}

.section-title h1,
.section-title h2 {
    margin: 0;
    font-size: clamp(1.45rem, 5vw, 2.2rem);
    line-height: 1.05;
    letter-spacing: 0;
}

.place-list,
.review-list,
.leaderboard {
    display: grid;
    gap: 10px;
}

.place-card,
.rank-row,
.review-card,
.selected-place {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.place-card:hover {
    border-color: rgba(15, 159, 122, 0.44);
}

.place-emoji {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: #fff4bf;
}

.place-content {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.place-content strong,
.place-content small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.place-content small,
.review-card time,
.rank-row small,
.selected-place small {
    color: var(--muted);
    font-size: 0.82rem;
}

.rating-pill {
    padding: 7px 9px;
    border-radius: 8px;
    background: #e8fff6;
    color: var(--accent-strong);
    font-weight: 800;
    white-space: nowrap;
}

.place-score {
    width: fit-content;
    min-width: 124px;
    padding: 16px;
    border-radius: 8px;
    background: var(--ink);
    color: #ffffff;
    text-align: center;
}

.place-score strong {
    font-size: 2.8rem;
    line-height: 1;
}

.place-score span {
    color: var(--sun);
    font-weight: 800;
}

.place-score small {
    display: block;
    margin-top: 6px;
    color: rgba(255, 255, 255, 0.75);
}

.form-panel {
    display: grid;
    gap: 14px;
    padding: 16px;
}

.form-panel.wide {
    max-width: 720px;
}

.form-panel label {
    display: grid;
    gap: 7px;
    font-weight: 800;
}

.form-panel input,
.form-panel select,
.form-panel textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 13px;
    background: #fbfdff;
    color: var(--ink);
    outline: none;
}

.form-panel input:focus,
.form-panel select:focus,
.form-panel textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(15, 159, 122, 0.12);
}

.form-link {
    margin: 0;
    color: var(--muted);
    text-align: center;
}

.form-link a {
    color: var(--accent-strong);
    font-weight: 800;
}

.auth-copy {
    align-self: center;
}

.auth-copy h1 {
    margin: 0;
    font-size: clamp(2rem, 8vw, 4.2rem);
    line-height: 1;
    letter-spacing: 0;
}

.search-box {
    position: relative;
}

.search-results {
    position: absolute;
    z-index: 20;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    display: grid;
    gap: 6px;
    max-height: 320px;
    overflow-y: auto;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: var(--shadow);
}

.search-results button {
    display: grid;
    gap: 4px;
    width: 100%;
    padding: 10px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--ink);
    text-align: left;
    cursor: pointer;
}

.search-results button:hover {
    border-color: var(--line);
    background: #f5f8fb;
}

.search-results small {
    color: var(--muted);
}

.selected-place {
    grid-template-columns: auto minmax(0, 1fr);
    background: #fff9da;
    border-color: #f0d86a;
}

.selected-place.is-hidden {
    display: none;
}

.selected-place div {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.selected-place strong,
.selected-place small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.review-card {
    grid-template-columns: 1fr;
    align-items: start;
}

.review-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.review-head span {
    color: var(--accent-strong);
    font-weight: 800;
}

.review-card p {
    margin: 0;
    color: #344054;
    line-height: 1.6;
}

.rank-row {
    grid-template-columns: auto minmax(0, 1fr) auto;
}

.rank-number {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--sun);
    font-weight: 800;
}

.empty-state {
    margin: 0;
    padding: 18px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    color: var(--muted);
    background: #fbfdff;
}

.not-found {
    display: grid;
    justify-items: start;
    gap: 12px;
    padding: 64px 0;
}

.contact-shell {
    display: grid;
    gap: 18px;
    padding: 24px 0;
}

.contact-title {
    margin-bottom: 0;
}

.dev-card {
    display: grid;
    justify-items: center;
    gap: 24px;
    padding: clamp(24px, 7vw, 56px);
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
    text-align: center;
}

.dev-avatar-wrap {
    position: relative;
    display: grid;
    place-items: center;
    width: clamp(132px, 34vw, 210px);
    aspect-ratio: 1;
    border-radius: 999px;
    background: var(--sun);
    box-shadow: 0 18px 52px rgba(24, 32, 51, 0.16);
    overflow: hidden;
}

.dev-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.dev-avatar-fallback {
    display: none;
    place-items: center;
    width: 100%;
    height: 100%;
    font-size: clamp(3rem, 12vw, 5rem);
}

.dev-copy {
    display: grid;
    gap: 10px;
    max-width: 720px;
}

.dev-copy h2 {
    margin: 0;
    font-size: clamp(2.4rem, 10vw, 4.4rem);
    line-height: 1;
    letter-spacing: 0;
}

.dev-role {
    margin: 0;
    color: var(--accent-strong);
    font-size: clamp(0.9rem, 3vw, 1.1rem);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0;
}

.dev-text {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: clamp(1rem, 3vw, 1.25rem);
    line-height: 1.6;
}

.dev-links {
    display: grid;
    width: min(760px, 100%);
    gap: 10px;
}

.dev-link {
    display: grid;
    gap: 4px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfdff;
    text-align: left;
}

.dev-link:hover {
    border-color: rgba(15, 159, 122, 0.44);
}

.dev-link span {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 800;
    text-transform: uppercase;
}

.dev-link strong {
    overflow-wrap: anywhere;
}

.footer {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 28px 16px;
    color: var(--muted);
}

.footer a {
    color: var(--accent-strong);
    font-weight: 800;
}

.popup {
    display: grid;
    gap: 5px;
    min-width: 190px;
}

.popup strong {
    color: var(--ink);
}

.popup span {
    color: var(--muted);
}

.popup a {
    color: var(--accent-strong);
    font-weight: 800;
}

@media (min-width: 760px) {
    .topbar {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 14px 26px;
    }

    .hero,
    .place-hero,
    .profile-hero {
        grid-template-columns: minmax(0, 1fr) auto;
        padding: 38px 0 28px;
    }

    .home-grid {
        grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.55fr);
        align-items: start;
    }

    .place-grid,
    .auth-shell {
        grid-template-columns: minmax(0, 0.9fr) minmax(320px, 0.7fr);
        align-items: start;
    }

    .create-shell {
        justify-items: center;
    }

    .create-shell .section-title,
    .create-shell .form-panel {
        width: min(720px, 100%);
    }

    .map-panel,
    .side-panel,
    .content-panel,
    .review-panel {
        padding: 18px;
    }

    .form-panel {
        padding: 22px;
    }

    .dev-links {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}
