*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --ios-blue: #007aff;
  --ios-separator: rgba(60, 60, 67, 0.29);
  --font-system: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Helvetica Neue", Helvetica, Arial, sans-serif;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  --alert-max-width: clamp(270px, 78vw, 300px);
  --alert-radius: 14px;
  --alert-title-size: 17px;
  --alert-message-size: 13px;
  --alert-btn-size: 17px;
  --alert-btn-padding: 12px 8px;
  --alert-icon-size: 36px;
  --alert-layer-padding: 20px;
}

@media (min-width: 768px) {
  :root {
    --alert-max-width: clamp(270px, 42vw, 320px);
    --alert-title-size: 18px;
    --alert-message-size: 14px;
    --alert-btn-size: 18px;
    --alert-btn-padding: 13px 10px;
    --alert-icon-size: 40px;
    --alert-layer-padding: 32px;
  }
}

@media (min-width: 1024px) {
  :root {
    --alert-max-width: 320px;
    --alert-layer-padding: 40px;
  }
}

@media (max-width: 374px) {
  :root {
    --alert-max-width: min(270px, calc(100vw - 32px - var(--safe-left) - var(--safe-right)));
    --alert-layer-padding: 16px;
  }
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

html, body {
  min-height: 100%;
  min-height: 100dvh;
  overflow: hidden;
}

body {
  font-family: var(--font-system);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: #1c1c1e;
  touch-action: manipulation;
}

#screen-content {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

.ios-wallpaper {
  position: absolute;
  inset: -40px;
  background:
    radial-gradient(ellipse 90% 70% at 12% 8%, #9fd4ff 0%, transparent 52%),
    radial-gradient(ellipse 70% 60% at 92% 18%, #f5c6e8 0%, transparent 48%),
    radial-gradient(ellipse 80% 50% at 70% 88%, #f0c48a 0%, transparent 50%),
    radial-gradient(ellipse 50% 40% at 18% 78%, #7ec8b8 0%, transparent 45%),
    linear-gradient(180deg, #6eb4e8 0%, #b8d4e8 38%, #e8d4c4 72%, #c8b8a8 100%);
  filter: blur(28px);
  transform: scale(1.08);
}

.ios-status-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding:
    calc(12px + var(--safe-top))
    calc(22px + var(--safe-right))
    0
    calc(26px + var(--safe-left));
  color: #fff;
  font-size: clamp(14px, 3.5vw, 15px);
  font-weight: 600;
  pointer-events: none;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.status-icons {
  display: flex;
  align-items: center;
  gap: clamp(4px, 1vw, 6px);
}

.status-icons svg {
  width: auto;
  height: clamp(10px, 2.8vw, 11px);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.25));
}

.alert-box {
  width: 100%;
  max-width: var(--alert-max-width);
  display: flex;
  flex-direction: column;
  background: rgba(242, 242, 247, 0.94);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border-radius: var(--alert-radius);
  overflow: hidden;
  box-shadow:
    0 0 0 0.5px rgba(255, 255, 255, 0.55) inset,
    0 10px 40px rgba(0, 0, 0, 0.28);
}

.alert-icon {
  display: flex;
  justify-content: center;
  padding-top: 18px;
}

.alert-icon svg {
  width: var(--alert-icon-size);
  height: var(--alert-icon-size);
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.12));
}

.alert-body {
  padding: 14px 16px 16px;
  text-align: center;
  overflow-y: auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.alert-body.has-icon {
  padding-top: 8px;
}

.alert-title {
  font-size: var(--alert-title-size);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.41px;
  color: #000;
  overflow-wrap: break-word;
}

.alert-message {
  font-size: var(--alert-message-size);
  line-height: 1.42;
  letter-spacing: -0.08px;
  color: #000;
  margin-top: 6px;
  overflow-wrap: break-word;
  white-space: pre-wrap;
}

.alert-phone {
  margin-top: 10px;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.2px;
  color: #000;
}

.alert-actions {
  flex-shrink: 0;
  border-top: 0.5px solid var(--ios-separator);
}

.alert-actions .alert-btn + .alert-btn {
  border-top: 0.5px solid var(--ios-separator);
}

.alert-btn {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: var(--alert-btn-padding);
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: var(--alert-btn-size);
  font-weight: 400;
  letter-spacing: -0.41px;
  color: var(--ios-blue);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.alert-btn:active {
  background: rgba(0, 0, 0, 0.06);
}

@media (hover: hover) and (pointer: fine) {
  .alert-btn:hover {
    background: rgba(0, 0, 0, 0.04);
  }
}

.alert-btn.bold {
  font-weight: 600;
}

#alert-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
}

.alert-layer {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  padding:
    calc(var(--alert-layer-padding) + var(--safe-top))
    calc(var(--alert-layer-padding) + var(--safe-right))
    calc(var(--alert-layer-padding) + var(--safe-bottom))
    calc(var(--alert-layer-padding) + var(--safe-left));
}

.alert-backdrop {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.28s ease;
  background: rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(20px) saturate(120%);
  -webkit-backdrop-filter: blur(20px) saturate(120%);
}

.alert-layer:nth-child(n+2) .alert-backdrop {
  background: rgba(0, 0, 0, 0.1);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.alert-layer.visible .alert-backdrop {
  opacity: 1;
}

.alert-layer {
  --offset-x: 0;
  --offset-y: 0;
}

.alert-layer .alert-box {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - var(--alert-layer-padding) * 2);
  overflow: hidden;
  transform: scale(1.08) translate(calc(var(--offset-x) * 1px), calc(var(--offset-y) * 1px));
  opacity: 0;
  transition:
    transform 0.32s cubic-bezier(0.22, 1.15, 0.36, 1),
    opacity 0.22s ease;
}

.alert-layer.visible .alert-box {
  transform: scale(1) translate(calc(var(--offset-x) * 1px), calc(var(--offset-y) * 1px));
  opacity: 1;
}

.alert-layer.vibrating .alert-box {
  animation: alert-vibrate 0.26s ease-out;
}

@keyframes alert-vibrate {
  0%, 100% {
    transform: scale(1) translate(calc(var(--offset-x) * 1px), calc(var(--offset-y) * 1px));
  }
  20% {
    transform: scale(1) translate(calc(var(--offset-x) * 1px + 1.3px), calc(var(--offset-y) * 1px));
  }
  40% {
    transform: scale(1) translate(calc(var(--offset-x) * 1px - 1.1px), calc(var(--offset-y) * 1px + 0.4px));
  }
  60% {
    transform: scale(1) translate(calc(var(--offset-x) * 1px + 0.7px), calc(var(--offset-y) * 1px));
  }
  80% {
    transform: scale(1) translate(calc(var(--offset-x) * 1px - 0.35px), calc(var(--offset-y) * 1px));
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  :root {
    --alert-layer-padding: 12px;
    --alert-icon-size: 28px;
  }

  .alert-icon {
    padding-top: 10px;
  }

  .alert-body {
    padding: 10px 14px 12px;
  }

  .alert-btn {
    min-height: 40px;
    padding: 8px;
  }

  .ios-status-bar {
    padding-top: calc(4px + var(--safe-top));
    font-size: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ios-wallpaper {
    filter: none;
    transform: none;
  }

  .alert-backdrop,
  .alert-layer .alert-box {
    transition: none;
  }

  .alert-layer.vibrating .alert-box {
    animation: none;
  }
}
