/* tool-style.css: 設定エリア整理 & 本場対応版（レイアウト調整済） */

/* --- 全体・ヘッダー・手牌エリア --- */
.mj-app-wrapper {
    max-width: 600px;
    margin: auto;
    padding-bottom: 60px;
    background: #fff;
    box-sizing: border-box;
}

.mj-sticky-header {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    z-index: 10000;
    background: #ffffff;
    padding: 8px 5px;
    border-bottom: 3px solid #1b4332;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.mj-title { text-align: center; font-size: 1.2rem; margin: 10px 0; color: #334155; font-weight: bold; }

.hand-table-area {
    background: #2d6a4f;
    padding: 10px 2px;
    border-radius: 8px;
    text-align: center;
}
.hand-tiles-wrapper {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 4px;
    width: 100%;
}
.hand-main-tiles { display: contents; }
.tile-slot {
    width: clamp(34px, 9vw, 44px);
    height: clamp(48px, 13vw, 62px);
    background: #fff;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(26px, 8.5vw, 36px);
    border-bottom: 4px solid #94a3b8;
    margin: 2px 1px;
    color: #000;
    flex-shrink: 0;
    cursor: pointer;
}
.agari-slot { border: 3px solid #ef4444 !important; background: #fff5f5; margin-left: 6px; }
.ui-guide { color: #fff; margin-top: 5px; font-weight: bold; font-size: 14px; }

/* --- 雀卓UI（重なり・サイズ調整版） --- */
.mj-table {
    display: grid !important;
    grid-template-columns: 25% 40% 25% !important;
    /* 真ん中の行を広げて重なりを防ぐ */
    grid-template-rows: 60px 110px 60px !important; 
    gap: 5px;
    justify-content: center;
    align-items: center;
    margin: 15px auto;
    width: 100%;
    max-width: 450px;
    position: relative; /* z-index用 */
}

.pos-top, .pos-left, .pos-right, .pos-bottom {
    height: 100%;
    width: 100%;
    z-index: 10; /* 中央エリアより手前に表示 */
}

.pos-top { grid-column: 2; grid-row: 1; margin-bottom: 5px; }
.pos-left { grid-column: 1; grid-row: 2; }
.table-center { 
    grid-column: 2; 
    grid-row: 2; 
    background: #2d6a4f; 
    color: #fff; 
    border: 3px solid #5c4033; 
    border-radius: 10px; 
    display: flex; 
    flex-direction: column;
    align-items: center; 
    justify-content: center; 
    font-weight: bold; 
    height: 100%; 
    font-size: clamp(16px, 4.5vw, 22px); 
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3); 
    line-height: 1.2;
    z-index: 1; /* 周りのボタンより奥に配置 */
}
.pos-right { grid-column: 3; grid-row: 2; }
.pos-bottom { grid-column: 2; grid-row: 3; margin-top: 5px; }

.oya-btn-label { 
    background: #fff; border: 1px solid #cbd5e1; border-radius: 8px; 
    display: flex; flex-direction: column; align-items: center; justify-content: center; 
    cursor: pointer; height: 100%; width: 100%; font-size: clamp(11px, 3vw, 14px); 
    box-sizing: border-box; padding: 2px;
}
.oya-btn-label.selected { background: #ef4444 !important; color: #fff !important; border-color: #b91c1c !important; }
.oya-btn-label input { display: none; }

/* --- 設定エリア --- */
.settings-container {
    background: #f8fafc;
    padding: 15px;
    border-radius: 12px;
    margin: 15px 5px;
    border: 1px solid #e2e8f0;
    
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    align-items: end;
}

.input-group {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.input-group label, .input-group b {
    font-size: 13px;
    font-weight: bold;
    color: #475569;
    margin-bottom: 5px;
    text-align: left;
    display: block;
}

.input-group select {
    padding: 0 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 15px;
    background: #fff;
    width: 100%;
    height: 42px;
    box-sizing: border-box;
    text-align: center;
}

/* カウンターBOX */
.counter-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    height: 42px;
    padding: 0 5px;
    box-sizing: border-box;
    width: 100%;
}

.mini-btn {
    width: 32px;
    height: 32px;
    border: 1px solid #cbd5e1;
    background: #f1f5f9;
    color: #334155;
    border-radius: 4px;
    font-weight: bold;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.mini-btn:active { background: #e2e8f0; }

.count-val {
    font-size: 18px;
    font-weight: bold;
    color: #333;
    flex: 1;
    text-align: center;
}

#pei-nuki-area {
    grid-column: 1 / -1;
    display: none;
    margin-top: 5px;
    border-top: 1px dashed #cbd5e1;
    padding-top: 10px;
}
#pei-nuki-area .counter-box {
    max-width: 200px;
    margin: 0 auto;
}
#pei-nuki-area b { text-align: center; }

@media (max-width: 400px) {
    .settings-container { gap: 10px; }
    .input-group select, .counter-box { font-size: 13px; height: 38px; }
    .mini-btn { width: 28px; height: 28px; }
}

/* --- 操作・パレットエリア --- */
.mode-selector { display: flex; gap: 8px; margin-bottom: 12px; padding: 0 5px; }
.mode-btn { flex: 1; padding: 16px 5px; border: 2px solid #cbd5e1; border-radius: 10px; font-weight: bold; font-size: clamp(16px, 4vw, 20px); background: #f1f5f9; color: #64748b; cursor: pointer; }
.mode-btn.active { background: #1e293b; color: #fff; border-color: #1e293b; }

.palette-container { display: grid !important; grid-template-columns: repeat(9, 1fr) !important; gap: 4px; margin-top: 20px; padding: 0 5px; }
@media (max-width: 600px) { 
    .palette-container { display: flex !important; flex-wrap: wrap !important; justify-content: center !important; gap: 6px !important; } 
    .cat-label { width: 100%; text-align: center; font-weight: bold; margin-top: 10px; color: #475569; } 
}

.tile-btn { font-size: clamp(24px, 8.5vw, 40px); background: #fff; border: 1px solid #cbd5e1; border-radius: 6px; aspect-ratio: 3/4; cursor: pointer; color: #000; padding: 0; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 3px rgba(0,0,0,0.1); }
@media (max-width: 600px) { .tile-btn { width: calc(14% - 6px); min-width: 40px; } }
.tile-btn.red { color: #ef4444 !important; }

/* --- モーダル・結果画面 --- */
.action-btn { padding: 16px; border-radius: 10px; font-size: 18px; font-weight: bold; background: #334155; color: white; border: none; cursor: pointer; width: 100%; margin-top: 10px; }
.mj-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.85); z-index: 10001; display: flex; justify-content: center; align-items: center; }
.modal-body { background: #fff; padding: 20px; border-radius: 15px; width: 90%; max-width: 380px; text-align: center; }
.score-display { background: #fff5f5; padding: 15px; border-radius: 10px; margin: 10px 0; font-size: clamp(2rem, 8vw, 3rem); color: #ef4444; font-weight: bold; }

#res-payment {
    font-size: 1.1rem;
    color: #475569;
    background: #f1f5f9;
    padding: 8px;
    border-radius: 6px;
    margin-bottom: 12px;
    font-weight: bold;
    display: none;
}

/* 役タグの基本スタイル */
.yaku-tag {
    display: inline-block;
    padding: 4px 10px;
    margin: 3px;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: bold;
    color: #475569;
    background: #e2e8f0;
}

/* --- 豪華演出スタイル --- */
.yaku-mangan { background: #fbbf24 !important; color: #92400e !important; box-shadow: 0 0 8px #fbbf24; }
.yaku-high { background: linear-gradient(135deg, #ef4444, #b91c1c) !important; color: #ffffff !important; box-shadow: 0 0 12px rgba(239, 68, 68, 0.6); animation: pulse-red 2s infinite; }
.yaku-yakuman { background: linear-gradient(45deg, #fde047, #fbbf24, #f59e0b, #fde047) !important; color: #78350f !important; border: 2px solid #d97706 !important; text-shadow: 0 1px 0 rgba(255,255,255,0.5); box-shadow: 0 0 20px #f59e0b; animation: shine-gold 3s infinite linear, shake-little 0.5s infinite; }

/* アニメーション定義 */
@keyframes pulse-red { 0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }
@keyframes shine-gold { 0% { background-position: 0% 50%; } 100% { background-position: 200% 50%; } }
@keyframes shake-little { 0% { transform: translate(0,0); } 25% { transform: translate(1px, 1px); } 50% { transform: translate(-1px, -1px); } 75% { transform: translate(1px, -1px); } 100% { transform: translate(0,0); } }

/* モーダル全体の震えエフェクト（役満用クラス） */
.modal-yakuman-shake { animation: big-shake 0.3s ease-in-out; }
@keyframes big-shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }

/* 役ごとのレイアウト */
.yaku-item { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; width: 100%; }
.yaku-han { font-weight: bold; color: #666; }

/* 符の内訳レイアウト */
.fu-details-container { margin-top: 15px; font-size: 0.9em; color: #444; text-align: left; padding: 10px; background: #f9f9f9; border-radius: 5px; }
.fu-title { font-weight: bold; margin-bottom: 8px; color: #222; }
.fu-detail-row { display: flex; justify-content: space-between; border-bottom: 1px dashed #ccc; padding: 2px 0; }
.res-basic-info { font-size: 1.2em; font-weight: bold; color: #e74c3c; margin-bottom: 5px; }