/* ===== リセット & ベース ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 18px; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Hiragino Kaku Gothic ProN', 'Meiryo', 'ヒラギノ角ゴ ProN', sans-serif;
  background: #1a3d1a;
  color: #fff;
  min-height: 100vh;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* ===== 画面切替 ===== */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; }

/* ===== ホーム画面 ===== */
#screen-home {
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 40px 24px;
  background: linear-gradient(160deg, #1a3d1a 0%, #2d6b2d 100%);
}
#screen-home h1 {
  font-size: 2.6rem;
  text-align: center;
  text-shadow: 2px 2px 8px rgba(0,0,0,0.6);
  line-height: 1.3;
}
#screen-home .subtitle {
  font-size: 1.2rem;
  color: #c8f0c8;
  text-align: center;
}
.appeal-points {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 360px;
}
.appeal-points span {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.95rem;
  color: #e0f0e0;
  white-space: nowrap;
}
.btn-primary {
  display: flex; flex-direction: column; align-items: center;
  background: #e63946;
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 22px 48px;
  font-size: 1.7rem;
  font-weight: bold;
  cursor: pointer;
  width: 100%; max-width: 360px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
  transition: transform .1s, box-shadow .1s;
  line-height: 1.4;
}
.btn-primary:active { transform: scale(0.97); box-shadow: 0 2px 8px rgba(0,0,0,0.4); }
.btn-primary .btn-sub { font-size: 1rem; opacity: 0.85; font-weight: normal; }
.btn-secondary {
  background: #2d6b2d;
  color: #c8f0c8;
  border: 3px solid #4caf50;
  border-radius: 20px;
  padding: 18px 48px;
  font-size: 1.4rem;
  cursor: pointer;
  width: 100%; max-width: 360px;
  transition: background .15s;
}
.btn-secondary:active { background: #3d8b3d; }

/* ===== チュートリアル画面 ===== */
#screen-tutorial {
  background: #1a3d1a;
  padding: 24px 20px;
  gap: 20px;
}
.tut-header { display: flex; justify-content: space-between; align-items: center; }
.tut-header button {
  background: none; border: none; color: #c8f0c8; font-size: 1rem; cursor: pointer; padding: 8px;
}
#tut-step { font-size: 1rem; color: #c8f0c8; }
#tut-title {
  font-size: 1.8rem;
  text-align: center;
  color: #fff;
  line-height: 1.3;
}
#tut-body {
  font-size: 1.2rem;
  line-height: 1.9;
  white-space: pre-line;
  color: #e0f0e0;
  text-align: center;
  padding: 0 8px;
}
#tut-tiles {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  min-height: 80px;
  padding: 12px;
  background: rgba(0,0,0,0.2);
  border-radius: 16px;
}
.tut-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 0 4px;
  margin-top: auto;
}
.tut-nav button {
  background: #2d6b2d;
  color: #fff;
  border: 2px solid #4caf50;
  border-radius: 14px;
  padding: 16px 28px;
  font-size: 1.3rem;
  cursor: pointer;
  flex: 1;
}
#tut-next { background: #e63946; border-color: #e63946; }
#tut-next:active { background: #c62828; }

/* ===== ゲーム画面 ===== */
#screen-game {
  background: #0e2b0e;
  padding: 8px;
  gap: 6px;
}
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
}
.game-header button {
  background: none; border: 2px solid #4caf50;
  color: #c8f0c8; border-radius: 10px; padding: 6px 14px;
  font-size: 0.9rem; cursor: pointer;
}
#deck-count { font-size: 1rem; color: #c8f0c8; }

.area-label {
  font-size: 0.85rem;
  color: #8bc08b;
  padding: 2px 8px;
}

/* CPU手牌 */
.cpu-hand-area {
  background: rgba(0,0,0,0.2);
  border-radius: 12px;
  padding: 10px 8px;
}
#cpu-hand {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
  min-height: 60px;
}

/* 捨て牌エリア */
.discard-area {
  background: rgba(0,0,0,0.25);
  border-radius: 12px;
  padding: 8px;
  display: flex;
  gap: 8px;
}
.discard-side { flex: 1; }
.discard-side .area-label { font-size: 0.8rem; }
#cpu-discards, #player-discards {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  min-height: 36px;
}

