#sanma-wrap {
  max-width: 920px !important;
  margin: 0 auto !important;
  padding: 2px !important;
  background:
    repeating-linear-gradient(88deg, transparent, transparent 5px, rgba(0,0,0,0.04) 5px, rgba(0,0,0,0.04) 6px),
    repeating-linear-gradient(178deg, transparent, transparent 5px, rgba(0,0,0,0.04) 5px, rgba(0,0,0,0.04) 6px),
    linear-gradient(160deg, #6b4820 0%, #4e3218 40%, #5c3d1e 70%, #3d2410 100%) !important;
  color: #f0f3f0 !important;
  border-radius: 10px !important;
  border: 3px solid #8a6030 !important;
  box-shadow:
    inset 0 0 0 1px rgba(255,215,120,0.15),
    inset 0 2px 0 rgba(255,200,100,0.12),
    0 16px 40px rgba(0,0,0,0.45) !important;
  font-family: 'Yu Gothic UI', 'Meiryo', sans-serif !important;
}

#sanma-header h3 {
  margin: 0 !important;
  padding: 0 !important;
  font-size: 13px !important;
  color: #f0f3f0 !important;
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  line-height: 1.3 !important;
  font-weight: 700 !important;
  list-style: none !important;
}

#sanma-sub {
  color: #cdd8d1;
  font-size: 10px;
  margin-top: 0;
}

#sanma-status-bar {
  margin-top: 2px;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 11px;
  padding: 1px 4px;
  border-radius: 8px;
  background: rgba(9, 20, 16, 0.5);
  border: 1px solid #2d5e48;
}

/* sm-doraを横長にして王牌が同じ行に入るようにする */
#sm-dora {
  display: inline-flex !important;
  align-items: center;
  flex-wrap: wrap;
  gap: 3px;
}

/* ==============================
   王牌エリア（status-barの直下・独立div）
   ============================== */
#sanma-wrap #sm-deadwall {
  display: block !important;
  margin-top: 2px !important;
  padding: 2px 4px !important;
  background: rgba(9, 20, 16, 0.5) !important;
  border: 1px solid #2d5e48 !important;
  border-radius: 0 0 8px 8px !important;
  line-height: 1 !important;
}

#sanma-wrap .sm-dw-label {
  display: inline-block !important;
  font-size: 10px !important;
  font-weight: bold !important;
  color: #7a9a88 !important;
  vertical-align: top !important;
  margin-right: 6px !important;
  margin-top: 10px !important;
}

#sanma-wrap .sm-dw-grid {
  display: inline-grid !important;
  grid-template-columns: repeat(7, 26px) !important;
  grid-template-rows: repeat(2, 36px) !important;
  gap: 2px !important;
  vertical-align: top !important;
}

#sanma-wrap .sm-dw-tile {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 26px !important;
  height: 36px !important;
  border-radius: 3px !important;
  overflow: hidden !important;
  box-sizing: border-box !important;
}

#sanma-wrap .sm-dw-tile.sm-dw-back {
  background: linear-gradient(160deg, #3a5a48 0%, #1e3028 100%) !important;
  border: 1px solid #4a6a58 !important;
}

#sanma-wrap .sm-dw-tile.sm-dw-dora {
  background: linear-gradient(180deg, #fffbe8 0%, #f5e8a0 100%) !important;
  border: 2px solid #d4a010 !important;
  box-shadow: 0 0 5px rgba(212,160,16,0.6) !important;
}

#sanma-wrap .sm-dw-tile-img {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  display: block !important;
}

#sanma-wrap .sm-dw-tile.sm-dw-used {
  background: rgba(0, 0, 0, 0.35) !important;
  border: 1px solid #2a3a30 !important;
}

/* 裏ドラ（アガリ後に開く、青枠） */
#sanma-wrap .sm-dw-tile.sm-dw-uradora {
  background: linear-gradient(180deg, #e8f4ff 0%, #b0d8f8 100%) !important;
  border: 2px solid #4080c0 !important;
  box-shadow: 0 0 5px rgba(64,128,200,0.6) !important;
}

/* Bot 手牌公開エリア */
#sanma-wrap .sm-bot-hand {
  margin-top: 6px;
  padding: 4px 6px;
  background: rgba(0,0,0,0.25);
  border-radius: 4px;
}

#sanma-wrap .sm-bot-hand-label {
  display: block;
  font-size: 10px;
  color: #9ab;
  margin-bottom: 3px;
}

