body {
    background-color: #ffffff;
    font-family: Arial, sans-serif;
    margin: 1%;
    padding: 0;
}

/* ---- 入力モード切り替え用 ---- */
#mpszInputArea, #imageInputArea {
    margin-bottom: 10px;
}

/* ---- MPSZ 入力エリア ---- */
#mpszInputArea {
    display: none; /* デフォルトは画像入力が選択されている */
}

/* ---- 画像入力エリア ---- */
#selectionBox {
    background-color: #f0f0ff;
    padding: 10px;
    margin: 5px 0;
    border: 1px solid #999;
}
#selectionBox img {
    cursor: pointer;
    vertical-align: bottom;
    margin: 0;
}
.tile-row {
    margin-bottom: 4px; /* スーツ行と行の間隔 */
}

/* チー用1行に7パターン */
.chi-block {
    display: inline-block;
    margin-right: 8px; 
    vertical-align: bottom;
}
.chi-block img {
    margin: 0;
}

#handDisplay {
    background-color: #208020;
    min-width: 700px;
    min-height: 83px;
    padding: 5px 10px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}
.tile-slot {
    position: relative;
    display: inline-block;
    margin: 0; /* 牌同士の隙間をなくす */
}
.tile-slot img {
    margin: 0;
}
.minus-button {
    background-color: #ccc;
    border: 1px solid #666;
    width: 20px;
    height: 20px;
    line-height: 18px;
    text-align: center;
    font-weight: bold;
    cursor: pointer;
    margin: 0 auto;
    display: block;
}

/* 鳴きブロック */
.meld-block {
    display: inline-block;
    margin: 0;
    position: relative; 
    vertical-align: bottom;
    margin-right: 8px; /* 鳴きの間にスペースを空ける */
}
.meld-tiles {
    display: inline-block;
    margin: 0;
    padding: 0;
}
.meld-tiles img {
    margin: 0;
}

.meld-minus-button {
    text-align: center;
}

/* ドラ / 裏ドラ 表示 (横並び) */
#doraDisplay, #uraDoraDisplay {
    display: flex;
    align-items: center;
    background-color: #fff8e0;
    padding: 5px;
    min-height: 83px;
    min-width: 50px;
    flex-wrap: wrap;
}
#doraDisplay span, #uraDoraDisplay span {
    display: inline-flex;
    align-items: center;
    margin-right: 5px;
}

/* ---- 計算結果エリア ---- */
#tileImages {
    background-color: #208020; /* MPSZ 形式の場合にも濃い緑色で表示 */
    min-width: 700px;
    margin-top: 0px;
    height: 63px;
    padding: 10px;
    align-items: flex-end; /* 下揃え */
}

.tileDisplay {
    background-color: #ffffdd;
    margin-top: 10px;
    margin-bottom: 10px;
    padding-left: 10px;
    display: flex;
    align-items: center;
}
.tileDisplay img {
    margin: 0px;
}

.meld-block.margin-left-first {
    margin-left: 8px;
}

/* 牌画像のサイズ調整用 */
.tile-normal {
    width: 47px;
    height: 63px;
}
.tile-rotated {
    width: 63px;
    height: 47px;
}
.tile-chi {
    width: 37.6px; /* 47px * 0.8 */
    height: 50.4px; /* 63px * 0.8 */
}
.tile-chi-rotated {
    width: 50.4px; /* 63px * 0.8 */
    height: 37.6px; /* 47px * 0.8 */
}
.tile-other {
    width: 42.3px; /* 47px * 0.9 */
    height: 56.4px; /* 63px * 0.9 */
}

/* ▼ 3ブロックを横並び。幅は中身によって伸縮するようにする ▼ */
#handDoraWrapper {
    display: flex;        /* Flexコンテナ */
    flex-wrap: wrap;      /* はみ出したら折り返す */
    align-items: flex-start;
    gap: 20px;
    margin-top: 10px;
}
.handDoraBlock {
    /* 幅固定せず、コンテンツ量に応じて伸縮 */
    /* flex: 0;  <- 指定しなくてもOK (デフォルトとほぼ同じ) */
}


/* タブのスタイル */
.tab-container {
    display: flex;
    margin-bottom: 10px;
}

.tab-button {
    padding: 8px 16px;
    border: 1px solid #ccc;
    cursor: pointer;
    background-color: #f0f0f0;
}

.tab-button.active {
    background-color: #ddd;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* MPSZ/画像入力タブ（右上） */
#input-mode-tabs {
    position: absolute;
    top: 10px;
    right: 10px;
}

.winning-type {
    padding: 2px 5px;
    border-radius: 5px;
    margin-right: 5px;
    margin: 5px;
}
.winning-type.tsumo {
    background-color: #fa5454; /* 青 */
    color: #ffffff;
}
.winning-type.ron {
    background-color: #7a5cff; /* 薄い青 */
    color: #ffffff;
}
.score {
    font-weight: bold;
    font-size: 1.5em;
}
.score_name {
    color:#ff0000;
    font-weight: bold;
    font-size: 1.3em;
}

/* スマートフォン向けのスタイル */
@media screen and (max-width: 480px) {
    body {
        font-size: 16px; /* 基本フォントサイズを調整 */
        margin: 5%; /* 余白を調整 */
    }

    /* 入力モード切り替えタブ */
    #input-mode-tabs {
        position: static; /* 絶対配置を解除 */
        text-align: center; /* 中央寄せ */
        margin-bottom: 10px;
    }

    .tab-button {
        padding: 6px 12px; /* ボタンのパディングを調整 */
        font-size: 14px; /* ボタンのフォントサイズを調整 */
    }

    /* 手牌、ドラ、裏ドラの表示エリア */
    #handDoraWrapper {
        flex-direction: column; /* 縦並びにする */
        align-items: center; /* 中央寄せ */
        gap: 10px; /* ブロック間の間隔を調整 */
    }

    .handDoraBlock {
        min-width: 70%;
        max-width: 90%;
        text-align: center; /* 中央寄せ */
    }

    #handDisplay,
    #tileImages {
        min-width: auto; /* 幅の最小値を解除 */
        width: 100%; /* 幅を100%にする */
        display: flex;
        justify-content: flex-start; /* 左寄せ */
    }

    #doraDisplay,
    #uraDoraDisplay {
        min-width: auto; /* 幅の最小値を解除 */
        width: 100%; /* 幅を100%にする */
        display: flex;
        flex-wrap: nowrap; /* 折り返し禁止 */
        overflow-x: auto; /* 横スクロールを許可 */
        justify-content: center; /* 中央寄せ */
    }

    /* 牌画像のサイズ */
    .tile-normal {
        width: 35px;
        height: 47px;
    }

    .tile-rotated {
        width: 47px;
        height: 35px;
    }

    .tile-chi {
        width: 28px;
        height: 38px;
    }

    .tile-chi-rotated {
        width: 38px;
        height: 28px;
    }

    .tile-other {
        width: 32px;
        height: 42px;
    }

    /* 計算結果 */
    .score {
        font-size: 1.2em;
    }

    .score_name {
        font-size: 1.1em;
    }

    /* ドラ・裏ドラがない場合に非表示 */
    .handDoraBlock.no-dora,
    .handDoraBlock.no-ura-dora {
        display: none;
    }

}