/* ==========================================================
   Modown 随机游戏推荐插件 — 前端样式
   匹配 Modown 模板兔主题风格 (v1.1.0)
   ========================================================== */

/* ── 整体区块 ── */
.modown-roll-game {
    background: #fff;
    color: #333;
    position: relative;
    border-bottom: 1px solid #f0f0f0;
    /* 抵消主题 .mocat:first-child { margin-top: -30px } */
    margin-top: 0 !important;
}

/* ── 修正标题区间距，防止 .mocat .desc { margin-top:-28px } 导致文字被 h2 下划线遮挡 ── */
.modown-roll-game h2 {
    margin-bottom: 12px;
}

.modown-roll-game .desc {
    margin-top: 0 !important;
    margin-bottom: 28px !important;
    padding-top: 4px;
}

/* ── 展示区 ── */
.roll-display-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 28px;
}

/* ── 游戏屏幕卡片 ── */
.roll-screen {
    position: relative;
    width: 260px;
    height: 340px;
    border-radius: 18px;
    overflow: hidden;
    background: #2a3a4a;
    box-shadow:
        0 0 0 2px rgba(0, 0, 0, .08),
        0 20px 60px rgba(0, 0, 0, .16);
    transition: box-shadow .3s;
}

/* 背景图通过 CSS 自定义属性注入，避免 img 定位冲突 */
.roll-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: var(--roll-bg, none);
    background-size: cover;
    background-position: center;
    z-index: 1;
    transition: filter .15s, transform .15s;
}

.roll-screen.rolling {
    box-shadow:
        0 0 0 2px rgba(178, 0, 3, .6),
        0 20px 60px rgba(0, 0, 0, .2),
        0 0 50px rgba(178, 0, 3, .18);
}

/* 底部渐变蒙版（让标题可读） */
.roll-screen::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent 45%, rgba(0, 0, 0, .75) 100%);
    pointer-events: none;
    z-index: 2;
}

/* ── 占位符 ── */
.roll-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 10px;
    padding: 20px;
}

.roll-placeholder-icon {
    font-size: 56px;
    line-height: 1;
    opacity: .6;
}

.roll-placeholder-text {
    font-size: 13px;
    color: rgba(255, 255, 255, .4);
}

/* 滚动时模糊背景图 */
.roll-screen.rolling::before {
    filter: blur(6px);
    transform: scale(1.06);
}

/* ── 扫描线装饰（仅在滚动中显示） ── */
.roll-scanlines {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    background: repeating-linear-gradient(
        to bottom,
        transparent, transparent 3px,
        rgba(0, 0, 0, .08) 3px, rgba(0, 0, 0, .08) 4px
    );
    opacity: 0;
    transition: opacity .2s;
}

.roll-screen.rolling .roll-scanlines {
    opacity: 1;
    animation: scanlines-move .4s linear infinite;
}

@keyframes scanlines-move {
    0%   { background-position: 0 0; }
    100% { background-position: 0 20px; }
}

/* ── 滚动闪烁 ── */
@keyframes roll-flash {
    0%, 100% { opacity: 1; }
    50%       { opacity: .82; }
}

.roll-screen.rolling {
    animation: roll-flash .12s linear infinite;
}

/* ── 游戏标题覆盖层 ── */
.roll-game-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 14px 14px;
    z-index: 4;
}

#roll-title {
    display: block;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    line-height: 1.45;
    text-shadow: 0 1px 4px rgba(0, 0, 0, .9);
    word-break: break-word;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* ── 加载中指示器 ── */
.roll-loading {
    display: flex;
    align-items: center;
    gap: 6px;
    color: rgba(0, 0, 0, .45);
    font-size: 12px;
    margin-top: 12px;
}

.roll-loading-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #b20003;
    animation: dot-bounce .75s ease-in-out infinite;
}

.roll-loading-dot:nth-child(2) { animation-delay: .12s; }
.roll-loading-dot:nth-child(3) { animation-delay: .24s; }

@keyframes dot-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%            { transform: translateY(-5px); }
}

/* ── 提示文字 ── */
.roll-hint {
    margin-top: 12px;
    font-size: 13px;
    color: rgba(0, 0, 0, .45);
    text-align: center;
    min-height: 20px;
    transition: color .3s;
}

/* ── 操作按钮 ── */
.roll-controls {
    display: flex;
    gap: 14px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-roll-start,
.btn-roll-stop {
    padding: 12px 44px;
    font-size: 16px;
    font-weight: 700;
    border-radius: 30px;
    cursor: pointer;
    border: none;
    transition: transform .2s, box-shadow .2s, opacity .2s;
    letter-spacing: .5px;
    line-height: 1.4;
}

/* 开始按钮 */
.btn-roll-start {
    background: #b20003;
    color: #fff;
    box-shadow: 0 4px 22px rgba(178, 0, 3, .45);
}

.btn-roll-start:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(178, 0, 3, .6);
    opacity: .95;
}