#sanma-wrap .sm-bot-hand-row {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  align-items: center;
}

#sanma-wrap .sm-bot-hand-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 29px;
  background: linear-gradient(180deg, #fffef9 0%, #f0ece0 100%);
  border: 1px solid #c8b88a;
  border-radius: 3px;
  overflow: hidden;
  flex-shrink: 0;
}

#sanma-wrap .sm-bot-hand-tile img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

#sanma-wrap .sm-bot-hand-tile.sm-is-dora {
  border: 2px solid #d4a010;
  box-shadow: 0 0 4px rgba(212,160,16,0.7);
}

#sanma-wrap .sm-bot-hand-tile.sm-winner-tile {
  border-color: #e04040;
  box-shadow: 0 0 5px rgba(220,60,60,0.8);
}

#sanma-wrap .sm-bot-hand-sep {
  display: inline-block;
  width: 6px;
}

#sanma-wrap .sm-bot-hand-tile.sm-meld-tile {
  background: linear-gradient(180deg, #f0ffe8 0%, #c8e8b0 100%);
  border-color: #5a9a40;
}

#sanma-wrap #sanma-table {
  margin-top: 2px !important;
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 2px !important;
  background:
    repeating-linear-gradient(
      45deg,
      transparent, transparent 3px,
      rgba(0,0,0,0.06) 3px, rgba(0,0,0,0.06) 6px
    ),
    repeating-linear-gradient(
      -45deg,
      transparent, transparent 3px,
      rgba(0,0,0,0.06) 3px, rgba(0,0,0,0.06) 6px
    ),
    radial-gradient(ellipse at 50% 50%, #2e8252 0%, #1c6038 55%, #104025 100%) !important;
  border: 8px solid #7a5228 !important;
  border-radius: 6px !important;
  padding: 2px !important;
  box-shadow:
    inset 0 0 50px rgba(0,0,0,0.45),
    inset 0 0 0 2px rgba(200,160,80,0.14) !important;
  position: relative !important;
}

.sm-player {
  border: 1px solid rgba(255,255,255,0.15);
  background: linear-gradient(180deg, rgba(10, 30, 20, 0.75), rgba(5, 15, 10, 0.65));
  border-radius: 4px;
  padding: 2px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.1),
    0 2px 8px rgba(0,0,0,0.35);
  backdrop-filter: blur(2px);
}

.sm-you {
  grid-column: 1 / span 2;
  border-color: #d8b65a;
}

.sm-name {
  font-weight: 700;
}

.sm-seat,
.sm-score {
  font-size: 11px;
  color: #d4ddd7;
  margin-top: 0;
}

.sm-river {
  margin-top: 0;
  min-height: 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1px;
}

.sm-river-tile-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 29px;
  background: linear-gradient(180deg, #fffef9 0%, #f0ece0 100%);
  border: 1px solid #c8b88a;
  border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
}

.sm-river-tile-wrap img {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  display: block !important;
}

.sm-river-tile {
  width: 22px !important;
  height: auto !important;
  border-radius: 2px;
  display: block !important;
  object-fit: contain;
}

.sm-river-sep {
  color: #aec7bc;
  margin: 0 4px;
  font-size: 13px;
}

.sm-meld-label {
  font-size: 11px;
  color: #d4ddd7;
  align-self: center;
}

/* 鳴き牌グループ */
.sm-meld-wrap {
  display: inline-flex !important;
  gap: 1px !important;
  align-items: center !important;
  margin-left: 2px !important;
  border: 1px solid #a07030 !important;
  border-radius: 3px !important;
  padding: 1px 2px !important;
  background: rgba(120, 80, 20, 0.2) !important;
}

/* 自摸切りマーク */
.sm-river-tile-wrap.sm-tsumo-giri {
  position: relative !important;
}
.sm-river-tile-wrap.sm-tsumo-giri::after {
  content: 'ツ' !important;
  position: absolute !important;
  bottom: -1px !important;
  right: -1px !important;
  font-size: 8px !important;
  color: #f0e040 !important;
  background: rgba(0,0,0,0.65) !important;
  border-radius: 2px !important;
  line-height: 1 !important;
  padding: 0 1px !important;
  pointer-events: none !important;
}

