/* Game page. The frame stands in for the provider's game, which arrives over the games API.
   Desktop and tablet play inside the page. Phone shows a detail screen first,
   then plays between the header and the tab bar without scrolling. */

.is-game .page {
  gap: var(--space-6);
}

.game-detail {
  display: none;
}

.stage {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--surface-0);
}

/* Theatre mode lets the game take the page's whole width. */
.is-theater .page {
  max-width: none;
}

.stage__currency select {
  height: 32px;
  padding: 0 var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-1);
  color: var(--ink);
  font-size: 13px;
}

/* Live stats float over the game. */
.live-stats {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  z-index: 3;
  width: 260px;
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  box-shadow: 0 8px 24px rgb(0 0 0 / calc(0.35 * var(--shade)));
}

.live-stats__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}

.live-stats__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
  margin: 0;
}

.live-stats__grid div {
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--surface-0);
}

.live-stats__grid dt {
  color: var(--ink-muted);
  font-size: 12px;
}

.live-stats__grid dd {
  margin: 0;
  font-weight: 700;
}

.frame {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #1A1240;
  color: #F3F7FB;
}

.frame__layer {
  position: absolute;
  inset: 0;
  display: none;
}

.frame[data-sample-slot-state-value="loading"] [data-layer="loading"],
.frame[data-sample-slot-state-value="intro"] [data-layer="intro"],
.frame[data-sample-slot-state-value="playing"] [data-layer="playing"] {
  display: flex;
}

.frame__loading {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  background: var(--surface-0);
  color: var(--ink-muted);
  font-size: 14px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--surface-3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.intro__bg,
.slot__bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.intro__bg {
  filter: brightness(0.35) saturate(1.1);
}

/* Centred, unless the frame is too short for it; then it starts at the top and scrolls. */
.intro {
  align-items: safe center;
  justify-content: center;
  padding: var(--space-8) var(--space-5);
  overflow-y: auto;
  text-align: center;
}

.intro__body {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-6);
  width: 100%;
}

.intro__title {
  color: #F5A524;
  font-family: var(--font-display);
  font-size: 52px;
  font-weight: 800;
  line-height: 1.05;
  text-shadow: 0 4px 24px rgb(0 0 0 / 0.5);
}

.intro__cards {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-4);
}

.intro__card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 200px;
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  background: rgb(255 255 255 / 0.1);
  text-align: center;
}

.intro__card div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.intro__card strong {
  font-size: 15px;
}

.intro__card span {
  color: #D9D3F5;
  font-size: 13px;
  line-height: 1.6;
}

.intro__continue {
  height: var(--control-xl);
  padding: 0 48px;
  border: 0;
  border-radius: var(--radius-full);
  background: #F5A524;
  color: #1A1240;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
}

.intro__options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-5);
  color: #D9D3F5;
  font-size: 13px;
}

.intro__options strong {
  color: #FFD54A;
}

.intro__options label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.intro__provider {
  color: #A9A2D6;
  font-size: 12px;
}

.slot {
  flex-direction: column;
}

.slot__bg {
  filter: brightness(0.55);
}

.slot__main {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-8);
  min-height: 0;
  padding: var(--space-6) var(--space-8) var(--space-3);
}

.slot__side {
  flex: 0 0 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  text-align: center;
}

.slot__title {
  color: #F5A524;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  line-height: 1.1;
  text-shadow: 0 2px 12px rgb(0 0 0 / 0.5);
}

.slot__pill {
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: rgb(255 255 255 / 0.14);
  font-size: 13px;
  font-weight: 700;
}

.slot__caption {
  color: #D9D3F5;
  font-size: 13px;
}

.slot__multiplier {
  color: var(--win);
  font-family: var(--font-display);
  font-size: 44px;
  font-weight: 800;
  line-height: 1;
}

/* As large as the board lets it be, either way, keeping its 6 by 5 shape. */
.slot__reels {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-rows: repeat(5, minmax(0, 1fr));
  gap: 6px;
  width: min(100cqw, 120cqh);
  aspect-ratio: 6 / 5;
  padding: 10px;
  border-radius: var(--radius-lg);
  background: rgb(10 6 30 / 0.55);
}

