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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    background: #f5f5f5;
    color: #1a1a1a;
    height: 100vh;
    overflow: hidden;
}

/* ========================
   HEADER / SEARCH BAR
======================== */
#header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: white;
    padding: 10px 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    display: flex;
    align-items: center;
    gap: 8px;
}

#header h1 {
    font-size: 18px;
    font-weight: 700;
    color: #2563eb;
    margin-right: 8px;
    white-space: nowrap;
    margin: 0;
}

#headerLogo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-right: 8px;
}

#logoImg {
    height: 32px;
    width: auto;
    border-radius: 6px;
    object-fit: contain;
}

#searchBar {
    display: flex;
    flex: 1;
    gap: 6px;
}

#searchInput {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    transition: border 0.2s;
}

#searchInput:focus {
    border-color: #2563eb;
}

#gpsBtn {
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

#gpsBtn:hover {
    background: #1d4ed8;
}

#gpsBtn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: #9ca3af;
}

/* ========================
   MAP
======================== */
#map {
    position: absolute;
    top: 58px;
    left: 0;
    right: 0;
    bottom: 320px;
    z-index: 1;
}

#centerPin {
    position: absolute;
    top: calc(58px + ((100vh - 58px - 320px) / 2));
    left: 50%;
    transform: translate(-50%, -100%);
    font-size: 32px;
    z-index: 1001;
    pointer-events: all !important;
    cursor: pointer;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
    transition: transform 0.2s ease, font-size 0.2s ease, filter 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
}

#centerPin:hover {
    filter: drop-shadow(0 3px 8px rgba(37,99,235,0.5));
    transform: translate(-50%, -112%);
}

#centerPin.pressed {
    content: '🔴';
    transform: translate(-50%, -75%) scale(0.85);
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.15));
}

#centerPin.loading {
    animation: pinBounce 0.5s ease infinite alternate;
}

#centerPin.done {
    transform: translate(-50%, -75%) scale(0.85);
    filter: drop-shadow(0 1px 6px rgba(37,99,235,0.6));
}

@keyframes pinBounce {
    from { transform: translate(-50%, -100%); }
    to   { transform: translate(-50%, -118%); }
}

#tapHint {
    position: absolute;
    top: calc(58px + ((100vh - 58px - 320px) / 2) + 20px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.65);
    color: white;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 20px;
    z-index: 500;
    pointer-events: none;
    white-space: nowrap;
    transition: opacity 0.3s;
}

#tapHint.hidden {
    opacity: 0;
}

/* ========================
   BOTTOM PANEL
======================== */
#panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 320px;
    background: white;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
    z-index: 1000;
    padding: 16px 14px 10px;
    overflow-y: auto;
}

#locationLabel {
    font-size: 15px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 12px;
}

.section-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #9ca3af;
    margin: 10px 0 8px;
}

/* ========================
   TOP SCENARIO CARDS
======================== */
.top-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 4px;
}

.top-card {
    flex: 1 1 calc(33.333% - 6px);
    min-width: 100px;
    max-width: 120px;
    background: #f0f7ff;
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    padding: 10px 8px;
    cursor: pointer;
    text-align: center;
    transition: transform 0.15s, background 0.15s;
    min-height: 72px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

@media (max-width: 400px) {
    .top-card {
        flex: 1 1 calc(50% - 4px);
        max-width: none;
    }
}

.top-card:hover {
    background: #dbeafe;
    transform: translateY(-2px);
}

.top-card .card-icon {
    font-size: 20px;
}

.top-card .card-label {
    font-size: 11px;
    font-weight: 600;
    color: #1e40af;
}

.top-card .card-flag {
    font-size: 10px;
    color: #f59e0b;
}

.top-card.more-card {
    background: #f9fafb;
    border-color: #e5e7eb;
}

.top-card.more-card:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.top-card.more-card .card-label {
    color: #6b7280;
}

.top-card.more-card .card-icon {
    font-size: 18px;
}

/* ========================
   COMPARE BUTTON
======================== */
#compareBtn {
    width: 100%;
    margin: 16px 0;
    padding: 12px;
    background: #f0f7ff;
    border: 2px solid #bfdbfe;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #1e40af;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

#compareBtn:hover {
    background: #dbeafe;
    border-color: #60a5fa;
    color: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.15);
}

/* ========================
   RESULTS PAGE
======================== */
#results-wrap {
    max-width: 420px;
    margin: 0 auto;
    padding: 0 0 40px;
    min-height: 100vh;
    background: white;
}

