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

:root {
    --green: #0B6E4F;
    --green-dark: #07543D;
    --green-light: #EAF7F1;
    --text: #17352B;
    --muted: #718078;
    --white: #FFFFFF;
    --bg: #F4F8F6;
    --border: #E1EAE5;
    --gold: #C99B45;
    --danger: #B3261E;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: "Poppins", sans-serif;
}

button {
    font-family: inherit;
    cursor: pointer;
}

button:active {
    transform: scale(.97);
}

.qibla-page {
    width: min(620px, 100%);
    margin: auto;
    padding: 10px 14px 35px;
}


/* =========================================================
   HEADER
   ========================================================= */

.qibla-header {
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.header-button {
    width: 42px;
    height: 42px;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: var(--white);
    color: var(--green);
    font-size: 16px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .03);
}

.header-title {
    text-align: center;
    flex: 1;
}

.header-title strong {
    display: block;
    font-size: 17px;
    font-weight: 700;
}

.header-title span {
    display: block;
    color: var(--muted);
    font-size: 9px;
    margin-top: 1px;
}


/* =========================================================
   LOCATION CARD
   ========================================================= */

.location-card {
    display: flex;
    align-items: center;
    gap: 11px;
    margin-top: 9px;
    padding: 12px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 16px;
}

.location-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: var(--green-light);
    color: var(--green);
}

.location-content {
    flex: 1;
    min-width: 0;
}

.location-content strong {
    display: block;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.location-content span {
    display: block;
    color: var(--muted);
    font-size: 9px;
    margin-top: 2px;
}

.refresh-button {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 10px;
    background: var(--green-light);
    color: var(--green);
}


/* =========================================================
   COMPASS SECTION
   ========================================================= */

.compass-section {
    margin-top: 15px;
}

.compass-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px 9px;
}

.compass-heading span {
    color: var(--muted);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1px;
}

.compass-heading strong {
    color: var(--green);
    font-size: 20px;
}


/* =========================================================
   COMPASS
   ========================================================= */

.compass {
    position: relative;
    width: min(350px, 86vw);
    aspect-ratio: 1;
    margin: 0 auto;
    border-radius: 50%;

    background:
        radial-gradient(
            circle at center,
            #ffffff 0%,
            #f8fbf9 57%,
            #e7f1ec 100%
        );

    border: 10px solid white;

    box-shadow:
        0 16px 40px rgba(7, 84, 61, .12),
        inset 0 0 0 1px var(--border);
}


/* outer ring */

.compass::before {
    content: "";
    position: absolute;
    inset: 10px;
    border: 1px solid #dbe7e1;
    border-radius: 50%;
}

.compass::after {
    content: "";
    position: absolute;
    inset: 24px;
    border: 1px dashed #dce8e2;
    border-radius: 50%;
}


/* =========================================================
   COMPASS RING
   ========================================================= */

.compass-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    transition: transform .12s linear;
}

.direction {
    position: absolute;
    z-index: 4;
    font-family: "Poppins", sans-serif;
    font-weight: 700;
    font-size: 16px;
}

.direction.north {
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    color: #B3261E;
}

.direction.east {
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text);
}

.direction.south {
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--text);
}

.direction.west {
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text);
}


/* =========================================================
   DEGREE MARKS
   ========================================================= */

.degree-mark {
    position: absolute;
    left: 50%;
    top: 7px;
    width: 2px;
    height: 9px;
    border-radius: 2px;
    background: #9EADA6;
    transform-origin: 50% calc((min(350px, 86vw) / 2) - 7px);
}

.mark-1 { transform: rotate(22.5deg); }
.mark-2 { transform: rotate(45deg); }
.mark-3 { transform: rotate(67.5deg); }
.mark-4 { transform: rotate(90deg); }
.mark-5 { transform: rotate(112.5deg); }
.mark-6 { transform: rotate(135deg); }
.mark-7 { transform: rotate(157.5deg); }
.mark-8 { transform: rotate(180deg); }


/* =========================================================
   QIBLA POINTER
   ========================================================= */

.qibla-pointer {
    position: absolute;
    z-index: 8;
    inset: 0;
    pointer-events: none;

    transition:
        transform .18s cubic-bezier(.2, .8, .2, 1);
}

.pointer-arrow {
    position: absolute;
    left: 50%;
    top: 21px;

    width: 54px;
    height: 54px;

    transform: translateX(-50%);

    display: grid;
    place-items: center;

    border-radius: 18px;

    background: var(--green);
    color: white;

    font-size: 21px;

    box-shadow:
        0 7px 20px rgba(11, 110, 79, .25);
}

.pointer-arrow::after {
    content: "";
    position: absolute;
    bottom: -13px;
    left: 50%;
    transform: translateX(-50%);

    border-left: 11px solid transparent;
    border-right: 11px solid transparent;
    border-top: 15px solid var(--green);
}

.pointer-glow {
    position: absolute;
    left: 50%;
    top: 16px;
    width: 70px;
    height: 70px;

    transform: translateX(-50%);

    border-radius: 50%;
    background: rgba(11, 110, 79, .07);

    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: translateX(-50%) scale(.9);
        opacity: .4;
    }

    50% {
        transform: translateX(-50%) scale(1.1);
        opacity: .9;
    }
}


/* =========================================================
   CENTER
   ========================================================= */

.compass-center {
    position: absolute;
    z-index: 10;

    left: 50%;
    top: 50%;

    transform: translate(-50%, -50%);

    width: 96px;
    height: 96px;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    border-radius: 50%;

    background: white;

    border: 1px solid var(--border);

    box-shadow:
        0 5px 20px rgba(0, 0, 0, .06);
}

