/* Mahjong Solitaire — page-specific styles.
   Shared layout, buttons, HUD, sidebar and modal styles come from
   assets/css/components.css + assets/css/game.css; this file only owns the
   layered tile board and the Mahjong-specific furniture. */

.page--mahjong .variant-tabs { margin-top: 16px; }

/* ---------- Stage furniture ---------- */
.mj-stage .mj-topbar {
  flex-wrap: wrap;
  gap: 8px 18px;
  padding-bottom: 10px;
}

.mj-hud {
  gap: clamp(12px, 2.2vw, 26px);
  padding: 0;
  margin-left: auto;
}

.mj-bottombar {
  flex-wrap: wrap;
  gap: 10px 16px;
}

.mj-toolbar {
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.mj-toolbar .btn {
  min-height: 34px;
  padding: 6px 12px;
  font-size: 0.82rem;
}

.mj-toolbar .btn .icon { width: 16px; height: 16px; }
.mj-toolbar .btn span { white-space: nowrap; }

.mj-status {
  color: rgba(247, 240, 227, 0.72);
  font-size: 0.76rem;
  min-width: 0;
}

.mj-assist {
  text-align: center;
  font-size: 0.84rem;
  margin: 12px 6px 0;
}

/* ---------- Board ---------- */
.mahjong-board-wrap {
  position: relative;
  z-index: 1;
  padding: clamp(14px, 2.4vw, 30px);
  min-height: clamp(240px, 46vh, 560px);
  overflow: auto;
  display: block;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(247, 240, 227, 0.25) transparent;
}

.mahjong-board-wrap::-webkit-scrollbar { height: 8px; width: 8px; }
.mahjong-board-wrap::-webkit-scrollbar-thumb { background: rgba(247, 240, 227, 0.22); border-radius: 999px; }

.mahjong-board {
  position: relative;
  margin: 0 auto;
  touch-action: manipulation;
}

/* ---------- Tiles ---------- */
.mj-tile {
  position: absolute;
  display: block;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  border-radius: calc(var(--mj-tile-w, 48px) * 0.11);
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  outline: 2px solid transparent;
  outline-offset: 0;
  filter: brightness(0.9) saturate(0.94);
  box-shadow:
    0 2px 0 rgba(8, 24, 18, 0.34),
    0 5px 10px rgba(8, 24, 18, 0.22);
  transition:
    transform 130ms var(--ease),
    filter 130ms var(--ease),
    box-shadow 130ms var(--ease),
    opacity 170ms var(--ease),
    outline-color 100ms linear;
}

.mj-tile img {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  -webkit-user-drag: none;
  border-radius: inherit;
}

.mj-tile.is-free { cursor: pointer; filter: none; }

.mj-tile.is-free:hover {
  transform: translateY(-2px);
  box-shadow:
    0 3px 0 rgba(8, 24, 18, 0.38),
    0 9px 16px rgba(8, 24, 18, 0.3);
}

.mj-tile.is-free:active { transform: translateY(0) scale(0.98); }

.mj-tile.is-selected {
  outline-color: var(--gold);
  filter: none;
  transform: translateY(-3px);
  z-index: 9000 !important;
  box-shadow:
    0 0 0 3px rgba(200, 162, 83, 0.5),
    0 12px 22px rgba(0, 0, 0, 0.34);
}

.mj-tile.is-hint {
  filter: none;
  z-index: 8500 !important;
  animation: mj-hint 1.05s var(--ease) infinite;
}

.mj-tile.is-invalid { animation: shake 340ms var(--ease); }

.mj-tile.is-removing {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-12px) scale(0.82) rotate(2deg);
  z-index: 9100 !important;
}

@keyframes mj-hint {
  0%, 100% { box-shadow: 0 0 0 2px rgba(200, 162, 83, 0.95), 0 8px 18px rgba(0, 0, 0, 0.3); }
  50% { box-shadow: 0 0 0 7px rgba(200, 162, 83, 0.14), 0 8px 18px rgba(0, 0, 0, 0.3); }
}

