body {
    font-family: Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    background-color: #e6f3ff;
}

#app-container {
    position: relative;
    width: 100%;
    /* ǉ */
    height: 100vh;
    /* ǉ */
    max-width: 600px;
    /* ̒lΈێ */
    margin: 0 auto;
    /*  */
}

#close-fullscreen-button {
    margin: 0 auto;
}

#close-fullscreen-button:hover {
    background-color: rgba(0, 0, 0, 0.7);
}

#gacha-container {
    width: 100%;
    height: 100%;
    /* ǉ */
    margin: 0 auto;
    aspect-ratio: 1 / 1.5;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    background: transparent;
    /* ���S�ɓ��� */
    padding: 20px;
    border-radius: 10px;
    box-sizing: border-box;
}

#start-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#video-container {
    display: none;
    position: fixed;
    /* 画面全体に固定 */
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    margin: 0;
    z-index: 9999;
    /* 最前面 */
    background-color: black;
}

#video-wrapper {
    position: relative;
    display: grid;
    place-items: center;
    /* グリッドで完全中央揃え */
    width: 100%;
    height: 100%;
    padding: 0;
    pointer-events: none;
    /* 動画自体のクリック判定を無効化 */
}

#gacha-sparkle-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1003; /* above sr-special-overlay 1002 */
    background: transparent;
    display: none;
}

#video-container video {
    width: 100%;
    height: 100%;
    max-width: 100vw;
    max-height: 100vh;
    object-fit: contain;
}

#video-controls {
    text-align: center;
    position: absolute;
    bottom: 50px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    z-index: 2147483647;
    /* 最大値 */
    pointer-events: auto;
    /* ボタンのクリックのみ有効化 */
}

#gacha-result {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, calc(-50% - 8px));
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 10px;
    z-index: 10;
}

#gacha-result .collection-item {
    margin: 0;
}

#gacha-button,
#multi-gacha-button,
#collection-button {
    padding: 15px 30px;
    font-size: 1.25rem;
    margin: 10px auto;
    cursor: pointer;
    display: block;
    width: 100%;
    position: relative;
    color: white;
    border: none;
    border-radius: 5px;
    text-align: center;
    text-decoration: none;
    transition: background-color 0.4s;
    background-color: rgba(135, 206, 250, 0.8);
    /* ���������x�̂���w�i�F */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    /* �e��ǉ����ă{�^���𕂂��オ�点�� */
}

#gacha-button:hover,
#multi-gacha-button:hover,
#collection-button:hover {
    background-color: rgba(95, 158, 160, 0.9);
    /* �z�o�[���̐F�������Z������ */
}



#multi-gacha-result-overlay {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#multi-gacha-result-overlay img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}



.multi-gacha-control-button {
    padding: 10px 20px;
    font-size: 1rem;
    cursor: pointer;
    background-color: #87cefa;
    color: white;
    border: none;
    border-radius: 5px;
    transition: background-color 0.3s;
}

.multi-gacha-control-button:hover {
    background-color: #5f9ea0;
}

#multi-gacha-result {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.multi-gacha-result-row {
    display: flex;
    justify-content: center;
    gap: 10px;
    width: 100%;
}

.multi-gacha-result-item {
    position: relative;
    width: 30%;
    /* Flexible width (approx 1/3) */
    max-width: 120px;
    aspect-ratio: 1 / 1;
}

.multi-gacha-result-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* Prevent cutting off */
}

.multi-gacha-result-item .rarity-icon {
    position: absolute;
    bottom: 5px;
    left: 5px;
    width: 40px;
    height: 20px;
}

.multi-gacha-result-item .new-icon {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 40px;
    height: 40px;
}

/* #multi-gacha-bg-video removed */

