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

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #ffffff;
    font-family: -apple-system, 'SF Pro Display', 'Segoe UI', sans-serif;
}

/* ── Top bar ──────────────────────────────────────────────────────────────── */
#topBar {
    position: fixed;
    /* Use env(safe-area-inset-top) for notch devices, fallback to 5px */
    top: max(5px, env(safe-area-inset-top));
    left: max(5px, env(safe-area-inset-left));
    right: max(5px, env(safe-area-inset-right));
    height: 48px;
    background: #ffffff;
    /* Removed border-radius as requested */
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .08);
}

#clock {
    font-size: 14px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
    color: #111;
    min-width: 68px;
}

#battery {
    font-size: 14px;
    font-weight: 600;
    color: #111;
    min-width: 44px;
    text-align: right;
}

/* ── Dynamic Island pill ─────────────────────────────────────────────────── */
#island {
    display: flex;
    align-items: center;
    /* Wider pill spacing */
    gap: 16px;
    background: #111;
    border-radius: 999px;
    /* Wider pill padding */
    padding: 8px 20px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .35);
}

#island button {
    all: unset;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    transition: background 0.18s, transform 0.12s;
}

#island button:hover {
    background: rgba(255, 255, 255, .15);
}

#island button:active {
    transform: scale(0.88);
}

#island button svg {
    width: 15px;
    height: 15px;
    pointer-events: none;
}

/* ── Iframe wrapper ──────────────────────────────────────────────────────── */
#frameWrap {
    position: fixed;
    /* dynamic top calculation: max safe-area-inset-top + 5px gap + 48px bar height */
    top: calc(max(5px, env(safe-area-inset-top)) + 5px + 48px);
    left: max(5px, env(safe-area-inset-left));
    right: max(5px, env(safe-area-inset-right));
    bottom: max(5px, env(safe-area-inset-bottom));
    /* Minimal radius at the bottom to match the inset look */
    border-radius: 0 0 4px 4px;
    overflow: hidden;
    z-index: 1;
    background: #fff;
}

#myIframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* ── Overlay classes logic ───────────────────────────────────────────────── */
/* Merged original overlay style with proper fixed centering */
#overlay {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    font-size: 24px;
    z-index: 10000;
    text-align: center;
}

/* Updated overlay button styling to match old styling but positioned below text */
#fullscreenBtn {
    margin-top: 20px;
    padding: 10px 20px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    z-index: 10001;
}

#fullscreenBtn:hover {
    background-color: #0056b3;
}

/* ── Custom alert ────────────────────────────────────────────────────────── */
#customAlert {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    overflow: hidden;
    transform: translate(-50%, -50%);
    padding: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border-radius: 10px;
    text-align: center;
    z-index: 10000;
    animation: fadeUp 0.3s ease;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translate(-50%, -40%);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}
