/* Mahjong Solitaire — own styles, theme variables only. Tiles are cream objects on both a
   light and a dark site (--gm-mj-face / --gm-mj-side with fixed fallbacks); the ink colours
   of the faces are --gm-mj-ink / -red / -green / -blue. */

.mj {
  width: 100%;
  max-width: 640px;
}

.mj-bar {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.mj-stat {
  flex: 1;
  min-width: 0;
  padding: 8px 10px 6px;
  text-align: center;
  border-radius: 10px;
  background: var(--gm-surface, #1b2740);
  border: 1px solid var(--gm-line, rgba(255, 255, 255, 0.09));
}

.mj-stat b {
  display: block;
  font: 500 1.35rem/1.15 var(--gm-display, "Fraunces", Georgia, serif);
  font-variant-numeric: tabular-nums;
}

.mj-lab {
  display: block;
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gm-muted, rgba(242, 238, 230, 0.66));
}

.mj-wrap {
  width: 100%;
  padding: 8px;
  box-sizing: border-box;
  overflow-x: auto;
  overflow-y: hidden;
  background: var(--gm-surface, #1b2740);
  border: 1px solid var(--gm-line, rgba(255, 255, 255, 0.09));
  border-radius: var(--gm-radius, 12px);
  -webkit-overflow-scrolling: touch;
}

.mj-board {
  --dz: 4px;
  --tw: 36px;
  --th: 48px;
  position: relative;
  margin: 0 auto;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.mj-tile {
  appearance: none;
  -webkit-appearance: none;
  position: absolute;
  display: block;
  width: var(--tw);
  height: var(--th);
  margin: 0;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.35);
  border-radius: 12%;
  background: var(--gm-mj-face, #f8f2e2);
  box-shadow: var(--dz) var(--dz) 0 var(--gm-mj-side, #c9b283), calc(var(--dz) + 1px) calc(var(--dz) + 1px) 4px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  touch-action: manipulation;
  transition: filter 0.15s ease, transform 0.15s ease;
}

.mj-tile[hidden] { display: none; }

.mj-tile svg {
  position: absolute;
  inset: 6% 8%;
  width: 84%;
  height: 88%;
  pointer-events: none;
}

.mj-tile.is-blocked {
  cursor: default;
  filter: brightness(0.78) saturate(0.85);
}

.mj-tile:focus-visible {
  outline: 3px solid var(--gm-accent-bright, #e0584a);
  outline-offset: 1px;
}

.mj-tile.is-selected {
  background: var(--gm-mj-face-sel, #fff0b0);
  outline: 3px solid var(--gm-accent, #c0392b);
  outline-offset: 0;
  transform: translate(-2px, -2px);
}

.mj-tile.is-hint {
  outline: 3px solid var(--gm-accent-bright, #e0584a);
  outline-offset: 0;
  animation: mj-pulse 0.7s ease-in-out 3;
}

.mj-tile.is-shake { animation: mj-shake 0.35s ease; }

.mj-shuffle {
  flex: none;
  margin-left: auto;
  min-height: 40px;
  white-space: nowrap;
  padding: 8px 16px;
  font-family: var(--gm-body, "DM Sans", system-ui, sans-serif);
  font-size: 0.86rem;
}

.mj-shuffle[hidden] { display: none; }

#gm-mahjong .gm-status { margin-top: 12px; }
#gm-mahjong .gm-status .gm-status-text { flex: 1 1 auto; min-width: 0; }
#gm-mahjong .gm-status.is-stuck .gm-dot { background: var(--gm-accent-bright, #e0584a); }

.gm-seg button,
.gm-actions .gm-btn { min-height: 44px; }

@keyframes mj-pulse {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-3px, -3px); }
}

@keyframes mj-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

@media (max-width: 480px) {
  .mj-bar { gap: 6px; }
  .mj-stat { padding: 8px 6px 6px; }
  .mj-stat b { font-size: 1.15rem; }
  .mj-wrap { padding: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .mj-tile, .mj-tile.is-hint, .mj-tile.is-shake { animation: none; transition: none; }
}