.slot__cell {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgb(42 30 102 / 0.85);
}

.slot__cell svg {
  width: 58%;
  height: 58%;
}

.slot__cell.is-winning {
  box-shadow: inset 0 0 0 2px var(--win);
  animation: slot-win 0.6s ease-in-out 2;
}

/* The reels and what lands on them: the win, or why a spin didn't happen. */
.slot__board {
  position: relative;
  flex: 1;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  container-type: size;
}

/* While a spin waits for its result, the symbols flicker past, blurred, like turning reels. */
.is-spinning .slot__cell svg {
  opacity: 0.85;
  filter: blur(1.5px);
  transform: translateY(6%);
}

.is-spinning .slot__spin .icon {
  animation: slot-turn 0.6s linear infinite;
}

.slot__win,
.slot__message {
  position: absolute;
  top: 50%;
  left: 50%;
  margin: 0;
  text-align: center;
  pointer-events: none;
  translate: -50% -50%;
}

.slot__win {
  padding: 8px 24px;
  border-radius: var(--radius-full);
  background: rgb(10 6 30 / 0.82);
  color: var(--win);
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 800;
  text-shadow: 0 2px 10px rgb(0 0 0 / 0.6);
  animation: slot-pop 0.35s ease-out;
}

.slot__win.is-big {
  color: #F5A524;
  font-size: 46px;
}

.slot__message {
  max-width: 85%;
  padding: 12px 18px;
  border-radius: var(--radius-lg);
  background: rgb(10 6 30 / 0.9);
  color: #FFFFFF;
  font-size: 14px;
  font-weight: 700;
}

.slot__win[hidden],
.slot__message[hidden] {
  display: none;
}

@keyframes slot-win {
  50% { transform: scale(1.08); }
}

@keyframes slot-pop {
  from { opacity: 0; scale: 0.6; }
}

@keyframes slot-turn {
  to { rotate: 360deg; }
}

@media (prefers-reduced-motion: reduce) {
  .slot__cell.is-winning,
  .slot__win,
  .is-spinning .slot__spin .icon {
    animation: none;
  }
}

.slot__bar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: 10px var(--space-6);
  background: rgb(0 0 0 / 0.45);
}

.slot__stats {
  display: flex;
  gap: var(--space-5);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.slot__stats span {
  display: flex;
  flex-direction: column;
}

.slot__stats small {
  color: #D9D3F5;
  font-size: 11px;
}

.slot__controls {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.slot__round {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: rgb(255 255 255 / 0.16);
  color: #FFFFFF;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
}

.slot__spin {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border: 0;
  border-radius: 50%;
  background: #F5A524;
  color: #1A1240;
  cursor: pointer;
}

.slot__spin .icon {
  stroke-width: 2.6;
}

.slot__spin:disabled,
.slot__round:disabled {
  opacity: 0.6;
  cursor: default;
}

.slot__options {
  display: flex;
  gap: var(--space-2);
}

.slot__pill-button {
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-full);
  background: rgb(255 255 255 / 0.16);
  color: #FFFFFF;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.slot__pill-button[aria-pressed="true"] {
  background: #F5A524;
  color: #1A1240;
}

/* The launch frame from the server: the provider's game, or a notice about why it can't open. */
.frame__launch {
  position: absolute;
  inset: 0;
  display: block;
}

.frame__game {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.frame__cover {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  background: var(--surface-0);
  color: var(--ink-muted);
  font-size: 14px;
  text-align: center;
}

.frame__cover[hidden] {
  display: none;
}

.frame__provider {
  font-size: 12px;
}

.frame-notice {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  overflow-y: auto;
  padding: var(--space-6);
  background: rgb(12 26 38 / 0.94);
  color: var(--ink);
  text-align: center;
}

.frame-notice__icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--surface-2);
}

.frame-notice__icon--accent { color: var(--focus); }
.frame-notice__icon--warn { color: var(--tile-amber); }
.frame-notice__icon--danger { color: var(--danger); }
.frame-notice__icon--muted { color: var(--ink-muted); }

