/* ===== MODE SELECT ===== */
.mj-mode { text-align: center; }
.mj-modebts { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-top: 2rem; }
.mj-mbtn {
  padding: 16px 40px; font-size: 1rem; font-weight: 700; border: none; border-radius: 12px;
  background: linear-gradient(135deg, #9480ff, #4ee8df); color: #fff; cursor: pointer;
  transition: transform .15s; line-height: 1.6;
}
.mj-mbtn:hover { transform: translateY(-3px); }
.mj-mbtn small { display: block; font-weight: 400; font-size: .78rem; opacity: .8; }

/* ===== GAME LAYOUT ===== */
#mjGame { display: none; width: 100%; max-width: 920px; }

#mjInfo {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  background: var(--surface, #12122a); border-radius: 10px; padding: 8px 14px; margin-bottom: 8px;
}
#mjScores { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.mj-sc {
  background: rgba(148,128,255,.15); border-radius: 6px;
  padding: 3px 10px; font-size: .75rem;
}
.mj-sc.you { background: rgba(148,128,255,.38); font-weight: 700; }
.mj-dora { display: flex; align-items: center; gap: 6px; font-size: .75rem; color: var(--text-muted, #9090bb); }
#mjWall { font-size: .72rem; color: var(--text-muted, #9090bb); margin-left: auto; }

/* ===== TABLE ===== */
#mjTable {
  background: #1b5218;
  border-radius: 14px;
  padding: 10px;
  display: grid;
  grid-template-areas:
    ". top ."
    "left center right"
    ". bottom .";
  grid-template-columns: 115px 1fr 115px;
  grid-template-rows: auto 1fr auto;
  gap: 6px;
  min-height: 460px;
}
#mjTable.p3 #mjLeft { visibility: hidden; }

#mjTop    { grid-area: top; }
#mjLeft   { grid-area: left; }
#mjRight  { grid-area: right; }
#mjBot    { grid-area: bottom; }

/* ===== CENTER POND ===== */
#mjCenter {
  grid-area: center;
  background: rgba(0,0,0,.18);
  border-radius: 10px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 300px;
}

/* 上家捨て牌ゾーン */
#dqTop {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  min-height: 88px;
}
#dqTop .mj-dc {
  transform: rotate(180deg);
}

/* 自家捨て牌ゾーン */
#dqBot {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 88px;
}

/* 中段（左家 + 局表示 + 右家） */
#mjCMid {
  flex: 1;
  display: flex;
  gap: 6px;
  align-items: stretch;
  min-height: 80px;
}
#dqLeft  { display: flex; align-items: center; justify-content: flex-end;   width: 90px; flex-shrink: 0; }
#dqRight { display: flex; align-items: center; justify-content: flex-start; width: 90px; flex-shrink: 0; }

/* 局風インジケーター */
#mjRound {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.07);
  border-radius: 8px;
  font-size: .75rem; color: rgba(255,255,255,.65);
  font-weight: 700; text-align: center; line-height: 1.5;
  letter-spacing: .05em;
}

/* ===== 捨て牌コンテナ ===== */
.mj-dc {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
}
/* 上家・自家：横6枚ずつ */
#dqTop .mj-dc, #dqBot .mj-dc {
  max-width: 200px;   /* sm tile ~32px × 6 */
  justify-content: flex-start;
}
/* 左家・右家：縦積み（3列まで） */
#dqLeft .mj-dc, #dqRight .mj-dc {
  max-width: 90px;
  max-height: 170px;
  overflow: hidden;
  flex-direction: column;
  flex-wrap: wrap;
}
#dqLeft .mj-dc  { justify-content: flex-end; }
#dqRight .mj-dc { justify-content: flex-start; }

.mj-pa { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px; }
.mj-pn { font-size: .68rem; color: rgba(255,255,255,.75); font-weight: 600; }
.mj-ps { font-size: .62rem; color: rgba(255,255,255,.45); }