@media (prefers-reduced-motion: reduce) {
  .mj-tile { transition: none; }
  .mj-tile.is-hint { animation: none; outline-color: var(--gold); }
}

/* ---------- Sidebar extras ---------- */
.mj-layout-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.mj-layout-list .btn-text { font-size: 0.86rem; }
.mj-layout-list .btn-text.is-current { color: var(--pine); font-weight: 650; text-decoration: none; }
.mj-layout-tiles { font-size: 0.7rem; color: var(--ink-faint); white-space: nowrap; }
.mj-shortcuts { margin-bottom: 10px; }
.mj-shortcuts li { font-size: 0.84rem; }

/* ---------- Modals ---------- */
.mj-win-detail { margin: 4px 0 0; font-size: 0.86rem; }
.mj-win-links { margin-top: 14px; font-size: 0.88rem; color: var(--muted); }
.mj-win-links a { color: var(--pine); font-weight: 600; }
.win-dialog .win-modal { padding: 4px 2px 0; }
.win-dialog .win-actions { justify-content: center; }
.win-dialog .modal__body:only-child { padding-top: 4px; }

.mj-help h3 { margin: 20px 0 6px; font-size: 1rem; }
.mj-help h3:first-child { margin-top: 0; }
.mj-help p { margin: 6px 0 0; }
.mj-help .shortcut-list { margin-top: 4px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .mj-toolbar .btn span { display: none; }
  .mj-toolbar .btn { padding: 8px 11px; }
  .mj-hud .hud-item { min-width: 44px; }
  .mj-hud .hud-item strong { font-size: 0.94rem; }
}

@media (max-width: 640px) {
  .page--mahjong .variant-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 2px 2px 6px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .page--mahjong .variant-tabs::-webkit-scrollbar { display: none; }
  .page--mahjong .variant-tab { flex: none; }
  .mj-stage .game-topbar { padding: 8px 10px; }
  .mj-stage .game-topbar__title { display: none; }
  .mj-hud { width: 100%; margin-left: 0; justify-content: space-between; gap: 6px; }
  .mj-hud .hud-item { min-width: 0; flex: 1; }
  .mj-hud .hud-item strong { font-size: 0.92rem; }
  .mj-hud .hud-item span { font-size: 0.54rem; letter-spacing: 0.08em; }
  .mahjong-board-wrap { padding: 8px 0; min-height: 320px; }
  .mj-bottombar { justify-content: center; padding: 9px 10px; }
  .mj-bottombar__info { justify-content: center; }
  .mj-status { display: none; }
  .mj-toolbar { justify-content: center; width: 100%; }
  .mj-toolbar .btn {
    flex: 1 1 0;
    min-width: 46px;
    padding: 9px 4px;
    justify-content: center;
  }
  .mj-toolbar .btn .icon { width: 18px; height: 18px; }
  .mj-assist { display: none; }
}

@media (max-width: 420px) {
  .mj-hud .hud-item strong { font-size: 0.84rem; }
  .mj-hud .hud-item span { font-size: 0.5rem; }
}

/* ---------- Fullscreen: tiles take over the screen ----------
   The stage itself becomes the fixed viewport layer (js/core/fullscreen.js);
   here we only decide how the mahjong furniture shares the height. */
.mj-stage.is-fullscreen .mj-topbar {
  flex: none;
  height: auto;
  padding: 8px 16px 10px;
}
.mj-stage.is-fullscreen .mj-bottombar {
  flex: none;
  padding: 8px 16px;
}
.mj-stage.is-fullscreen .mahjong-board-wrap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  overflow: auto;
}
.mj-stage.is-fullscreen .mahjong-board { margin: auto; }
.mj-stage.is-fullscreen .game-topbar__title span { font-size: 0.72rem; }
@media (max-width: 640px) {
  .mj-stage.is-fullscreen .mj-topbar { padding: 6px 10px 8px; }
  .mj-stage.is-fullscreen .mahjong-board-wrap { padding: 8px 6px; }
  .mj-stage.is-fullscreen .mj-bottombar { padding: 6px 8px; }
}
