/* A game's page: the board on a sheet of paper, Maimo standing on the sheet's top edge, a row of tiles below.
   The paper, the tiles and the buttons themselves are in /shared/nyant.css; this file is the table and the nine boards. */

/* ---- the name of the game and Maimo, on the city above the sheet ---- */
.stage-row { width: min(100% - 24px, var(--wrap)); margin: 0 auto -32px; display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; min-height: 104px; position: relative; z-index: 2; pointer-events: none; }
.stage-row h1 { padding-bottom: 26px; font: 400 clamp(28px, 8vw, 44px)/1 var(--dot); letter-spacing: .04em; color: var(--text); text-shadow: 3px 3px 0 var(--ink), 0 0 14px rgba(0,0,0,.5); }
.stage-row h1 small { display: block; margin-top: 8px; font-size: 13px; letter-spacing: .12em; text-shadow: 1px 1px 0 var(--ink), 0 0 8px rgba(0,0,0,.8); }
#buddy { position: relative; flex: none; width: 128px; height: 128px; margin-right: 2px; }
#buddy canvas { display: block; width: 100%; height: 100%; transform-origin: 50% 94%; opacity: 0; filter: drop-shadow(0 3px 0 rgba(30,27,28,.25)); }
#buddy.here canvas { opacity: 1; }
/* What Maimo says: a slip of paper beside it, over the small Japanese name for the moment it is up. */
#buddy-says { position: absolute; right: 116px; bottom: 14px; margin: 0; padding: 5px 10px; background: var(--paper); color: var(--ink); font: 400 14px var(--dot); box-shadow: 3px 3px 0 var(--ink); max-width: calc(100% - 128px); }