/* ステータス */
.game-status {
  text-align: center;
  font-size: 1.1rem;
  padding: 8px 12px;
  border-radius: 10px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.game-status.player-turn { background: rgba(76,175,80,0.25); color: #c8f0c8; }
.game-status.tenpai { background: rgba(230,57,70,0.35); color: #ffcc00; font-weight: bold; animation: pulse 1.2s ease-in-out infinite; }
.game-status.cpu-turn { background: rgba(0,0,0,0.3); color: #8bc08b; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.7} }

/* プレイヤー手牌 */
.player-hand-area {
  background: rgba(0,80,0,0.3);
  border-radius: 12px;
  padding: 10px 8px;
  border: 2px solid rgba(76,175,80,0.4);
}
#player-hand {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  min-height: 80px;
}

/* 捨てるボタン */
#btn-discard {
  display: none;
  width: 100%;
  background: #e63946;
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 18px;
  font-size: 1.4rem;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
#btn-discard:active { background: #c62828; }

/* ===== 牌デザイン ===== */
.tile {
  width: 54px;
  height: 72px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  border: 2px solid rgba(255,255,255,0.3);
  transition: transform .12s, box-shadow .12s;
  position: relative;
  cursor: default;
  box-shadow: 2px 3px 6px rgba(0,0,0,0.5);
  overflow: hidden;
}
.tile > svg {
  display: block;
  width: 100%;
  height: 100%;
}
.tile.small {
  width: 30px; height: 40px;
  font-size: 0.55rem;
  border-radius: 5px;
  border-width: 1px;
}
.tile.selected {
  transform: translateY(-10px);
  box-shadow: 0 8px 20px rgba(255,204,0,0.7);
  border-color: #ffcc00;
}
.tile:not(.small)[style*="pointer: pointer"], .tile:not(.small)[style*="cursor: pointer"] {
  cursor: pointer;
}
/* 萬子：赤系 */
.tile.man { background: linear-gradient(145deg, #fff8f0, #ffe0cc); color: #c62828; }
.tile.man .tile-top { font-size: 1.4rem; line-height: 1; }
.tile.man .tile-bot { font-size: 0.7rem; color: #c62828; }
/* 筒子：青系 */
.tile.pin { background: linear-gradient(145deg, #f0f4ff, #ccd8ff); color: #1a3c8b; }
.tile.pin .tile-top { font-size: 1.4rem; line-height: 1; color: #1a3c8b; }
.tile.pin .tile-bot { font-size: 0.7rem; color: #1a3c8b; }
/* 索子：緑系 */
.tile.sou { background: linear-gradient(145deg, #f0fff0, #ccf0cc); color: #1a6b1a; }
.tile.sou .tile-top { font-size: 1.4rem; line-height: 1; color: #1a6b1a; }
.tile.sou .tile-bot { font-size: 0.7rem; color: #1a6b1a; }
/* 字牌：ベージュ・特殊色 */
.tile.honor { background: linear-gradient(145deg, #fffbe6, #fde68a); color: #5a3a00; }
.tile.honor .tile-top { font-size: 1.3rem; line-height: 1; }
/* 裏牌 */
.tile.back { background: linear-gradient(145deg, #2d6b2d, #1a3d1a); border-color: rgba(255,255,255,0.15); }
/* 字牌の特殊色 */
.tile.honor[data-id="31"] .tile-top { color: #666; }   /* 白 */
.tile.honor[data-id="32"] .tile-top { color: #1a6b1a; } /* 發 */
.tile.honor[data-id="33"] .tile-top { color: #c62828; } /* 中 */

/* small牌 */
.tile.small .tile-top { font-size: 0.75rem; line-height: 1; }
.tile.small .tile-bot { font-size: 0.5rem; }

/* ===== 結果オーバーレイ ===== */
#result-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
#result-overlay.active { display: flex; }
.result-box {
  background: #1a3d1a;
  border: 3px solid #4caf50;
  border-radius: 24px;
  padding: 40px 32px;
  text-align: center;
  width: 100%; max-width: 360px;
  gap: 20px;
  display: flex;
  flex-direction: column;
}
#result-title { font-size: 2.2rem; }
#result-msg { font-size: 1.2rem; color: #c8f0c8; line-height: 1.6; }
.result-btns { display: flex; flex-direction: column; gap: 14px; }
.result-btns button {
  padding: 18px;
  border-radius: 14px;
  font-size: 1.3rem;
  border: none;
  cursor: pointer;
  font-weight: bold;
}
.result-btns .btn-again { background: #e63946; color: #fff; font-size: 1.6rem; padding: 24px; }
.result-btns .btn-home  { background: #2d6b2d; color: #c8f0c8; border: 2px solid #4caf50; }

/* ===== ホームのサブリンク ===== */
.link-sub, .link-guide {
  display: block;
  text-align: center;
  font-size: 1.2rem;
  padding: 14px 24px;
  border-radius: 14px;
  cursor: pointer;
  width: 100%; max-width: 360px;
  text-decoration: none;
}
.link-sub {
  color: #c8f0c8;
  background: rgba(255,255,255,0.08);
  border: 2px solid rgba(76,175,80,0.4);
}
.link-guide {
  color: #fde68a;
  background: rgba(253,230,138,0.08);
  border: 2px solid rgba(253,230,138,0.4);
}

/* ===== 練習モード：捨て牌エリア ===== */
.discard-area-solo {
  background: rgba(0,0,0,0.25);
  border-radius: 12px;
  padding: 8px 12px;
}
#player-discards {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 40px;
}

/* ===== 打牌アニメーション（練習モード） ===== */
@keyframes discardThrow {
  0%   { transform: translateY(0) scale(1); opacity: 1; }
  20%  { transform: translateY(-14px) scale(1.1) rotate(-6deg); opacity: 1; }
  60%  { transform: translateY(32px) scale(0.85) rotate(6deg); opacity: 0.7; }
  100% { transform: translateY(88px) scale(0.5) rotate(12deg); opacity: 0; }
}
.tile-discarding {
  animation: discardThrow 0.36s cubic-bezier(0.4, 0, 0.85, 1) forwards;
  pointer-events: none;
  position: relative;
  z-index: 20;
}

/* ===== レスポンシブ（タブレット以上） ===== */
@media (min-width: 600px) {
  html { font-size: 20px; }
  .tile { width: 63px; height: 84px; }
  .tile .tile-top { font-size: 1.6rem; }
}
