* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --cp-space-bg: #2d165d;
    --cp-space-panel: #4d236d;
    --cp-space-muted: #8c76d2;
    --cp-space-card-top: 125px;
}

html,
body {
    margin: 0;
    width: 100%;
    min-height: 100%;
    overflow-x: hidden;
    background: var(--cp-space-bg);
    color: #fff;
    font-family:
        'Source Han Sans SC', 'Noto Sans CJK SC', Arial, 'Helvetica Neue',
        Helvetica, sans-serif;
}

button {
    border: 0;
    padding: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

.app-shell {
    width: 100%;
    max-width: 768px;
    min-height: 100vh;
    margin: 0 auto;
    background: var(--cp-space-bg);
}

.cp-space {
    position: relative;
    width: min(100vw, 768px);
    min-height: 100vh;
    margin: 0 auto;
    overflow: hidden;
    background: var(--cp-space-bg);
}

.cp-space::before,
.cp-space::after {
    position: absolute;
    inset: 0;
    pointer-events: none;
    content: '';
}

.cp-space::before {
    z-index: 0;
    background: url('./assets/space-bg@4x.webp') center top / 100% auto repeat-y;
}

.cp-space::after {
    display: none;
}

.top-nav {
    position: relative;
    z-index: 2;
    height: 44px;
}

.back-button {
    position: absolute;
    left: 16px;
    top: 10px;
    width: 24px;
    height: 24px;
}

.back-button span {
    position: absolute;
    left: 8px;
    top: 5px;
    width: 10px;
    height: 10px;
    border-left: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(45deg);
}

.top-nav h1 {
    position: absolute;
    left: 50%;
    top: 12px;
    margin: 0;
    color: #fff;
    font-size: 18px;
    font-weight: 500;
    line-height: 20px;
    letter-spacing: 0;
    text-align: center;
    transform: translateX(-50%);
}

.tab-bar {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    align-items: center;
    width: calc(100% - 32px);
    max-width: 343px;
    height: 47px;
    margin: 16px auto 0;
    padding: 0;
    border-radius: 27.5px;
    background: var(--cp-space-panel);
}

.tab-button {
    position: relative;
    height: 47px;
    color: var(--cp-space-muted);
    font-size: 18px;
    font-weight: 500;
    line-height: 18px;
    letter-spacing: 0;
    text-align: center;
}

.tab-button span {
    position: relative;
    z-index: 1;
}

.tab-button.is-active {
    color: #fff;
}

.tab-button.is-active::before {
    position: absolute;
    left: 50%;
    top: 0;
    width: min(130px, calc(100% + 16px));
    height: 47px;
    background: url('./assets/tab-active.png') center / 100% 100% no-repeat;
    content: '';
    transform: translateX(-50%);
}

.content-panel {
    position: relative;
    z-index: 2;
    width: 100%;
    padding: 18px 10px 40px;
}

.relation-list {
    display: grid;
    gap: 10px;
    justify-items: center;
    width: 100%;
}

.relation-card {
    position: relative;
    width: min(355px, calc(100vw - 20px));
    aspect-ratio: 355 / 203;
    color: #ff0979;
    --heart-size: 33.8%;
    --button-width: 35.8%;
    --button-height: 14.8%;
    --accent-color: #ff0979;
    --accent-shadow: rgba(110, 17, 108, 0.75);
    --avatar-y: 6.9%;
    --heart-y: 2.5%;
    --button-y: 73.9%;
    border-radius: 10px;
    isolation: isolate;
}

.relation-card[data-level='2'] {
    --accent-color: #0967ff;
    --heart-size: 33.8%;
    --button-width: 35.8%;
    --button-height: 18.7%;
}

.relation-card[data-level='3'] {
    --accent-color: #7c09ff;
    --heart-size: 40.6%;
    --button-width: 45.9%;
    --button-height: 17.2%;
    --avatar-y: 9.9%;
    --heart-y: 0;
    --button-y: 76.4%;
}

.relation-card[data-level='4'] {
    --accent-color: #ff090d;
    --heart-size: 37.7%;
    --button-width: 36.6%;
    --button-height: 20.7%;
}

.relation-card[data-level='5'] {
    --accent-color: #ff090d;
    --heart-size: 42.8%;
    --button-width: 37.5%;
    --button-height: 17.2%;
    --heart-y: 0;
    --button-y: 76.8%;
}

.relation-card-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 10px;
    object-fit: fill;
    user-select: none;
    -webkit-user-drag: none;
}

.relation-avatar {
    position: absolute;
    z-index: 2;
    top: var(--avatar-y);
    width: 28.7%;
    aspect-ratio: 1;
    margin: 0;
}

