:root {
    --gap: 1rem;
    --item-size: 150px;
    --red: #c8000f;
    --icon-size: 7rem;
    --purple: #414293;
}

body {
    background-color: #fde;
    margin: 0;
    padding: 0;
    font-family: 'Noto Serif JP', serif;
    font-optical-sizing: auto;
}

body r {
    color: var(--red);
    cursor: inherit;
}

* {
    transition: all 0.2s ease-in-out;
    cursor: default;
    user-select: none;
}

#question-text {
    user-select: text;
}

#app {
    width: calc(100% - 2rem);
    margin: 1rem;
    display: flex;
}

.hidden {
    display: none !important;
}

#result,
#quiz {
    flex-grow: 1;
    padding-left: 2rem;
    text-align: center;
    position: relative;
}

h1.title {
    position: relative;
    text-align: center;
    font-size: 2rem;
    margin: 0;
    margin-bottom: 0.5rem;
}

h1.title:before,
h1.title:after {
    content: '';
    display: block;
    width: calc(100% / 2 - 10rem);
    height: 4px;
    background: var(--purple);
    top: 50%;
    position: absolute;
}

h1.title:before {
    left: 0;
}

h1.title:after {
    right: 0;
}

#characters {
    width: calc((var(--item-size) + var(--gap) * 2) * 4);
    min-width: 46rem;
}

#characters > .item {
    display: inline-block;
    margin: var(--gap);
    position: relative;
    width: var(--item-size);
    height: calc(var(--item-size) / 3 * 2);
    cursor: pointer;
}

#characters > .item:not(.active) img {
    filter: grayscale(0.7);
}

#characters > .item.active img,
#characters > .item:hover img {
    transform: translate(-50%, -50%) scale(1.15);
    filter: grayscale(0);
}

#characters > .item:nth-of-type(7n + 5):nth-of-type(-n + 15) {
    margin-left: calc(var(--gap) + var(--item-size) / 2);
}

#characters > .item img {
    width: var(--item-size);
    position: relative;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    cursor: pointer;
}

#rank-section,
#hidden-message {
    position: relative;
    min-width: 25rem;
    max-width: 36rem;
    margin: auto;
}

img {
    pointer-events: none;
}

#rank-img {
    height: 20%;
    position: absolute;
    top: 60%;
    left: 37.5%;
}

#result-text {
    width: calc(100% / 6);
    position: absolute;
    top: 11%;
    right: 13.8%;
    color: #fff;
    font-size: clamp(3rem, 4vw, 3.5rem);
}

.rank-icon {
    width: var(--icon-size);
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
}

#rank-icon-left {
    left: calc(var(--icon-size) * -1.1);
    animation: floating 3s ease-in-out infinite alternate;
}

#rank-icon-right {
    right: calc(var(--icon-size) * -1.1);
    animation: floating 3s ease-in-out infinite alternate-reverse;
}

#initial-text {
    width: 80%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--purple);
    font-size: 2rem;
    opacity: 0;
}

#result-img {
    width: 100%;
}

.result-data {
    opacity: 0;
}

.result-data:nth-of-type(n + 2) {
    margin-top: 1rem;
}

#progress {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: auto;
}

#progress span {
    margin: 0.5rem 2rem;
}

.hexagon {
    --half-height: calc(var(--height) / 2);
    height: var(--height);
    clip-path: polygon(var(--half-height) 0, calc(100% - var(--half-height)) 0, 100% 50%, calc(100% - var(--half-height)) 100%, var(--half-height) 100%, 0 50%);
}

.rank-button {
    --height: 1.5rem;
    --width: 6rem;
    width: var(--width);
    display: inline-block;
    cursor: pointer;
    background-color: #aaa;
}

.rank-button.active,
.rank-button:hover {
    transform: scale(1.25);
    z-index: 1;
}

.rank-button:nth-of-type(n + 2) {
    margin-left: calc(var(--width) * -0.25);
}

.rank-button:nth-of-type(1) {
    background-color: #fff;
}

.rank-button:nth-of-type(2) {
    background-color: #d9d9e9;
}

.rank-button:nth-of-type(3) {
    background-color: #b3b3d4;
}

.rank-button:nth-of-type(4) {
    background-color: #8d8ebe;
}

.rank-button:nth-of-type(5) {
    background-color: #6768a9;
}

#hidden-message {
    overflow: hidden;
}

#hidden-img {
    width: 100%;
    position: relative;
}