.multi-result-wrapper {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.gacha-result-card-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.level-up-banner {
    text-align: center;
    pointer-events: none;
    animation: levelUpPop 0.45s cubic-bezier(0.34, 1.45, 0.64, 1) both;
    margin-bottom: 10px;
    z-index: 5;
}

.level-up-title {
    font-size: clamp(1.4rem, 5vw, 2rem);
    font-weight: 900;
    line-height: 1.1;
    color: #ffe033;
    -webkit-text-stroke: 2px #7a1f1f;
    paint-order: stroke fill;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.25));
}

.level-up-lv {
    font-size: clamp(1.2rem, 4.5vw, 1.75rem);
    font-weight: 900;
    line-height: 1.15;
    color: #ffe033;
    -webkit-text-stroke: 2px #7a1f1f;
    paint-order: stroke fill;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.25));
}

@keyframes levelUpPop {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }

    70% {
        opacity: 1;
        transform: scale(1.12);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.multi-result-button-wrapper {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
}

button {
    padding: 10px 20px;
    font-size: 1.25rem;
    cursor: pointer;
    z-index: 1000;
    background-color: #87cefa;
    color: white;
    border: none;
    border-radius: 5px;
    transition: background-color 0.4s;
}

button:hover {
    background-color: #5f9ea0;
}

#collection {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px 6px;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    margin-bottom: 0;
    padding: 8px 6px 12px;
    box-sizing: border-box;
    align-content: start;
    justify-items: center;
    -webkit-overflow-scrolling: touch;
}

/* コレクション画面のアイテムは常に3列・従来比約80%サイズ */
#collection .collection-item {
    position: relative;
    width: 80%;
    max-width: 80%;
    height: auto;
    aspect-ratio: 1 / 1;
    margin: 0;
    overflow: visible;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#collection .collection-item > img:not(.collection-rarity-icon):not(.collection-new-icon) {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* サムネ直下にレベルを近づけて、上下どちらの表記か分かりやすく */
#collection .collection-item .level {
    bottom: -4px;
    font-size: 11px;
    padding: 1px 4px;
    white-space: nowrap;
}

/* NEWマークは右上を維持しつつ、サムネ内側に少し入れてはみ出しを防ぐ */
#collection .collection-item .collection-new-icon {
    position: absolute !important;
    top: 4px !important;
    right: 4px !important;
    width: 26px !important;
    height: 26px !important;
    z-index: 11 !important;
}

.collection-item {
    position: relative;
    width: 140px;
    height: 140px;
    margin: 10px;
    overflow: visible;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.collection-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.collection-item .level {
    position: absolute;
    bottom: -24px;
    /* 摜̉4pẍʒu */
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
}

.collection-item .collection-new-icon {
    position: absolute !important;
    top: -15px !important;
    right: -15px !important;
    width: 30px !important;
    height: 30px !important;
    z-index: 11 !important;
}

#fullscreen-image {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.large-image-container {
    position: relative;
    max-width: 90%;
    max-height: 80%;
    margin-bottom: 20px;
}

.large-image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}


/* コメントは画像コンテナ上にオーバーレイ表示（ボタンは .image-controls の flex に載せる） */
#comment-box {
    position: absolute;
    bottom: 10px;
    left: 10px;
    right: 10px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px;
    border-radius: 5px;
    max-height: 30%;
    overflow-y: auto;
    z-index: 1;
}

.image-controls {
    position: fixed;
    bottom: 20px;
    left: 0;
    right: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    box-sizing: border-box;
}

.image-controls button {
    padding: 10px 20px;
    font-size: 1rem;
    cursor: pointer;
    background-color: rgba(135, 206, 250, 0.8);
    color: white;
    border: none;
    border-radius: 5px;
    transition: background-color 0.3s;
}

.image-controls button:hover {
    background-color: rgba(95, 158, 160, 0.9);
}

#show-comment-button,
#set-home-image-button,
#replay-sr-special-button {
    /* position は static（.image-controls の flex 子として配置） */
    position: static;
    padding: 10px 20px;
    font-size: 1rem;
    cursor: pointer;
    background-color: rgba(135, 206, 250, 0.8);
    color: white;
    border: none;
    border-radius: 5px;
    transition: background-color 0.3s;
}

