:root {
    color-scheme: light;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    color: #514b44;
    background: #e8e0d1;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100svh;
    display: grid;
    place-items: center;
    padding: 36px 20px;
    background: #344e58 center / cover no-repeat;
}

main:has(pixiv-daily-ranking[data-view-mode="16:9"]) {
    --gallery-ratio: calc(16 / 9);
}

main:has(pixiv-daily-ranking[data-view-mode="4:3"]) {
    --gallery-ratio: calc(4 / 3);
}

main:has(pixiv-daily-ranking[data-view-mode="3:4"]) {
    --gallery-ratio: calc(3 / 4);
}

main {
    --gallery-ratio: calc(16 / 9);
    /* 为标题、页脚及四周留白预留高度，图片区域保持所选比例。 */
    --pixiv-view-max-width: max(1px, calc((100svh - var(--gallery-reserved-height, 284px)) * var(--gallery-ratio)));
    width: min(100%, 1280px, max(390px, calc(var(--pixiv-view-max-width) + 38px)));
}

@media (max-width: 540px) {
    main {
        --gallery-reserved-height: 332px;
    }
}

.hint, .credit {
    text-align: center;
    line-height: 1.8;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0, 0, 0, .85);
}

.hint {
    font-size: 13px;
    margin: 22px 0 5px;
}

.credit {
    font-size: 11px;
    margin: 0;
}

.wallpaper-credit {
    margin-top: 5px;
}

a {
    color: inherit;
    text-underline-offset: 3px;
}

a:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 4px;
}

::selection {
    color: #fff;
    background: #514b44;
}