#hidden-message.play #hidden-img {
    transition: all 0.2s ease-in-out, transform 20s ease-in-out;
    transform: rotate(5deg) scale(1.5);
    transform-origin: center 25%;
}

#hidden-message::before,
#hidden-message::after {
    content: '';
    display: block;
    width: 50%;
    height: 200%;
    position: absolute;
    top: -50%;
    background-color: rgba(0, 0, 0, 0.5);
    transform: rotate(0);
    transition: all 1s ease-in-out;
    z-index: 1;
}

#hidden-message.play::before,
#hidden-message.play::after {
    transform: rotate(90deg);
}

#hidden-message.play #hidden-message-play {
    visibility: hidden;
    opacity: 0;
}

.button {
    height: 3rem;
    background: #000;
    color: #fff;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease-in-out, opacity 1s ease-in-out, visibility 1s ease-in-out;
    box-shadow: 4px 4px 0 0 var(--red);
    cursor: pointer;
}

.button div {
    width: 90%;
    font-size: 1.25rem;
    border-left: 1px solid currentColor;
    border-right: 1px solid currentColor;
    cursor: pointer;
}

#question,
#quiz {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

#question-navigation {
    display: flex;
    position: relative;
    justify-content: space-between;
}

#question-navigation .button {
    width: calc(100% / 4);
}

#question-navigation .button.hidden {
    display: unset !important;
    visibility: hidden;
    opacity: 0;
    transition: all 0s ease-in-out;
}

#question-navigation .button:hover {
    transform: translate(4px, 4px);
    box-shadow: none;
}

#question-container {
    background: radial-gradient(ellipse at 50% 50%, #111 0%, var(--purple) 100%);
    height: 10rem;
    padding: 2rem;
    clip-path: polygon(2rem 0, 100% 0, 100% calc(100% - 2rem), calc(100% - 2rem) 100%, 0 100%, 0 2rem);
}

#question-text {
    color: #fff;
    text-align: left;
    font-size: 1.5rem;
}

#question-option-container {
    flex-grow: 1;
    align-items: center;
}

#question-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-gap: 1rem;
    padding: 1rem;
}

.question-option-button {
    display: flex;
    height: 3rem;
    align-items: center;
    background: #fff;
    cursor: pointer;
    padding: 1rem;
    color: var(--purple);
    border: 4px solid transparent;
}

.question-option-button.correct {
    background: #388e3c;
    color: #fff;
}

.question-option-button.incorrect {
    background: #e00;
    color: #fff;
}

.question-option-button.selected {
    border-color: var(--purple);
}

#result-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 70%;
    margin: 1rem auto;
}

#result-navigation .button {
    width: calc(100% / 2.5);
}

#question:not(.completed) #question-submit,
#question:not(.selected) #question-next,
#quiz:not(.submitted) #question-submit span,
#quiz:not(.submitted) + #result #result-navigation,
#quiz.submitted + #result #result-progress {
    display: none;
}

#hidden-message-play,
#quiz-start,
#quiz-skip {
    width: 18rem;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

#hidden-message-play:hover,
#quiz-start:hover,
#quiz-skip:hover {
    transform: translate(-50%, -50%) scale(1.1);
    box-shadow: 8px 8px 0 0 var(--red);
}

#quiz-option {
    border-bottom: 4px solid var(--purple);
}

#quiz-chara {
    max-width: 60%;
    margin-top: 2rem;
    margin-bottom: 2rem;
}

#quiz-start {
    top: calc(78% - 3rem);
}

#quiz-skip {
    top: calc(78% + 3rem);
}

#hidden-message::before {
    left: 0;
    transform-origin: top right;
}

#hidden-message::after {
    right: 0;
    transform-origin: bottom left;
}

.animate #initial-text {
    animation: fadeInOut 4s;
}

.animate .result-data {
    opacity: 1;
    animation: fadeIn 6s;
}

#question.animate {
    animation: fadeIn 0.5s;
}

@keyframes fadeInOut {
    0%,
    100% {
        opacity: 0;
    }

    30%,
    70% {
        opacity: 1;
        z-index: 999;
    }
}

@keyframes fadeIn {
    0%,
    66.6666% {
        opacity: 0;
    }

    100% {
        opacity: 1;
    }
}

@keyframes floating {
    0% {
        transform: translateY(-25%);
    }

    100% {
        transform: translateY(-75%);
    }
}
