/* Mahjong in the AleGry look: paper background, ink outlines, hard shadows; ivory tiles stacked in layers. */
:root {
  --paper: #FFF7EA;
  --ink: #1D1533;
  --muted: #574D6E;
  --primary: #D93D22;
  --lemon: #FFD23F;
  --lemon-light: #FFF3C4;
  --plum-light: #EFE8FF;
  --mint-light: #DDF6EF;
  --sky-light: #E3F4FF;
  --sand-light: #F6EBD9;
  --tomato-light: #FFE3DC;
  --bar: var(--plum-light);
  --line: 3px solid var(--ink);
  --radius: 18px;
  --radius-sm: 10px;
  --font-heading: 'Fredoka', 'Trebuchet MS', 'Segoe UI', sans-serif;
  --font-body: 'Nunito', 'Segoe UI', Verdana, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { background: var(--paper); color: var(--ink); }
body { margin: 0; padding: 4px 8px 12px 4px; font: 16px/1.5 var(--font-body); }
h2, h3 { font-family: var(--font-heading); line-height: 1.15; }
:focus-visible { outline: 3px solid #7A5CFA; outline-offset: 2px; }
.notice { margin: 1rem; padding: .75rem 1rem; border: 2px solid var(--ink); border-radius: var(--radius-sm); background: var(--lemon-light); }

.button { font: 700 1rem var(--font-heading); padding: .6rem 1.1rem; border: var(--line); border-radius: 999px; background: var(--primary); color: #fff; box-shadow: 3px 3px 0 var(--ink); cursor: pointer; }
.button:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.button:disabled { opacity: .45; cursor: default; transform: none; box-shadow: 3px 3px 0 var(--ink); }
.button--ghost { background: #fff; color: var(--ink); }
.button--small { font-size: .9rem; padding: .4rem .85rem; box-shadow: 2px 2px 0 var(--ink); }
.button[aria-pressed="false"] { opacity: .6; }

.board { background: #fff; border: var(--line); border-radius: var(--radius); box-shadow: 5px 5px 0 var(--ink); overflow: hidden; }
.board__bar { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: space-between; padding: .7rem 1rem; background: var(--bar); border-bottom: var(--line); }
.board__bar p { margin: 0; }
.board__counters { display: flex; flex-wrap: wrap; gap: .3rem 1rem; font-weight: 700; font-size: .9rem; }
.board__counters strong { font: 700 1.1rem var(--font-heading); }
.board__actions { display: flex; gap: .5rem; }

.overlay { position: absolute; inset: 0; display: grid; place-items: center; padding: .75rem; background: rgba(20, 15, 43, .55); overflow: auto; }
.overlay__box { width: min(100%, 26rem); padding: 1.1rem 1.25rem; border: var(--line); border-radius: var(--radius); background: #fff; box-shadow: 5px 5px 0 var(--ink); text-align: center; }
.overlay__box h2 { margin: 0 0 .4rem; font-size: 1.6rem; }
.overlay__box p { margin: 0 0 .8rem; }
.overlay__actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin: 0 !important; }
.overlay__actions:empty { display: none; }

.board__options { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.board__label { font-weight: 700; font-size: .9rem; }
.board__options select { padding: .35rem .7rem; border: var(--line); border-radius: 999px; background: #fff; color: var(--ink); font: 700 .9rem var(--font-body); }
.info { min-height: 1.6em; margin: .6rem 1rem 0; text-align: center; font-weight: 700; }

.keys { margin: .6rem 1rem 1rem; text-align: center; font-size: .85rem; color: var(--muted); }

.mg-toast { position: fixed; left: 50%; top: 1rem; z-index: 50; max-width: calc(100% - 2rem); transform: translate(-50%, -6rem); visibility: hidden; padding: .6rem 1.1rem; border-radius: 999px; background: var(--ink); color: #fff; font-weight: 800; text-align: center; transition: transform .25s ease, visibility .25s; }
.mg-toast.is-visible { transform: translate(-50%, 0); visibility: visible; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

:root { --bar: var(--mint-light); --tile: #FFFDF5; --side: #E4CF9F; }
.score { justify-content: center; margin: .7rem 1rem 0; }
.puzzle-title { margin: .5rem 1rem 0; text-align: center; font-size: 1.15rem; }
.screen { position: relative; max-width: 46rem; margin: .5rem auto 0; padding: .8rem .5rem; border: var(--line); border-radius: var(--radius-sm); background: #E7F3EC; }
.overlay { border-radius: calc(var(--radius-sm) - 3px); }
.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; margin: .7rem 1rem 0; }
.actions .is-nudge { animation: nudge 1s ease-in-out 3; background: var(--lemon); }
@keyframes nudge { 50% { transform: scale(1.08); } }
.board__options select { max-width: 13rem; }

.table { position: relative; margin: 0 auto; user-select: none; -webkit-user-select: none; }
.table__inner { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.tile { position: absolute; width: 44px; height: 56px; padding: 0; border: 2px solid var(--ink); border-radius: 7px; background: var(--tile); box-shadow: 3px 4px 0 -1px var(--side), 4px 5px 0 0 var(--ink); font: 28px/1 "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; cursor: pointer; touch-action: manipulation; transition: transform .12s ease, opacity .25s ease, filter .2s; }
.tile span { display: block; pointer-events: none; }
.tile.is-blocked { filter: brightness(.86) saturate(.8); cursor: default; }
.tile.is-picked { background: #FFE58A; transform: translateY(-3px); }
.tile.is-hint { animation: blink .6s ease-in-out 3; }
.tile.is-gone { opacity: 0; transform: scale(.6); pointer-events: none; }
.tile.is-shake { animation: shake .3s; }
.tile:focus { outline: none; }
.tile:focus-visible { outline: 3px solid #7A5CFA; outline-offset: 1px; }
@keyframes blink { 50% { background: #C9F0E2; box-shadow: 0 0 0 4px #20B69A, 4px 5px 0 0 var(--ink); } }
@keyframes shake { 25% { margin-left: -4px; } 75% { margin-left: 4px; } }

@media (max-width: 640px) {
  .board__bar { padding: .6rem .75rem; }
  .screen { margin: .5rem .4rem 0; padding: .5rem .2rem; }
}
