/* Mahjong Solitaire */

.mj-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
    user-select: none;
    width: 100%;
}

.mj-hud {
    display: flex;
    gap: 1.2rem;
    font-weight: 600;
    color: var(--color-text-light);
    font-variant-numeric: tabular-nums;
    flex-wrap: wrap;
    justify-content: center;
}

/* Tiles are absolutely placed from their own --tx/--ty/--tl, so half-step
   offsets and stacking come out of the data rather than the markup order. */
.mj-board {
    --mj-cols: 10;
    --mj-rows: 6;
    --mj-tw: min(calc(94vw / (var(--mj-cols) + 1)), 46px);
    --mj-th: calc(var(--mj-tw) * 1.32);
    position: relative;
    width: calc(var(--mj-tw) * (var(--mj-cols) + 0.6));
    height: calc(var(--mj-th) * (var(--mj-rows) + 0.6));
    margin: 0 auto;
}

.mj-tile {
    position: absolute;
    left: calc(var(--tx) * var(--mj-tw) - var(--tl) * 4px);
    top: calc(var(--ty) * var(--mj-th) - var(--tl) * 5px);
    width: var(--mj-tw);
    height: var(--mj-th);
    /* Higher layers must paint over lower ones. */
    z-index: calc(var(--tl) * 100 + 10);
    border: 1px solid #b9a884;
    border-radius: 5px;
    background: linear-gradient(#fffdf3, #f2e9d2);
    box-shadow: 1px 2px 0 #c9b896, 1px 2px 4px rgba(0, 0, 0, 0.28);
    font-size: calc(var(--mj-tw) * 0.72);
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
    padding: 0;
    color: #2b2b33;
    -webkit-tap-highlight-color: transparent;
}

/* Only free tiles are actionable, and they say so. */
.mj-tile.free {
    cursor: pointer;
    border-color: #8d7a55;
}

.mj-tile:not(.free) { filter: brightness(0.86) saturate(0.7); }

.mj-tile.selected {
    background: linear-gradient(#fff0b0, #ffe066);
    box-shadow: 0 0 0 3px var(--color-primary-dark), 1px 2px 4px rgba(0, 0, 0, 0.3);
}

.mj-tile.hint {
    background: linear-gradient(#d6f5df, #aee9c0);
    box-shadow: 0 0 0 3px var(--color-success), 1px 2px 4px rgba(0, 0, 0, 0.3);
}

.mj-tile:focus-visible {
    outline: 3px solid var(--color-text);
    outline-offset: 2px;
}

.mj-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.mj-btn {
    padding: 0.55rem 1.2rem;
    font-size: 0.95rem;
    font-weight: 600;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-card-bg);
    color: var(--color-text);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.mj-btn:hover:not(:disabled) { border-color: var(--color-primary-dark); }
.mj-btn:disabled { opacity: 0.45; cursor: default; }
.mj-btn:focus-visible {
    outline: 3px solid var(--color-text);
    outline-offset: 2px;
}

.mj-feedback {
    min-height: 1.4em;
    margin: 0;
    font-weight: 600;
    color: var(--color-text-light);
    text-align: center;
}

/* The layout is wider than the default game column. */
.game-container .content:has(.mj-stage) { max-width: 680px; }
