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

:root {
    --incoming-gap-x: 12px;
    --safe-top: 48px;
    --statusbar-h: 30px;
    --action-row-bottom: calc(100px + env(safe-area-inset-bottom, 20px));
    --key-size: 84px;
    --key-gap-x: 24px;
    --key-gap-y: 14px;
    --ios-bg-light: #fff;
    --ios-bg-dark: #353535;
    --ios-text-dark: #000;
    --ios-text-light: #fff;
    --ios-key-bg: #f2f2f7;
    --ios-key-bg-hover: #e5e5ea;
    --ios-key-bg-active: #d1d1d6;
    --ios-green: #34c759;
    --ios-green-hover: #30b254;
    --ios-red: #ff3b30;
    --ios-red-hover: #d70015;
    --chip-bg: rgba(120, 120, 128, 0.25);
    --chip-bg-hover: rgba(120, 120, 128, 0.36);
    --space-bg: #04050a;
    --star-color: rgba(255, 255, 255, 0.9);
}

@media (prefers-color-scheme: light) {
    :root {
        --space-bg: #f5f5f7;
        --star-color: rgba(0, 0, 0, 0.85);
    }
}

html,
body {
    overflow: hidden !important;
    touch-action: manipulation;
    height: 100%;
    position: fixed;
    width: 100%;
}

body {
    background: var(--space-bg);
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 72px 32px;
    font-family:
        -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
        "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    position: relative;
}

#starfield {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    pointer-events: none;
}

.iphone-x {
    position: absolute;
    width: 375px;
    height: 812px;
    border-radius: 68px;
    padding: 14px;
    background: #252525;
    box-shadow:
        0 24px 60px rgba(0, 0, 0, 0.45),
        inset 0 0 0 2px rgba(255, 255, 255, 0.04),
        inset 0 0 18px rgba(0, 0, 0, 0.6);
    outline: 1px solid rgba(255, 255, 255, 0.04);
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

.btn {
    position: absolute;
    background: #252525;
    border-radius: 6px;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.06),
        inset 0 -1px 0 rgba(0, 0, 0, 0.4);
}

.btn--volume-up {
    left: -3px;
    top: 136px;
    width: 5px;
    height: 72px;
}

.btn--volume-down {
    left: -3px;
    top: 212px;
    width: 5px;
    height: 72px;
}

.btn--sleep {
    right: -3px;
    top: 176px;
    width: 5px;
    height: 94px;
}

.iphone-x__bezel {
    width: 100%;
    height: 100%;
    border-radius: 54px;
    background: #000;
    position: relative;
    box-shadow:
        inset 0 0 20px rgba(0, 0, 0, 0.65),
        inset 0 0 0 1px rgba(255, 255, 255, 0.03);
    overflow: hidden;
}

.notch {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 210px;
    height: 32px;
    background: #252525;

    border-bottom-left-radius: 18px;
    border-bottom-right-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 28px;
    z-index: 20;
}

.notch__speaker {
    width: 60px;
    height: 6px;
    background: #1a1a1a;
    border-radius: 3px;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.06),
        inset 0 -1px 0 rgba(0, 0, 0, 0.5);
}

.notch__camera {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%,
            #3aa3ff 0,
            #0a3b66 40%,
            #000 60%);
    box-shadow:
        0 0 0 2px #0b0b0b,
        inset 0 0 6px rgba(58, 163, 255, 0.5);
}