/* ===== TILES ===== */
.mj-t {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  width: 38px; height: 52px;
  background: linear-gradient(160deg, #fff 60%, #f0ece0);
  border-radius: 5px;
  border: 1px solid #bbb;
  box-shadow: 0 3px 0 #999, 0 4px 6px rgba(0,0,0,.35);
  user-select: none; cursor: default;
  margin: 2px 1px;
  transition: transform .12s, box-shadow .12s;
  line-height: 1.1;
  gap: 0;
}
.mj-t.sm {
  width: 24px; height: 33px;
  box-shadow: 0 2px 0 #999, 0 3px 4px rgba(0,0,0,.3);
  margin: 1px;
}
.mj-t.clk { cursor: pointer; }
.mj-t.clk:hover { transform: translateY(-7px); box-shadow: 0 10px 0 #999, 0 12px 10px rgba(0,0,0,.35); }
.mj-t.sel {
  transform: translateY(-14px);
  box-shadow: 0 14px 0 #6040cc, 0 16px 14px rgba(148,128,255,.5);
  border-top-color: #9480ff;
  border-right-color: #9480ff;
  border-bottom-color: #9480ff;
  /* border-left はスーツ色を維持 */
  background: linear-gradient(160deg, #f8f4ff 60%, #e8e0ff);
}
.mj-t.bk {
  background: linear-gradient(160deg, #2a7a26, #1a5518);
  border-color: #1a5018;
  box-shadow: 0 3px 0 #0e3010, 0 4px 6px rgba(0,0,0,.4);
}

/* ===== スーツ別 左端カラー ===== */
.mj-t.suit-man  { border-left: 4px solid #c82020; }
.mj-t.suit-pin  { border-left: 4px solid #1060c0; }
.mj-t.suit-sou  { border-left: 4px solid #1a8030; }
.mj-t.suit-wind { border-left: 4px solid #334c6e; }
.mj-t.suit-drag { border-left: 4px solid #b07800; }
/* 選択時も左端スーツ色を維持 → border-left は上書きしない */

/* ===== 牌グリフ ===== */
.mj-glyph {
  font-family: 'Segoe UI Symbol', 'Noto Sans Symbols 2', 'Apple Symbols', sans-serif;
  font-size: 2rem;
  color: #1a1a1a;
  line-height: 1;
  user-select: none;
}
.mj-glyph.sm { font-size: 1.25rem; }

/* ===== OPPONENTS ===== */
.mj-oh { display: flex; flex-wrap: wrap; justify-content: center; max-width: 145px; }
.mj-ob { width: 14px; height: 20px; background: #1b5218; border-radius: 2px; border: 1px solid #143d11; display: inline-block; margin: .5px; }
.mj-om { display: flex; flex-wrap: wrap; gap: 2px; justify-content: center; }

/* ===== CENTER DISCARD QUADRANTS ===== */
.mj-dq { display: flex; align-items: center; justify-content: center; }
.mj-dc { display: flex; flex-wrap: wrap; justify-content: center; max-width: 155px; }
#dqTop  .mj-dc { transform: rotate(180deg); }
#dqLeft .mj-dc { transform: rotate(90deg); }
#dqRight .mj-dc { transform: rotate(-90deg); }

/* ===== PLAYER BOTTOM ===== */
#mjMelds { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-bottom: 4px; }
.mj-mg   { display: flex; gap: 1px; background: rgba(0,0,0,.2); border-radius: 4px; padding: 2px; }
#mjHand  { display: flex; flex-wrap: wrap; justify-content: center; }
#mjLabel { font-size: .7rem; color: rgba(255,255,255,.65); text-align: center; margin-top: 3px; }

/* ===== ACTION BAR ===== */
#mjAct {
  background: var(--surface, #12122a); border-radius: 10px; padding: 10px 14px; margin-top: 8px;
  display: flex; flex-direction: column; align-items: center; gap: 8px; min-height: 62px;
}
#mjMsg  { font-size: .83rem; color: var(--text-muted, #9090bb); text-align: center; }
#mjBtns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.mj-ab { padding: 8px 18px; border: none; border-radius: 8px; font-size: .88rem; font-weight: 700;
         cursor: pointer; transition: transform .1s; }
.mj-ab:hover { transform: scale(1.04); }
.mj-ab.pr { background: linear-gradient(135deg, #9480ff, #4ee8df); color: #fff; }
.mj-ab.dn { background: linear-gradient(135deg, #ff6b6b, #ff9f43); color: #fff; }
.mj-ab.wn { background: linear-gradient(135deg, #f9ca24, #f0932b); color: #111; }
.mj-ab.ol { background: transparent; border: 2px solid rgba(148,128,255,.4); color: var(--text, #f0f0ff); }
.mj-ab.gh { background: rgba(255,255,255,.07); color: var(--text-muted, #9090bb); }
.mj-ab.sm { padding: 5px 12px; font-size: .76rem; }

/* ===== RESULT OVERLAY ===== */
#mjResult {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.8);
  z-index: 500; align-items: center; justify-content: center;
}
#mjResult.on { display: flex; }
.mj-rbox {
  background: var(--surface, #12122a); border-radius: 16px; padding: 28px 32px;
  text-align: center; max-width: 420px; width: 90%;
}
.mj-rbox h2 { font-size: 1.6rem; margin-bottom: .5rem; }
.mj-yl { list-style: none; padding: 0; margin: 12px 0;
          display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.mj-yl li { background: rgba(148,128,255,.2); border-radius: 6px; padding: 3px 10px; font-size: .8rem; }
.mj-pr { font-size: 1.3rem; font-weight: 700; margin: 10px 0; }
.mj-ss { font-size: .82rem; color: var(--text-muted, #9090bb); margin: 8px 0; }
.mj-rb { display: flex; gap: 10px; justify-content: center; margin-top: 16px; }

/* ===== TOAST ===== */
#mjToast {
  position: fixed; top: 80px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.85); color: #fff; padding: 7px 18px;
  border-radius: 20px; font-size: .88rem; z-index: 400;
  opacity: 0; transition: opacity .25s; pointer-events: none;
}
#mjToast.on { opacity: 1; }

@media (max-width: 600px) {
  #mjTable { grid-template-columns: 90px 1fr 90px; }
  .mj-t    { font-size: 1.6rem; margin: 1px; }
  .mj-t.sm { font-size: 1rem; margin: .5px; }
  .mj-ob   { width: 10px; height: 14px; }
}
