:root {
  --gp-bg: var(--t-bg, #08090d);
  --gp-deep: color-mix(in srgb, var(--gp-bg) 88%, #000);
  --gp-panel: color-mix(in srgb, var(--t-bg2, #14161e) 94%, transparent);
  --gp-panel-strong: color-mix(in srgb, var(--t-bg3, #1c1f28) 96%, transparent);
  --gp-border: color-mix(in srgb, var(--t-ac, #9b7cff) 18%, var(--t-bd, #30333e));
  --gp-border-hot: color-mix(in srgb, var(--t-ac, #9b7cff) 68%, white);
  --gp-text: var(--t-fg, #f6f7fb);
  --gp-muted: var(--t-fg2, #a8abb8);
  --gp-accent: var(--t-ac, #9b7cff);
  --gp-gradient: var(--t-gr, linear-gradient(135deg, #7157dd, #a95dcc));
  --gp-green: #6ee7a8;
  --gp-radius: 18px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--gp-bg); }
body.game-portal-page {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--gp-text);
  background: var(--gp-bg);
  font-family: Inter, Outfit, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.game-portal-page::before {
  content: "";
  position: fixed;
  inset: -20px;
  z-index: -2;
  background: var(--t-bgr, none) center / cover;
  filter: blur(var(--t-blur, 8px));
  transform: scale(1.035);
}
body.game-portal-page::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--gp-bg) 67%, transparent), var(--gp-bg) 88%),
    repeating-linear-gradient(90deg, transparent 0 79px, rgba(255,255,255,.018) 80px);
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.portal-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 70px;
  display: grid;
  grid-template-columns: 210px minmax(280px, 620px) 210px;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 10px max(22px, calc((100vw - 1280px) / 2));
  border-bottom: 1px solid var(--gp-border);
  background: color-mix(in srgb, var(--gp-deep) 91%, transparent);
  box-shadow: 0 14px 34px rgba(0,0,0,.18);
  backdrop-filter: blur(20px) saturate(125%);
}
.portal-bar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  opacity: .55;
  background: linear-gradient(90deg, transparent 5%, var(--gp-accent), transparent 95%);
}
.portal-brand {
  width: max-content;
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--gp-text);
  text-decoration: none;
}
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--gp-border);
  border-radius: 13px;
  background: var(--gp-panel-strong);
  box-shadow: inset 0 1px rgba(255,255,255,.12), 0 8px 22px rgba(0,0,0,.3);
}
.brand-mark img { width: 36px; height: 36px; border-radius: 10px; }
.brand-name { font-size: 18px; font-weight: 900; line-height: 1; letter-spacing: -.055em; }
.brand-name > span { color: var(--gp-muted); }
.brand-name small {
  display: block;
  margin-top: 5px;
  color: var(--gp-accent);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.portal-search {
  height: 46px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 13px;
  border: 1px solid var(--gp-border);
  border-radius: 14px;
  background: color-mix(in srgb, var(--gp-panel) 88%, transparent);
  box-shadow: inset 0 1px rgba(255,255,255,.055), 0 8px 24px rgba(0,0,0,.12);
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
.portal-search:focus-within {
  border-color: var(--gp-border-hot);
  background: var(--gp-panel-strong);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--gp-accent) 17%, transparent), 0 10px 28px rgba(0,0,0,.2);
}
.portal-search svg { width: 19px; height: 19px; flex: 0 0 auto; fill: none; stroke: var(--gp-muted); stroke-width: 2; }
.portal-search input { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--gp-text); background: transparent; font-size: 15px; }
.portal-search input::placeholder { color: color-mix(in srgb, var(--gp-muted) 78%, transparent); }
.portal-search kbd {
  min-width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border: 1px solid var(--gp-border);
  border-radius: 7px;
  color: var(--gp-muted);
  background: var(--gp-panel-strong);
  font-size: 12px;
  box-shadow: inset 0 -2px rgba(0,0,0,.22);
}
.portal-wallet {
  width: max-content;
  height: 48px;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 13px 5px 7px;
  border: 1px solid var(--gp-border);
  border-radius: 15px;
  color: var(--gp-text);
  background: var(--gp-panel);
  box-shadow: inset 0 1px rgba(255,255,255,.06);
  text-decoration: none;
  transition: transform .16s ease, border-color .16s ease;
}
.portal-wallet:hover { transform: translateY(-1px); border-color: var(--gp-border-hot); }
.portal-wallet img { border-radius: 50%; filter: drop-shadow(0 3px 7px rgba(0,0,0,.45)); }
.portal-wallet small, .portal-wallet strong { display: block; }
.portal-wallet small { color: var(--gp-muted); font-size: 12px; line-height: 1; }
.portal-wallet strong { margin-top: 4px; font-size: 15px; line-height: 1; }

.portal-main { width: min(1280px, calc(100% - 44px)); margin: 0 auto; padding: 26px 0 76px; }
.portal-heading { display: flex; align-items: end; justify-content: space-between; gap: 28px; margin-bottom: 22px; }
.portal-title-wrap { display: flex; flex-direction: column; align-items: flex-start; }
.library-count {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 8px;
  color: var(--gp-muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.library-count i { width: 7px; height: 7px; border-radius: 50%; background: var(--gp-green); box-shadow: 0 0 14px color-mix(in srgb, var(--gp-green) 70%, transparent); }
.portal-heading h1 { margin: 0; font-size: clamp(40px, 4.4vw, 58px); line-height: .9; letter-spacing: -.07em; }
.reward-card {
  width: min(390px, 100%);
  padding: 12px 14px;
  border: 1px solid var(--gp-border);
  border-radius: 16px;
  background: var(--gp-panel);
  box-shadow: inset 0 1px rgba(255,255,255,.06), 0 14px 35px rgba(0,0,0,.18);
}
.reward-copy { display: flex; align-items: center; gap: 11px; }
.reward-copy img { border-radius: 50%; filter: drop-shadow(0 4px 8px rgba(0,0,0,.42)); }
.reward-copy span { min-width: 0; flex: 1; }
.reward-copy strong, .reward-copy small { display: block; }
.reward-copy strong { font-size: 14px; }
.reward-copy small { margin-top: 4px; overflow: hidden; color: var(--gp-muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.reward-meter { height: 5px; margin-top: 11px; overflow: hidden; border-radius: 99px; background: color-mix(in srgb, var(--gp-muted) 15%, transparent); }
.reward-meter i { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--gp-gradient); box-shadow: 0 0 12px var(--gp-accent); transition: width .3s ease; }

.section-heading { min-height: 38px; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 0 12px; }
.section-heading h2 { margin: 0; font-size: 20px; letter-spacing: -.035em; }
.section-heading > span { color: var(--gp-muted); font-size: 13px; }
.featured-section { margin-bottom: 25px; }
.shuffle-button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  border: 1px solid var(--gp-border);
  border-radius: 10px;
  color: var(--gp-muted);
  background: var(--gp-panel);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}
.shuffle-button span { color: var(--gp-accent); font-size: 17px; }
.shuffle-button:hover { color: var(--gp-text); border-color: var(--gp-border-hot); }
.featured-grid { height: 310px; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); grid-template-rows: repeat(2, 1fr); gap: 12px; }
.featured-grid .game-card { grid-column: span 3; min-height: 0; aspect-ratio: auto; }
.featured-grid .game-card-hero { grid-column: span 6; grid-row: span 2; }
.featured-grid .game-card-hero .game-card-copy { padding: 22px; }
.featured-grid .game-card-hero .game-card-copy strong { font-size: clamp(22px, 2vw, 30px); }
.featured-grid .game-card-hero .game-card-copy small { margin-top: 6px; font-size: 13px; }
.featured-grid .game-card-hero .game-card-play { right: 20px; bottom: 20px; width: 46px; height: 46px; opacity: 1; transform: none; font-size: 14px; }

.browse-bar { display: flex; align-items: center; gap: 18px; margin: 0 0 20px; }
.browse-bar > strong { flex: 0 0 auto; font-size: 14px; }
.category-strip { min-width: 0; display: flex; gap: 7px; margin: 0; padding: 2px 2px 7px; overflow-x: auto; scrollbar-width: thin; }
.category-chip {
  min-height: 35px;
  flex: 0 0 auto;
  padding: 0 14px;
  border: 1px solid var(--gp-border);
  border-radius: 10px;
  color: var(--gp-muted);
  background: var(--gp-panel);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease, background .15s ease, transform .15s ease;
}
.category-chip:hover { color: var(--gp-text); border-color: var(--gp-border-hot); transform: translateY(-1px); }
.category-chip.is-active { color: #fff; border-color: transparent; background: var(--gp-gradient); box-shadow: 0 7px 20px color-mix(in srgb, var(--gp-accent) 18%, transparent); }
.recent-section { margin-bottom: 28px; }

.game-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 13px; }
.game-grid-recent { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.game-card {
  position: relative;
  min-width: 0;
  aspect-ratio: 4 / 3;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--gp-border);
  border-radius: var(--gp-radius);
  color: #fff;
  background: var(--gp-panel-strong);
  box-shadow: 0 8px 24px rgba(0,0,0,.22);
  cursor: pointer;
  text-align: left;
  isolation: isolate;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.game-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
  box-shadow: inset 0 1px rgba(255,255,255,.09);
  pointer-events: none;
}
.game-card::after { content: ""; position: absolute; inset: 31% 0 0; z-index: 1; background: linear-gradient(transparent, rgba(5,7,11,.96)); }
.game-card:hover, .game-card:focus-visible { transform: translateY(-4px); border-color: var(--gp-border-hot); box-shadow: 0 18px 42px rgba(0,0,0,.45), 0 0 0 1px color-mix(in srgb, var(--gp-accent) 18%, transparent); }
.game-card:focus-visible { outline: 3px solid color-mix(in srgb, var(--gp-accent) 58%, white); outline-offset: 3px; }
.game-card img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .28s ease, filter .28s ease; }
.game-card:hover img, .game-card:focus-visible img { transform: scale(1.055); filter: saturate(.92) brightness(.72); }
.game-card-copy { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; min-width: 0; padding: 14px; padding-right: 48px; }
.game-card-copy strong { display: block; overflow: hidden; color: #fff; font-size: 14px; line-height: 1.25; text-overflow: ellipsis; text-shadow: 0 2px 8px #000; white-space: nowrap; }
.game-card-copy small { display: block; margin-top: 4px; overflow: hidden; color: #c7cad3; font-size: 12px; font-weight: 650; text-overflow: ellipsis; text-transform: uppercase; letter-spacing: .055em; white-space: nowrap; }
.game-card-play { position: absolute; right: 12px; bottom: 12px; z-index: 3; width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.22); border-radius: 50%; color: #fff; background: color-mix(in srgb, var(--gp-accent) 80%, #151722); box-shadow: 0 7px 20px rgba(0,0,0,.38); opacity: 0; transform: translateY(5px) scale(.92); transition: opacity .17s ease, transform .17s ease; font-size: 11px; }
.game-card:hover .game-card-play, .game-card:focus-visible .game-card-play { opacity: 1; transform: none; }
.game-fallback { position: absolute; inset: 0; display: grid; place-items: center; color: var(--gp-muted); background: linear-gradient(145deg, color-mix(in srgb, var(--gp-accent) 17%, var(--gp-panel-strong)), var(--gp-panel-strong)); font-size: 42px; font-weight: 950; }
.game-loading { grid-column: 1 / -1; min-height: 240px; display: grid; place-items: center; align-content: center; gap: 12px; color: var(--gp-muted); font-size: 14px; }
.game-loading i, .player-loading i { width: 34px; height: 34px; border: 3px solid color-mix(in srgb, var(--gp-accent) 18%, transparent); border-top-color: var(--gp-accent); border-radius: 50%; animation: spin .8s linear infinite; }
.portal-empty { padding: 60px 20px; border: 1px dashed var(--gp-border); border-radius: 18px; color: var(--gp-muted); background: var(--gp-panel); text-align: center; }
.load-more { min-height: 44px; display: block; margin: 24px auto 0; padding: 0 22px; border: 1px solid var(--gp-border); border-radius: 12px; color: var(--gp-text); background: var(--gp-panel); font-weight: 800; cursor: pointer; }
.load-more:hover { border-color: var(--gp-border-hot); background: var(--gp-panel-strong); }

.game-player { position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column; background: #05060a; }
.game-player[hidden] { display: none; }
.player-bar { min-height: 66px; display: flex; align-items: center; gap: 11px; padding: 9px 14px; border-bottom: 1px solid rgba(255,255,255,.1); background: #0e1016; color: #f6f7fb; box-shadow: 0 10px 28px rgba(0,0,0,.3); }
.player-close, .player-tool { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; padding: 0 14px; border: 1px solid rgba(255,255,255,.13); border-radius: 11px; color: #f6f7fb; background: rgba(255,255,255,.045); text-decoration: none; font-size: 13px; font-weight: 800; cursor: pointer; }
.player-close { width: 42px; padding: 0; font-size: 21px; }
.player-close:hover, .player-tool:hover { border-color: rgba(255,255,255,.28); background: rgba(255,255,255,.09); }
.player-name { min-width: 0; margin-right: auto; }
.player-name small, .player-name strong { display: block; }
.player-name small { color: #8f95a5; font-size: 11px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.player-name strong { max-width: 42vw; margin-top: 3px; overflow: hidden; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.player-earning { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid rgba(71,215,131,.16); border-radius: 10px; color: #bcf7d2; background: rgba(71,215,131,.065); font-size: 12px; font-weight: 800; }
.player-earning i { width: 7px; height: 7px; border-radius: 50%; background: #47d783; box-shadow: 0 0 12px #47d783; }
.player-earning.is-paused { color: #b3b6c0; border-color: rgba(255,255,255,.09); background: rgba(255,255,255,.035); }
.player-earning.is-paused i { background: #777d8a; box-shadow: none; }
.player-stage { position: relative; min-height: 0; flex: 1; background: #020306; }
.player-stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #05060a; }
.player-loading { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; align-content: center; gap: 12px; color: #b8bbc5; background: #090a10; font-size: 14px; transition: opacity .2s, visibility .2s; }
.player-loading.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.coin-toast { position: fixed; left: 50%; bottom: 24px; z-index: 1500; padding: 12px 17px; border: 1px solid color-mix(in srgb, #47d783 45%, transparent); border-radius: 999px; color: #d8ffe6; background: #102219ef; box-shadow: 0 14px 36px rgba(0,0,0,.55); opacity: 0; transform: translate(-50%, 12px); pointer-events: none; font-size: 14px; font-weight: 850; transition: opacity .2s ease, transform .2s ease; }
.coin-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

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

@media (max-width: 1120px) {
  .portal-bar { grid-template-columns: 180px minmax(240px, 1fr) auto; padding-inline: 18px; }
  .portal-main { width: min(100% - 34px, 1080px); }
  .game-grid, .game-grid-recent { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .featured-grid { height: 390px; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: 1.5fr 1fr 1fr; }
  .featured-grid .game-card, .featured-grid .game-card-hero { grid-column: span 1; grid-row: span 1; }
  .featured-grid .game-card-hero { grid-column: span 2; }
  .featured-grid .game-card:nth-child(4), .featured-grid .game-card:nth-child(5) { display: none; }
  .game-grid, .game-grid-recent { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .portal-bar { grid-template-columns: auto minmax(210px, 1fr) auto; gap: 12px; }
  .brand-name { display: none; }
  .portal-heading { align-items: flex-end; }
  .reward-card { max-width: 350px; }
}

@media (max-width: 660px) {
  body.game-portal-page::after { background: color-mix(in srgb, var(--gp-bg) 87%, transparent); }
  .portal-bar { min-height: auto; grid-template-columns: 1fr auto; gap: 9px; padding: 8px 12px 10px; }
  .portal-brand { grid-column: 1; }
  .brand-name { display: block; }
  .portal-wallet { grid-column: 2; }
  .portal-wallet small { display: none; }
  .portal-search { grid-column: 1 / -1; grid-row: 2; height: 43px; }
  .portal-main { width: calc(100% - 24px); padding-top: 18px; }
  .portal-heading { display: grid; gap: 15px; margin-bottom: 20px; }
  .portal-heading h1 { font-size: 42px; }
  .reward-card { width: 100%; max-width: none; }
  .featured-grid { height: auto; display: flex; gap: 9px; margin-right: -12px; overflow-x: auto; padding: 0 12px 9px 0; scroll-snap-type: x proximity; }
  .featured-grid .game-card, .featured-grid .game-card-hero, .featured-grid .game-card:nth-child(4), .featured-grid .game-card:nth-child(5) { width: 54vw; min-width: 54vw; height: auto; display: block; aspect-ratio: 4 / 3; scroll-snap-align: start; }
  .featured-grid .game-card-hero { width: 78vw; min-width: 78vw; }
  .featured-grid .game-card-hero .game-card-copy { padding: 15px 50px 15px 15px; }
  .featured-grid .game-card-hero .game-card-copy strong { font-size: 18px; }
  .featured-grid .game-card-hero .game-card-play { right: 12px; bottom: 12px; width: 36px; height: 36px; }
  .browse-bar { display: block; margin-bottom: 17px; }
  .browse-bar > strong { display: block; margin-bottom: 8px; }
  .category-strip { margin-right: -12px; }
  .game-grid, .game-grid-recent { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
  .game-card { border-radius: 14px; }
  .game-card-copy { padding: 11px; padding-right: 11px; }
  .game-card-copy strong { font-size: 13px; }
  .game-card-copy small { font-size: 11px; }
  .game-card-play { display: none; }
  .player-bar { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; gap: 7px; padding: 7px; }
  .player-name strong { max-width: none; }
  .player-earning { grid-column: 2; width: max-content; padding: 3px 0; border: 0; background: transparent; }
  .player-tool { grid-row: 1 / 3; }
  .player-tool#player-new-tab { display: none; }
  .player-tool#player-fullscreen { grid-column: 3; }
  .game-player { height: 100dvh; }
}

@media (max-width: 440px) {
  .brand-name { font-size: 16px; }
  .portal-search kbd { display: none; }
  .portal-wallet { padding-right: 9px; }
  .portal-wallet img { width: 27px; height: 27px; }
  .game-grid, .game-grid-recent { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .category-chip { min-height: 34px; padding-inline: 12px; }
}

@media (min-width: 761px) and (max-height: 780px) {
  .portal-bar { min-height: 60px; padding-block: 7px; }
  .brand-mark { width: 39px; height: 39px; }
  .portal-main { padding-top: 18px; }
  .portal-heading { margin-bottom: 15px; }
  .portal-heading h1 { font-size: 43px; }
  .featured-grid { height: 250px; }
  .featured-section { margin-bottom: 18px; }
  .browse-bar { margin-bottom: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; transition-duration: .001ms !important; }
  .game-card:hover, .game-card:focus-visible, .portal-wallet:hover, .category-chip:hover { transform: none; }
}