.phone-screen {
    position: absolute;
    inset: 0;
    border-radius: 54px;
    overflow: hidden;
    background: #252525;
    z-index: 5;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

.status-bar {
    height: var(--statusbar-h);
    padding: 0 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    z-index: 10;
    margin-top: var(--safe-top);
    transition:
        background-color 0.3s ease,
        color 0.3s ease;
    -webkit-font-smoothing: antialiased;
    font-smooth: always;
}

.status-bar.light {
    background: var(--ios-bg-light);
    color: var(--ios-text-dark);
}

.status-bar.dark {
    background: var(--ios-bg-dark);
    color: var(--ios-text-light);
}

.sb-icon,
.battery,
.battery * {
    color: currentColor;
}

.status-bar .bars rect {
    fill: currentColor;
}

.battery-svg .fill {
    fill: currentColor;
    opacity: 0.9;
    transition:
        width 0.25s ease,
        fill 0.25s ease,
        opacity 0.25s ease;
}

.battery-svg {
    width: 20px;
    height: 12px;
    display: inline-block;
    vertical-align: middle;
}

.status-bar.light .battery-svg rect:first-child {
    stroke: #000 !important;
}

.status-bar.dark .battery-svg rect:first-child {
    stroke: #fff !important;
}

.time {
    font-size: 17px;
    letter-spacing: -0.3px;
}

.sb-right {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.sb-icon.bars {
    width: 16px;
    height: 16px;
    opacity: 0.9;
}

.sb-icon.lte {
    min-width: 16px;
    text-align: right;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.battery {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.battery-perc {
    font-size: 12px;
    opacity: 0.9;
    font-variant-numeric: tabular-nums;
}

.screen-content {
    height: calc(100% - 44px + 1px);
    margin-top: -1px;
    position: relative;
    overflow: hidden;
}

.view {
    position: absolute;
    inset: 0;
    opacity: 0;
    visibility: hidden;
    display: flex;
    flex-direction: column;
    background: #fff;
    transition: opacity 0.2s ease-in-out;
    pointer-events: none;
}

.view.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.view-in-call,
.view-incoming {
    background: var(--ios-bg-dark);
    color: var(--ios-text-light);
}

.view-dialer {
    padding: 24px 20px calc(var(--action-row-bottom) + var(--key-size) + 24px);
    gap: 16px;
    background: var(--ios-bg-light);
    color: var(--ios-text-dark);
}

.dialer-header {
    text-align: center;
    margin-top: 8px;
}

.dialer-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--ios-text-dark);
    margin: 6px 0 16px;
}

.number-display {
    min-height: 56px;
    display: grid;
    place-items: center;
}

.number-text {
    font-size: 34px;
    font-weight: 300;
    color: var(--ios-text-dark);
    letter-spacing: 2px;
    font-family:
        "SF Pro Text",
        "SF Mono",
        ui-monospace,
        Menlo,
        monospace,
        -apple-system,
        BlinkMacSystemFont;
}

.number-text:empty::before {
    content: "Введите номер";
    color: #8e8e93;
    font-size: 18px;
    letter-spacing: 0;
}

.keypad {
    display: grid;
    grid-template-columns: repeat(3, var(--key-size));
    grid-auto-rows: var(--key-size);
    gap: var(--key-gap-y) var(--key-gap-x);
    width: calc(var(--key-size) * 3 + var(--key-gap-x) * 2);
    margin: 0 auto;
    justify-content: center;
    pointer-events: auto;
    z-index: 5;
}

.key {
    width: var(--key-size);
    height: var(--key-size);
    border-radius: 50%;
    border: none;
    background: var(--ios-key-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition:
        transform 0.08s ease,
        background 0.08s ease;
    cursor: pointer;
}

.key:hover {
    background: var(--ios-key-bg-hover);
}

.key:active {
    transform: scale(0.95);
    background: var(--ios-key-bg-active);
}

.digit {
    font-size: 36px;
    font-weight: 200;
    line-height: 1;
    color: var(--ios-text-dark);
    font-family:
        "SF Pro Display",
        -apple-system,
        BlinkMacSystemFont,
        system-ui,
        Arial,
        sans-serif;
}

.letters {
    font-size: 11px;
    color: #8e8e93;
    letter-spacing: 0.5px;
    margin-top: 2px;
    text-transform: uppercase;
    font-family:
        "SF Pro Text",
        -apple-system,
        BlinkMacSystemFont,
        system-ui,
        Arial,
        sans-serif;
}

.dialer-actions {
    position: absolute;
    bottom: var(--action-row-bottom);
    left: 50%;
    transform: translateX(-50%);
    display: grid;
    grid-template-columns: repeat(3, var(--key-size));
    column-gap: var(--key-gap-x);
    width: calc(var(--key-size) * 3 + var(--key-gap-x) * 2);
    justify-content: center;
    align-items: center;
    z-index: 5;
    pointer-events: auto;
}

.call-button {
    grid-column: 2;
}

.backspace-button {
    grid-column: 3;
}

.call-button,
.backspace-button {
    width: var(--key-size);
    height: var(--key-size);
    border-radius: 50%;
    border: none;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition:
        transform 0.1s ease,
        background 0.1s ease;
}

.call-button {
    background: var(--ios-green);
}

.call-button:hover {
    background: var(--ios-green-hover);
    transform: scale(1.05);
}

.call-button:active {
    transform: scale(0.95);
}

.backspace-button {
    background: var(--ios-key-bg);
}

.backspace-button:hover {
    background: var(--ios-key-bg-hover);
}

.backspace-button:active {
    transform: scale(0.95);
}

.call-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding-top: 32px;
    flex: 0 0 auto;
}

.contact-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: #110c1d;
    display: grid;
    place-items: center;
    overflow: hidden;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
    margin-bottom: 20px;
    pointer-events: none !important;
    z-index: 1;
}

.contact-avatar .avatar-visual {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: grid;
    place-items: center;
    backface-visibility: hidden;
    will-change: transform;
    pointer-events: none;
}

.contact-avatar .avatar-visual .plasma {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    box-shadow:
        inset 0 0 8px rgba(255, 255, 255, 0.15),
        0 0 10px rgba(58, 121, 255, 0.25);
    pointer-events: none;
}

.contact-name {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 4px;
}

.call-status {
    font-size: 18px;
    opacity: 0.85;
}

.call-timer {
    font-size: 16px;
    margin-top: 6px;
    color: #fff;
    font-variant-numeric: tabular-nums;
}

.call-controls {
    padding: 16px 12px 0;
    display: flex;
    flex-direction: column;
    gap: 38px;
    flex: 0 0 auto;
    padding-bottom: calc(var(--action-row-bottom) + var(--key-size) + 28px);
}

.controls-row {
    display: flex;
    justify-content: center;
    gap: 28px;
}

.control-btn {
    position: relative;
    overflow: visible;
    width: var(--key-size);
    height: var(--key-size);
    border-radius: 50%;
    border: none;
    background: var(--chip-bg);
    color: #fff;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition:
        transform 0.1s ease,
        background 0.1s ease;
}

.control-btn:hover {
    background: var(--chip-bg-hover);
    transform: scale(1.05);
}

.control-btn:active {
    transform: scale(0.95);
}

.control-btn svg {
    width: 32px;
    height: 32px;
    fill: none;
    stroke: #fff;
    stroke-width: 2;
    display: inline-block;
}

.control-btn .btn-text {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.2px;
    line-height: 1.2;
    color: #fff;
    opacity: 0.95;
    white-space: nowrap;
    pointer-events: none;
}

.view-in-call::before,
.view-incoming::before {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: max(20px, env(safe-area-inset-bottom, 20px));
    background: var(--ios-bg-dark);
    pointer-events: none;
    z-index: 0;
}

.view-in-call .call-actions-bottom {
    position: absolute;
    bottom: var(--action-row-bottom);
    left: 50%;
    transform: translateX(-50%);
    display: grid;
    grid-template-columns: repeat(3, var(--key-size));
    column-gap: var(--key-gap-x);
    width: calc(var(--key-size) * 3 + var(--key-gap-x) * 2);
    justify-content: center;
    align-items: center;
    z-index: 3;
}

.end-call-button {
    grid-column: 2;
    width: var(--key-size);
    height: var(--key-size);
    border-radius: 50%;
    border: none;
    display: grid;
    place-items: center;
    background: var(--ios-red);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
    cursor: pointer;
    transition:
        transform 0.1s ease,
        background 0.1s ease;
}

.end-call-button:hover {
    background: var(--ios-red-hover);
    transform: scale(1.05);
}

.end-call-button:active {
    transform: scale(0.95);
}

.view-incoming .call-info {
    padding-top: 24px;
    margin-bottom: 10px;
    z-index: 1;
}

.incoming-actions {
    position: absolute;
    bottom: var(--action-row-bottom);
    left: 50%;
    transform: translateX(-50%);
    display: grid;
    grid-template-columns: repeat(3, var(--key-size));
    column-gap: var(--incoming-gap-x);
    width: calc(var(--key-size) * 3 + var(--incoming-gap-x) * 2);
    align-items: center;
    z-index: 999;
    pointer-events: auto;
    opacity: 1;
    visibility: visible;
}

.incoming-actions .answer-button {
    grid-column: 3;
}

.incoming-actions .decline-button {
    grid-column: 1;
}

.decline-button,
.answer-button {
    width: var(--key-size);
    height: var(--key-size);
    border-radius: 50%;
    border: none;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition:
        transform 0.1s ease,
        background 0.1s ease;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transform: translateZ(0);
    will-change: transform;
    backface-visibility: hidden;
}

.decline-button {
    background: var(--ios-red);
}

.decline-button:hover {
    background: var(--ios-red-hover);
    transform: translateZ(0) scale(1.05);
}

.decline-button:active {
    transform: translateZ(0) scale(0.95);
}

.answer-button {
    background: var(--ios-green);
}

.answer-button:hover {
    background: var(--ios-green-hover);
    transform: translateZ(0) scale(1.05);
}

.answer-button:active {
    transform: translateZ(0) scale(0.95);
}

.incoming-actions:hover,
.incoming-actions *:hover {
    opacity: 1 !important;
    visibility: visible !important;
}

@keyframes plasma-rotate {
    100% {
        transform: rotate(360deg);
    }
}

.contact-avatar .plasma .circle {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: grid;
    place-items: center;
}

.contact-avatar .plasma .circle:nth-child(1) {
    transform: rotate(0deg) translate(38px);
}

.contact-avatar .plasma .circle:nth-child(2) {
    transform: rotate(36deg) translate(38px);
}

.contact-avatar .plasma .circle:nth-child(3) {
    transform: rotate(72deg) translate(38px);
}

.contact-avatar .plasma .circle:nth-child(4) {
    transform: rotate(108deg) translate(38px);
}

.contact-avatar .plasma .circle:nth-child(5) {
    transform: rotate(144deg) translate(38px);
}

.contact-avatar .plasma .circle:nth-child(6) {
    transform: rotate(180deg) translate(38px);
}

.contact-avatar .plasma .circle:nth-child(7) {
    transform: rotate(216deg) translate(38px);
}

.contact-avatar .plasma .circle:nth-child(8) {
    transform: rotate(252deg) translate(38px);
}

.contact-avatar .plasma .circle:nth-child(9) {
    transform: rotate(288deg) translate(38px);
}

.contact-avatar .plasma .circle:nth-child(10) {
    transform: rotate(324deg) translate(38px);
}

.contact-avatar .plasma .circle .dot {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    animation: plasma-rotate 5s linear infinite;
    pointer-events: none;
}

.contact-avatar .plasma .circle:nth-child(odd) .dot {
    animation-duration: 4.5s;
}

.contact-avatar .plasma .circle:nth-child(even) .dot {
    animation-duration: 5.5s;
}

.contact-avatar .plasma .circle .dot i {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    margin: auto;
    height: 80px;
    border-right: 2px dashed transparent;
    border-left: 1px dashed transparent;
    transform-origin: 50% 50%;
}

.contact-avatar .plasma .circle .dot:nth-child(1) i {
    transform: rotate(18deg) translate(38px);
    border-color: hsla(352.5, 100%, 50%, 1);
}

.contact-avatar .plasma .circle .dot:nth-child(2) i {
    transform: rotate(36deg) translate(38px);
    border-color: hsla(350, 100%, 50%, 1);
}

.contact-avatar .plasma .circle .dot:nth-child(3) i {
    transform: rotate(54deg) translate(38px);
    border-color: hsla(347.5, 100%, 50%, 1);
}

.contact-avatar .plasma .circle .dot:nth-child(4) i {
    transform: rotate(72deg) translate(38px);
    border-color: hsla(345, 100%, 50%, 1);
}

.contact-avatar .plasma .circle .dot:nth-child(5) i {
    transform: rotate(90deg) translate(38px);
    border-color: hsla(342.5, 100%, 50%, 1);
}

.contact-avatar .plasma .circle .dot:nth-child(6) i {
    transform: rotate(108deg) translate(38px);
    border-color: hsla(340, 100%, 50%, 1);
}

.contact-avatar .plasma .circle .dot:nth-child(7) i {
    transform: rotate(126deg) translate(38px);
    border-color: hsla(337.5, 100%, 50%, 1);
}

.contact-avatar .plasma .circle .dot:nth-child(8) i {
    transform: rotate(144deg) translate(38px);
    border-color: hsla(335, 100%, 50%, 1);
}

.contact-avatar .plasma .circle .dot:nth-child(9) i {
    transform: rotate(162deg) translate(38px);
    border-color: hsla(332.5, 100%, 50%, 1);
}

.contact-avatar .plasma .circle .dot:nth-child(10) i {
    transform: rotate(180deg) translate(38px);
    border-color: hsla(330, 100%, 50%, 1);
}

.contact-avatar .plasma .circle .dot:nth-child(11) i {
    transform: rotate(198deg) translate(38px);
    border-color: hsla(327.5, 100%, 50%, 1);
}

.contact-avatar .plasma .circle .dot:nth-child(12) i {
    transform: rotate(216deg) translate(38px);
    border-color: hsla(325, 100%, 50%, 1);
}

.contact-avatar .plasma .circle .dot:nth-child(13) i {
    transform: rotate(234deg) translate(38px);
    border-color: hsla(322.5, 100%, 50%, 1);
}

.contact-avatar .plasma .circle .dot:nth-child(14) i {
    transform: rotate(252deg) translate(38px);
    border-color: hsla(320, 100%, 50%, 1);
}

.contact-avatar .plasma .circle .dot:nth-child(15) i {
    transform: rotate(270deg) translate(38px);
    border-color: hsla(317.5, 100%, 50%, 1);
}

.contact-avatar .plasma .circle .dot:nth-child(16) i {
    transform: rotate(288deg) translate(38px);
    border-color: hsla(315, 100%, 50%, 1);
}

.contact-avatar .plasma .circle .dot:nth-child(17) i {
    transform: rotate(306deg) translate(38px);
    border-color: hsla(312.5, 100%, 50%, 1);
}

.contact-avatar .plasma .circle .dot:nth-child(18) i {
    transform: rotate(324deg) translate(38px);
    border-color: hsla(310, 100%, 50%, 1);
}

.contact-avatar .plasma .circle .dot:nth-child(19) i {
    transform: rotate(342deg) translate(38px);
    border-color: hsla(307.5, 100%, 50%, 1);
}

.contact-avatar .plasma .circle .dot:nth-child(20) i {
    transform: rotate(360deg) translate(38px);
    border-color: hsla(305, 100%, 50%, 1);
}

.iphone-x.shake {
    animation: shake-with-scale 0.15s ease-in-out infinite;
}

@keyframes shake-with-scale {

    0%,
    100% {
        transform: translate(-50%, -50%) scale(var(--scale, 1)) translateX(0);
    }

    25% {
        transform: translate(-50%, -50%) scale(var(--scale, 1)) translateX(-2px);
    }

    75% {
        transform: translate(-50%, -50%) scale(var(--scale, 1)) translateX(2px);
    }
}

.hidden {
    display: none !important;
}

.key:focus {
    outline: none;
}

.key:focus-visible {
    outline: 2px solid rgba(88, 86, 214, 0.6);
    outline-offset: 2px;
}

@media (max-width: 480px) {
    body {
        padding: 30px 20px;
    }
}

@media (481px <=width <=768px) {
    body {
        padding: 72px 28px;
    }
}

@media (min-width: 769px) {
    body {
        padding: 88px 36px;
    }
}

@media screen and (max-width: 350px) {
    body {
        padding: 24px 10px;
    }
}

/* Исправление масштабирования для мобильных */
@media (max-width: 768px) {
    body {
        padding: 20px;
    }
}

@media (max-height: 700px) {
    body {
        padding: 10px;
    }
}