#results-header {
    background: #2563eb;
    color: white;
    padding: 16px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
}

#backBtn {
    background: none;
    border: none;
    color: white;
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

#results-header h2 {
    font-size: 18px;
    font-weight: 700;
}

#results-header .city-name {
    font-size: 13px;
    opacity: 0.8;
    margin-top: 2px;
}

.results-section {
    padding: 20px 16px;
    border-bottom: 1px solid #f3f4f6;
}

.total-box {
    text-align: center;
    padding: 24px 16px;
    background: #f0f9ff;
    border-bottom: 1px solid #e0f2fe;
}

.total-box .total-label {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 4px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.total-box .total-amount {
    font-size: 52px;
    font-weight: 800;
    color: #1e40af;
    line-height: 1;
}

.breakdown-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #9ca3af;
    margin-bottom: 12px;
}

.breakdown-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f9fafb;
    font-size: 15px;
}

.breakdown-row:last-child {
    border-bottom: none;
}

.breakdown-row .row-label {
    color: #374151;
}

.breakdown-row .row-amount {
    font-weight: 600;
    color: #1a1a1a;
}

.breakdown-row.base-row {
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 12px;
    margin-bottom: 4px;
}

.breakdown-row.base-row .row-label {
    font-weight: 600;
    color: #1a1a1a;
}

.breakdown-row.total-additional {
    border-top: 2px solid #e5e7eb;
    padding-top: 12px;
    margin-top: 8px;
}

.breakdown-row.total-additional .row-amount {
    color: #dc2626;
}

.insight-box {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 12px;
    padding: 14px 16px;
    margin: 16px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.insight-box .insight-icon {
    font-size: 20px;
    line-height: 1;
}

.insight-box .insight-text {
    font-size: 14px;
    color: #92400e;
    font-weight: 500;
    line-height: 1.4;
}

/* ========================
   COMPARISON PAGE
======================== */
#compare-wrap {
    max-width: 420px;
    margin: 0 auto;
    padding: 0 0 40px;
    min-height: 100vh;
    background: white;
}

#compare-header {
    background: #2563eb;
    color: white;
    padding: 16px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
}

#compare-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.compare-cities {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.compare-city {
    padding: 20px 16px;
    border-bottom: 2px solid #f3f4f6;
}

.compare-city:last-child {
    border-bottom: 1px solid #f3f4f6;
}

.compare-city .city-label {
    font-size: 15px;
    color: #1a1a1a;
    margin-bottom: 8px;
    font-weight: 700;
}

.compare-city .city-total {
    font-size: 32px;
    font-weight: 800;
    color: #1e40af;
    line-height: 1;
    margin-bottom: 8px;
}

.compare-city .city-breakdown {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #f3f4f6;
}

.compare-city .breakdown-item {
    font-size: 13px;
    color: #6b7280;
}

.compare-city .breakdown-item.additional {
    color: #dc2626;
    font-weight: 600;
}

.compare-city.winner {
    background: #f0fdf4;
    border-left: 4px solid #15803d;
}

.compare-city.winner .city-total {
    color: #15803d;
}

.compare-city.loser {
    background: #fef2f2;
    border-left: 4px solid #dc2626;
}

.compare-city.loser .city-total {
    color: #dc2626;
}

.savings-box {
    text-align: center;
    padding: 20px 16px;
    border-bottom: 1px solid #f3f4f6;
}

.savings-box .savings-label {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.savings-box .savings-amount {
    font-size: 32px;
    font-weight: 800;
    color: #15803d;
}

.savings-box .savings-sub {
    font-size: 13px;
    color: #6b7280;
    margin-top: 2px;
}

.why-box {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 12px;
    padding: 14px 16px;
    margin: 16px;
    display: flex;
    gap: 10px;
}

.why-box .why-icon {
    font-size: 20px;
}

.why-box .why-text {
    font-size: 14px;
    color: #92400e;
    font-weight: 500;
    line-height: 1.4;
}

/* ========================
   LOADING STATE
======================== */
.loading {
    text-align: center;
    padding: 40px 20px;
    color: #6b7280;
    font-size: 15px;
}

.spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid #e5e7eb;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin-bottom: 10px;
}

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

/* ========================
   ERROR STATE
======================== */
.error-box {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 12px;
    padding: 14px 16px;
    margin: 16px;
    color: #dc2626;
    font-size: 14px;
    text-align: center;
}