/* 立直宣言牌（横向き） */
.sm-river-tile-wrap.sm-riichi-tile {
  width: 29px !important;
  height: 22px !important;
  overflow: visible !important;
  border: 1px solid #e08030 !important;
  box-shadow: 0 0 5px rgba(220,120,30,0.7) !important;
}
.sm-river-tile-wrap.sm-riichi-tile img,
.sm-river-tile-wrap.sm-riichi-tile span.sm-tile-text {
  transform: rotate(90deg) !important;
  transform-origin: center !important;
  width: 22px !important;
  height: 29px !important;
  object-fit: contain !important;
}

#sanma-controls,
#sm-advice-panel,
#sm-hand-panel,
#sm-log-panel {
  margin-top: 2px;
  border: 1px solid #2f614b;
  border-radius: 4px;
  background: rgba(8, 18, 15, 0.58);
  padding: 2px 4px;
}

/* 手牌 + 鳴き牌を横並びにするコンテナ */
#sm-hand-row {
  display: flex !important;
  align-items: flex-end !important;
  gap: 12px !important;
  flex-wrap: wrap !important;
}

/* 鳴き牌グループコンテナ */
#sm-melds {
  display: flex !important;
  gap: 8px !important;
  align-items: flex-end !important;
  flex-wrap: wrap !important;
}

/* 1副露グループ */
.sm-meld-group {
  display: inline-flex !important;
  align-items: center !important;
  gap: 2px !important;
  border: 1px solid #7a5520 !important;
  border-radius: 4px !important;
  padding: 4px !important;
  background: rgba(80, 50, 10, 0.25) !important;
  min-height: 52px !important;
}

/* 鳴き牌1枚のラッパー */
.sm-meld-tile-wrap {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 36px !important;
  height: 48px !important;
  background: linear-gradient(180deg, #fffef9 0%, #f4f1e8 70%, #e6e1d3 100%) !important;
  border: 1.5px solid #c8b88a !important;
  border-radius: 4px !important;
  box-shadow: 0 2px 4px rgba(0,0,0,0.25) !important;
  overflow: hidden !important;
  flex-shrink: 0 !important;
}

.sm-meld-tile-wrap img {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
}

/* 横向き（鳴かせた牌） */
.sm-meld-tile-wrap.sm-meld-sideways {
  width: 48px !important;
  height: 36px !important;
  transform: rotate(90deg) !important;
  transform-origin: center !important;
  border-color: #d4a020 !important;
  box-shadow: 0 0 6px rgba(220,160,30,0.6), 0 2px 4px rgba(0,0,0,0.25) !important;
}

/* 裏向き（暗カンの端2枚） */
.sm-meld-tile-wrap.sm-meld-facedown {
  background: linear-gradient(135deg, #1a3a2a 0%, #0d2018 60%, #142d1e 100%) !important;
  border-color: #4a7755 !important;
}

.sm-meld-back {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  background:
    repeating-linear-gradient(45deg, transparent, transparent 3px, rgba(255,255,255,0.05) 3px, rgba(255,255,255,0.05) 4px) !important;
}

#sm-message {
  font-size: 11px;
  margin-bottom: 2px;
}

#sm-actions {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
}

#sm-actions button {
  border: 1px solid #4a7f67;
  background: linear-gradient(180deg, #2f654f, #214c39);
  color: #eef5f1;
  border-radius: 4px;
  padding: 3px 6px;
  cursor: pointer;
  font-size: 11px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.22);
}

#sm-actions button:hover {
  background: linear-gradient(180deg, #3a7b5f, #2d624b);
}

.sm-panel-title {
  font-size: 10px;
  color: #ced8d1;
  margin-bottom: 1px;
  border-bottom: 1px solid #315f4b;
  padding-bottom: 0;
}

#sm-advice-body {
  line-height: 1.2;
  font-size: 11px;
  white-space: pre-wrap;
}

#sm-hand {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.sm-hand-sep {
  display: inline-block;
  width: 6px;
  height: 58px;
  background: linear-gradient(180deg, rgba(255,220,100,0.6), rgba(255,180,50,0.3));
  border-radius: 3px;
  flex-shrink: 0;
  align-self: center;
}

.sm-tile.sm-drawn {
  border-color: #d4a020;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.9),
    inset 0 -2px 0 rgba(0,0,0,0.08),
    0 0 8px rgba(255,200,50,0.7),
    0 3px 6px rgba(0,0,0,0.22);
}

.sm-tile.sm-riichi-candidate {
  border-color: #dd0000 !important;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.9),
    inset 0 -2px 0 rgba(0,0,0,0.08),
    0 0 10px rgba(220, 0, 0, 0.85),
    0 3px 6px rgba(0,0,0,0.22) !important;
}