.frame-notice__title {
  max-width: 460px;
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  line-height: 1.4;
  text-wrap: balance;
}

.frame-notice__body {
  max-width: 420px;
  margin: 0;
  color: var(--ink-muted);
  line-height: 1.7;
}

.frame-notice__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-3);
}

.frame-notice__status {
  flex-basis: 100%;
}

/* The sample game fills its iframe. */
.sample-game {
  margin: 0;
  background: #1A1240;
}

.frame--sample {
  height: 100vh;
  aspect-ratio: auto;
}

.frame__badge {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  z-index: 3;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: rgb(12 26 38 / 0.8);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.stage__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3) var(--space-2) var(--space-4);
  background: var(--surface-2);
}

.stage__tools {
  display: flex;
  align-items: center;
  gap: 2px;
}

.game-below {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  container-type: inline-size;
}

/* The game's card, and the side panel's game lists below it, or beside it when there's room. */
.game-below__row {
  display: grid;
  align-items: start;
  gap: var(--space-6);
}

.game-below__games {
  display: flex;
  flex-direction: column;
  height: 440px;
  padding: 0;
}

.game-below__frame {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

@container (min-width: 820px) {
  .game-below__row {
    grid-template-columns: minmax(0, 1fr) 340px;
  }

  .game-below__games {
    height: 600px;
  }
}

.game-info {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-6);
}

.provider {
  display: flex;
  align-items: center;
  gap: 14px;
}

.game-info .provider {
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--line);
}

.provider__logo {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: var(--surface-3);
  font-family: var(--font-display);
  font-weight: 800;
}

.provider__text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.provider__name {
  font-weight: 700;
}

.provider__followers {
  color: var(--ink-muted);
  font-size: 13px;
}

.game-info__title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.game-info__stats {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.game-info__stats > summary {
  list-style: none;
  cursor: pointer;
}

.game-info__stats > summary::-webkit-details-marker {
  display: none;
}

.game-info__toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--ink-muted);
  font-size: 14px;
  font-weight: 600;
}

.game-info__toggle .icon {
  rotate: -90deg;
  transition: rotate 0.2s var(--ease-standard);
}

.game-info__stats[open] .game-info__toggle .icon {
  rotate: 0deg;
}

.game-info__stats > summary:hover .game-info__toggle {
  color: var(--ink);
}

.game-info__title-row h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
}

.game-info__meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--ink-muted);
  font-size: 13px;
}

/* The phone's game card, measured from it: a 110px cover beside the name, then the row
   with the currency and full screen, then the play buttons, 16px apart. */
.game-detail {
  flex-direction: column;
  gap: var(--space-4);
}

.game-detail .card {
  padding: var(--space-4);
}

