* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
  background: #0b3d24;
  color: #eee;
  overflow: hidden;
}
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}
#topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 6px 14px;
  background: #052715;
  border-bottom: 2px solid #1a5c38;
  font-size: 14px;
  flex-shrink: 0;
}
#topbar #roundInfo { font-weight: bold; font-size: 16px; }
#topbar button {
  margin-left: auto;
  padding: 4px 12px;
  border-radius: 6px;
  border: none;
  background: #2d7a4d;
  color: #fff;
  cursor: pointer;
}
#topbar button:hover { background: #38935e; }

#table {
  flex: 1;
  display: grid;
  grid-template-columns: 140px 1fr 140px;
  grid-template-rows: 150px 1fr 170px;
  gap: 4px;
  padding: 6px;
  min-height: 0;
}
.seat-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 0;
  min-width: 0;
}
#seat-top { grid-column: 2; grid-row: 1; }
#seat-left { grid-column: 1; grid-row: 2; }
#seat-right { grid-column: 3; grid-row: 2; }
#seat-bottom { grid-column: 2; grid-row: 3; }
#center-info {
  grid-column: 2; grid-row: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #12603a 0%, #0b3d24 75%);
  border-radius: 12px;
  border: 3px solid #1a5c38;
  padding: 8px;
  min-height: 0;
  overflow: hidden;
}

.player-label {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 10px;
  background: #05271580;
  white-space: nowrap;
}
.player-label.dealer { background: #a13a2a; font-weight: bold; }
.player-label.riichi { outline: 2px solid #e0c040; }
.player-label.current-turn { outline: 2px solid #6fe0a0; }

.hand-row { display: flex; gap: 2px; }
.meld-row { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.discard-pond {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  max-width: 220px;
  justify-content: center;
  align-content: flex-start;
}
#seat-top .discard-pond, #seat-bottom .discard-pond { max-width: 320px; }

.tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fdfdf5;
  color: #111;
  border-radius: 4px;
  border: 1px solid #999;
  box-shadow: 0 1px 2px rgba(0,0,0,0.4);
  font-size: 22px;
  width: 30px;
  height: 40px;
  flex-shrink: 0;
  user-select: none;
}
.tile.small { font-size: 16px; width: 22px; height: 30px; }
.tile.tiny { font-size: 13px; width: 16px; height: 22px; }
.tile.back {
  background: repeating-linear-gradient(45deg, #1a5c38, #1a5c38 4px, #14472c 4px, #14472c 8px);
  border: 1px solid #0b3d24;
}
.tile.dora-tile { box-shadow: 0 0 6px 2px #ffcc33; }
.tile.called { outline: 2px solid #6fa8ff; transform: rotate(8deg); }

.human-hand .tile {
  cursor: pointer;
  transition: transform 0.1s;
  font-size: 30px;
  width: 38px;
  height: 52px;
}
.human-hand .tile:hover { transform: translateY(-8px); }
.human-hand .tile.drawn { margin-left: 8px; }

#seat-left .hand-row, #seat-right .hand-row { flex-direction: column; }

#doraDisplay { font-size: 13px; margin-bottom: 6px; text-align: center; }
#log {
  font-size: 11px;
  color: #cde;
  max-height: 90px;
  overflow-y: auto;
  width: 90%;
  text-align: center;
  line-height: 1.5;
}

#actionBar {
  flex-shrink: 0;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px;
  background: #052715;
  border-top: 2px solid #1a5c38;
  flex-wrap: wrap;
}
#actionBar button {
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
  color: #fff;
  background: #b0862c;
}
#actionBar button:hover { filter: brightness(1.15); }
#actionBar button.riichi { background: #c0392b; }
#actionBar button.win { background: #d4af37; color: #222; }
#actionBar button.skip { background: #555; }
#actionBar .hint { font-size: 13px; color: #ddc; }

#modalOverlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
#modalOverlay.hidden { display: none; }
#modalContent {
  background: #123425;
  border: 2px solid #2d7a4d;
  border-radius: 12px;
  padding: 24px 32px;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
  text-align: center;
}
#modalContent h2 { margin-top: 0; }
#modalContent table { margin: 0 auto; border-collapse: collapse; }
#modalContent td, #modalContent th { padding: 3px 10px; font-size: 14px; text-align: left; }
#modalContent .yaku-list { font-size: 13px; color: #dde; margin: 8px 0; text-align: left; display: inline-block; }
#modalContent button {
  margin-top: 16px;
  padding: 10px 24px;
  border-radius: 8px;
  border: none;
  background: #2d7a4d;
  color: #fff;
  font-size: 15px;
  cursor: pointer;
}
#modalContent button:hover { background: #38935e; }
.score-plus { color: #6fe0a0; }
.score-minus { color: #e07070; }
