/*
  TOP MEGA888 GAMES COMPONENT
  Change these variables to match your website branding.

  --games-screen-ratio is the ONE place the screenshot aspect ratio is
  defined. Every screenshot in assets/games/ must be cropped to it before
  upload. Change it here and nowhere else.
*/
/*
  Scoped to the component. These were on :root in the demo page; they are
  confined here so nothing leaks into the rest of the site.
*/
.top-games {
  --games-bg: #1e1f2b;
  --games-surface: #262739;
  --games-surface-soft: #2f3145;
  --games-text: #ffffff;
  --games-muted: #c7c9d6;
  --games-border: rgba(255, 255, 255, 0.14);
  --games-red: #ffffff;
  --games-red-dark: #ffffff;
  --games-gold: #ffffff;
  --games-radius-large: 28px;
  --games-radius-medium: 16px;
  --games-screen-ratio: 16 / 9;
}

/*
  The demo page had `* { box-sizing: border-box }`, a `body { ... }` rule and a
  bare `button, a` rule. Applied site-wide those would change your layout and
  repaint the page background. They are scoped to the component here instead.
*/
.top-games,
.top-games *,
.top-games *::before,
.top-games *::after {
  box-sizing: border-box;
}

.top-games {
  background: var(--games-bg);
  color: var(--games-text);
  border-radius: var(--games-radius-large);
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.2);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

.top-games button,
.top-games a {
  font: inherit;
}

.games-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  border: 0;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.top-games {
  padding: 72px 20px;
  scroll-margin-top: 24px;
}

.top-games__container {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.top-games__header {
  position: static;
  display: block;
  height: auto;
  padding: 0;
  background: none;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  max-width: 720px;
  margin-bottom: 28px;
}

.top-games__title {
  margin: 0;
  font-size: clamp(1.75rem, 2.6vw, 2.35rem);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.top-games__intro {
  margin: 14px 0 0;
  color: var(--games-muted);
  font-size: 1.05rem;
  line-height: 1.7;
}

.top-games__tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.game-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 8px 12px;
  overflow: hidden;
  border: 1px solid var(--games-border);
  border-radius: 12px;
  background: transparent;
  color: var(--games-text);
  cursor: pointer;
  text-align: left;
  transition: border-color 160ms ease, background 160ms ease,
    transform 160ms ease;
}

.game-tab:hover {
  border-color: var(--games-gold);
  transform: translateY(-1px);
}

.game-tab:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.38);
  outline-offset: 2px;
}

.game-tab[aria-selected="true"] {
  border-color: transparent;
  background: var(--games-red);
  color: #1e1f2b;
}

.game-tab__thumbnail {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 8px;
  background: var(--games-surface-soft);
  object-fit: cover;
}

.game-tab__thumbnail[hidden] {
  display: none;
}

.game-tab__name {
  overflow: hidden;
  font-size: 0.9rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-showcase {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.75fr);
  overflow: hidden;
  border: 1px solid var(--games-border);
  border-radius: var(--games-radius-large);
  background: var(--games-surface);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.28);
}

.game-showcase:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.42);
  outline-offset: 3px;
}

.game-showcase__visual {
  min-width: 0;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 20%, rgba(255, 255, 255, 0.07), transparent 30%),
    var(--games-surface-soft);
}

/*
  .game-screen is the positioning context for hotspots and it does NOT clip,
  so tooltips can overflow it. The bezel border lives here, which means a
  hotspot's percentage coordinates resolve against the padding box - exactly
  the box .game-screen__frame occupies. Clipping happens on the frame alone.
*/
.game-screen {
  position: relative;
  margin: 0;
  border: 8px solid #080607;
  border-radius: 20px;
  background: #0d090b;
}

.game-screen__frame {
  position: relative;
  aspect-ratio: var(--games-screen-ratio);
  overflow: hidden;
  border-radius: 12px;
  background: #0d090b;
}

.game-screen__image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/*
  Author-origin rule. Without it the UA's [hidden] { display: none } loses to
  .game-screen__image { display: block } and a broken image stays visible
  behind the fallback panel.
*/
.game-screen__image[hidden] {
  display: none;
}

/*
  Busy indicator. Sits above the screenshot but below the label and
  hotspots, so the previous picture stays readable underneath while the next
  one decodes. Only ever shown when a load is actually slow - see
  LOADING_DELAY in the script.
*/
.game-screen__loader {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: rgba(8, 6, 7, 0.38);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
  visibility: hidden;
}

.game-screen.is-loading .game-screen__loader {
  opacity: 1;
  visibility: visible;
}

.game-screen__loader::before {
  position: absolute;
  top: 0;
  left: 0;
  width: 40%;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--games-gold), transparent);
  content: "";
  animation: games-loading-sweep 1100ms linear infinite;
}

@keyframes games-loading-sweep {
  from { transform: translateX(-100%); }
  to { transform: translateX(350%); }
}

.game-screen__fallback {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  padding: 36px;
  background:
    repeating-linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.035) 0 14px,
      transparent 14px 28px
    ),
    #170f12;
  color: var(--games-muted);
  text-align: center;
}

.game-screen__fallback.is-visible {
  display: grid;
}

.game-screen__fallback strong {
  display: block;
  margin-bottom: 8px;
  color: var(--games-text);
  font-size: 1.05rem;
}

