/* ================================================================
 * もめんびより - WP埋め込みスタイル
 * ----------------------------------------------------------------
 * - ゲーム本体はすべて Canvas 描画。ここは入れ物の見た目だけ
 * - 全画面ではなく、ページ内に収まるコンテナ（16:9）に収める
 * ================================================================ */

.ts-momen-container {
    width: 100%;
    max-width: 1000px;
    margin: 1.5em auto;
    aspect-ratio: 16 / 9;
    background: #0f131c;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.25);
}

.ts-momen-container canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    touch-action: none;
}

/* 全画面モード時はコンテナを画面いっぱいに（aspect-ratio や角丸は解除） */
.ts-momen-container:fullscreen,
.ts-momen-container:-webkit-full-screen,
.ts-momen-container.tm-pseudo-fs {
    max-width: none;
    width: 100vw;
    height: 100vh;
    margin: 0;
    border-radius: 0;
    aspect-ratio: auto;
}

/* iPhone等、要素の全画面APIが無い端末向けの擬似全画面（画面に固定して最前面に）
 * z-index はテーマのヘッダー・フッターに負けない値。JS側で body 直下へ移してから使う */
.ts-momen-container.tm-pseudo-fs {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
}

/* 100vh だと iOS のアドレスバーぶん下が切れるので、対応ブラウザでは dvh を使う */
@supports (height: 100dvh) {
    .ts-momen-container.tm-pseudo-fs { height: 100dvh; }
}

/* 擬似全画面中は背景ページをスクロールさせない（JSが html に付け外しする） */
html.tm-fs-lock,
html.tm-fs-lock body { overflow: hidden; }

/* スマホ縦持ちは16:9だと高さが足りず文字とボタンが重なるので、縦長の入れ物にする */
@media (max-width: 640px) {
    .ts-momen-container { aspect-ratio: 4 / 5; }
}

/* aspect-ratio 未対応の古いブラウザ向けフォールバック（16:9 = 56.25%） */
@supports not (aspect-ratio: 16 / 9) {
    .ts-momen-container {
        height: 0;
        padding-bottom: 56.25%;
    }
    .ts-momen-container canvas {
        position: absolute;
        inset: 0;
    }
    @media (max-width: 640px) {
        .ts-momen-container { padding-bottom: 125%; }
    }
}

/* ================================================================
 * ランキング UI（canvas の上に重ねるオーバーレイ）
 * ================================================================ */
.tm-rank-form,
.tm-rank-panel {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(86%, 420px);
    box-sizing: border-box;
    background: rgba(20, 25, 36, 0.96);
    border: 1px solid #3a2a4a;
    border-radius: 12px;
    padding: 24px;
    color: #efe6cf;
    font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
    z-index: 5;
}

.tm-rank-form-title,
.tm-rank-panel-title {
    font-size: 18px;
    margin: 0 0 10px;
    color: #efe6cf;
}
.tm-rank-form-score { font-size: 14px; color: #9aa6bd; margin: 0 0 16px; }
.tm-rank-form-score strong { color: #f5e642; font-size: 20px; }

/* テーマの input[type="text"] 指定に負けないよう、セレクタを強めにして全プロパティを明示する */
.ts-momen-container input.tm-rank-name {
    display: block;
    width: 100%;
    max-width: none;
    min-height: 0;
    height: auto;
    box-sizing: border-box;
    margin: 0;
    padding: 12px 14px;
    font-size: 16px;
    line-height: 1.4;
    text-align: left;
    font-family: inherit;
    border: 1px solid #4a5a78;
    border-radius: 8px;
    background: #0f131c;
    color: #efe6cf;
    box-shadow: none;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}
.ts-momen-container input.tm-rank-name:focus { border-color: #7fa8df; }

.tm-rank-form-btns { display: flex; gap: 10px; margin-top: 18px; }
.tm-rank-btn {
    flex: 1;
    padding: 12px 0;
    font-size: 15px;
    border: 1px solid #4a5a78;
    border-radius: 8px;
    background: transparent;
    color: #efe6cf;
    cursor: pointer;
    font-family: inherit;
}
/* 主ボタン（のこす）を広く・面で見せ、従ボタン（やめる）は枠だけの控えめに */
.tm-rank-btn-main { flex: 1.7; background: #3a4a6e; border-color: #5a6a8e; }
.tm-rank-btn:hover { filter: brightness(1.15); }
.tm-rank-form-msg { font-size: 13px; color: #e2533b; margin: 10px 0 0; min-height: 1em; }

/* ランキングパネル */
.tm-rank-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.tm-rank-month {
    font-size: 13px; padding: 5px 8px; border-radius: 6px;
    background: #0f131c; color: #efe6cf; border: 1px solid #4a5a78;
    font-family: inherit;
}
.tm-rank-list {
    list-style: none; margin: 0 0 14px; padding: 0;
    max-height: 46vh; overflow-y: auto;
    counter-reset: rank;
}
.tm-rank-list li {
    display: flex; align-items: baseline; gap: 10px;
    padding: 6px 4px; border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 14px;
}
.tm-rank-list li::before {
    counter-increment: rank; content: counter(rank);
    width: 1.8em; text-align: right; color: #9aa6bd; font-size: 13px; flex: none;
}
.tm-rank-list li:nth-child(1)::before { color: #f5d342; }
.tm-rank-list li:nth-child(2)::before { color: #cfd6e0; }
.tm-rank-list li:nth-child(3)::before { color: #d99a6c; }
.tm-rank-list .tm-rank-name-cell { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-rank-list .tm-rank-score-cell { color: #f5e642; flex: none; }
.tm-rank-empty { color: #9aa6bd; font-size: 13px; padding: 8px 4px; }

/* パネル下の「とじる」は全幅のバーにする（そのままだと内容幅の小さな箱が左に寄ってしまう） */
.tm-rank-panel .tm-rank-btn {
    display: block;
    width: 100%;
}
