/* apps/miniGames.css — 互动组件模块
 *
 * 全部类名带 mg- 前缀（模块隔离，见 [[module-css-isolation]]）。
 * 主题只改外壳：内页永远浅色，一律吃 --panel / --text / --muted / --line / --accent（AI/03）。
 * 模块自己的色收敛成一个 --mg-tint，定义在根类上。
 */

.mg-page {
    --mg-tint: #7C4DFF;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--panel);
    font-size: 14px;
    color: var(--text);
}

/* 子页（详情 / 改源码 / 游玩）让位整条全局返回栏，返回由页内自画的 ← 承担。
   同 textgame.css / divination.css / bookClub.css 的 :has() 先例。 */
.phone-screen:has(.mg-page[data-mg-page]:not([data-mg-page="list"])) #topBar {
    display: none;
}

/* ============ 通用零件 ============ */

.mg-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px 16px 24px;
    -webkit-overflow-scrolling: touch;
}

.mg-card {
    background: var(--panel-strong);
    border: 1px solid #ececf0;
    border-radius: 14px;
    padding: 12px 14px;
    margin-bottom: 10px;
}

.mg-subnav {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 10px;
    border-bottom: 1px solid #ececf0;
    background: var(--panel-strong);
    flex: 0 0 auto;
}

.mg-subnav-main { flex: 1; min-width: 0; }

.mg-subnav-title {
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mg-subnav-note {
    font-size: 11px;
    color: var(--muted);
    margin-top: 1px;
}

.mg-icon-btn {
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mg-icon-btn:active { background: #f2f2f5; }

.mg-head-btn {
    flex: 0 0 auto;
    border: none;
    border-radius: 14px;
    background: var(--mg-tint);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 7px 12px;
    cursor: pointer;
}

.mg-sec-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    margin: 16px 2px 8px;
}

.mg-sec-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.mg-link-btn {
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    padding: 2px 4px;
    cursor: pointer;
}

.mg-empty {
    padding: 22px 16px;
    text-align: center;
    font-size: 13px;
    color: var(--muted);
    line-height: 1.7;
}

.mg-note {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.7;
    margin: 10px 2px;
}

.mg-note code {
    background: #f2f2f5;
    border-radius: 4px;
    padding: 1px 4px;
    font-size: 11px;
}

.mg-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.mg-btn {
    flex: 1;
    padding: 11px;
    border-radius: 12px;
    border: 1px solid #dcdce2;
    background: var(--panel-strong);
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.mg-btn:active { background: #f2f2f5; }

.mg-btn-primary {
    border-color: transparent;
    background: var(--mg-tint);
    color: #fff;
}

/* ============ 列表条目 ============ */

.mg-item { cursor: pointer; }
.mg-item:active { background: #fafafc; }

.mg-item-title {
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.mg-item-note {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

.mg-badge {
    font-size: 10px;
    font-weight: 500;
    color: var(--mg-tint);
    border: 1px solid currentColor;
    border-radius: 6px;
    padding: 0 4px;
    line-height: 15px;
}

/* ============ 运行记录 ============ */

.mg-run { padding: 10px 14px; }
.mg-run-line { font-size: 13px; }
.mg-run-note { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* ============ 表单 ============ */

.mg-field { margin-bottom: 12px; }

.mg-label {
    font-size: 12px;
    color: var(--muted);
    margin: 0 2px 5px;
}

.mg-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #dcdce2;
    border-radius: 10px;
    background: var(--panel-strong);
    color: var(--text);
    font-size: 14px;
    outline: none;
}

.mg-input:focus { border-color: var(--mg-tint); }

/* 源码：定高框内滚，不撑开整页 */
.mg-textarea {
    width: 100%;
    height: 260px;
    resize: none;
    padding: 10px 12px;
    border: 1px solid #dcdce2;
    border-radius: 10px;
    background: var(--panel-strong);
    color: var(--text);
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 12px;
    line-height: 1.6;
    outline: none;
    -webkit-overflow-scrolling: touch;
}

.mg-textarea:focus { border-color: var(--mg-tint); }

.mg-source {
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 11px;
    line-height: 1.7;
    color: var(--muted);
    word-break: break-all;
}

/* ============ 沙箱 ============ */

.mg-stage { display: block; }

.mg-frame {
    display: block;
    width: 100%;
    height: 200px;    /* 沙箱报高之前先坐着，别让框塌成 0 */
    border: 0;
    background: transparent;
}

.mg-error {
    background: #fdecea;
    border: 1px solid #f5c6c0;
    color: #b3261e;
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 12px;
    line-height: 1.6;
    margin-bottom: 10px;
    word-break: break-word;
}

.mg-result {
    border-color: #d9d0ff;
    background: #f7f5ff;
}

.mg-result-title {
    font-size: 12px;
    color: var(--mg-tint);
    font-weight: 600;
    margin-bottom: 4px;
}

.mg-result-line {
    font-size: 13px;
    line-height: 1.6;
    word-break: break-word;
}

/* ============ toast ============ */

.mg-toast {
    position: fixed;
    left: 50%;
    bottom: 84px;
    transform: translateX(-50%) translateY(8px);
    background: rgba(0, 0, 0, .82);
    color: #fff;
    font-size: 12px;
    line-height: 1.5;
    padding: 9px 16px;
    border-radius: 18px;
    max-width: 280px;
    text-align: center;
    z-index: 3000;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s, transform .2s;
}

.mg-toast.is-show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