#show-comment-button:hover,
#set-home-image-button:hover,
#replay-sr-special-button:hover {
    background-color: rgba(95, 158, 160, 0.9);
}

@media screen and (max-width: 600px) {
    .image-controls button,
    #show-comment-button,
    #set-home-image-button,
    #replay-sr-special-button {
        padding: 8px 12px;
        font-size: 0.875rem;
    }
}

#fullscreen-image img {
    max-width: 90%;
    max-height: 90%;
    width: auto;
    height: auto;
}

.gacha-icon {
    width: 1.5em;
    height: 1.5em;
    vertical-align: middle;
}

#skip-button,
#to-result-button,
#sr-special-close-button,
#back-button {
    padding: 10px 20px;
    font-size: 1.25rem;
    cursor: pointer;
    z-index: 1000;
    background-color: #87cefa;
    color: white;
    border: none;
    border-radius: 5px;
    transition: background-color 0.4s;
    margin: 5px;
    display: inline-block;
}

#skip-button:hover,
#to-result-button:hover,
#sr-special-close-button:hover,
#back-button:hover {
    background-color: #5f9ea0;
}

#result-container {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin-top: 20px;
}

#final-result-container {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    max-width: 600px;
    text-align: center;
    z-index: 1000;
    flex-direction: column;
    align-items: center;
}

#final-gacha-result {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin-bottom: 20px;
}

#final-gacha-result .collection-item {
    animation: dropIn 0.5s ease-out forwards;
    opacity: 0;
    margin: 0;
}

#final-result-container #back-button {
    display: block;
    margin: 10px auto 0;
}

#multi-gacha-result-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: calc(100% - 40px);
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    z-index: 20;
    background-color: rgba(255, 255, 255, 0.9);
    padding: 20px;
    box-sizing: border-box;
    border-radius: 10px;
}

.button-container {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

#multi-gacha-result {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 100%;
    gap: 10px;
}

.multi-gacha-result-row {
    display: flex;
    justify-content: center;
    gap: 10px;
    width: 100%;
}

.multi-gacha-result-row-1 {
    justify-content: center;
}

.multi-gacha-result-row-2 {
    justify-content: center;
}

.multi-result-row {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    /* KvɉĐ܂Ԃ */
    width: 100%;
    /* s̕Reiς */
}

.multi-result-item {
    width: 120px;
    /* TCY */
    height: 120px;
    position: relative;
    overflow: visible;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
    margin: 15px 5px;
    /* }[W𒲐 */
}

.multi-result-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.multi-result-row-2 {
    justify-content: center;
}

.multi-result-row-2 .multi-result-item {
    width: 96px;
    height: 96px;
}

.multi-result-item .collection-new-icon {
    position: absolute;
    top: -15px;
    right: -15px;
    width: 30px;
    height: 30px;
    z-index: 11;
}

.collection-item .collection-rarity-icon,
.multi-result-item .collection-rarity-icon,
#multi-gacha-result .collection-rarity-icon {
    position: absolute !important;
    bottom: 4px !important;
    left: 4px !important;
    width: 40px !important;
    height: 24px !important;
    z-index: 10 !important;
}

#multi-back-button {
    padding: 10px 20px;
    font-size: 1.25rem;
    cursor: pointer;
    background-color: #87cefa;
    color: white;
    border: none;
    border-radius: 5px;
    transition: background-color 0.4s;
}

#multi-back-button:hover {
    background-color: #5f9ea0;
}

.multi-result-item.sr-item::before,
#final-gacha-result .collection-item.sr-item::before {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    background: linear-gradient(45deg, #ffd700, #ffcc00, #ffd700);
    z-index: -1;
    filter: blur(10px);
    opacity: 0;
    animation: goldenGlow 2s infinite;
}