.btn-roll-start:active {
    transform: translateY(0);
}

/* 停止按钮 */
.btn-roll-stop {
    background: #e53935;
    color: #fff;
    box-shadow: 0 4px 22px rgba(229, 57, 53, .4);
    animation: stop-pulse .9s ease-in-out infinite;
}

@keyframes stop-pulse {
    0%, 100% { transform: scale(1); }
    50%       { transform: scale(1.05); }
}

.btn-roll-stop:hover {
    background: #c62828;
    box-shadow: 0 8px 28px rgba(229, 57, 53, .6);
}

/* ═══════════════════════════════════════════════════════════
   弹窗
   ═══════════════════════════════════════════════════════════ */

.roll-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .82);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.roll-modal {
    background: #fff;
    border-radius: 22px;
    max-width: 400px;
    width: 100%;
    overflow: hidden;
    position: relative;
    box-shadow: 0 30px 90px rgba(0, 0, 0, .55);
    animation: modal-pop-in .38s cubic-bezier(.34, 1.56, .64, 1) both;
}

@keyframes modal-pop-in {
    from {
        transform: scale(.55) translateY(40px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

/* ── 关闭按钮 ── */
.roll-modal-close {
    position: absolute;
    top: 11px;
    right: 14px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(0, 0, 0, .18);
    border: none;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s;
}

.roll-modal-close:hover {
    background: rgba(0, 0, 0, .35);
}

/* ── 顶部 Banner ── */
.roll-modal-header-banner {
    background: linear-gradient(135deg, #b20003 0%, #8b0000 100%);
    padding: 22px 20px 38px;
    text-align: center;
    position: relative;
}

.roll-modal-trophy {
    display: block;
    font-size: 52px;
    line-height: 1;
    margin-bottom: 8px;
    animation: trophy-pop .5s cubic-bezier(.34, 1.56, .64, 1) .1s both;
}

@keyframes trophy-pop {
    from { transform: scale(0) rotate(-20deg); opacity: 0; }
    to   { transform: scale(1) rotate(0);      opacity: 1; }
}

.roll-modal-recommend-text {
    color: rgba(255, 255, 255, .9);
    font-size: 14px;
    line-height: 1.5;
}

/* ── 弹窗主体 ── */
.roll-modal-body {
    padding: 0 24px 28px;
    margin-top: 15px;
}

.roll-modal-img-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

#modal-img {
    width: 290px;
    height: 185px;
    object-fit: cover;
    border-radius: 14px;
    border: 4px solid #fff;
    box-shadow: 0 6px 28px rgba(0, 0, 0, .22);
    background: #1b2838;
    display: block;
    max-width: 100%;
}

#modal-img[src=""] {
    background: linear-gradient(135deg, #1b2838, #2a475e);
}

.roll-modal-title {
    text-align: center;
    font-size: 17px;
    font-weight: 700;
    color: #222;
    margin-bottom: 20px;
    line-height: 1.45;
    word-break: break-word;
    padding: 0 6px;
}

/* ── 弹窗按钮 ── */
.roll-modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.roll-modal-actions .btn {
    padding: 11px 28px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform .2s, box-shadow .2s, opacity .2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    line-height: 1.4;
    border: none;
}

/* 前往游玩 */
.roll-modal-actions .btn-play {
    background: #b20003;
    color: #fff !important;
    box-shadow: 0 4px 16px rgba(178, 0, 3, .4);
}

.roll-modal-actions .btn-play:hover {
    transform: translateY(-2px);
    box-shadow: 0 7px 22px rgba(178, 0, 3, .55);
    opacity: 1;
}

/* 再来一次 */
.roll-modal-actions .btn-again {
    background: #f2f2f2;
    color: #444;
}

.roll-modal-actions .btn-again:hover {
    background: #e5e5e5;
    transform: translateY(-2px);
}

/* ── 彩纸粒子 ── */
.roll-confetti-particle {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 2px;
    pointer-events: none;
    animation: confetti-fall 1.6s ease-out forwards;
    z-index: 20;
}

@keyframes confetti-fall {
    0%   { transform: translateY(-10px) rotate(0deg);   opacity: 1; }
    100% { transform: translateY(140px) rotate(400deg); opacity: 0; }
}

/* ═══════════════════════════════════════════════════════════
   响应式
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .roll-screen {
        width: 230px;
        height: 300px;
    }

    .btn-roll-start,
    .btn-roll-stop {
        padding: 11px 36px;
        font-size: 15px;
    }

    #modal-img {
        width: 180px;
        height: 115px;
    }

    .roll-modal-title {
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    .roll-modal-actions {
        flex-direction: column;
        align-items: center;
    }

    .roll-modal-actions .btn {
        width: 100%;
        justify-content: center;
    }
}