.sm-tile.sm-riichi-candidate:hover {
  background: linear-gradient(180deg, #fff8f8, #ffe0e0) !important;
}

.sm-tile {
  border: 2px solid #c8b88a;
  background: linear-gradient(180deg, #fffef9 0%, #f4f1e8 70%, #e6e1d3 100%);
  border-radius: 6px;
  width: 44px;
  height: 58px;
  padding: 3px;
  cursor: pointer;
  box-sizing: border-box;
  overflow: hidden;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.85),
    inset 0 -2px 0 rgba(0,0,0,0.08),
    0 3px 6px rgba(0,0,0,0.22);
  transform: translateY(0);
  transition: transform .08s ease, box-shadow .08s ease, background .12s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sm-tile:hover {
  background: linear-gradient(180deg, #fffdf1 0%, #f8f4e4 70%, #ebe4cf 100%);
  transform: translateY(-4px);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.9),
    inset 0 -2px 0 rgba(0,0,0,0.08),
    0 8px 14px rgba(0,0,0,0.32);
}

.sm-tile:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none;
}

.sm-tile.sm-red {
  border-color: #c06060;
  background: linear-gradient(180deg, #fff5f5 0%, #f7e6e6 74%, #ead4d4 100%);
}

.sm-tile-img {
  width: 36px;
  height: auto;
  display: block;
  pointer-events: none;
}

/* 手牌ボタン内では親に合わせる */
.sm-tile .sm-tile-img {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
}

.sm-tile-text {
  font-size: 11px;
  font-weight: 700;
  color: #333;
  line-height: 1;
  pointer-events: none;
}

.sm-status-tile {
  width: 22px !important;
  height: auto !important;
  object-fit: contain;
  vertical-align: middle;
  display: inline-block !important;
}

.sm-dora-label {
  font-size: 11px;
  font-weight: bold;
  color: #b8860b;
  letter-spacing: 0.05em;
  margin-right: 4px;
  vertical-align: middle;
}

.sm-dora-tile-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 48px;
  background: linear-gradient(180deg, #fffbe8 0%, #f5e8a0 100%);
  border: 2px solid #d4a010;
  border-radius: 4px;
  box-shadow:
    0 0 8px rgba(212,160,16,0.7),
    0 2px 4px rgba(0,0,0,0.3);
  overflow: hidden;
  vertical-align: middle;
  flex-shrink: 0;
}

.sm-dora-tile-wrap img {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  display: block !important;
}

/* 裏ドララベル */
.sm-dora-label.sm-ura-label {
  color: #7ab0e0 !important;
  margin-left: 8px !important;
}

/* 裏ドラ牌（青枠） */
.sm-dora-tile-wrap.sm-ura-dora-tile-wrap {
  background: linear-gradient(180deg, #e8f4ff 0%, #b0d8f8 100%) !important;
  border-color: #4080c0 !important;
  box-shadow:
    0 0 8px rgba(64,128,200,0.7),
    0 2px 4px rgba(0,0,0,0.3) !important;
}

/* 手牌内ドラ牌ハイライト */
.sm-tile.sm-is-dora {
  border-color: #d4a010 !important;
  background: linear-gradient(180deg, #fffbe8 0%, #f5e8a0 60%, #e8d070 100%) !important;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.9),
    inset 0 -2px 0 rgba(0,0,0,0.08),
    0 0 6px rgba(212,160,16,0.6),
    0 3px 6px rgba(0,0,0,0.2) !important;
}

/* 待ち牌エリア */
#sm-waits {
  min-height: 14px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  padding: 0 2px;
  margin-bottom: 0;
}

.sm-waits-label {
  font-size: 12px;
  font-weight: bold;
  color: #1a5c1a;
  background: rgba(255,255,255,0.7);
  padding: 2px 5px;
  border-radius: 3px;
  flex-shrink: 0;
}

.sm-wait-tile-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 35px;
  background: linear-gradient(180deg, #e8ffe8 0%, #c0f0c0 100%);
  border: 1.5px solid #2a8a2a;
  border-radius: 3px;
  box-shadow:
    0 0 5px rgba(42,138,42,0.5),
    0 1px 3px rgba(0,0,0,0.2);
  overflow: hidden;
  flex-shrink: 0;
}

.sm-wait-tile-wrap img {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  display: block !important;
}

#sm-log {
  max-height: 60px;
  overflow-y: auto;
  line-height: 1.2;
  font-size: 10px;
  white-space: pre-wrap;
}

@media (max-width: 640px) {
  #sanma-table {
    grid-template-columns: 1fr;
  }

  .sm-you {
    grid-column: auto;
  }

  /* 牌を2/3サイズに縮小 */
  .sm-tile {
    width: 29px !important;
    height: 38px !important;
    padding: 2px !important;
    border-radius: 4px !important;
  }

  .sm-tile-text {
    font-size: 8px !important;
  }

  /* 捨て牌を小さく */
  .sm-river-tile-wrap {
    width: 15px !important;
    height: 20px !important;
  }

  .sm-river-tile-wrap.sm-riichi-tile {
    width: 20px !important;
    height: 15px !important;
  }

  .sm-river-tile-wrap.sm-riichi-tile img,
  .sm-river-tile-wrap.sm-riichi-tile span.sm-tile-text {
    width: 15px !important;
    height: 20px !important;
  }

  .sm-river {
    gap: 1px !important;
  }
}

/* ============================
   エフェクト表示
   ============================ */

#sanma-table {
  position: relative !important;
}