@keyframes goldenGlow {

    0%,
    100% {
        opacity: 0.5;
        filter: blur(10px) brightness(1);
    }

    50% {
        opacity: 1;
        filter: blur(15px) brightness(1.2);
    }
}

.multi-result-item.sr-item img,
#final-gacha-result .collection-item.sr-item img {
    animation: goldenImageGlow 2s infinite;
}

@keyframes goldenImageGlow {

    0%,
    100% {
        filter: drop-shadow(0 0 5px rgba(255, 215, 0, 0.7));
    }

    50% {
        filter: drop-shadow(0 0 15px rgba(255, 215, 0, 0.9));
    }
}

@keyframes fadeInFromWhite {
    from {
        filter: brightness(2) saturate(0);
    }

    to {
        filter: brightness(1) saturate(1);
    }
}

/* 通常はカラー表示。fade-in 時のみ白フラッシュ→カラーの演出 */
#gacha-bg-video {
    filter: brightness(1) saturate(1);
}

#gacha-bg-video.fade-in {
    animation: fadeInFromWhite 1s ease-out forwards;
}

@keyframes dropIn {
    0% {
        opacity: 0;
        transform: translateY(-50px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

#collection-container {
    display: none;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 600px;
    height: 100vh;
    max-height: 100vh;
    margin: 0 auto;
    padding: 12px 12px 0;
    box-sizing: border-box;
    overflow: hidden;
}

.collection-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    width: 100%;
    margin-top: 0;
    padding: 12px 0 calc(12px + env(safe-area-inset-bottom, 0px));
    background: rgba(230, 243, 255, 0.55);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.06);
    z-index: 50;
    position: relative;
}

#completion-rate,
.collection-container-header,
#collection-container .sort-control {
    flex-shrink: 0;
    width: 100%;
}

#back-to-gacha-button,
#clear-button,
#clear-home-image-button {
    padding: 10px 20px;
    font-size: 1.25rem;
    cursor: pointer;
    background-color: #87cefa;
    color: white;
    border: none;
    border-radius: 5px;
    transition: background-color 0.4s;
    width: 200px;
    max-width: 100%;
}

#back-to-gacha-button:hover,
#clear-button:hover,
#clear-home-image-button:hover {
    background-color: #5f9ea0;
}

.large-image-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    height: 80%;
    max-width: 90vw;
    max-height: 80vh;
    overflow: hidden;
    background-color: black;
}

#large-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transform-origin: center;
    touch-action: none;
}

.image-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}


#stone-counter,
#completion-rate {
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 10px;
}

#stone-counter {
    display: flex;
    align-items: center;
    justify-content: center;
}

#stone-counter .gacha-icon {
    margin-right: 5px;
}

.settings-icon {
    width: 30px;
    height: 30px;
    cursor: pointer;
    position: absolute;
    top: 10px;
    right: 10px;
}

#settings-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    width: 80%;
    /* ύX */
    max-width: 300px;
    /* ǉ */
}

#close-settings {
    margin-top: 20px;
}

.volume-control {
    margin-bottom: 20px;
}

#volume-slider {
    width: 200px;
    vertical-align: middle;
}

#volume-value {
    display: inline-block;
    width: 40px;
    text-align: right;
}

.movie-setting {
    margin-bottom: 20px;
}

#movie-toggle {
    margin-right: 10px;
}

#clear-data-button {
    margin-top: 20px;
    padding: 10px 20px;
    background-color: #ff4d4d;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

#clear-data-button:hover {
    background-color: #ff3333;
}

.spacer {
    height: 20px;
}

#multi-gacha-video-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    overflow: hidden;
}

#multi-gacha-video {
    position: absolute;
    width: 100vmin;
    /* ビューポートの短い方を基準に */
    height: 100vmin;
    /* アスペクト比を保持 */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    object-fit: contain;
    /* coverからcontainに変更 */
}