.relation-avatar--left {
    left: 5.1%;
}

.relation-avatar--right {
    right: 5.1%;
}

.relation-avatar-photo,
.relation-avatar-frame {
    position: absolute;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
}

.relation-avatar-photo {
    left: 21.6%;
    top: 17.6%;
    z-index: 1;
    width: 56.9%;
    aspect-ratio: 1;
    border-radius: 50%;
    object-fit: cover;
}

.relation-avatar-photo--placeholder {
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #f65ca8, #7631dc);
    color: #fff;
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
}

.relation-avatar-frame {
    inset: 0;
    z-index: 2;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.relation-name {
    position: absolute;
    z-index: 3;
    top: 67%;
    width: 84%;
    overflow: hidden;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 14px;
    text-align: center;
    text-overflow: ellipsis;
    text-shadow: 0 1px 4px rgba(93, 23, 88, 0.75);
    white-space: nowrap;
}

.relation-name--left {
    left: 8%;
}

.relation-name--right {
    right: 8%;
}

.relation-heart-art {
    position: absolute;
    z-index: 1;
    left: 50%;
    top: var(--heart-y);
    display: block;
    width: var(--heart-size);
    aspect-ratio: 1;
    object-fit: contain;
    transform: translateX(-50%);
    user-select: none;
    -webkit-user-drag: none;
}

.relation-days {
    position: absolute;
    z-index: 2;
    left: 50%;
    top: 23.5%;
    display: flex;
    align-items: baseline;
    justify-content: center;
    width: 28%;
    height: 14%;
    color: #fff;
    text-align: center;
    text-shadow:
        0 1px 0 var(--accent-color),
        0 2px 7px var(--accent-shadow);
    transform: translateX(-50%);
}

.relation-days strong {
    font-size: 20px;
    font-weight: 800;
    line-height: 20px;
}

.relation-days span {
    margin-left: 3px;
    font-size: 10px;
    font-weight: 700;
    line-height: 12px;
}

.relation-level {
    position: absolute;
    z-index: 2;
    top: 55.6%;
    width: 8.45%;
    aspect-ratio: 30 / 16;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    text-align: center;
}

.relation-level--current {
    left: 8.45%;
}

.relation-level--next {
    right: 8.45%;
}

.relation-level img {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
}

.relation-level span {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    text-shadow: 0 0 1px #fc8ab1;
}

.relation-progress {
    position: absolute;
    z-index: 2;
    left: 19.15%;
    top: 58.1%;
    width: 62%;
    height: 3%;
    overflow: hidden;
    border-radius: 999px;
}

.relation-progress span {
    position: absolute;
    left: 0;
    top: 0;
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    overflow: hidden;
}

.relation-progress-track,
.relation-progress-fill {
    position: absolute;
    left: 0;
    top: 0;
    display: block;
    width: 100%;
    height: 100%;
    user-select: none;
    -webkit-user-drag: none;
}

.relation-progress-fill {
    width: auto;
    min-width: 100%;
}

.relation-exp {
    position: absolute;
    z-index: 2;
    left: 25%;
    top: 62.6%;
    width: 50%;
    overflow: hidden;
    color: var(--accent-color);
    font-size: 11px;
    font-weight: 700;
    line-height: 14px;
    text-align: center;
    text-overflow: ellipsis;
    text-shadow: 0 0 1px rgba(255, 255, 255, 0.72);
    white-space: nowrap;
}

.cancel-button {
    position: absolute;
    z-index: 3;
    left: 50%;
    top: var(--button-y);
    width: var(--button-width);
    height: var(--button-height);
    color: var(--accent-color);
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    text-shadow: 0 0 1px rgba(255, 255, 255, 0.8);
    transform: translateX(-50%);
}

.cancel-button-art {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    user-select: none;
    -webkit-user-drag: none;
}

.cancel-button span {
    position: relative;
    z-index: 1;
}

.cancel-button:disabled {
    opacity: 0.7;
    cursor: wait;
}

.empty-state {
    width: min(355px, calc(100vw - 20px));
    margin: 0 auto;
    padding: 56px 18px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    background: rgba(77, 35, 109, 0.68);
    color: rgba(255, 255, 255, 0.72);
    font-size: 14px;
    line-height: 20px;
    text-align: center;
}

.empty-state--button {
    display: block;
    cursor: pointer;
}

[dir='rtl'] .back-button span {
    transform: rotate(225deg);
}

@media (min-width: 769px) {
    .cp-space {
        width: 768px;
    }

    .content-panel {
        padding-right: 206px;
        padding-left: 206px;
    }
}