.game-detail__main {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.game-detail__head {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.game-detail__cover {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 110px;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border-radius: var(--radius-md);
}

.game-detail__image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.game-detail__title {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
  min-width: 0;
}

.game-detail__title h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
}

.game-detail__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.game-detail__provider {
  color: var(--ink-muted);
  font-size: 14px;
}

/* "Display" in grey, then the currency in white with its arrow. */
.game-detail__display {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.display-select__label {
  color: var(--ink-muted);
  font-size: 14px;
}

.game-detail__display select {
  height: 32px;
  padding: 0 var(--space-1);
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}

.game-detail__actions {
  display: flex;
  gap: var(--space-2);
}

.game-detail__actions .button {
  flex: 1;
  height: 40px;
  padding: 0 var(--space-3);
}

.game-detail__actions .game-detail__play {
  flex: 1.4;
}

.game-detail__actions .icon-button {
  width: 48px;
  height: 40px;
  background: var(--surface-3);
}

/* The phone's more games, three to a row. Only a phone shows them; elsewhere the side panel does. */
.game-recos {
  display: none;
  flex-direction: column;
  gap: var(--space-3);
}

.game-recos__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.game-info__phone-title {
  display: none;
}

/* Tablet */
@media (max-width: 1099px) {
  .slot__side {
    display: none;
  }

}

/* Phone */
@media (max-width: 767px) {
  .is-game-play .game-below,
  .is-game-detail .stage,
  .game-below__games {
    display: none;
  }

  .is-game-detail .game-detail,
  .game-recos {
    display: flex;
  }

  /* The game's card under the phone's: the studio with a heart alone to follow it, then
     "the game's statistics" folding over the players, the saves and the tabs. */
  .game-info {
    padding: var(--space-4);
  }

  .game-info .provider__logo {
    width: 48px;
    height: 48px;
  }

  .game-info .provider__name {
    font-size: 18px;
  }

  .game-info .provider__follow {
    width: 48px;
    height: 40px;
    padding: 0;
  }

  .game-info .provider__follow span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .game-info__title-row h1,
  .game-info__toggle-text,
  .game-info__meta .favorite-toggle,
  .game-details__thumb {
    display: none;
  }

  .game-info__phone-title {
    display: block;
    color: var(--ink-muted);
  }

  .game-info__meta {
    font-size: 15px;
  }

  .game-info__meta > span + span {
    padding-left: var(--space-3);
    border-left: 1px solid var(--line);
  }

  .game-stats > .segmented {
    overflow-x: auto;
    scrollbar-width: none;
  }

  .game-stats > .segmented button {
    height: 44px;
    padding: 0 var(--space-5);
    font-size: 16px;
  }

  .is-game-play .footer,
  .is-game-play .stage__bar {
    display: none;
  }

  /* Play on a phone: the game on a card 16px in from the header, the edges and the bar. */
  .is-game-play .stage {
    position: fixed;
    top: calc(var(--phone-header-height) + var(--space-4));
    right: var(--space-4);
    bottom: calc(var(--bottom-nav-height) + var(--space-4) + env(safe-area-inset-bottom, 0px));
    left: var(--space-4);
    z-index: 5;
    display: flex;
    flex-direction: column;
    border-radius: var(--radius-md);
    background: var(--surface-2);
  }

  .is-game-play .frame {
    flex: 1;
    min-height: 0;
    aspect-ratio: auto;
  }

  .slot__main {
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-3) var(--space-2);
  }

  .slot__side--title {
    display: flex;
    flex: none;
    flex-direction: row;
  }

  .slot__title {
    font-size: 22px;
  }

  .slot__board {
    width: 100%;
  }

  .slot__reels {
    gap: 4px;
    padding: 8px;
  }

  .slot__bar {
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
  }

  .slot__pill-button--wide,
  .stage__wide-only {
    display: none;
  }

  .intro {
    padding: var(--space-5) var(--space-4);
  }

  .intro__body {
    gap: var(--space-4);
  }

  .intro__title {
    font-size: 32px;
  }

  .intro__cards {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    width: 100%;
  }

  .intro__card {
    flex-direction: row;
    width: auto;
    text-align: left;
  }
}

@media (max-width: 767px) {
  .frame-notice__actions {
    flex-direction: column;
    align-self: stretch;
  }

  .frame-notice__actions .button,
  .frame-notice__actions form {
    width: 100%;
  }
}

/* The game's statistics: tabs over panels that switch in place. */
.game-stats,
.game-stats__panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.game-stats [role="tabpanel"][hidden] {
  display: none;
}

.game-challenges {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.game-challenge {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--surface-0);
  color: var(--ink);
  font-size: 14px;
}

.game-challenge__prize strong {
  color: var(--win);
}

.game-details {
  display: flex;
  gap: var(--space-4);
}

.game-details__thumb {
  display: grid;
  flex: none;
  place-items: center;
  width: 120px;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border-radius: var(--radius-md);
}

.game-details__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.game-details__text {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  color: var(--ink-muted);
  font-size: 14px;
  line-height: 1.6;
}

.game-details__text p {
  margin: 0;
}

.game-details__tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* The game's tags: small round pills. */
.game-details__tags span {
  padding: 0 var(--space-2);
  border-radius: var(--radius-full);
  background: var(--surface-3);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  line-height: 20px;
}