#multi-gacha-skip-button {
    margin-top: 10px;
    padding: 10px 20px;
    font-size: 1.25rem;
    cursor: pointer;
    background-color: #87cefa;
    color: white;
    border: none;
    border-radius: 5px;
    transition: background-color 0.4s;
}

#multi-gacha-skip-button:hover {
    background-color: #5f9ea0;
}

.multi-gacha-overlay-item {
    width: 120px;
    height: 120px;
    position: relative;
    overflow: visible;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
    margin: 15px 5px;
}

.multi-gacha-overlay-row-2 .multi-gacha-overlay-item {
    width: 144px;
    height: 144px;
}

.multi-result-row-2 .multi-gacha-overlay-item {
    width: 180px;
    height: 180px;
}

.multi-gacha-overlay-item img {
    width: 180px;
    /* I[o[C摜̃TCY */
    height: 180px;
}

@keyframes pulsate {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

#title-logo-wrap {
    position: relative;
    max-width: 80%;
    width: 100%;
    margin-bottom: 20px;
}

#title-logo {
    max-width: 100%;
    width: 100%;
    height: auto;
    display: block;
    animation: pulsate 2s ease-in-out infinite;
}

#app-version {
    position: absolute;
    right: 4%;
    bottom: 6%;
    color: #fff;
    font-size: clamp(0.95rem, 4.5vw, 1.25rem);
    font-weight: bold;
    line-height: 1;
    pointer-events: none;
    z-index: 2;
    -webkit-text-stroke: 2px #000;
    paint-order: stroke fill;
}

.main-button {
    padding: 15px 30px;
    font-size: 1.25rem;
    margin: 10px auto;
    cursor: pointer;
    display: block;
    width: 100%;
    max-width: 300px;
    /* {^̍ő啝ݒ */
    position: relative;
    color: white;
    border: none;
    border-radius: 5px;
    text-align: center;
    text-decoration: none;
    transition: background-color 0.4s;
    background-color: rgba(135, 206, 250, 0.8);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.main-button:hover {
    background-color: rgba(95, 158, 160, 0.9);
}

#mini-game-button {
    background-color: rgba(255, 165, 0, 0.8);
    /* : IW */
}

#mini-game-button:hover {
    background-color: rgba(255, 140, 0, 0.9);
}

#multi-back-button,
#back-to-gacha-button {
    position: relative;
    z-index: 1000;
}

/* コレクション画面は flex レイアウト（戻るを下に固定し、一覧だけスクロール） */
#collection-container.collection-open {
    display: flex;
}

#user-guide-button {
    background-color: #4CAF50;
    /* ΐF */
    color: white;
    padding: 15px 30px;
    font-size: 1.25rem;
    margin: 10px auto;
    cursor: pointer;
    display: block;
    width: 100%;
    max-width: 300px;
    border: none;
    border-radius: 5px;
    text-align: center;
    text-decoration: none;
    transition: background-color 0.4s;
}

#user-guide-button:hover {
    background-color: #45a049;
}

/* 動画コンテナの共通スタイル */
#video-container,
#multi-gacha-video-container,
#multi-gacha-bg-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    overflow: hidden;
}

/* 動画の共通スタイル（#video-container video より詳細度を上げて重ねる） */
#video-container #gacha-video,
#video-container #gacha-bg-video,
#gacha-video,
#multi-gacha-video,
#gacha-bg-video,
#multi-gacha-bg-video {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    max-width: 600px;
    /* アプリの最大幅に合わせる */
    max-height: 900px;
    /* アスペクト比を考慮 */
    object-fit: cover;
    z-index: 2;
}

/* モバイルデバイス用の調整 */
@media screen and (max-width: 600px) {

    #video-container #gacha-video,
    #video-container #gacha-bg-video,
    #gacha-video,
    #multi-gacha-video,
    #gacha-bg-video,
    #multi-gacha-bg-video {
        width: 100vw;
        height: 100vh;
        max-width: none;
        max-height: none;
    }
}

