/* Mahjong Solitaire (js/games/mahjong.js). Kit styles: css/game.css.
 * Tiles stay ivory in both themes (they are the real object); the table follows the theme.
 * Sizes come from the script: --tw / --th (tile face) and --d (tile thickness). */

.mj-room { position: absolute; inset: 0; overflow: hidden; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; background: var(--surface-100); }
.mj-board { position: absolute; inset: 0; }
/* light theme: a soft sage table so the ivory tiles stand out */
:root[data-theme="light"] .mj-room { background: var(--surface-300); background: color-mix(in srgb, var(--toy-mint) 24%, var(--surface-300)); }
:root[data-theme="light"] .mj-tile { --edge-1: #DCCFAE; --edge-2: #C6B68C; }

/* a tile: ivory face, its thickness drawn as stacked edges below and to the right */
.mj-tile {
  --edge-1: #E3D7B9; --edge-2: #D0C199; --back-1: #3E7F6E; --back-2: #2C6153;
  position: absolute; left: 0; top: 0; width: var(--tw, 48px); height: var(--th, 64px);
  margin: 0; padding: 0; border: 0; border-radius: calc(var(--tw, 48px) * .13);
  background: linear-gradient(160deg, #FFFDF6 0%, #FBF6E9 45%, #F0E7D0 100%);
  box-shadow:
    inset 0 0 0 1px rgba(120, 100, 60, .28),
    calc(var(--d) * .25) calc(var(--d) * .25) 0 var(--edge-1),
    calc(var(--d) * .5) calc(var(--d) * .5) 0 var(--edge-2),
    calc(var(--d) * .75) calc(var(--d) * .75) 0 var(--back-1),
    var(--d) var(--d) 0 var(--back-2),
    calc(var(--d) + 2px) calc(var(--d) + 3px) 6px rgba(0, 0, 0, .35);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: opacity .24s ease, transform .24s ease;
}
.mj-tile[hidden] { display: none; }
.mj-face { position: absolute; inset: 4% 5%; width: 90%; height: 92%; pointer-events: none; }
.mj-tile:focus { outline: none; }
.mj-tile:focus-visible::before { content: ""; position: absolute; inset: -4px; border-radius: inherit; border: 3px dashed var(--focus-ring); pointer-events: none; }

/* blocked tiles look dimmer when "Highlight free tiles" is on */
.mj-tile::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: rgba(38, 32, 20, .42); opacity: 0; transition: opacity .2s ease; pointer-events: none; }
.mj-dim .mj-tile.is-blocked::after { opacity: 1; }
.mj-tile.is-blocked { cursor: default; }

/* picked: a clear accent ring and a warm tint */
.mj-tile.is-selected, .mj-tile.is-hint { z-index: 2; }
.mj-tile.is-selected { background: linear-gradient(160deg, #FFFFFF 0%, #EDEBFF 100%); transform: translate(-2px, -2px); }
.mj-tile.is-selected::before, .mj-tile.is-hint::before {
  content: ""; position: absolute; inset: -5px; border-radius: calc(var(--tw, 48px) * .13 + 4px);
  border: 4px solid var(--accent); box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 30%, transparent); pointer-events: none; z-index: 1;
}
.mj-tile.is-hint::before { animation: mj-pulse 1s ease-in-out 3; }
@keyframes mj-pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }

/* taken: a gentle lift and fade */
.mj-tile.is-gone { opacity: 0; transform: translateY(-10%) scale(.9); pointer-events: none; }

/* blocked tap: a tiny shake */
.mj-tile.is-nope { animation: mj-shake .36s ease; }
@keyframes mj-shake { 0%, 100% { translate: 0 0; } 25% { translate: -4px 0; } 50% { translate: 4px 0; } 75% { translate: -2px 0; } }

/* shuffled: the faces settle in */
.mj-shuffling .mj-face { animation: mj-settle .45s ease; }
@keyframes mj-settle { 0% { opacity: 0; transform: scale(.85); } 100% { opacity: 1; transform: none; } }

.mj-done .mj-board { transition: opacity .6s ease; }

/* no pairs left: a calm card at the bottom with Shuffle first */
.mj-stuck {
  position: absolute; left: 50%; bottom: max(16px, env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 8;
  width: min(30rem, calc(100% - 24px)); display: flex; flex-direction: column; gap: var(--space-3);
  padding: var(--space-4) var(--space-5); border-radius: var(--radius-lg);
  background: var(--surface-200); border: 1.5px solid var(--accent); box-shadow: var(--shadow-float); color: var(--ink);
}
.mj-stuck[hidden] { display: none; }
.mj-stuck-text { margin: 0; font-size: .95rem; line-height: 1.4; }
.mj-stuck-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.mj-stuck .icon { width: 1.1rem; height: 1.1rem; }

@media (prefers-reduced-motion: reduce) {
  .mj-tile, .mj-tile::after { transition: none; }
  .mj-tile.is-hint::before { animation: none; opacity: 1; }
  .mj-tile.is-nope, .mj-shuffling .mj-face { animation: none; }
}
