/* The game page (/misc/play/) is a grid of square cells. game-page.js picks
   the cell size and the number of columns and rows from the window, so the
   grid spans the page and its last row, which holds the banner ad, ends it.
   The script gives the game and the ad boxes their cells; game tiles flow
   into every cell left over. */
.game-page {
  --pad: 20px;
  padding: var(--pad);
}
.game-page.is-laid-out {
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--cell));
  grid-auto-rows: var(--cell);
  grid-auto-flow: dense;
  gap: var(--gap);
  justify-content: center;
}

#gameframe {
  /* The bar under the game and the border are drawn in this unit, 1vw;
     game-page.js gives it a floor on small screens. */
  --u: 1vw;
  min-width: 0;
  min-height: 0;
}
/* Until the script has run, or without it. */
.game-page:not(.is-laid-out) #gameframe {
  height: min(72vh, 56vw);
}
#gameframe .gameDisplay {
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  outline: calc(0.2 * var(--u)) solid
    color-mix(in srgb, var(--site-border, #ffffff) 45%, transparent);
  box-shadow: 0 6px 12px 0 rgba(0, 0, 0, 0.24);
  background-color: var(--site-border, #353d49);
  border-radius: var(--site-radius-md, 14px);
  overflow: hidden;
}
#gameframe .game {
  flex: 1;
  min-height: 0;
  width: 100%;
  background-color: var(--site-surface-3, #444);
  background-repeat: no-repeat;
  background-position: center;
}
#gameframe .game iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}
#gameframe .options {
  flex: none;
  box-sizing: border-box;
  width: 100%;
  height: calc(4.5 * var(--u));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--u);
  padding: 0 calc(1.5 * var(--u)) 0 calc(0.6 * var(--u));
}
#gameframe .options .left,
#gameframe .options .right {
  display: flex;
  align-items: center;
  min-width: 0;
}
#gameframe .options .right {
  flex: none;
  gap: calc(1.2 * var(--u));
}
.gametext {
  display: flex;
  align-items: center;
  min-width: 0;
}
.gameicon {
  flex: none;
  width: calc(2.6 * var(--u));
  height: calc(2.6 * var(--u));
  border-radius: var(--site-radius-sm, 10px);
  background: var(--site-button, #19191b);
  transition: 0.4s;
}
.margin {
  margin-left: calc(0.7 * var(--u));
  min-width: 0;
}
.flex {
  display: flex;
  min-width: 0;
}
.titletext {
  margin: 0;
  padding: 0;
  font-size: calc(1.4 * var(--u));
  color: var(--site-text, #ffffff);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bytext {
  display: block;
  margin: calc(0.2 * var(--u)) 0 0;
  color: var(--site-muted, #cfcfcf);
  font-size: calc(0.8 * var(--u));
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fullscreenbtn {
  border-radius: var(--site-radius-sm, 10px);
  font-size: calc(1.6 * var(--u));
  cursor: pointer;
  transition: transform 0.3s ease-in-out;
}
.fullscreenbtn:hover {
  transform: scaleX(1.2) scaleY(1.2) rotate(-10deg);
}
/* Cloud save status and Save button (save-status.js). */
.savebtn {
  display: inline-flex;
  align-items: center;
  gap: calc(0.5 * var(--u));
  height: calc(2.6 * var(--u));
  padding: 0 calc(0.9 * var(--u));
  border: 1px solid
    color-mix(in srgb, var(--site-border, #ffffff) 70%, transparent);
  border-radius: 999px;
  background: var(--site-button, #19191b);
  color: var(--site-text, #ffffff);
  font-family: inherit;
  font-size: calc(1.1 * var(--u));
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition:
    border-color 0.2s ease,
    background-color 0.2s ease;
}
.savebtn[hidden] {
  display: none;
}
.savebtn i {
  font-size: calc(1.25 * var(--u));
}
.savebtn:hover:not(:disabled) {
  border-color: var(--site-muted, #cfcfcf);
}
.savebtn:focus-visible {
  outline: 2px solid var(--site-accent, #f5b942);
  outline-offset: 2px;
}
.savebtn[data-state="ok"] i {
  color: #4ade80;
}
.savebtn[data-state="pending"] i {
  color: var(--site-accent, #f5b942);
}
.savebtn[data-state="warn"] i {
  color: #60a5fa;
}
.savebtn[data-state="error"] i {
  color: #f87171;
}
.savebtn[data-state="busy"] {
  cursor: progress;
}
.savebtn:disabled {
  cursor: default;
  opacity: 0.7;
}
/* Narrow screens: the icon alone, the label stays in its tooltip. */
@media (max-width: 560px) {
  .savebtn-label {
    display: none;
  }
}

.reloadbtn {
  font-size: calc(1.6 * var(--u));
  cursor: pointer;
  transition: transform 0.55s ease-in-out;
}
.reloadbtn:hover {
  transform: scaleX(1.2) scaleY(1.2) rotate(360deg);
}

/* An ad box is centred in its cells; .ad-fit is the ad itself, scaled by the
   script to fit them. */
.ad-box {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
}
.ad-box[hidden] {
  display: none;
}
.ad-fit {
  flex: none;
  position: relative;
  background-color: var(--site-surface-2, #3d4756);
  border-radius: var(--site-radius-sm, 10px);
  outline: 2px solid
    color-mix(in srgb, var(--site-border, #ffffff) 45%, transparent);
  box-shadow: 0 6px 12px 0 rgba(0, 0, 0, 0.24);
  overflow: hidden;
}
/* A square ad box is framed like a big game tile and fills its cells; the
   250x250 ad is scaled to fill the frame. */
.ad-box--square {
  background-color: var(--site-surface-2, #3d4756);
  border-radius: var(--site-radius-md, 14px);
  outline: 2px solid
    color-mix(in srgb, var(--site-border, #ffffff) 45%, transparent);
  box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.24);
  overflow: hidden;
}
.ad-box--square .ad-fit {
  border-radius: 0;
  outline: none;
  box-shadow: none;
}
.ad-fit [data-55gms-ad] {
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  min-height: 0 !important;
  aspect-ratio: auto !important;
}
.ad-fit [data-55gms-ad] a {
  display: block;
  width: 100%;
  height: 100%;
}
.ad-fit [data-55gms-ad] img {
  width: 100% !important;
  height: 100% !important;
  object-fit: fill;
}
/* A Google ad comes at its own size in pixels, so it is scaled to the box. */
.ad-fit [data-55gms-ad] ins.adsbygoogle {
  transform: scale(var(--ad-scale-x, 1), var(--ad-scale-y, 1));
  transform-origin: 0 0;
}

/* Game tiles: the hover and the clip are the games page's (games.css). */
.game-tile {
  position: relative;
  display: block;
  min-width: 0;
  min-height: 0;
  color: #fff;
  text-decoration: none;
  border-radius: var(--site-radius-md, 14px);
  touch-action: manipulation;
}
.game-tile[hidden] {
  display: none;
}
.game-tile:empty {
  background-color: color-mix(
    in srgb,
    var(--site-surface-2, #3d4756) 55%,
    transparent
  );
}
.game-tile:hover,
.game-tile:focus-visible {
  z-index: 1;
}
.game-tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--site-radius-md, 14px);
  box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.24);
  transition: all 0.35s ease;
}
.game-tile:hover img,
.game-tile:focus-visible img {
  transform: scale(1.05) translateY(-3px);
  filter: brightness(0.7);
}
.game-preview {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  border-radius: var(--site-radius-md, 14px);
  transform: scale(1.05) translateY(-3px);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.game-preview.is-shown {
  opacity: 1;
}
.game-tile-name {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: calc(100% - 12px);
  transform: translate(-50%, 0);
  color: #fff;
  font-family: "Roboto", serif;
  font-weight: 500;
  font-size: 0.75rem;
  line-height: 1.2;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  opacity: 0;
  transition:
    opacity 0.35s ease,
    transform 0.35s ease;
}
.game-tile:hover .game-tile-name,
.game-tile:focus-visible .game-tile-name {
  opacity: 1;
  transform: translate(-50%, -10px);
}
.game-link.is-previewing .game-tile-name {
  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.95),
    0 0 8px rgba(0, 0, 0, 0.8);
}

@media (prefers-reduced-motion: reduce) {
  .game-tile img,
  .game-tile-name {
    transition: none;
  }
}

/* Shown by game-page.js from a game's rewarded-ad click until the ad opens. */
.ad-wait {
  position: fixed;
  inset: auto;
  margin: 0;
  z-index: 2147483646;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(320px, calc(100vw - 32px));
  padding: 12px 18px;
  border: 0;
  border-radius: var(--site-radius-pill, 999px);
  background: rgba(0, 0, 0, 0.82);
  color: #fff;
  font:
    500 0.95rem/1.3 system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  overflow: visible;
}
.ad-wait[hidden] {
  display: none;
}
.ad-wait-spin {
  display: none;
  flex: none;
  width: 18px;
  height: 18px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: ad-wait-spin 0.8s linear infinite;
}
.ad-wait.is-busy .ad-wait-spin {
  display: block;
}
@keyframes ad-wait-spin {
  to {
    transform: rotate(1turn);
  }
}
@media (prefers-reduced-motion: reduce) {
  .ad-wait-spin {
    animation-duration: 2.4s;
  }
}