/* タブレットとデスクトップ用の調整 */
@media screen and (min-width: 601px) {

    #gacha-video,
    #multi-gacha-video,
    #gacha-bg-video,
    #multi-gacha-bg-video {
        width: 100%;
        height: 100%;
        max-width: 600px;
        max-height: 900px;
        margin: auto;
    }

    /* 1枚ずつ結果表示のサムネ（PCだと小さく感じるため拡大） */
    .multi-result-item {
        width: min(42vmin, 280px);
        height: min(42vmin, 280px);
    }

    .multi-result-item .collection-new-icon {
        top: -18px;
        right: -18px;
        width: 48px;
        height: 48px;
    }

    .multi-result-item .collection-rarity-icon {
        width: 56px !important;
        height: 34px !important;
        bottom: 8px !important;
        left: 8px !important;
    }

    #gacha-result .collection-item {
        width: min(42vmin, 280px);
        height: min(42vmin, 280px);
    }

    #gacha-result .collection-item .collection-new-icon {
        top: -18px !important;
        right: -18px !important;
        width: 48px !important;
        height: 48px !important;
    }

    #gacha-result .collection-item .collection-rarity-icon {
        width: 56px !important;
        height: 34px !important;
        bottom: 8px !important;
        left: 8px !important;
    }
}

/* 結果オーバーレイの共通スタイル */
#gacha-result,
#multi-gacha-result-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    z-index: 1001;
}

/* SR特別演出 */
#sr-special-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1002;
    pointer-events: none;
    background: transparent;
    transition: background-color 0.25s ease;
}

/* パン演出中は真っ白背景（bg動画は隠れる） */
#sr-special-overlay.is-white-bg {
    background: #ffffff;
}

.sr-zoom-stage {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: none;
    opacity: 0;
    transition: opacity 0.45s ease;
}

.sr-zoom-stage.is-visible {
    opacity: 1;
}

.sr-zoom-frame {
    width: 100%;
    height: 100%;
    background-repeat: no-repeat;
    background-size: 220%;
    border-radius: 0;
    box-shadow: none;
}

.sr-zoom-frame.zoom-br {
    background-position: 88% 92%;
}

.sr-zoom-frame.zoom-ml {
    background-position: 26% 48%;
}

.sr-zoom-frame.zoom-tr {
    background-position: 84% 14%;
}

/* アップ表示中の微スクロール（フェード＋ホールドに合わせる） */
.sr-zoom-frame.zoom-br.is-panning {
    animation: srPanBr 1.15s ease-out forwards;
}

.sr-zoom-frame.zoom-ml.is-panning {
    animation: srPanMl 1.15s ease-out forwards;
}

.sr-zoom-frame.zoom-tr.is-panning {
    animation: srPanTr 1.15s ease-out forwards;
}

@keyframes srPanBr {
    from {
        background-position: 98% 100%;
    }

    to {
        background-position: 88% 92%;
    }
}

@keyframes srPanMl {
    from {
        background-position: 12% 48%;
    }

    to {
        background-position: 26% 48%;
    }
}

@keyframes srPanTr {
    from {
        background-position: 96% 6%;
    }

    to {
        background-position: 84% 14%;
    }
}

.sr-full-stage {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

.sr-full-stage .level-up-banner {
    position: relative;
    z-index: 6;
    margin-bottom: 12px;
}

.sr-full-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: min(90vw, 520px);
    height: min(90vw, 520px);
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, rgba(255, 230, 120, 0.95) 0%, rgba(255, 180, 0, 0.55) 35%, rgba(255, 140, 0, 0) 70%);
    pointer-events: none;
    animation: srGlowPulse 2s ease-in-out infinite;
}

@keyframes srGlowPulse {
    0%,
    100% {
        opacity: 0.75;
        transform: translate(-50%, -50%) scale(1);
    }

    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.08);
    }
}