.kaaba-symbol {
    color: var(--green);
    font-size: 25px;
}

.compass-center span {
    margin-top: 4px;
    color: var(--muted);
    font-size: 7px;
    text-align: center;
}


/* =========================================================
   ALIGNMENT CARD
   ========================================================= */

.alignment-card {
    display: flex;
    align-items: center;
    gap: 10px;

    margin: 13px auto 0;
    padding: 11px 13px;

    width: min(350px, 86vw);

    border-radius: 13px;

    background: var(--green-light);
}

.status-dot {
    width: 9px;
    height: 9px;
    flex-shrink: 0;

    border-radius: 50%;
    background: #9AA69F;
}

.status-dot.good {
    background: var(--green);
    box-shadow: 0 0 0 5px rgba(11, 110, 79, .1);
}

.status-dot.warning {
    background: var(--gold);
}

.alignment-card strong {
    display: block;
    font-size: 11px;
}

.alignment-card span {
    display: block;
    color: var(--muted);
    font-size: 9px;
    margin-top: 2px;
}


/* =========================================================
   DETAILS
   ========================================================= */

.details-card {
    margin-top: 14px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 7px;
}

.detail-item {
    min-width: 0;
    padding: 11px 8px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 14px;
    text-align: center;
}

.detail-icon {
    color: var(--green);
    font-size: 13px;
    margin-bottom: 6px;
}

.detail-item span {
    display: block;
    color: var(--muted);
    font-size: 8px;
}

.detail-item strong {
    display: block;
    color: var(--text);
    font-size: 11px;
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* =========================================================
   CALIBRATION
   ========================================================= */

.calibration-card {
    display: flex;
    gap: 11px;
    margin-top: 12px;
    padding: 14px;

    background: white;
    border: 1px solid var(--border);
    border-radius: 16px;
}

.calibration-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;

    display: grid;
    place-items: center;

    border-radius: 12px;

    background: var(--green-light);
    color: var(--green);
}

.calibration-content {
    flex: 1;
}

.calibration-content strong {
    display: block;
    font-size: 12px;
}

.calibration-content p {
    color: var(--muted);
    font-size: 9px;
    line-height: 1.5;
    margin: 3px 0 9px;
}

#calibrateButton {
    border: 0;
    background: var(--green-light);
    color: var(--green);
    border-radius: 9px;
    padding: 8px 11px;
    font-size: 9px;
    font-weight: 600;
}


/* =========================================================
   BUTTONS
   ========================================================= */

.primary-button,
.secondary-button {
    width: 100%;
    min-height: 45px;
    border-radius: 12px;
    font-weight: 600;
    margin-top: 12px;
}

.primary-button {
    border: 0;
    background: var(--green);
    color: white;
    box-shadow: 0 7px 18px rgba(11, 110, 79, .16);
}

.secondary-button {
    border: 1px solid var(--border);
    background: white;
    color: var(--green);
}


/* =========================================================
   TIPS
   ========================================================= */

.tips-card {
    margin-top: 14px;
    padding: 15px;

    background: var(--green-light);
    border-radius: 16px;
}

.tips-header {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--green);
    font-size: 12px;
    margin-bottom: 8px;
}

.tips-card ul {
    padding-left: 17px;
}

.tips-card li {
    color: var(--muted);
    font-size: 9px;
    line-height: 1.6;
    margin: 4px 0;
}


/* =========================================================
   MODAL
   ========================================================= */

.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 18px;
}

.modal[hidden] {
    display: none;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(5, 35, 26, .55);
    backdrop-filter: blur(4px);
}

.modal-card {
    position: relative;
    z-index: 2;

    width: min(430px, 100%);

    padding: 24px 20px;

    background: white;
    border-radius: 22px;

    box-shadow: 0 20px 60px rgba(0, 0, 0, .2);
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;

    width: 35px;
    height: 35px;

    border: 0;
    border-radius: 10px;

    background: var(--bg);
    color: var(--text);
}

.modal-icon {
    width: 52px;
    height: 52px;

    display: grid;
    place-items: center;

    border-radius: 15px;

    background: var(--green-light);
    color: var(--green);

    font-size: 22px;
}

.modal-card h2 {
    margin-top: 15px;
    font-size: 20px;
}

.modal-card p {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.7;
    margin-top: 10px;
}


/* =========================================================
   FOOTER
   ========================================================= */

footer {
    text-align: center;
    padding: 22px 0 5px;
}

footer strong {
    display: block;
    color: var(--green);
    font-size: 13px;
}

footer span {
    color: var(--muted);
    font-size: 9px;
}


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 480px) {

    .qibla-page {
        padding: 7px 10px 28px;
    }

    .compass {
        width: min(330px, 88vw);
    }

    .details-card {
        gap: 5px;
    }

    .detail-item {
        padding: 10px 5px;
    }

    .detail-item span {
        font-size: 7px;
    }

    .detail-item strong {
        font-size: 10px;
    }

    .compass-center {
        width: 88px;
        height: 88px;
    }

    .pointer-arrow {
        width: 49px;
        height: 49px;
        top: 19px;
    }
}

@media (max-width: 360px) {

    .compass {
        width: 285px;
    }

    .direction {
        font-size: 13px;
    }

    .compass-center {
        width: 78px;
        height: 78px;
    }

    .kaaba-symbol {
        font-size: 21px;
    }

    .details-card {
        grid-template-columns: 1fr;
    }

    .detail-item {
        display: flex;
        align-items: center;
        text-align: left;
        gap: 10px;
    }

    .detail-icon {
        margin: 0;
    }
}
