.mahjong-board {
  position: relative;
  margin: 0 auto;
  /* width/height set dynamically by JS */
}

.mj-tile {
  position: absolute;
  width: 46px;
  height: 56px;
  background: linear-gradient(160deg, #fffaf0, #f5e8c8 100%);
  border: 1px solid #c8b48c;
  border-radius: 5px;
  /* 3-D stack effect via layered box-shadow */
  box-shadow:
    1px 1px 0 #c0a070,
    2px 2px 0 #a88a58,
    3px 3px 0 #8a7040,
    4px 4px 0 rgba(100,75,20,0.35),
    inset 0 1px 0 rgba(255,255,255,0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  font-family: -apple-system, "Microsoft JhengHei", "Noto Sans TC", sans-serif;
  transition: filter .1s, transform .12s;
  box-sizing: border-box;
  /* extra padding so characters don't clip */
  padding: 2px;
}

body.dark .mj-tile {
  background: linear-gradient(160deg, #483a22, #2e2218);
  border-color: #6a5a3a;
  box-shadow:
    1px 1px 0 #2e2418,
    2px 2px 0 #221a10,
    3px 3px 0 #18120a,
    4px 4px 0 rgba(0,0,0,0.40),
    inset 0 1px 0 rgba(255,255,255,0.12);
}

.mj-tile .mj-label {
  font-size: 18px;
  font-weight: 800;
  color: #1a1410;
  line-height: 1.1;
  text-align: center;
  font-family: 'Noto Serif TC', 'Source Han Serif TC', 'SimSun', serif;
}

body.dark .mj-tile .mj-label {
  color: #f0e0c0;
}

.mj-tile .mj-sub {
  font-size: 9px;
  color: #776e65;
  line-height: 1;
  text-align: center;
}

body.dark .mj-tile .mj-sub {
  color: #a09080;
}

/* Non-free tiles: darkened, not clickable */
.mj-tile:not(.free) {
  filter: brightness(0.72) saturate(0.6);
  cursor: not-allowed;
}

.mj-tile.free:hover {
  filter: brightness(1.12);
  transform: translateY(-3px) scale(1.03);
}

.mj-tile.selected {
  background: #fff8c0;
  border-color: var(--accent);
  box-shadow:
    1px 1px 0 #c8a820,
    2px 2px 0 #a88a10,
    3px 3px 0 #8a6c00,
    0 0 0 2px var(--accent),
    0 0 12px rgba(237,194,46,0.40);
  transform: translateY(-2px);
  filter: brightness(1.08);
}

body.dark .mj-tile.selected {
  background: #4a3a10;
}

.mj-tile.hint {
  animation: hint-pulse .45s ease infinite alternate;
}

@keyframes hint-pulse {
  from { filter: brightness(1.0); }
  to   { filter: brightness(1.45) drop-shadow(0 0 5px var(--accent)); }
}

.mj-tile.removed {
  display: none;
}

/* Overlay (win / stuck) */
.overlay[hidden] { display: none; }
.overlay {
  position: absolute;
  inset: 0;
  background: var(--overlay-bg, rgba(238,228,218,0.88));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border-radius: var(--radius-lg);
  z-index: 9999;
}

main.app {
  position: relative;
}

.overlay-text {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-strong);
}

.overlay-sub {
  font-size: 1rem;
  color: var(--text-muted);
  text-align: center;
}

/* Scroll fallback for boards too wide to scale (very narrow viewports) */
.board-wrapper {
  overflow-x: auto;
  overflow-y: visible;
  display: flex;
  justify-content: center;
}

/* SitePause: hide tiles while paused */
.mahjong-board.site-paused { visibility: hidden; }