/* ---- the sheet ---- */
#play { padding-top: 12px; }
#play .stub { margin-bottom: 10px; align-items: baseline; padding-right: 0; }
#play .stub b { font: inherit; }
#clock { font: 400 16px var(--dot); letter-spacing: .04em; }
#table { width: min(100%, max(240px, calc(100dvh - 318px))); margin-inline: auto; }
#read { min-height: 44px; margin-top: 10px; padding: 9px 10px; border: 2px dashed var(--ink); font: 400 14px/1.45 var(--dot); letter-spacing: .02em; }
#extras { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px; margin-top: 10px; }
#extras:empty { display: none; }
.modes { display: inline-flex; border: var(--edge); background: var(--card); }
.modes button { border: 0; background: none; padding: 6px 12px; font: 400 14px var(--dot); }
.modes button small, .archive small { margin-left: 5px; font-size: 10px; color: var(--muted); }
.modes button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.modes button[aria-pressed="true"] small { color: #cfcabb; }
.archive { display: inline-flex; align-items: center; gap: 6px; font: 700 10px var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.archive input { padding: 5px 6px; border: var(--edge); background: var(--card); font: 400 13px var(--mono); }
.rule { margin-top: 10px; font-size: 13px; line-height: 1.6; color: #37322f; }
.rule small { display: block; color: var(--muted); font-size: 12px; }
/* ---- the tiles under the sheet ---- */
#dock { width: min(100% - 24px, var(--wrap)); margin: -6px auto 0; display: flex; justify-content: center; flex-wrap: wrap; gap: 10px 14px; }
#dock .tile-btn i { width: 48px; height: 48px; }

/* ---- the ticket at the end ---- */
dialog.ticket { padding: 16px 18px 18px; text-align: center; }
dialog.ticket[open] { display: grid; gap: 12px; }
dialog.ticket .stub { margin: 0 44px 0 0; text-align: left; }
dialog.ticket h2 { font-size: 30px; letter-spacing: .06em; }
.stamp { justify-self: center; display: grid; gap: 1px; min-width: 150px; margin: 6px 0 2px; padding: 8px 14px 7px; border: 3px solid var(--accent); outline: 2px solid var(--accent); outline-offset: 3px; color: var(--accent); transform: rotate(-7deg); }
.stamp b { font: 400 22px/1.1 var(--dot); letter-spacing: .08em; }
.stamp span { font: 700 9px var(--mono); letter-spacing: .26em; }
.stamp.fresh { animation: stamp .42s steps(6) .22s backwards; }
@keyframes stamp { from { transform: rotate(9deg) scale(2.6); opacity: 0; } 60% { transform: rotate(-9deg) scale(.92); opacity: 1; } }
.story-line { display: grid; gap: 3px; padding: 9px 10px; border: 2px dashed var(--ink); text-align: left; }
.story-line b { font: 700 10px var(--mono); letter-spacing: .14em; }
.story-line span { font: 400 15px/1.45 var(--dot); }
.story-line small { font: 700 10px var(--mono); letter-spacing: .06em; color: var(--mikan-deep); }
dialog.ticket .next-up { border-top: 0; padding-top: 0; }

/* ---- a board: square cells, pictures of big pixels ---- */
.grid { position: relative; display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); grid-template-rows: repeat(var(--rows), minmax(0, 1fr)); width: 100%; aspect-ratio: 1; border: 3px solid var(--ink); background: var(--ink);
  touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; container-type: inline-size; }
.grid .cell { position: relative; min-width: 0; min-height: 0; margin: 0; padding: 0; border: 0; background: var(--card) var(--pic, none) center / 76% no-repeat; image-rendering: pixelated; color: var(--ink);
  font: 400 calc(100cqw / var(--cols) * .46) / 1 var(--dot); display: grid; place-items: center; }
.grid .cell:focus-visible { outline: 3px solid var(--ink); outline-offset: -5px; }
.grid .glow { box-shadow: inset 0 0 0 4px var(--lit), inset 0 0 0 6px var(--ink) !important; animation: glow .9s steps(2) infinite; }
@keyframes glow { 50% { filter: brightness(1.12); } }
.grid.demo { max-width: 200px; margin-inline: auto; touch-action: auto; }

/* NAWABARI: territories in colour, a wall wherever two meet */
.nb .cell { box-shadow: inset -1px -1px 0 rgba(30,27,28,.28); }
.nb .wr { border-right: 3px solid var(--ink); }
.nb .wb { border-bottom: 3px solid var(--ink); }
.nb .mark::after { content: ""; width: 34%; height: 34%; background: linear-gradient(45deg, transparent 42%, rgba(30,27,28,.62) 42% 58%, transparent 58%), linear-gradient(-45deg, transparent 42%, rgba(30,27,28,.62) 42% 58%, transparent 58%); }
.nb .cat { animation: put .18s steps(3); }
.nb .bad { background-color: var(--accent) !important; animation: nyant-shake .3s steps(4); }
.nb .why { box-shadow: inset 0 0 0 3px rgba(30,27,28,.75); }
@keyframes put { from { background-size: 30%; } }

/* OSANPO: a walk drawn square to square, fish to pass in order */
.os .cell { background-color: #efe9d6; background-size: 82%; font-size: calc(100cqw / var(--cols) * .36); }
.os .cell.alt { background-color: #e6dfc9; }
.os .walked { background-color: #f6d9b4; }
.os .walked.alt { background-color: #f1cfa4; }
.os .wr { border-right: 4px solid var(--ink); }
.os .wb { border-bottom: 4px solid var(--ink); }
.os .fish { background-size: 44%; background-position: right 5% bottom 6%; }
.os .cell b { display: grid; place-items: center; width: 56%; height: 56%; margin: -12% 0 0 -12%; background: var(--ink); color: var(--paper); font: inherit; }
.os .got b { background: var(--good); }
.os .want b { background: var(--lit); color: var(--ink); box-shadow: 0 0 0 2px var(--ink); animation: glow .9s steps(2) infinite; }
.os .last b { background: var(--accent); }
.os .last.want b { background: var(--lit); }
.os .trail { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.os .trail polyline { fill: none; stroke: var(--accent); stroke-width: .22; stroke-linejoin: miter; stroke-linecap: square; opacity: .62; }
.os .walker { position: absolute; background: var(--pic) center / 84% no-repeat; image-rendering: pixelated; pointer-events: none; transition: left .08s steps(2), top .08s steps(2); filter: drop-shadow(2px 2px 0 rgba(30,27,28,.35)); }

/* NEKOAWASE: sixteen cards face down */
.mm { border: 0; background: none; gap: 8px; touch-action: manipulation; }
.mm .cell { background: none; }
.mm .cell i { position: absolute; inset: 0; background: var(--pic, none) center / 62% no-repeat; image-rendering: pixelated; box-shadow: 3px 3px 0 var(--ink); transition: transform .12s steps(3); }
.mm .cell .back { background-color: var(--ink); background-size: 52%; }
.mm .cell .face { background-color: var(--paper, #f4f1e8); background-size: 132%; background-position: center 62%; image-rendering: auto; border: 2px solid var(--ink); transform: scaleX(0); }
.mm .open .back { transform: scaleX(0); }
.mm .open .face { transform: scaleX(1); transition-delay: .12s; }
.mm .cell.matched .face { background-color: #ffe9ad; }
.mm .cell:not(.open):hover .back { transform: translate(-1px, -2px); }

/* NEKO 2048: boxes slide and join */
.bx { --cols: 4; --rows: 4; background: #cfc8b5; touch-action: none; outline: 0; }
.bx .slot { box-shadow: inset 0 0 0 3px #cfc8b5; background: #e2dccb; }
.bx .boxes { position: absolute; inset: 0; pointer-events: none; }
.bx .box { position: absolute; left: 0; top: 0; width: 25%; height: 25%; padding: 3px; display: grid; place-items: center; background: #efe9d8 content-box; color: var(--ink); font: 400 calc(100cqw * .092) / 1 var(--dot); transition: transform .11s steps(4); box-shadow: inset 0 0 0 3px #cfc8b5, inset 0 0 0 5px var(--ink); }
.bx .v4 { background-color: #eadfb9; } .bx .v8 { background-color: #f3c98b; } .bx .v16 { background-color: #f0a35e; } .bx .v32 { background-color: #e8794a; }
.bx .v64 { background-color: var(--accent); color: #fff; } .bx .v128 { background-color: var(--lit); font-size: calc(100cqw * .078); } .bx .v256 { background-color: #f6bd3a; font-size: calc(100cqw * .078); }
.bx .v512 { background-color: #a9dcc4; font-size: calc(100cqw * .078); } .bx .v1024 { background-color: #a9cfe8; font-size: calc(100cqw * .062); }
.bx .v2048, .bx .v4096 { background-color: var(--ink); color: var(--lit); font-size: calc(100cqw * .062); }
.bx .pop { animation: pop .16s steps(4); }
.bx .born { animation: born .16s steps(4); }
@keyframes pop { 40% { scale: 1.16; } }
@keyframes born { from { scale: .3; } }

/* SWEEPER: a meadow of closed squares */
.sw { touch-action: manipulation; }
.sw .cell { background-color: #b9dba6; box-shadow: inset 3px 3px 0 rgba(255,255,255,.5), inset -3px -3px 0 rgba(30,27,28,.28); background-size: 62%; }
.sw .cell:nth-child(odd) { background-color: #aed39a; }
.sw .open { background-color: #efe9d6; box-shadow: inset -1px -1px 0 rgba(30,27,28,.22); }
.sw .open:nth-child(odd) { background-color: #e8e1cc; }
.sw [data-n="1"] { color: #2f6fb5; } .sw [data-n="2"] { color: #2f8a5c; } .sw [data-n="3"] { color: #c8402f; } .sw [data-n="4"] { color: #6b4aa8; } .sw [data-n="5"] { color: #96352a; }
.sw .thorn { background-color: #d8d2c0; }
.sw .hit { background-color: var(--accent); animation: nyant-shake .3s steps(4); }
.sw .safe { background-color: var(--lit); }

/* SLIDE: fifteen tiles and a gap */
.sl { touch-action: none; background: #57534c; }
.sl .cell { background-color: var(--card); box-shadow: inset 3px 3px 0 rgba(255,255,255,.7), inset -3px -3px 0 rgba(30,27,28,.3), 0 0 0 1px var(--ink); }
.sl .home { background-color: var(--lit); }
.sl .gap { background: none; box-shadow: none; }

/* CHOUCHIN: lanterns, lit or dark */
.lt { background: #171a22; gap: 3px; touch-action: manipulation; }
.lt .cell { background-color: #262a36; background-size: 66%; }
.lt .on { background-color: #5a4318; box-shadow: inset 0 0 0 3px var(--lit), 0 0 18px rgba(255,207,90,.55); z-index: 1; }
.lt .turned { animation: put .16s steps(3); }

/* REVERSI: black cats and white cats */
.rv { background: #2c6a55; gap: 2px; touch-action: manipulation; }
.rv .cell { background-color: #7fc8a9; background-size: 80%; }
.rv .can::after { content: ""; width: 26%; height: 26%; background: var(--lit); box-shadow: 2px 2px 0 rgba(30,27,28,.45); }
.rv .turned { animation: turn-over .28s steps(4); }
.rv .placed { animation: put .16s steps(3); }
@keyframes turn-over { from { transform: scaleX(-1); filter: brightness(1.6); } 50% { transform: scaleX(0); } }

/* SUZUAWASE: four bells */
.sm { gap: 10px; border: 0; background: none; touch-action: manipulation; }
.sm .cell { background-color: var(--pad); background-size: 38%; box-shadow: 5px 5px 0 var(--ink); filter: brightness(.62) saturate(.8); transition: filter .08s steps(2), transform .08s steps(2); }
.sm .listen { filter: brightness(.86); }
.sm .on { filter: brightness(1.25); transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--ink), 0 0 26px var(--pad); }

@media (max-width: 560px) {
  #play .stub { font-size: 9px; letter-spacing: .08em; white-space: nowrap; gap: 6px; }
  .stage-row { min-height: 96px; }
  #buddy { width: 112px; height: 112px; }
  #dock .tile-btn i { width: 46px; height: 46px; }
  .mm { gap: 6px; }
}
