/* Mahjong Solitaire: the stack of tiles on the felt table. app.js sizes the tiles (--w on .field) to the room the table
   (#wrap) is given, and places each tile.
   Upright screens: the counters and tools in a row above the table (in two rows on a narrow phone).
   Wide screens: one column beside the table, the counters over the tools.
   A sideways phone: the counters on one side of the table and the tools on the other. */
.stage { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 10px max(12px, var(--gk-safe-end)) max(12px, var(--gk-safe-bottom)) max(12px, var(--gk-safe-start)); }
.hud { flex: none; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 12px; }
.stats, .tools { display: flex; align-items: stretch; gap: 8px; }
.hud .gk-stat { min-width: 70px; padding: 4px 10px; justify-content: center; }
.tool { min-width: 64px; padding: 4px 10px; flex-direction: column; gap: 2px; }
.tool span { font-size: var(--gk-text-lg); line-height: 1; }
.tool small { font-size: var(--gk-text-xs); font-weight: var(--gk-medium); }

/* The table: blue felt in a navy rim with a gold edge. */
.table { position: relative; flex: 1 1 0; min-width: 0; min-height: 0; width: 100%; display: grid; place-items: center; overflow: hidden;
  border: 5px solid var(--gk-rim); border-radius: var(--gk-r-lg);
  background: radial-gradient(ellipse at 50% 42%, color-mix(in srgb, var(--gk-felt) 85%, var(--gk-white)) 0, var(--gk-felt) 42%, var(--gk-felt-deep) 100%);
  box-shadow: 0 0 0 2px var(--gk-gold-deep), var(--gk-shadow-2), var(--gk-inset), inset 0 0 60px color-mix(in srgb, var(--gk-night) 60%, transparent); }

/* The tiles. Their faces and edges are the tile art, not the site's colours: app.js sets them on .field from the worn tile
   skin (games/mahjong/art.js); the values here are the ivory tiles. --face-picked, --face-shine and --face-dim (a chosen face,
   the lit rim and the shade of a blocked tile) are only set by skins that need their own. */
.field { --w: 40px; --h: calc(var(--w) * 1.32); --d: calc(var(--w) * .12); --face: #fbf3df; --face-line: #d2bd92; --edge: #dcbc82; --edge-deep: #a27840;
  position: relative; direction: ltr; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.tile { position: absolute; width: var(--w); height: var(--h); padding: 0; border: 0; border-radius: calc(var(--w) * .15); background: var(--face) center / 84% 86% no-repeat;
  box-shadow: inset 0 0 0 1px var(--face-line), inset calc(var(--w) * .04) calc(var(--w) * .04) 0 var(--face-shine, var(--gk-shine)), calc(var(--d) * .5) calc(var(--d) * .5) 0 var(--edge), var(--d) var(--d) 0 var(--edge-deep), calc(var(--d) + 1px) calc(var(--d) + 2px) 4px var(--gk-dark);
  transition: opacity var(--gk-move), scale var(--gk-move), filter var(--gk-fast), translate var(--gk-fast); }
.tile.blocked { filter: var(--face-dim, brightness(.8) saturate(.85)); cursor: default; }
.tile:not(.blocked):hover { filter: brightness(1.06); }
.tile.selected { background-color: var(--face-picked, var(--gk-gold-pale)); translate: calc(var(--d) * -.5) calc(var(--d) * -.5);
  box-shadow: inset 0 0 0 calc(var(--w) * .06) var(--gk-gold-deep), calc(var(--d) * .5) calc(var(--d) * .5) 0 var(--edge), calc(var(--d) * 1.5) calc(var(--d) * 1.5) 0 var(--edge-deep), calc(var(--d) * 1.5 + 2px) calc(var(--d) * 1.5 + 4px) 8px var(--gk-dark); }
.tile.hinted { animation: hinted .45s ease-in-out 4 alternate; }
@keyframes hinted { to { background-color: color-mix(in srgb, var(--gk-good) 55%, var(--face)); box-shadow: inset 0 0 0 calc(var(--w) * .07) var(--gk-go), var(--d) var(--d) 0 var(--edge-deep); } }
.tile.gone { opacity: 0; scale: .5; pointer-events: none; }
.tile.shake { animation: shake .26s; }
@keyframes shake { 25% { translate: -3px 0; } 75% { translate: 3px 0; } }
/* While the New game pop-up is up on arrival, the table is shown clear (shared/flow.js). */
html.gk-clear .tile { visibility: hidden; }

/* A phone: the best time goes, the tools are square buttons with their pictures only (their names are read out). */
@media (max-width: 599px) {
  .stage { gap: 8px; padding-top: 8px; }
  .hud { gap: 6px; } .stats, .tools { gap: 5px; }
  .hud .gk-stat { min-width: 0; padding: 4px 6px; }
  .hud .gk-stat b { font-size: var(--gk-text-md); }
  .best-stat, .tool small { display: none; }
  .tool { min-width: var(--gk-tap); padding: 0; }
  .table { border-width: 4px; }
}
/* A tablet: a larger row. */
@media (min-width: 600px) and (max-width: 1023px) { .stage { gap: 14px; padding-top: 14px; } .hud { gap: 10px 16px; } .hud .gk-stat { min-width: 80px; } .tool { min-width: 72px; } }
/* Desktop: larger counters and tools. */
@media (min-width: 1024px) { .stage { gap: 22px; padding-top: 14px; } .hud .gk-stat { min-width: 92px; } .tool { min-width: 80px; min-height: 54px; } }
/* Wide screens: the table first, then one column with the counters over the tools. */
@media (orientation: landscape) {
  .stage { flex-direction: row; justify-content: center; }
  .table { order: 1; align-self: stretch; width: auto; max-width: 1500px; }
  .hud { order: 2; width: 148px; flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 18px; }
  .stats, .tools { flex-direction: column; align-items: stretch; gap: 10px; }
  .hud .gk-stat { min-width: 0; }
  .tool { flex-direction: row; gap: 10px; padding: 8px 14px; }
  .tool small { font-size: var(--gk-text-sm); }
}
/* A sideways phone: no height for one column, so the counters stand on one side of the table and the tools on the other. */
@media (orientation: landscape) and (max-height: 560px) {
  .stage { gap: 10px; padding-top: 6px; padding-bottom: max(6px, var(--gk-safe-bottom)); }
  .hud { display: contents; }
  .stats { order: 1; } .table { order: 2; } .tools { order: 3; }
  .stats, .tools { flex: none; width: 88px; gap: 6px; }
  .hud .gk-stat { padding: 2px 6px; }
  .hud .gk-stat b { font-size: var(--gk-text-md); }
  .tool { min-height: var(--gk-tap); flex-direction: column; gap: 2px; padding: 4px 6px; }
  .tool small { font-size: var(--gk-text-xs); }
  .table { border-width: 4px; }
}
/* Without movement the hinted pair is simply marked. */
@media (prefers-reduced-motion: reduce) {
  .tile.hinted { animation: none; background-color: color-mix(in srgb, var(--gk-good) 55%, var(--face)); box-shadow: inset 0 0 0 calc(var(--w) * .07) var(--gk-go), var(--d) var(--d) 0 var(--edge-deep); }
  .tile.shake { animation: none; }
}