.game-screen__label {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 3;
  max-width: calc(100% - 28px);
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: rgba(8, 6, 7, 0.82);
  backdrop-filter: blur(8px);
  color: #ffffff;
  font-size: 0.88rem;
  font-weight: 700;
}

/* --- Hotspots ------------------------------------------------------- */

.game-hotspot {
  position: absolute;
  top: var(--y);
  left: var(--x);
  z-index: 4;
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  border: 3px solid #1e1f2b;
  border-radius: 50%;
  background: var(--games-gold);
  color: #1e1f2b;
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
  transform: translate(-50%, -50%);
}

.game-hotspot:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.55);
  outline-offset: 3px;
}

.game-hotspot__tip {
  /*
    --tip-x / --tip-y carry the whole transform so edge-flip variants change
    one value each instead of rewriting the transform. The reveal rules sit
    after the variants so their --tip-y: 0 wins on equal specificity.
  */
  --tip-x: -50%;
  --tip-y: 5px;
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  z-index: 5;
  width: max-content;
  max-width: 190px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #080607;
  color: #ffffff;
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.35;
  opacity: 0;
  pointer-events: none;
  text-align: left;
  transform: translate(var(--tip-x), var(--tip-y));
  transition: opacity 150ms ease, transform 150ms ease;
  visibility: hidden;
}

/* Vertical flip and horizontal alignment are independent and combine. */
.game-hotspot.is-below .game-hotspot__tip {
  top: calc(100% + 10px);
  bottom: auto;
  --tip-y: -5px;
}

.game-hotspot.is-start .game-hotspot__tip {
  --tip-x: -17px;
}

.game-hotspot.is-end .game-hotspot__tip {
  --tip-x: calc(-100% + 17px);
}

@media (hover: hover) {
  .game-hotspot:hover .game-hotspot__tip {
    opacity: 1;
    visibility: visible;
    --tip-y: 0;
  }
}

.game-hotspot:focus-visible .game-hotspot__tip,
.game-hotspot[aria-expanded="true"] .game-hotspot__tip {
  opacity: 1;
  visibility: visible;
  --tip-y: 0;
}

/* Dev-mode coordinate helper marker. */
.game-screen__crosshair {
  position: absolute;
  top: var(--y);
  left: var(--x);
  z-index: 6;
  width: 18px;
  height: 18px;
  border: 2px solid var(--games-gold);
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

/* --- Showcase content ----------------------------------------------- */

.game-showcase__content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 38px 32px;
}

.game-panel[hidden] {
  display: none;
}

/*
  Without JavaScript every panel renders, so the nine games read as a plain
  list. These separators only ever show in that state - with the script
  running, exactly one panel is visible at a time.
*/
.game-panel + .game-panel {
  margin-top: 26px;
  padding-top: 26px;
  border-top: 1px solid var(--games-border);
}

.game-showcase__category {
  margin: 0 0 10px;
  color: var(--games-gold);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.game-showcase__name {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.7rem);
  line-height: 1.08;
}

.game-showcase__specialty {
  margin: 16px 0 0;
  color: var(--games-muted);
  line-height: 1.7;
}

.game-showcase__features {
  display: grid;
  gap: 13px;
  margin: 26px 0 0;
  padding: 22px 0 0;
  border-top: 1px solid var(--games-border);
  list-style: none;
}

.game-showcase__feature {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 10px;
  align-items: start;
  color: var(--games-muted);
  line-height: 1.45;
}

.game-showcase__feature-number {
  color: var(--games-gold);
  font-weight: 800;
}

.game-showcase__downloads {
  margin-top: 28px;
}

.game-showcase__downloads-label {
  margin: 0 0 12px;
  color: var(--games-text);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.4;
}

/*
  auto-fit puts the buttons side by side when the column is wide enough and
  stacks them when it is not. grid-auto-rows: 1fr keeps both the same height
  even when one label wraps to two lines and the other does not.
*/
.game-showcase__cta-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  grid-auto-rows: 1fr;
  gap: 10px;
}

.game-showcase__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 12px 20px;
  border: 1px solid transparent;
  border-radius: 9999px;
  background: var(--games-red);
  color: #1e1f2b;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

/* The button that does NOT match the visitor's device. Still full size and
   fully clickable - de-emphasised, never hidden. */
.game-showcase__cta--secondary {
  border-color: var(--games-border);
  background: transparent;
  color: var(--games-text);
  box-shadow: none;
}

.game-showcase__cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}

.game-showcase__cta--secondary:hover {
  border-color: var(--games-gold);
  box-shadow: none;
}

.game-showcase__cta:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.42);
  outline-offset: 3px;
}

.top-games__note {
  margin: 16px 0 0;
  color: var(--games-muted);
  font-size: 0.86rem;
  line-height: 1.6;
}

@media (max-width: 820px) {
  .game-showcase {
    grid-template-columns: 1fr;
  }

  .game-showcase__content {
    border-top: 1px solid var(--games-border);
  }
}

@media (max-width: 620px) {
  .top-games {
    padding: 52px 16px;
  }

  .top-games__tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .game-tab__thumbnail {
    display: none;
  }

  .game-showcase__visual {
    padding: 14px;
  }

  .game-showcase__content {
    padding: 30px 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .top-games,
  .top-games *,
  .top-games *::before,
  .top-games *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }

  /* The sweep is an animation, not a transition, so it needs killing
     separately. A static full-width bar still reads as "busy". */
  .game-screen__loader::before {
    width: 100%;
    animation: none;
    opacity: 0.85;
  }
}
