/* Mahjong Solitaire: page-specific styles on top of ../arcade-common/pz.css */
body[data-tod="day"] { --accent: #0f9d6b; --accent2: #2575d0; --glow: rgba(15, 157, 107, .22); --felt1: #bfe6d3; --felt2: #86c4a6; --tside: #2a8f6e; --tside2: #1c6b52; }
body[data-tod="night"] { --accent: #2fd0a0; --accent2: #6a7dff; --glow: rgba(47, 208, 160, .22); --felt1: #174a43; --felt2: #08221f; --tside: #2a8f6e; --tside2: #14503c; }
.field > span em { font-style: normal; text-transform: none; letter-spacing: 0; font-weight: 400; }
.col { display: grid; gap: 16px; min-width: 0; }
.menu-grid > * { min-width: 0; }

/* hero demo board */
.hero-board { position: relative; width: 100%; margin: 12px 0 2px; border-radius: 14px; border: 1px solid var(--line); background: radial-gradient(120% 120% at 50% 20%, var(--felt1), var(--felt2)); overflow: hidden; pointer-events: none; user-select: none; -webkit-user-select: none; }
.hero-board .board { position: absolute; left: 0; top: 0; }

/* layout picker */
.modes { display: grid; gap: 8px; }
.modes button { text-align: left; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; padding: 10px 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--card2); min-height: 64px; }
.modes button b { font-size: 1rem; }
.modes button span { grid-column: 1; font-size: .8rem; color: var(--muted); line-height: 1.3; }
.modes button small { grid-column: 2; grid-row: 1 / span 2; font-weight: 700; font-size: .78rem; color: var(--muted); white-space: nowrap; }
.modes button[aria-checked="true"] { border-color: transparent; background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; box-shadow: 0 6px 18px var(--glow); }
.modes button[aria-checked="true"] span, .modes button[aria-checked="true"] small { color: rgba(255, 255, 255, .94); }
.layouts button { grid-template-columns: 56px 1fr auto; }
.layouts .thumb { grid-column: 1; grid-row: 1 / span 2; width: 56px; height: 44px; display: block; }
.layouts button b, .layouts button span { grid-column: 2; }
.layouts button small { grid-column: 3; }
.layouts button[aria-checked="true"] .thumb rect { opacity: .95; }
.daily { display: flex; align-items: center; gap: 12px; justify-content: space-between; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.daily-t { display: grid; gap: 2px; min-width: 0; }
.daily-t b { font-size: .98rem; }
.daily-t span { color: var(--muted); font-size: .8rem; }
.daily .btn { min-width: 130px; flex: 0 0 auto; }
@media (max-width: 420px) { .daily .btn { width: 100%; } .layouts button { grid-template-columns: 48px 1fr auto; padding: 10px; } .layouts .thumb { width: 48px; } }

/* how to play */
.how { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; }
.how li { display: flex; gap: 12px; align-items: flex-start; font-size: .9rem; line-height: 1.45; color: var(--ink); }
.how .pi { flex: none; width: 38px; height: 38px; border-radius: 12px; background: var(--card2); border: 1px solid var(--line); display: grid; place-items: center; font-size: 1.2rem; }

/* leaderboard */
.lb { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.lb li { display: grid; grid-template-columns: 28px 1fr auto auto; gap: 8px; align-items: center; padding: 8px 10px; border-radius: 12px; background: var(--card2); font-size: .92rem; min-width: 0; }
.lb li.me { outline: 2px solid var(--accent); }
.lb .rk { font-weight: 800; color: var(--muted); text-align: center; }
.lb li:nth-child(-n+3) .rk { color: var(--accent); }
.lb .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.lb .md { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; white-space: nowrap; }
.lb b { font-variant-numeric: tabular-nums; }
#lbBody .hint { text-align: center; padding: 14px 4px; }

/* play screen */
body[data-screen="play"] { overflow: hidden; position: fixed; inset: 0; width: 100%; overscroll-behavior: none; }
body[data-screen="play"] .top, body[data-screen="play"] main > #scMenu { display: none; }
.play { position: fixed; inset: 0; z-index: 20; margin: 0; display: flex; flex-direction: column; background: radial-gradient(120% 90% at 50% 30%, var(--felt1), var(--felt2)); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.phud { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 4px max(10px, env(safe-area-inset-left)); flex: none; }
.hudbtn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 1.1rem; box-shadow: var(--shadow); }
.hudbtn[aria-pressed="false"] { opacity: .55; }
.hstats { display: flex; justify-content: space-around; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 4px 6px; min-height: 44px; min-width: 0; box-shadow: var(--shadow); }
.hstats div { text-align: center; min-width: 0; line-height: 1.1; display: grid; align-content: center; }
.hstats span { font-size: .6rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.hstats b { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.hud-fx { position: absolute; left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 4; text-align: center; pointer-events: none; }
.hud-fx span { display: inline-block; max-width: 100%; padding: 8px 14px; border-radius: 999px; background: var(--card); color: var(--ink); border: 1px solid var(--line); font-weight: 700; font-size: .88rem; box-shadow: var(--shadow); animation: fxin .2s; }
@keyframes fxin { from { transform: translateY(8px); opacity: 0; } }
.board-wrap { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; margin: 2px max(6px, env(safe-area-inset-left)); }
.board { position: absolute; left: 0; top: 0; }
body.paused #board { visibility: hidden; }
.ptools { flex: none; display: flex; gap: 8px; padding: 6px max(10px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); width: 100%; max-width: 620px; margin: 0 auto; }
.tbtn { flex: 1 1 0; min-width: 0; min-height: 48px; border-radius: 14px; border: 2px solid var(--line); background: var(--card); color: var(--ink); font-weight: 700; font-size: .92rem; display: inline-flex; align-items: center; justify-content: center; gap: 5px; padding: 6px 4px; box-shadow: var(--shadow); white-space: nowrap; }
.tbtn i { font-style: normal; font-size: 1.15rem; }
.tbtn em { font-style: normal; display: inline-block; min-width: 1.4em; padding: 0 5px; border-radius: 999px; background: var(--card2); border: 1px solid var(--line); font-size: .78rem; text-align: center; }
.tbtn:disabled { opacity: .45; cursor: not-allowed; }
@media (max-width: 420px) { .tbtn span { font-size: .85rem; } .tbtn em { padding: 0 4px; min-width: 1.2em; } }
@media (max-width: 360px) { .tbtn i { display: none; } .hstats b { font-size: .95rem; } .phud { gap: 5px; } }

/* short landscape screens (phones on their side): the toolbar moves to the right so the board gets the full height */
@media (max-height: 500px) and (orientation: landscape) {
  .play { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto minmax(0, 1fr); }
  .phud { grid-column: 1 / -1; }
  .board-wrap { grid-column: 1; grid-row: 2; margin: 0 4px 6px max(6px, env(safe-area-inset-left)); }
  .ptools { grid-column: 2; grid-row: 2; flex-direction: column; justify-content: center; width: 132px; max-width: none; margin: 0; padding: 0 max(10px, env(safe-area-inset-right)) 8px 4px; }
  .tbtn { flex: 0 0 auto; width: 100%; }
  .hud-fx { bottom: 14px; right: 150px; }
}

/* tiles: the element is the full 2 x 2 footprint (so touching tiles never leave gaps to tap); the face sits inside, the jade edge shows to the right and below */
.tile { position: absolute; margin: 0; padding: 0; border: 0; background: linear-gradient(135deg, var(--tside), var(--tside2)); border-radius: var(--r, 6px); cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; transition: transform .22s ease, opacity .22s ease; will-change: transform; }
.tile .tface { position: absolute; left: 0; top: 0; right: var(--t, 3px); bottom: var(--t, 3px); border-radius: var(--r, 6px); background: linear-gradient(160deg, #fffef6, #f2ebd2 75%, #e6dcbb); box-shadow: inset 0 0 0 1px rgba(60, 40, 10, .22), inset 1px 1px 0 rgba(255, 255, 255, .9); display: block; transition: filter .15s, background .15s; }
.tile .tface svg { position: absolute; left: 7%; top: 5%; width: 86%; height: 90%; display: block; pointer-events: none; }
.tile.blocked { cursor: not-allowed; }
.tile.blocked .tface { filter: brightness(.7) saturate(.75); }
.tile.sel .tface { background: linear-gradient(160deg, #fff6c7, #ffe58a 80%); box-shadow: inset 0 0 0 3px #f5a800, 0 0 0 2px rgba(255, 190, 0, .6); }
.tile.hint .tface { animation: hintpulse .8s ease-in-out infinite alternate; }
@keyframes hintpulse { from { box-shadow: inset 0 0 0 2px #1fb56a, 0 0 0 0 rgba(31, 181, 106, .0); background: linear-gradient(160deg, #fffef6, #f2ebd2); } to { box-shadow: inset 0 0 0 3px #1fb56a, 0 0 0 4px rgba(31, 181, 106, .55); background: linear-gradient(160deg, #eafff1, #b9f0cf); } }
.tile:focus-visible { outline: none; }
.tile:focus-visible .tface { box-shadow: inset 0 0 0 3px #2f7bff, 0 0 0 3px rgba(47, 123, 255, .6); }
.tile.shake { animation: shake .26s; }
@keyframes shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.tile.gone { opacity: 0; transform: scale(.6); pointer-events: none; }
.tile.out { display: none; }
.hero-board .tile { cursor: default; }

/* result / pause / stuck overlays */
.newbest { display: inline-block; margin-bottom: 6px; padding: 4px 14px; border-radius: 999px; font-weight: 800; font-size: .85rem; color: #10231c; background: linear-gradient(135deg, #ffd24a, #ff9a3d); animation: pulse .6s; }
@keyframes pulse { from { transform: scale(1.3); } }
.ovscore { font-size: clamp(2.6rem, 14vw, 3.6rem); font-weight: 800; line-height: 1.05; background: linear-gradient(90deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; font-variant-numeric: tabular-nums; }
.ovmode { color: var(--muted); font-weight: 700; font-size: .85rem; letter-spacing: .06em; text-transform: uppercase; }
.ovstats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0 4px; }
.ovstats div { background: var(--card2); border-radius: 12px; padding: 8px 4px; min-width: 0; }
.ovstats b { display: block; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.ovstats span { display: block; color: var(--muted); font-size: .66rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
.ovname { text-align: left; margin-top: 12px; }
.ovboard { text-align: left; margin-top: 8px; }
.ovboard .label { margin: 8px 0 0; }
.ovboard .lb { margin-top: 6px; }
.overlay .row .btn { flex: 1 1 130px; }
.overlay .btn.go { margin-top: 0; width: auto; }
@media (max-width: 380px) { .ovstats { grid-template-columns: repeat(2, 1fr); } }
.seg button, .chips button { min-height: 44px; }
.seg { padding: 2px; }
.btn.small { min-height: 44px; }
.overlay > .card { display: flex; flex-direction: column; overflow: hidden; padding: 16px; }
.overlay .ovbody { overflow-y: auto; min-height: 0; flex: 1 1 auto; overscroll-behavior: contain; padding: 0 2px; }
.overlay .big, .overlay h2, .overlay .row { flex: none; }
body[data-tod="night"] .ovscore { background-image: linear-gradient(90deg, #5ff0c0, #8da0ff); }
@media (max-height: 680px) { .overlay .big { display: none; } .overlay h2 { font-size: 1.3rem; margin-top: 0; } .ovscore { font-size: 2.6rem; } .ovboard { display: none; } }
@media (max-height: 520px) { .overlay .row { margin-top: 10px; flex-wrap: nowrap; } .overlay .row .btn { flex: 1 1 0; padding: 8px 6px; font-size: .9rem; } .ovstats { margin-top: 8px; } .ovname { margin-top: 6px; } }
@media (max-width: 420px) { .overlay .row { gap: 8px; } .overlay .row .btn { flex: 1 1 28%; padding: 8px 4px; font-size: .88rem; } .overlay .row .btn[data-role="again"] { flex-basis: 100%; } }
.pausecard { background: var(--card); }
@media (prefers-reduced-motion: reduce) { .tile, .tile.gone { transition: none; } .tile.hint .tface { animation: none; box-shadow: inset 0 0 0 3px #1fb56a, 0 0 0 4px rgba(31, 181, 106, .55); } }