.sr-full-card {
    position: relative;
    width: min(72vw, 340px);
    max-height: 72vh;
    z-index: 1;
    transform: scale(4.2);
    opacity: 0;
}

.sr-full-card.sr-don-animate {
    animation: srDonShrink 0.42s cubic-bezier(0.15, 0.85, 0.35, 1) forwards;
}

.sr-full-card.sr-don-static {
    transform: scale(1);
    opacity: 1;
}

@keyframes srDonShrink {
    0% {
        transform: scale(4.2);
        opacity: 0.45;
    }

    /* 勢いよく縮んで 10% オーバーシュート */
    62% {
        transform: scale(0.9);
        opacity: 1;
    }

    /* すぐ正規サイズへ戻す */
    82% {
        transform: scale(1.02);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.sr-full-card img#sr-full-img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 72vh;
    object-fit: contain;
    border-radius: 2px;
    filter: drop-shadow(0 0 12px rgba(255, 215, 0, 0.85));
}

.sr-full-card .collection-rarity-icon {
    position: absolute !important;
    bottom: 8px !important;
    left: 8px !important;
    width: 52px !important;
    height: 32px !important;
    z-index: 10 !important;
}

.sr-full-card .collection-new-icon {
    position: absolute !important;
    top: -12px !important;
    right: -12px !important;
    width: 40px !important;
    height: 40px !important;
    z-index: 11 !important;
}

/* 最終結果コンテナの統一 */
#final-result-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    max-width: 600px;
    aspect-ratio: 2 / 3;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Mini Game Integration Styles */
#minigame-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20000;
    /* Ensure on top */
}

#minigame-wrapper {
    position: relative;
    width: 375px;
    height: 667px;
    background: black;
    border: 2px solid white;
    max-width: 100%;
    max-height: 100%;
}

#minigame-frame {
    width: 100%;
    height: 100%;
    display: block;
}

#close-minigame-button {
    position: absolute;
    top: -40px;
    right: 0;
    padding: 10px 20px;
    background: #ff4444;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20000;
}

.modal-content {
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    max-width: 80%;
    width: 300px;
}

.modal-content.is-poyon-in {
    animation: modalPoyon 0.48s cubic-bezier(0.34, 1.45, 0.64, 1) both;
}

