/* ==================================================================
   H5GamesNest – shared UI (header + nav + footer + page cards + grids)
   Class names are prefixed mg- so they never collide with the inline
   styles the mirrored game pages already ship with.
   Design reference: 1.png (header) / 2.png (footer) / 5.png (ad)
                     6-9.png (company / contact / privacy / terms)
================================================================== */

:root{
  --mg-grad:linear-gradient(135deg,#25c9d6 0%,#4a7dff 48%,#d6249f 100%);
  --mg-grad-soft:linear-gradient(90deg,#eaf3ff 0%,#ffffff 42%,#ffffff 58%,#fdeef7 100%);
  --mg-ink:#2b2f45;
  --mg-muted:#6b7280;
}

/* reset so width:100% + padding never overflows the viewport (fixes mobile
   horizontal-scroll on the shared pages, e.g. contact at <=425px) */
*{box-sizing:border-box}
html,body{margin:0}

/* ---------------------------------------------------------------- HEADER */
.mg-header{
  position:static;      /* not sticky — header scrolls away with the page */
  width:100%;
  background:var(--mg-grad-soft);
  border-bottom:1px solid #eceffa;
  box-shadow:0 2px 14px rgba(30,50,100,.06);
}
.mg-header-inner{
  max-width:1320px;
  margin:0 auto;
  display:flex;
  align-items:center;
  gap:22px;
  padding:12px 26px;
}

/* --- logo --- */
.mg-logo{
  display:flex;
  align-items:center;
  gap:10px;
  text-decoration:none;
  flex-shrink:0;
}
.mg-logo-badge{
  width:42px;
  height:42px;
  border-radius:13px;
  background:linear-gradient(135deg,#6d3bf5 0%,#a855f7 100%);
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:22px;
  line-height:1;
  box-shadow:0 5px 12px rgba(109,59,245,.35);
  transition:transform .2s ease;
}
.mg-logo:hover .mg-logo-badge{transform:rotate(-8deg) scale(1.08)}
.mg-logo-text{
  font-family:'Baloo 2','Comic Sans MS','Segoe UI',sans-serif;
  font-size:25px;
  font-weight:800;
  letter-spacing:.3px;
  white-space:nowrap;
  text-shadow:0 1px 0 rgba(255,255,255,.85),0 2px 3px rgba(30,50,100,.14);
}
.mg-logo-text b{font-weight:800}
.mg-logo-text b:nth-child(1){color:#ef4444}
.mg-logo-text b:nth-child(2){color:#f97316}
.mg-logo-text b:nth-child(3){color:#eab308}
.mg-logo-text b:nth-child(4){color:#22c55e}
.mg-logo-text b:nth-child(5){color:#10b981}
.mg-logo-text b:nth-child(6){color:#06b6d4}
.mg-logo-text b:nth-child(7){color:#3b82f6}
.mg-logo-text b:nth-child(8){color:#6366f1}
.mg-logo-text b:nth-child(9){color:#8b5cf6}
.mg-logo-text b:nth-child(10){color:#ec4899}
.mg-logo-text b:nth-child(11){color:#f43f5e}

/* --- primary nav (HOME / NEW / HOT / CATEGORIES) --- */
.mg-nav{
  display:flex;
  align-items:center;
  gap:26px;
  margin:0 auto 0 8px;
  flex-shrink:0;
}
.mg-nav a{
  display:inline-flex;
  align-items:center;
  gap:8px;
  text-decoration:none;
  color:#3b4256;
  font-weight:800;
  font-size:14px;
  letter-spacing:.6px;
  text-transform:uppercase;
  padding:6px 4px;
  border-bottom:2.5px solid transparent;
  transition:color .15s ease,border-color .15s ease;
}
.mg-nav a svg{width:20px;height:20px;stroke:currentColor;fill:none;stroke-width:2}
.mg-nav a:hover,
.mg-nav a.active{color:#6d3bf5;border-bottom-color:#d6249f}

/* --- search pill --- */
.mg-search{
  flex:1 1 auto;
  max-width:430px;
  margin:0;
  margin-left:auto;
  display:flex;
  align-items:center;
  gap:8px;
  background:#f4f6fc;
  border:2px solid #e7ebf7;
  border-radius:999px;
  padding:5px 6px 5px 20px;
  transition:background .2s ease,border-color .2s ease,box-shadow .2s ease;
}
.mg-search:focus-within{
  background:#fff;
  border-color:#4a7dff;
  box-shadow:0 0 0 4px rgba(74,125,255,.15);
}
.mg-search-icon{display:flex;align-items:center;flex-shrink:0;color:#9aa3b5}
.mg-search-icon svg{width:18px;height:18px}
.mg-search-input{
  flex:1 1 auto;
  min-width:0;
  border:none;
  outline:none;
  background:transparent;
  padding:9px 4px;
  font-size:15px;
  color:#333;
  font-family:'Segoe UI',Arial,sans-serif;
}
.mg-search-input::placeholder{color:#9aa3b5}
.mg-search-btn{
  flex-shrink:0;
  border:none;
  outline:none;
  cursor:pointer;
  border-radius:999px;
  width:42px;
  height:42px;
  display:flex;
  align-items:center;
  justify-content:center;
  color:#fff;
  background:var(--mg-grad);
  box-shadow:0 3px 8px rgba(109,59,245,.3);
  transition:filter .15s ease,transform .15s ease;
}
.mg-search-btn svg{width:19px;height:19px;stroke:#fff;fill:none;stroke-width:2.4}
.mg-search-btn:hover{filter:brightness(1.08)}
.mg-search-btn:active{transform:scale(.94)}

/* collapsible wrapper for nav + search.
   Desktop: display:contents makes it "transparent", so .mg-nav and .mg-search
   stay direct flex children of .mg-header-inner (desktop layout unchanged).
   Mobile: it becomes the drop-down drawer that the burger toggles. */
.mg-collapse{display:contents}

/* mobile menu toggle (hidden on desktop) */
.mg-burger{display:none;background:none;border:none;cursor:pointer;padding:6px;color:#3b4256}
.mg-burger svg{width:26px;height:26px;stroke:currentColor;fill:none;stroke-width:2.2}

@media (max-width:980px){
  .mg-header-inner{flex-wrap:wrap;gap:12px;padding:10px 16px}
  .mg-burger{display:inline-flex;order:3;margin-left:auto}
  /* the whole drawer (search + nav) collapses under the burger */
  .mg-collapse{
    display:flex;flex-direction:column;gap:12px;
    order:4;flex-basis:100%;width:100%;margin:0;
    max-height:0;overflow:hidden;transition:max-height .28s ease;
  }
  .mg-collapse.open{max-height:440px}
  .mg-search{order:-1;flex:0 0 auto;max-width:none;margin:0}
  .mg-nav{
    flex:0 0 auto;
    flex-direction:column;align-items:stretch;gap:2px;margin:0;
  }
  .mg-nav a{padding:12px 6px;border-bottom:1px solid #eef1fa}
  .mg-nav a.active{border-bottom-color:#eef1fa;color:#6d3bf5}
}
@media (max-width:600px){
  .mg-logo-text{font-size:19px}
  .mg-logo-badge{width:36px;height:36px;font-size:19px;border-radius:11px}
}

/* ---------------------------------------------------------------- FOOTER */
.mg-footer{
  width:100%;
  padding:34px 16px 40px;
  background:#fff;
  border-top:2px solid transparent;
  border-image:linear-gradient(90deg,#8ecbff 0%,#ffffff 30%,#ffffff 70%,#ffb3d9 100%) 1;
}
.mg-footer-links{
  display:flex;
  flex-wrap:wrap;
  justify-content:center;
  gap:12px 34px;
  margin-bottom:20px;
}
.mg-footer-links a{
  text-decoration:none;
  color:#3b4256;
  font-weight:800;
  font-size:13px;
  letter-spacing:1.2px;
  text-transform:uppercase;
  transition:color .15s ease;
}
.mg-footer-links a:hover{color:#d6249f}
.mg-footer-logo{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:9px;
  text-decoration:none;
}
.mg-footer-logo .mg-logo-badge{width:34px;height:34px;font-size:18px;border-radius:11px}
.mg-footer-logo .mg-logo-text{font-size:21px}
.mg-footer-copy{text-align:center;color:#9aa3b5;font-size:12.5px;margin-top:14px}

/* ---------------------------------------------------------------- PAGE SHELL
   Soft gradient background used by company / contact / privacy / terms
   and the new / hot / category / list grid pages.                        */
.mg-page{
  min-height:100vh;
  background:
    radial-gradient(circle at 0% 0%,rgba(140,200,255,.35) 0,rgba(140,200,255,0) 30%),
    radial-gradient(circle at 100% 20%,rgba(255,170,220,.35) 0,rgba(255,170,220,0) 32%),
    linear-gradient(180deg,#f3f7ff 0%,#fbf7fb 100%);
  padding:34px 20px 60px;
}
.mg-container{max-width:1320px;margin:0 auto}

/* white rounded content card (6-9.png) */
.mg-card{
  position:relative;
  max-width:1240px;
  margin:0 auto;
  background:#fff;
  border-radius:20px;
  padding:38px 44px 44px;
  box-shadow:0 24px 60px rgba(60,80,140,.12);
  overflow:hidden;
}
.mg-card::before{      /* little gradient tab, top-left */
  content:"";
  position:absolute;
  top:0;left:34px;
  width:78px;height:5px;
  border-radius:0 0 6px 6px;
  background:var(--mg-grad);
}
.mg-card-title{
  display:flex;
  align-items:center;
  gap:14px;
  font-size:26px;
  font-weight:800;
  letter-spacing:.5px;
  text-transform:uppercase;
  color:#1f2333;
  margin-bottom:10px;
}
.mg-card-title::before{
  content:"";
  width:6px;height:26px;border-radius:4px;
  background:var(--mg-grad);
}
.mg-card hr,.mg-card-rule{
  border:none;height:1px;background:#eceff6;margin:0 0 22px;
}
.mg-card p{
  color:#4a5163;
  font-size:16px;
  line-height:1.9;
  margin:0 0 18px;
}
.mg-card h3{
  color:#2b2f45;
  font-size:17px;
  font-weight:700;
  margin:22px 0 8px;
}
.mg-card a.inline{color:#4a7dff}

@media (max-width:600px){
  .mg-card{padding:26px 20px 30px;border-radius:16px}
  .mg-card-title{font-size:21px}
  .mg-card p{font-size:15px}
}

/* ---------------------------------------------------------------- CONTACT FORM (7.png) */
.mg-form{display:flex;flex-direction:column;gap:18px;max-width:100%}
.mg-form input,
.mg-form textarea{
  width:100%;
  background:#f5f8ff;
  border:1.5px solid #e6ecfa;
  border-radius:12px;
  padding:16px 18px;
  font-size:15px;
  color:#2b2f45;
  font-family:'Segoe UI',Arial,sans-serif;
  outline:none;
  transition:border-color .15s ease,box-shadow .15s ease,background .15s ease;
}
.mg-form input::placeholder,
.mg-form textarea::placeholder{color:#9aa3b5}
.mg-form input:focus,
.mg-form textarea:focus{
  background:#fff;border-color:#4a7dff;box-shadow:0 0 0 4px rgba(74,125,255,.12);
}
.mg-form textarea{min-height:210px;resize:vertical;line-height:1.6}
.mg-submit{
  align-self:flex-start;
  border:none;cursor:pointer;
  color:#fff;font-weight:800;letter-spacing:1.5px;text-transform:uppercase;
  font-size:14px;
  padding:15px 46px;
  border-radius:12px;
  background:var(--mg-grad);
  box-shadow:0 10px 22px rgba(109,59,245,.28);
  transition:filter .15s ease,transform .15s ease;
}
.mg-submit:hover{filter:brightness(1.07)}
.mg-submit:active{transform:scale(.97)}
.mg-form-note{color:#22a06b;font-size:14px;font-weight:600;margin-top:6px}

/* ---------------------------------------------------------------- SECTION HEAD (grids) */
.mg-section-head{
  max-width:1240px;margin:0 auto 20px;
  display:flex;align-items:center;gap:14px;
}
.mg-section-head h1{
  display:flex;align-items:center;gap:14px;
  font-size:26px;font-weight:800;letter-spacing:.5px;text-transform:uppercase;color:#1f2333;
}
.mg-section-head h1::before{
  content:"";width:6px;height:26px;border-radius:4px;background:var(--mg-grad);
}
.mg-section-sub{max-width:1240px;margin:-8px auto 24px;color:#6b7280;font-size:14.5px}

/* ---------------------------------------------------------------- GAME TILE GRID (new / hot / list / search) */
.mg-grid{
  max-width:1240px;margin:0 auto;
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(122px,1fr));
  gap:22px 16px;
}
.mg-grid a{display:block;text-decoration:none;transition:transform .15s ease}
.mg-grid a:hover{transform:translateY(-5px) scale(1.03)}
.mg-tile-img{
  width:100%;aspect-ratio:1/1;border-radius:20px;overflow:hidden;
  background:#e6ecfa;box-shadow:0 6px 16px rgba(30,50,100,.16);
}
.mg-tile-img img{width:100%;height:100%;object-fit:cover;display:block}
.mg-tile-name{
  margin-top:8px;font-size:13px;line-height:1.3;color:#3b4256;text-align:center;font-weight:600;
  overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;
}

/* ---------------------------------------------------------------- CATEGORY TILES (category.html) */
.mg-cats{
  max-width:1240px;margin:0 auto;
  display:grid;grid-template-columns:repeat(auto-fill,minmax(210px,1fr));gap:20px;
}
.mg-cat{
  display:flex;align-items:center;gap:18px;
  padding:28px 24px;border-radius:18px;text-decoration:none;
  color:#fff;position:relative;overflow:hidden;
  box-shadow:0 12px 26px rgba(40,60,120,.16);
  transition:transform .15s ease,box-shadow .15s ease;
}
.mg-cat:hover{transform:translateY(-4px);box-shadow:0 18px 34px rgba(40,60,120,.24)}
.mg-cat-ico{
  width:70px;height:70px;flex-shrink:0;border-radius:18px;
  background:rgba(255,255,255,.22);
  display:flex;align-items:center;justify-content:center;font-size:40px;
}
.mg-cat-txt b{display:block;font-size:21px;font-weight:800;letter-spacing:.3px}
.mg-cat-txt span{font-size:13px;opacity:.9}

.mg-empty{max-width:1240px;margin:40px auto;text-align:center;color:#7d879c;font-size:18px}
.mg-empty .emoji{font-size:46px;display:block;margin-bottom:12px}

/* ---------------------------------------------------------------- ADVERTISEMENT (5.png) — single-game page only */
.mg-ad{width:100%;margin:34px 0}
.mg-ad-label{
  display:flex;align-items:center;justify-content:center;gap:14px;
  color:#9aa6bd;font-size:11px;font-weight:700;letter-spacing:3px;text-transform:uppercase;
  margin-bottom:12px;
}
.mg-ad-label::before,
.mg-ad-label::after{content:"";height:1px;width:34px;background:#c9d2e6}
.mg-ad-box{
  width:100%;min-height:170px;
  border-radius:14px;
  background:linear-gradient(180deg,#f6f8fd 0%,#eef2fa 100%);
  border:1px solid #eceff7;
  display:flex;align-items:center;justify-content:center;
  overflow:hidden;
}
.mg-ad-box .adsbygoogle{width:100%;display:block}
/* top-of-page ad banner (new / hot / category / list) — aligned to the content column */
.mg-ad--top{margin:0 auto 30px;max-width:1240px}
.mg-ad-ph{font-family:Arial,Helvetica,sans-serif;color:#8a94ab;font-size:22px}
.mg-ad-ph b{color:#5b6b8c}

/* Google Ad Manager (GPT) ad block — <div class="ad"> (game pages) */
.ad{width:100%;max-width:1240px;margin:16px auto;box-sizing:border-box;padding:0 12px;
  text-align:center;font-family:Arial,Helvetica,sans-serif;}
.ad>p{margin:0 0 8px;font-size:11px;font-weight:700;letter-spacing:3px;color:#9aa6bd;text-transform:uppercase;}
.ad .h5-gpt{margin:0 auto;min-height:100px;display:flex;align-items:center;justify-content:center;
  width:100%;}

@media (max-width:600px){
  .mg-grid{grid-template-columns:repeat(auto-fill,minmax(96px,1fr));gap:16px 10px}
  .mg-tile-img{border-radius:16px}
  .mg-section-head h1{font-size:21px}
  .mg-page{padding:22px 12px 44px}
}

/* ---- small phones (<=425px): tidy the card/contact form ---- */
@media (max-width:425px){
  .mg-page{padding:16px 10px 36px}
  .mg-card{padding:22px 16px 26px;border-radius:14px}
  .mg-card-title{font-size:18px;gap:10px}
  .mg-card p{font-size:14.5px}
  .mg-form{gap:14px}
  .mg-form input,.mg-form textarea{padding:13px 14px;font-size:14px;border-radius:10px}
  .mg-form textarea{min-height:150px}
  .mg-submit{width:100%;text-align:center;padding:15px 20px;letter-spacing:1px}
  .mg-footer{padding:26px 14px 32px}
  .mg-footer-links{gap:10px 20px}
}
