/* --------------------------------------------------
   규칙 설명: 모바일은 아래에서 올라오는 시트, 넓은 화면은 가운데 창
   -------------------------------------------------- */

.modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(5, 8, 14, 0.7);
}

.modal-content {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 85dvh;
    overflow-y: auto;
    padding: 10px 18px calc(22px + var(--safe-bottom));
    background: var(--surface);
    border-top: 1px solid var(--line-strong);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    animation: sheet-up 0.22s ease-out;
}

@keyframes sheet-up {
    from { transform: translateY(24px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.sheet-handle {
    width: 40px;
    height: 4px;
    margin: 0 auto 12px;
    border-radius: 999px;
    background: var(--line-strong);
}

.close-button {
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: 20px;
}

#rule-modal-title {
    font-size: 18px;
    color: var(--text);
    margin-bottom: 12px;
}

.rule-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    color: #cdd4e4;
    font-size: 14px;
    line-height: 1.5;
}

/* --- 그림 도움말 (help.js) ------------------------------------------ */
.help-step {
    padding: 12px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.help-step-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.help-step-head h3 {
    margin: 0;
    font-size: 15px;
    color: var(--text);
}

.help-num {
    flex-shrink: 0;
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
}

.help-visual {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 8px;
    margin-bottom: 8px;
    background: rgba(0, 0, 0, 0.18);
    border-radius: 10px;
}

.help-row {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 5px;
}

.help-sub {
    font-size: 12px;
    color: var(--muted);
}

.help-caption {
    margin: 0;
    font-size: 13px;
}

.help-caption b,
.rule-body strong {
    color: var(--text);
}

/* 그림 속 카드 (게임과 같은 색·문양) */
.help-card {
    position: relative;
    width: 30px;
    height: 42px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 800;
    background-image: none;
}

.help-card.dim {
    opacity: 0.55;
}

.hc-mark {
    position: absolute;
    top: -7px;
    right: -7px;
    width: 16px;
    height: 16px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    font-size: 10px;
    color: #fff;
}

.hc-mark.ok { background: var(--up); }
.hc-mark.no { background: var(--down); }

.help-arrow {
    color: var(--muted);
    font-size: 13px;
}

.help-dots {
    color: var(--muted);
    letter-spacing: 2px;
}

.help-gap {
    width: 14px;
}

.help-pile {
    flex-shrink: 0;
    padding: 2px 7px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 800;
    color: #0f1420;
}

.help-pile.up { background: var(--up); }
.help-pile.down { background: var(--down); }
.help-pile.big { font-size: 13px; padding: 8px 10px; }

.help-flow {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
}

.help-flow-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 70px;
    font-size: 12px;
    color: var(--text);
    text-align: center;
}

.help-icon {
    font-size: 24px;
    line-height: 1;
}

.help-result {
    gap: 16px;
}

.help-flow-item.win .help-icon { filter: drop-shadow(0 0 6px rgba(47, 212, 134, 0.6)); }
.help-flow-item.lose .help-icon { filter: drop-shadow(0 0 6px rgba(255, 99, 128, 0.6)); }

.help-btn {
    padding: 8px 10px;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    font-size: 12px;
}

.help-bubble {
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    background: var(--card-face);
    color: var(--card-ink);
}

.help-bubble.no {
    background: rgba(255, 99, 128, 0.15);
    color: var(--down);
    text-decoration: line-through;
}

@media (min-width: 900px) {
    .modal-content {
        left: 50%;
        right: auto;
        top: 50%;
        bottom: auto;
        width: min(560px, 92vw);
        transform: translate(-50%, -50%);
        border: 1px solid var(--line-strong);
        border-radius: var(--radius-lg);
        padding: 22px 24px 24px;
        animation: none;
    }

    .sheet-handle {
        display: none;
    }
}