@keyframes modalPoyon {
    0% {
        opacity: 0;
        transform: scale(0.72);
    }

    55% {
        opacity: 1;
        transform: scale(1.1);
    }

    75% {
        transform: scale(0.96);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-content h2 {
    margin-top: 0;
    color: #333;
}

.modal-content p {
    color: #666;
    margin: 20px 0;
    font-size: 1.1em;
}

.modal-buttons {
    display: flex;
    justify-content: center;
}

.modal-button {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
}

.modal-button:hover {
    background-color: #45a049;
}

/* Mini game select modal: icon cards */
.minigame-select-content {
    width: min(420px, 92vw);
    max-width: 92%;
    padding: 24px 20px 20px;
}

.minigame-select-content h2 {
    margin-bottom: 18px;
    font-size: 1.25em;
}

.minigame-select-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    gap: 12px 14px;
    margin-bottom: 22px;
}

.minigame-select-card {
    flex: 1 1 100px;
    max-width: 120px;
    min-width: 96px;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    font: inherit;
    color: #333;
    -webkit-tap-highlight-color: transparent;
}

.minigame-select-card:focus-visible {
    outline: 2px solid #4CAF50;
    outline-offset: 4px;
    border-radius: 12px;
}

.minigame-select-card.is-locked {
    opacity: 0.55;
    cursor: not-allowed;
}

.minigame-select-card.is-locked:hover .minigame-select-icon,
.minigame-select-card.is-locked:active .minigame-select-icon {
    transform: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.minigame-select-icon {
    display: block;
    width: 100%;
    max-width: 120px;
    aspect-ratio: 1;
    height: auto;
    object-fit: cover;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.minigame-select-card:hover .minigame-select-icon,
.minigame-select-card:active .minigame-select-icon {
    transform: scale(1.04);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
}

.minigame-select-label {
    font-size: 0.9em;
    font-weight: 600;
    line-height: 1.3;
    text-align: center;
    color: #333;
}

.minigame-select-lock-hint {
    display: none;
    position: absolute;
    inset: 0 auto auto 0;
    width: 100%;
    max-width: 120px;
    aspect-ratio: 1;
    box-sizing: border-box;
    padding: 8px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.62);
    color: #fff;
    font-size: 0.72em;
    font-weight: 600;
    line-height: 1.35;
    text-align: center;
    pointer-events: none;
}

.minigame-select-card.is-locked .minigame-select-lock-hint {
    display: grid;
    place-items: center;
}

.minigame-select-footer {
    justify-content: center;
}

.minigame-select-footer .modal-button {
    min-width: 120px;
}

/* My SR Theater modal */
.sr-theater-content {
    width: min(340px, 90vw);
    max-width: 90%;
    padding: 24px 20px 20px;
}

.sr-theater-content h2 {
    margin-bottom: 6px;
    font-size: 1.25em;
}

.sr-theater-desc {
    margin: 0 0 10px;
    font-size: 0.88em;
    color: #555;
    line-height: 1.4;
}

.sr-theater-cost-label {
    margin: 0 0 14px;
    font-size: 0.95em;
    font-weight: 600;
    color: #444;
}

.sr-theater-preview-box {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 4;
    max-height: 280px;
    margin: 0 auto 12px;
    border: 2px dashed #ccc;
    border-radius: 10px;
    background: #f7f7f7;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sr-theater-preview-box img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.sr-theater-preview-placeholder {
    color: #888;
    font-size: 0.9em;
    padding: 12px;
}

.sr-theater-recent-section {
    width: 100%;
    margin: 0 0 14px;
    text-align: left;
}

.sr-theater-recent-title {
    margin: 0 0 8px;
    font-size: 0.9em;
    font-weight: 600;
    color: #444;
}

.sr-theater-recent {
    display: flex;
    flex-direction: row;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
}

.sr-theater-recent-empty {
    margin: 0;
    font-size: 0.82em;
    color: #999;
}

.sr-theater-recent-thumb {
    flex: 0 0 auto;
    width: 56px;
    height: 74px;
    padding: 0;
    border: 2px solid #ddd;
    border-radius: 6px;
    background: #eee;
    overflow: hidden;
    cursor: pointer;
}

.sr-theater-recent-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

.sr-theater-recent-thumb:hover,
.sr-theater-recent-thumb:focus-visible {
    border-color: #888;
    outline: none;
}

.sr-theater-file-label {
    display: inline-block;
    margin-bottom: 16px;
    cursor: pointer;
    box-sizing: border-box;
}

.sr-theater-buttons {
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.sr-theater-buttons .modal-button {
    min-width: 120px;
}

.modal-button-cancel {
    background-color: #888;
}

.modal-button-cancel:hover {
    background-color: #777;
}

/* ガチャ確認モーダル */
.gacha-confirm-content {
    width: min(320px, 90vw);
}

.gacha-confirm-content #gacha-confirm-message {
    margin: 4px 0 0;
}

.gacha-confirm-stones {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 10px 0 0;
    font-size: 1.15em;
    font-weight: bold;
    color: #333;
}

.gacha-confirm-stones .gacha-icon {
    width: 1.4em;
    height: 1.4em;
    vertical-align: middle;
}

.gacha-confirm-arrow {
    margin: 0 4px;
    color: #666;
    font-weight: normal;
}

.gacha-confirm-buttons {
    gap: 10px;
    margin-top: 28px;
}

/* Loading Spinner */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}