*,
*::after,
*::before {
    box-sizing: border-box;
}

:root {
    font-size: 16px;
    --color-text: #000;
    --color-bg: #1e293b;
    --color-link: #888;
    --color-link-hover: #000;
}

body {
    margin: 0;
    color: var(--color-text);
    background-color: var(--color-bg);
    font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
}

/* Page Loader */
.js .loading::before,
.js .loading::after {
    content: "";
    position: fixed;
    z-index: 1000;
}

.js .loading::before {
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--color-bg);
}

.js .loading::after {
    top: 50%;
    left: 50%;
    width: 60px;
    height: 60px;
    margin: -30px 0 0 -30px;
    border-radius: 50%;
    opacity: 0.4;
    background: var(--color-link);
    animation: loaderAnim 0.7s linear infinite alternate forwards;
}

@keyframes loaderAnim {
    to {
        opacity: 1;
        transform: scale3d(0.5, 0.5, 1);
    }
}

a {
    text-decoration: none;
    color: var(--color-link);
    outline: none;
    cursor: pointer;
}

a:hover {
    color: var(--color-link-hover);
    outline: none;
}

/* Better focus styles from https://developer.mozilla.org/en-US/docs/Web/CSS/:focus-visible */
a:focus {
    /* Provide a fallback style for browsers
	 that don't support :focus-visible */
    outline: none;
    background: lightgrey;
}

a:focus:not(:focus-visible) {
    /* Remove the focus indicator on mouse-focus for browsers
	 that do support :focus-visible */
    background: transparent;
}

main {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.unbutton {
    background: none;
    border: 0;
    padding: 0;
    margin: 0;
    font: inherit;
    cursor: pointer;
}

.unbutton:focus {
    outline: none;
}

.frame {
    color: var(--color-title);
    padding: 1.5rem;
    display: grid;
    grid-template-columns: auto auto 1fr;
    grid-template-rows: auto;
    grid-template-areas: "title prev sponsor";
    justify-content: start;
    grid-gap: 2rem;
    z-index: 1000;
}

.frame a:not(.frame__title-back) {
    white-space: nowrap;
    overflow: hidden;
    position: relative;
}

.frame a:not(.frame__title-back)::before {
    content: "";
    height: 1px;
    width: 100%;
    background: currentColor;
    position: absolute;
    top: 90%;
    transition: transform 0.3s;
    transform-origin: 0% 50%;
}

.frame a:not(.frame__title-back):hover::before {
    transform: scaleX(0);
    transform-origin: 100% 50%;
}

.frame__title {
    grid-area: title;
    display: flex;
}

.frame__title-main {
    font-size: 1rem;
    margin: 0;
    font-weight: normal;
}

.frame__title-back {
    position: relative;
    display: flex;
    align-items: flex-end;
    margin-bottom: 0.15rem;
}

.frame__title-back span {
    display: none;
}

.frame__title-back svg {
    fill: currentColor;
}

.frame__prev {
    grid-area: prev;
}

.content {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

canvas {
    position: absolute;
    top: 0;
    left: 0;
}

.ui-controls {
    position: relative;
    width: 100%;
    font-family: inherit;
    user-select: none;
    line-height: 1.5;
    padding: 10px;
    pointer-events: none;
}

.ui-controls #roll-btn {
    background-color: #273e9a;
    font-weight: bold;
    color: #ffffff;
    border: none;
    padding: 1em 1.5em;
    border-radius: 1.5em;
    text-decoration: none;
    display: inline-block;
    cursor: pointer;
    margin: 0;
    transition: background-color 0.2s, transform 0.1s;
    pointer-events: auto;
}
.ui-controls #roll-btn:active {
    transform: translateY(2px);
}
.ui-controls #roll-btn:hover {
    background-color: #3737af;
}

#results {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap; /* Для того чтобы изображения располагались в строку или в несколько строк */
    margin-top: 20px;
}

.result-image {
    width: 60px; /* Настраиваем размер изображения */
    height: 60px;
    margin: 10px;
    border-radius: 6px;
    object-fit: cover; /* Чтобы изображение корректно отображалось */
}

/* POPUP */
#roll-btn {
    position: absolute;
    bottom: 10px;
    left: 10px;
    color: #fff;
    z-index: 50;
}
#settings-btn {
    position: absolute;
    bottom: 10px;
    right: 10px;
    color: #fff;
    z-index: 50;
}
#start-btn {
    margin-top: 20px;
}
#dice-popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    color: #fff;
    background-color: rgba(0, 18, 32, 0.9);
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.popup-content {
    padding: 20px;
    border-radius: 10px;
    text-align: center;
}

.dice-option {
    display: inline-block;
    padding: 10px;
    margin: 5px;
    cursor: pointer;
    color: #001220;
    font-weight: bold;
    border-radius: 5px;
    background-color: #fff;
    opacity: 0.5;
    transition: background-color 0.3s;
}

.dice-option.active {
    opacity: 1;
}