.sm-effect {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.5);
  font-size: 64px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 20px rgba(255,80,0,0.9), 4px 4px 0 #800, -2px -2px 0 #600;
  white-space: nowrap;
  pointer-events: none;
  z-index: 200;
  opacity: 0;
  transition: none;
}
.sm-effect.sm-effect-show {
  animation: sm-effect-pop 1.2s ease-out forwards;
}
.sm-effect.sm-effect-hide {
  opacity: 0 !important;
}
@keyframes sm-effect-pop {
  0%   { transform: translate(-50%,-50%) scale(0.3); opacity: 1; }
  25%  { transform: translate(-50%,-50%) scale(1.3); opacity: 1; }
  55%  { transform: translate(-50%,-50%) scale(1.0); opacity: 1; }
  85%  { transform: translate(-50%,-50%) scale(1.05); opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(1.2); opacity: 0; }
}
/* 各エフェクトの色 */
.sm-effect-riichi {
  color: #ffd700;
  text-shadow: 0 0 20px rgba(255,200,0,0.9), 3px 3px 0 #a06000, -2px -2px 0 #604000;
}
.sm-effect-tsumo {
  color: #60ff60;
  text-shadow: 0 0 20px rgba(0,255,0,0.7), 3px 3px 0 #006000, -2px -2px 0 #004000;
}
.sm-effect-ron {
  color: #ff6060;
  text-shadow: 0 0 20px rgba(255,0,0,0.7), 3px 3px 0 #800000, -2px -2px 0 #500000;
}
.sm-effect-pon {
  color: #80cfff;
  text-shadow: 0 0 16px rgba(0,120,255,0.7), 3px 3px 0 #003080, -2px -2px 0 #002050;
}
.sm-effect-kan {
  color: #ff90ff;
  text-shadow: 0 0 16px rgba(200,0,255,0.7), 3px 3px 0 #600060, -2px -2px 0 #400040;
}

/* ============================
   ご褒美イラスト
   ============================ */

/* ご褒美を見るボタン */
#sm-reward-btn {
  padding: 8px 18px !important;
  background: linear-gradient(135deg, #e84393, #c0145a) !important;
  color: #fff !important;
  border: none !important;
  border-radius: 20px !important;
  cursor: pointer !important;
  font-size: 14px !important;
  font-weight: bold !important;
  box-shadow: 0 2px 8px rgba(232,67,147,0.5) !important;
  animation: sm-reward-pulse 1.5s infinite !important;
}
@keyframes sm-reward-pulse {
  0%,100% { transform: scale(1); }
  50%      { transform: scale(1.05); }
}

/* ご褒美オーバーレイ */
#sm-reward-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 9999;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  cursor: pointer;
}
#sm-reward-overlay.active {
  display: flex;
}
.sm-reward-msg {
  font-size: 28px;
  font-weight: bold;
  color: #ffd700;
  text-shadow: 0 0 20px #ffd700;
}
#sm-reward-img {
  max-width: 80vw;
  max-height: 70vh;
  border-radius: 8px;
  box-shadow: 0 4px 30px rgba(0,0,0,0.8);
}
.sm-reward-hint {
  color: #aaa;
  font-size: 14px;
}
