/* v2.9: moderation fixes. Preserve the original theme and allow content to fit
   the embedded game field, not the surrounding browser window. */
* {
  scrollbar-width: thin;
  scrollbar-color: #c99039 #151a23;
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #151a23; border-radius: 8px; }
::-webkit-scrollbar-thumb { background: #c99039; border: 2px solid #151a23; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #ffb23f; }
::-webkit-scrollbar-corner { background: #151a23; }

/* Main menu must fit on one screen with NO scrolling (moderation requirement). */
#screen-main { overflow: hidden; }
.topbar { flex: 0 0 auto; min-width: 0; }
.mm-body { flex: 1 1 auto; min-height: 0; min-width: 0; }
.mm-left { justify-content: flex-start; min-width: 0; }
.mm-left > * { flex-shrink: 0; }
.play-card { overflow: visible; }
.pc-actions { position: relative; z-index: 1; }
.mm-right { min-width: 0; min-height: 280px; }
.pc-text { min-width: 0; }
.pc-text > b { display: block; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Progressive compaction so the menu always fits the actual iframe height.
   Natural content height ~718px; each step removes padding/gaps (never information). */
@media (max-height: 730px) {
  .topbar { padding: 10px 24px; }
  .mm-body { padding: 6px 24px 12px; }
  .mm-left { gap: 10px; }
}
@media (max-height: 680px) {
  .topbar { padding: 8px 24px; }
  .mm-body { padding: 4px 24px 8px; }
  .play-card { padding: 16px; }
  .mm-tiles { gap: 8px; }
  .mm-tile { padding: 10px; }
  .mm-tip { padding: 8px 12px; font-size: 12px; }
}
@media (max-height: 650px) {
  .topbar { padding: 10px 16px; }
  .mm-body { padding: 4px 16px 16px; gap: 16px; }
  .play-card { padding: 16px; }
  .pc-mode { font-size: 26px; margin-top: 8px; }
  .pc-actions { margin-top: 12px; }
  .pc-actions .btn { padding: 10px 16px; }
  .mm-tile { padding: 10px; }
  .mm-tile .tile-ico { width: 30px; height: 30px; margin-bottom: 3px; }
  #case-open-panel { gap: 8px; padding: 12px; }
  .case-open-img { height: 54px; }
  #case-open-title { font-size: 20px; }
  .res-icon { height: 90px; }
  .case-result { padding: 10px; }
  .case-actions { bottom: -12px; padding: 8px 0; }
}
@media (max-height: 560px) {
  /* very short landscape windows: keep everything visible, drop to minimum chrome */
  .topbar { padding: 6px 12px; }
  .topbar .logo { font-size: 20px; }
  .mm-body { padding: 2px 12px 6px; }
  .mm-left { gap: 6px; }
  .play-card { padding: 10px 12px; }
  .pc-mode { font-size: 20px; margin-top: 4px; }
  .pc-text { font-size: 12px; }
  .pc-actions { margin-top: 6px; }
  .pc-actions .btn { padding: 8px 12px; font-size: 13px; }
  .mm-tiles { gap: 6px; }
  .mm-tile { padding: 6px; border-radius: 10px; }
  .mm-tile .tile-ico { width: 22px; height: 22px; margin-bottom: 2px; }
  .mm-tile b { font-size: 11px; }
  .mm-tile .tile-sub { font-size: 10px; }
  .mm-tip { display: none; }
}
.profile-name {
  display: block; width: 100%; padding: 10px 0; font-size: 22px;
  font-weight: 600; overflow-wrap: anywhere; user-select: text;
}
.pf-main { min-width: 0; }

/* A single scroll owner per content page, based on the actual iframe height.
   v3.4: the page must GROW with its content (align-self: flex-start instead of the
   flex stretch). While stretched, .page was only as tall as the viewport, so the
   sticky .page-head (whose containing block is .page) detached near the bottom of
   long menus; content then scrolled into the banner strip, the overlap check
   cleared the banner and it stayed cleared for the 31s SDK cooldown
   (CrazyGames moderation: "Banner clears on scroll"). min-height: 100% keeps the
   previous look when the content fits on one screen. */
.screen:not(#screen-main):not(#case-open):not(#screen-pause) > .page {
  align-self: flex-start;
  min-height: 100%;
  max-height: none; height: auto; overflow: visible; flex-shrink: 0;
}
#case-open { padding: 12px; overflow: hidden; }
#case-open-panel {
  width: min(860px, 100%); max-width: 100%;
  max-height: calc(100% - 8px); min-height: 0;
  overflow-x: hidden; overflow-y: auto; padding: 20px;
}
#case-open-panel > * { flex-shrink: 0; }
.case-actions {
  position: sticky; bottom: -20px; z-index: 3;
  padding: 12px 0; margin-top: auto; background: #10141c;
  border-top: 1px solid rgba(255,255,255,.12);
}
.case-actions .btn { max-width: 100%; white-space: normal; }
.case-result { overflow: hidden; }
.case-open-panel.revealed .case-reel-window { display: none; }
.dm-box, .pause-box, .search-card { max-height: calc(100% - 24px); overflow-y: auto; }

@media (max-width: 900px) {
  .mm-body { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .mm-right { display: none; }
  .topbar-right { gap: 6px; }
}
@media (max-width: 480px) {
  .topbar-right { flex-wrap: wrap; gap: 4px; }
  .quick-btns { gap: 4px; }
  .topbar-right .reward-chip { min-width: 36px; padding: 5px; }
  .topbar-right .profile-chip { padding: 4px; }
  .topbar-right .gold-chip { padding: 8px; font-size: 14px; }
  .mm-body { padding-left: 12px; padding-right: 12px; }
  .mm-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pc-actions .btn { flex: 1 1 auto; }
  .case-actions { gap: 6px; }
  .case-actions .btn { padding: 10px; font-size: 13px; }
  .pf-card { padding: 14px; gap: 14px; }
}

/* ===================== v3.2 moderation fixes ===================== */
/* One CrazyGames banner (320x50) at the top centre of the game field. It never takes
   clicks unless a creative is inside, and every menu reserves an opaque header strip
   for it, so it never covers game UI (an overlap check in JS hides it as a safety net). */
#top-ad {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%);
  width: 320px; height: 50px; z-index: 160; pointer-events: none;
}
#top-ad.hidden { display: none; }
#cg-banner-top { width: 320px; height: 50px; overflow: hidden; pointer-events: none; }
#cg-banner-top * { pointer-events: auto; }

/* Main menu (wide screens with the banner): the top bar keeps only the logo; the
   sound / language / daily reward / free case / profile / gold buttons move to the
   bottom left of the menu. */
.mm-bottom { display: none; }
body.ad-top #screen-main .topbar { min-height: 74px; padding-top: 12px; padding-bottom: 12px; }
body.ad-top #screen-main .mm-body { grid-template-rows: minmax(0, 1fr) auto; row-gap: 12px; }
body.ad-top #screen-main .mm-bottom { display: flex; grid-column: 1 / -1; min-width: 0; }
body.ad-top .mm-bottom .topbar-right { display: flex; flex-wrap: wrap; justify-content: flex-start; align-items: center; gap: 8px; width: auto; }
body.ad-top .mm-bottom .quick-btns { margin-right: 0; }

/* Content pages: the header row is a sticky opaque bar that also holds the banner, so
   scrolled content never passes under the banner. */
body.ad-top :is(#screen-play, #screen-cases, #screen-missions, #screen-inventory, #screen-profile, #screen-settings) > .page { padding-top: 0; }
body.ad-top :is(#screen-play, #screen-cases, #screen-missions, #screen-inventory, #screen-profile, #screen-settings) > .page > .page-head {
  position: sticky; top: 0; z-index: 6; flex-shrink: 0;
  min-height: 74px; padding: 12px 0; margin: 0;
  background: #0b0e14;
  box-shadow: 0 0 0 100vmax #0b0e14, 0 1px 0 100vmax rgba(255,255,255,.05);
  clip-path: inset(0 -100vmax -1px);
}
/* Cases / Inventory: the subtitle notes sit under the title, keeping the header centre free */
.head-titles { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.head-notes { display: flex; gap: 10px; flex-wrap: wrap; }
.head-space { flex: 1 1 auto; min-width: 0; }
.page-head .head-space + .gold-chip { margin-left: 0; }

/* pop-ups and toasts start below the banner strip */
body.ad-top #daily-modal { padding-top: 78px; }
body.ad-top #case-open { padding-top: 74px; }
body.ad-top #case-open-panel { max-height: calc(100% - 4px); }
body.ad-top #toast { top: 74px; }

/* Smaller screens (no right-hand showcase): the menu tiles grow to fill the free space
   instead of leaving the lower half of the menu empty. */
@media (max-width: 900px) {
  #screen-main .mm-left { min-height: 0; }
  #screen-main .mm-tiles { flex: 1 1 auto; flex-shrink: 1; min-height: 0; max-height: 380px; grid-auto-rows: minmax(0, 1fr); }
  #screen-main .mm-tile { justify-content: center; align-items: center; text-align: center; padding: 8px 6px; min-height: 0; }
  #screen-main .mm-tile .tile-ico { width: clamp(28px, 14vh, 72px); height: clamp(28px, 14vh, 72px); margin: 0 0 4px; }
  #screen-main .mm-tile b { font-size: clamp(12px, 2.6vh, 16px); }
  #screen-main .mm-tile span { display: block; }
}
@media (max-width: 900px) and (max-height: 330px) {
  #screen-main .mm-tile span { display: none; }
}
/* header title column never reaches the centred banner (it wraps instead) */
.head-titles { align-items: flex-start; }
body.ad-top .page-head .head-titles { max-width: calc(50% - 230px); }
body.ad-top .page-head .head-note { font-size: 13px; line-height: 1.3; }

/* ===================== v3.3: UI scales with the screen ===================== */
/* In fullscreen / on large monitors the menus were rendered at their fixed 1280px design
   size and left a lot of empty space. --ui-zoom (set in platform.js from the game-field size,
   >= 1, base 1280x740) scales every menu, pop-up and toast proportionally. The in-match HUD
   and the 3D game canvas are not affected. */
.screen, #daily-modal, #ad-demo, #toast { zoom: var(--ui-zoom, 1); }

/* Inventory uses one scroll container. Captions and sticker controls are in flow,
   never on top of the preview, and cannot cover the item cards. */
#screen-inventory .inv-layout { grid-template-columns: minmax(220px, 360px) minmax(0, 1fr); }
#screen-inventory .inv-layout > * { min-width: 0; }
#screen-inventory .inv-layout:has(.inv-preview.hidden) { grid-template-columns: minmax(0, 1fr); }
#screen-inventory .inv-preview { width: 100%; max-width: none; }
#screen-inventory .inv-preview::after { display: none; }
#screen-inventory .preview-host {
  width: 100%; height: clamp(104px, 26vh, 180px); aspect-ratio: auto;
  display: grid; place-items: center; overflow: hidden; pointer-events: none;
}
img.preview-flat { display: block; width: 85%; height: 94%; object-fit: contain; pointer-events: none; }
img.preview-flat.portrait { width: auto; max-width: 80%; }
#screen-inventory .preview-canvas, #screen-inventory .showcase-canvas { width: 100%; height: 100%; pointer-events: none; }
#screen-inventory .preview-canvas { width: min(100%, 360px); height: auto; max-height: 100%; object-fit: contain; }
#screen-inventory .preview-caption { position: static; padding: 8px 12px; overflow-wrap: anywhere; }
#screen-inventory .inv-stickers { position: static; display: flex; flex-wrap: wrap; padding: 0 12px 10px; }
#screen-inventory .inv-stickers:empty { display: none; }
#screen-inventory .st-pick { position: static; flex: 1 0 100%; min-width: 0; max-width: none; width: 100%; }
#screen-inventory .inventory-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); }
#screen-inventory .i-actions { flex-wrap: wrap; margin-top: auto; }
#screen-inventory .i-actions .btn { white-space: normal; min-width: 0; flex: 1 1 auto; }
.inv-pages { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; padding: 10px 0; }
.case-odds summary { padding: 6px 0; color: #d6dce8; font-size: 12px; cursor: pointer; }
.case-card .c-odds { display: grid; gap: 4px; padding: 3px 0 7px; }
.c-odds > span { display: grid; align-items: center; grid-template-columns: 7px minmax(0, 1fr) auto; gap: 6px; }
.c-odds i { width: 6px; height: 6px; border-radius: 50%; background: var(--dot); }
.c-odds b { color: #eef1f5; font-variant-numeric: tabular-nums; }
.case-card > button { margin-top: auto; }
.map-thumb { position: relative; }
.map-difficulty { position: absolute; left: 8px; bottom: 8px; border-radius: 5px; padding: 4px 7px; font-size: 11px; font-weight: 700; color: #fff0c9; background: #332917; }
.map-difficulty.easy { color: #bbffda; background: #133b2c; }
.map-difficulty.hard { color: #ffd9d6; background: #532625; }
@media (max-width: 980px), (pointer: coarse) {
  #screen-inventory .inv-layout { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  #screen-inventory .inv-layout .inv-preview { position: relative; }
  #screen-inventory .preview-host { height: clamp(74px, 17vh, 116px); }
  #screen-inventory .inv-filter { align-self: stretch; }
  #screen-inventory .inv-item:hover { transform: none; }
  #screen-inventory :is(.seg-btn, .i-actions .btn, .inv-pages .btn, .st-slot, .st-opt, .back-btn) { min-height: 44px; touch-action: manipulation; }
  #screen-inventory .i-actions .btn { padding: 6px; }
  #screen-inventory .inv-item .i-icon { height: 54px; }
}
