* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Arial, sans-serif;
}

body {
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

/* ── Backend selector bar ──────────────────────────────────────────────────── */
.backend-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    padding: 10px 20px;
    position: sticky;
    top: 0;
    z-index: 500;
    box-shadow: 0 2px 6px rgba(0,0,0,0.07);
    flex-wrap: wrap;
}

.backend-label {
    font-weight: 600;
    color: #555;
    font-size: 0.9rem;
}

.backend-toggle {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.backend-btn {
    padding: 8px 16px;
    background: #f0f0f0;
    color: #444;
    border: 2px solid transparent;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 500;
    transition: all 0.2s;
    box-shadow: none;
}

.backend-btn:hover {
    background: #e4e4e4;
    transform: none;
    box-shadow: none;
}

.backend-btn.active {
    background: #e74c3c;
    color: #fff;
    border-color: #c0392b;
}

.badge {
    display: inline-block;
    font-size: 0.7rem;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 4px;
    font-weight: 700;
    vertical-align: middle;
}

.badge.free {
    background: #2ecc71;
    color: #fff;
}

/* ── API key section ───────────────────────────────────────────────────────── */
.api-key-section {
    display: flex;
    justify-content: center;
    padding: 30px 20px;
}

.api-key-card {
    background: #fff;
    border-radius: 12px;
    padding: 28px 32px;
    max-width: 520px;
    width: 100%;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.api-key-card h3 {
    color: #e74c3c;
    margin-bottom: 10px;
    font-size: 1.3rem;
}

.api-key-card p {
    color: #555;
    font-size: 0.9rem;
    margin-bottom: 14px;
}

.api-key-card a {
    color: #3498db;
}

.api-key-input-row {
    display: flex;
    gap: 10px;
}

.api-key-input-row input[type="password"] {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.95rem;
    background: #fafafa;
}

.api-key-input-row .primary-btn {
    width: auto;
    margin-top: 0;
    padding: 10px 18px;
    font-size: 0.9rem;
    text-transform: none;
    letter-spacing: 0;
}

.api-key-status {
    margin-top: 10px;
    font-size: 0.85rem;
    padding: 6px 10px;
    border-radius: 6px;
}

.api-key-status.ok    { background: #d4edda; color: #155724; }
.api-key-status.error { background: #f8d7da; color: #721c24; }

/* ── Main container ────────────────────────────────────────────────────────── */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

h1 {
    text-align: center;
    margin-bottom: 30px;
    color: #e74c3c;
    font-size: 2.5rem;
    font-weight: bold;
    text-shadow: 1px 1px 1px rgba(0,0,0,0.1);
}

h2 {
    margin-bottom: 15px;
    color: #e74c3c;
    font-size: 1.8rem;
}

.location-section, .range-section, .location-controls {
    background-color: white;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    transition: box-shadow 0.3s ease;
}

.location-section:hover, .range-section:hover, .location-controls:hover {
    box-shadow: 0 6px 15px rgba(0,0,0,0.12);
}

#map {
    height: 350px;
    margin-bottom: 20px;
    border-radius: 10px;
    border: 1px solid #ddd;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

label {
    display: block;
    margin-bottom: 5px;
}

input[type="number"] {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: white;
}

input[type="range"] {
    width: 100%;
    margin: 10px 0;
}

.distance-input-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

.distance-input-container input[type="number"] {
    width: 80px;
    flex-shrink: 0;
}

.distance-input-container input[type="range"] {
    flex-grow: 1;
    width: auto;
}

button {
    padding: 12px 18px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

button:hover {
    background-color: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    background-color: #bdc3c7;
    cursor: not-allowed;
    transform: none;
}

.primary-btn {
    background-color: #e74c3c;
    width: 100%;
    padding: 14px;
    font-size: 16px;
    margin-top: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.primary-btn:hover { background-color: #c0392b; }
.primary-btn:disabled { background-color: #e74c3c80; }

.hidden { display: none !important; }

#restaurant-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 20px;
    border: 1px solid #eee;
    padding: 10px;
    border-radius: 4px;
}

.wheel-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 20px auto;
}

#wheel {
    display: block;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    position: relative;
    transition: transform 5s cubic-bezier(0.17, 0.67, 0.12, 0.99);
    transform: rotate(0deg);
    box-shadow: 0 6px 15px rgba(0,0,0,0.2);
    cursor: pointer;
}

#wheel:hover {
    box-shadow: 0 8px 20px rgba(0,0,0,0.25);
}

#wheel.spinning {
    cursor: wait;
    opacity: 0.9;
}

#css-wheel-pointer {
    position: absolute;
    width: 30px;
    height: 30px;
    background-color: #e74c3c;
    clip-path: polygon(0% 0%, 100% 0%, 50% 100%);
    left: 50%;
    transform: translateX(-50%);
    top: -15px;
    z-index: 10;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.cuisine-filter-container {
    margin-top: 20px;
    background-color: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}

.cuisine-filter-container h3 {
    margin-bottom: 15px;
    color: #e74c3c;
    font-size: 1.4rem;
}

.cuisine-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.cuisine-checkboxes label {
    display: flex;
    align-items: center;
    gap: 6px;
    background-color: #f8f9fa;
    padding: 8px 12px;
    border-radius: 6px;
    transition: all 0.2s;
    border: 1px solid #e0e0e0;
    font-size: 0.9rem;
    cursor: pointer;
}

.cuisine-checkboxes label:hover {
    background-color: #e9ecef;
    transform: translateY(-2px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.cuisine-checkboxes label input:checked + span {
    color: #e74c3c;
    font-weight: bold;
}

.restaurant-item {
    background-color: white;
    padding: 15px 20px;
    margin-bottom: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: all 0.3s;
    border-left: 4px solid #e74c3c;
}

.restaurant-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.15);
}

.restaurant-item h3 { margin-bottom: 8px; color: #e74c3c; }

.restaurant-item a {
    color: #e74c3c;
    text-decoration: none;
    transition: color 0.2s;
}

.restaurant-item a:hover {
    color: #c0392b;
    text-decoration: underline;
}

.modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden { display: none !important; }

.modal-content {
    background-color: white;
    padding: 40px;
    border-radius: 12px;
    max-width: 550px;
    width: 90%;
    text-align: center;
    position: relative;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.close-button {
    position: absolute;
    top: 10px; right: 15px;
    font-size: 24px;
    cursor: pointer;
}

#chosen-restaurant {
    margin-top: 20px;
    font-size: 20px;
    font-weight: bold;
    color: #e74c3c;
}

.winner-name {
    font-size: 1.6rem;
    margin-bottom: 10px;
}

.winner-name a { color: #e74c3c; text-decoration: none; }
.winner-name a:hover { text-decoration: underline; }

.restaurant-details {
    font-size: 15px;
    color: #555;
    margin-top: 8px;
}

.location-action-group {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.location-action-group button { flex-grow: 1; }

/* btn-label: text label next to icon, hidden on tiny screens */
.btn-label { vertical-align: middle; }

.map-hint {
    font-size: 0.85rem;
    color: #888;
    margin-top: 8px;
}

.bottom-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.spin-duration-section {
    margin-top: 10px;
    padding: 10px 0;
}

@media (max-width: 768px) {
    /* Extra bottom space for fixed action bar */
    body { padding-bottom: 74px; }

    .bottom-section { grid-template-columns: 1fr; }

    h1 { font-size: 1.6rem; margin-bottom: 16px; }
    h2 { font-size: 1.3rem; }

    .container { padding: 12px; }

    .location-controls {
        padding: 16px;
        margin-bottom: 16px;
    }

    /* Compact backend bar */
    .backend-bar { gap: 6px; padding: 8px 12px; }
    .backend-label { display: none; }
    .backend-btn { padding: 7px 12px; font-size: 0.82rem; }

    /* Map shorter on mobile */
    #map { height: 220px; }

    /* Fixed bottom action bar */
    .location-action-group {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        margin-top: 0;
        padding: 10px 16px;
        background: #fff;
        border-top: 1px solid #e0e0e0;
        box-shadow: 0 -3px 12px rgba(0,0,0,0.12);
        z-index: 400;
        gap: 10px;
    }

    .location-action-group button {
        padding: 10px 8px;
        font-size: 0.85rem;
    }

    .location-action-group .primary-btn {
        margin-top: 0;
        width: auto;
        padding: 10px 14px;
        font-size: 0.85rem;
        text-transform: none;
        letter-spacing: 0;
    }

    /* Constrain wheel on mobile */
    .wheel-wrapper { margin: 12px auto; }
    #wheel { width: 260px; height: 260px; }
    #css-wheel-pointer { top: -12px; width: 24px; height: 24px; }

    /* Results list taller on mobile */
    #restaurant-list { max-height: 400px; }
}

/* Very small screens: hide text labels in backend & action buttons, icons only */
@media (max-width: 420px) {
    .backend-btn .btn-label { display: none; }
    .location-action-group .btn-label { display: none; }
    .backend-btn { padding: 8px 12px; }
}
