/* Mythical Motions Games: one dark theme, Baloo 2 headings, Nunito body. */
:root {
  color-scheme: dark;
  --bg: #0d0f1f;
  --bg2: #141832;
  --card: #1c2144;
  --card-hi: #262c58;
  --line: rgba(255, 255, 255, .08);
  --text: #f3f4ff;
  --muted: #a7accf;
  --accent: #ffb703;
  --accent-ink: #2a1a00;
  --pink: #ff4d8d;
  --green: #3ddc97;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --head: 'Baloo 2', system-ui, sans-serif;
  --body: 'Nunito', system-ui, sans-serif;
  --max: 1280px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: radial-gradient(1200px 600px at 10% -10%, #2a1f5c 0%, transparent 60%),
              radial-gradient(900px 500px at 100% 0%, #3b1236 0%, transparent 55%), var(--bg);
  background-attachment: fixed;
  color: var(--text); font: 16px/1.55 var(--body);
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
h1, h2, h3 { font-family: var(--head); line-height: 1.15; margin: 0 0 .4em; letter-spacing: -.01em; }
h1 { font-size: clamp(28px, 4vw, 44px); }
h2 { font-size: clamp(22px, 2.6vw, 28px); }
h3 { font-size: 19px; }
p { margin: 0 0 1em; }
.wrap { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 16px; }
main { flex: 1; padding-bottom: 48px; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 50;
  background: rgba(13, 15, 31, .82); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.top .wrap { display: flex; align-items: center; gap: 16px; height: 64px; }
.logo { display: flex; align-items: center; gap: 10px; font: 800 21px/1 var(--head); white-space: nowrap; }
.logo svg { width: 38px; height: 38px; flex: none; }
.logo b { color: var(--accent); font-weight: 800; }
.search { flex: 1; max-width: 460px; margin-left: auto; position: relative; }
.search input {
  width: 100%; height: 42px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--text); font: 600 15px var(--body); padding: 0 16px 0 42px;
}
.search input::placeholder { color: var(--muted); }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 14px 0 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 16px;
  border-radius: 999px; background: var(--card); border: 1px solid var(--line);
  font: 700 15px var(--body); color: var(--text); cursor: pointer; transition: background .15s, transform .15s;
}
.chip:hover { background: var(--card-hi); transform: translateY(-1px); }
.chip[aria-pressed="true"], .chip.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

/* ---------- home ---------- */
.hello { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 14px; margin-top: 18px; }
.hello h1 { margin: 0; font-size: clamp(26px, 3.4vw, 36px); }
.hello p { margin: 0; color: var(--muted); font-weight: 700; }
.wave { display: inline-block; transform-origin: 70% 70%; animation: wave 2.4s ease-in-out 1s 2; }
@keyframes wave { 0%, 60%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(16deg); } 20%, 40% { transform: rotate(-8deg); } }
.logo:hover svg { animation: wiggle .5s ease-in-out; }
@keyframes wiggle { 25% { transform: rotate(-10deg); } 75% { transform: rotate(10deg); } }
.hero { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-top: 16px; }
/* Store banners already carry the game's logo, so titles sit in a caption strip under the art, never on it. */
.hero-main, .hero-side a {
  display: flex; flex-direction: column; overflow: hidden; border-radius: var(--radius);
  background: var(--card); box-shadow: var(--shadow); transition: transform .18s ease;
}
.hero-main:hover, .hero-side a:hover { transform: translateY(-3px); }
.hero-img { flex: 1; min-height: 0; aspect-ratio: 16 / 9; background: #000 center/cover no-repeat; transition: transform .3s ease; }
.hero-cap { display: flex; align-items: center; gap: 16px; padding: 14px 18px; }
.hero-cap > div { flex: 1; min-width: 0; }
.hero-main h2 { font-size: clamp(22px, 2.6vw, 30px); margin: 0 0 2px; }
.hero-main p { color: var(--muted); margin: 0; font-size: 15px; }
.hero-side { display: grid; gap: 16px; }
.hero-side .hero-cap { padding: 10px 14px; font: 800 18px/1.15 var(--head); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 46px; padding: 0 22px;
  border-radius: 999px; border: 0; cursor: pointer; font: 800 17px var(--head);
  background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 0 #b77f00; transition: transform .1s, box-shadow .1s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #b77f00; }
.btn.ghost { background: var(--card); color: var(--text); box-shadow: 0 6px 0 #0a0c1a; }
.btn.ghost:active { box-shadow: 0 2px 0 #0a0c1a; }
.btn svg { width: 18px; height: 18px; }
.section { margin-top: 36px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-head h2 { margin: 0; }
.section-head a { color: var(--accent); font-weight: 800; }
.empty { padding: 32px; text-align: center; color: var(--muted); background: var(--bg2); border-radius: var(--radius); }

/* ---------- game cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.grid.row { grid-auto-flow: column; grid-auto-columns: minmax(180px, 220px); grid-template-columns: none; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.card {
  position: relative; display: block; overflow: hidden; border-radius: var(--radius); background: var(--card);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .3); transition: transform .18s ease, box-shadow .18s ease;
  aspect-ratio: 4 / 3;
}
.card img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s ease; }
.card .name {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 22px 12px 10px;
  font: 800 16px/1.15 var(--head); background: linear-gradient(180deg, transparent, rgba(8, 9, 22, .9));
}
.card .badge {
  position: absolute; top: 8px; left: 8px; padding: 2px 9px; border-radius: 999px;
  background: var(--pink); color: #fff; font: 800 12px/20px var(--body); letter-spacing: .03em; text-transform: uppercase;
}
.card:hover { transform: translateY(-4px) scale(1.02); box-shadow: 0 14px 30px rgba(0, 0, 0, .45); }
.card:hover img { transform: scale(1.06); }
.card[hidden] { display: none; }

/* ---------- game page ---------- */
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; margin-top: 16px; }
.player { min-width: 0; }
.stage {
  position: relative; border-radius: var(--radius); overflow: hidden; background: #000; box-shadow: var(--shadow);
  aspect-ratio: 16 / 9;
}
.stage.portrait { aspect-ratio: auto; height: min(82vh, 860px); }
.stage.portrait::before { content: ''; position: absolute; inset: -30px; background: var(--art) center/cover no-repeat; filter: blur(20px) brightness(.4); }
.stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #000; }
.stage.portrait iframe { left: 50%; width: min(100%, calc(min(82vh, 860px) * .5625)); transform: translateX(-50%); }
.cover {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: #000 center/cover no-repeat; text-align: center; padding: 16px; cursor: pointer;
}
.cover::before { content: ''; position: absolute; inset: 0; background: rgba(8, 9, 22, .55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.cover > * { position: relative; }
.cover img { width: min(300px, 60%); border-radius: var(--radius); box-shadow: var(--shadow); aspect-ratio: 4 / 3; object-fit: cover; }
.cover h1 { margin: 0; font-size: clamp(24px, 3.4vw, 38px); text-shadow: 0 3px 12px rgba(0, 0, 0, .5); }
.cover .btn { height: 56px; padding: 0 34px; font-size: 22px; }
.stage.playing .cover { display: none; }
.player-bar { display: flex; align-items: center; gap: 10px; padding: 12px 4px; flex-wrap: wrap; }
.player-bar .title { font: 800 20px/1.2 var(--head); margin-right: auto; }
.icon-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); font: 700 14px var(--body); cursor: pointer;
}
.icon-btn:hover { background: var(--card-hi); }
.icon-btn svg { width: 18px; height: 18px; }
.exit-btn { display: none; }
.info { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-top: 8px; }
.info h2 { font-size: 22px; margin-top: 4px; }
.info h2:not(:first-child) { margin-top: 22px; }
.info ol, .info ul { margin: 0 0 1em; padding-left: 1.3em; }
.info li { margin: .25em 0; }
.keys { border-collapse: collapse; width: 100%; max-width: 520px; }
.keys td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.keys td:first-child { white-space: nowrap; width: 1%; }
kbd { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--card-hi); border: 1px solid var(--line); border-bottom-width: 3px; font: 700 13px var(--body); }
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tags a, .tags span { padding: 4px 12px; border-radius: 999px; background: var(--card); font-size: 14px; font-weight: 700; color: var(--muted); }
.tags a:hover { color: var(--text); background: var(--card-hi); }
.side { display: flex; flex-direction: column; gap: 14px; }
.side h3 { margin: 4px 0 0; }
.mini { display: flex; gap: 12px; align-items: center; padding: 8px; border-radius: var(--radius-sm); background: var(--bg2); transition: background .15s; }
.mini:hover { background: var(--card); }
.mini img { width: 96px; height: 72px; object-fit: cover; border-radius: 8px; flex: none; }
.mini b { font: 800 16px/1.2 var(--head); display: block; }
.mini span { font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.crumbs { font-size: 14px; color: var(--muted); padding-top: 14px; }
.crumbs a:hover { color: var(--text); }

/* phone: the game opens as a full-screen layer */
body.mobile-play { overflow: hidden; }
body.mobile-play .stage { position: fixed; inset: 0; z-index: 1000; border-radius: 0; height: auto; aspect-ratio: auto; }
body.mobile-play .stage.portrait iframe { width: 100%; left: 0; transform: none; }
/* games keep their own buttons in the corners, so the close tab sits mid-way down the left edge */
body.mobile-play .exit-btn {
  display: inline-flex; position: fixed; z-index: 1001; top: 50%; left: calc(env(safe-area-inset-left, 0px)); transform: translateY(-50%);
  width: 30px; height: 52px; padding: 0 0 0 2px; align-items: center; justify-content: center; border-radius: 0 12px 12px 0;
  background: rgba(0, 0, 0, .5); border: 1px solid rgba(255, 255, 255, .22); border-left: 0; color: #fff; cursor: pointer; opacity: .8;
}
body.mobile-play .exit-btn svg { width: 16px; height: 16px; }

/* ---------- ads ---------- */
.ad-slot { display: none; }
body.ads-on .ad-slot, body.ads-preview .ad-slot { display: flex; align-items: center; justify-content: center; margin: 0 auto; }
body.ads-preview .ad-slot {
  border: 2px dashed rgba(255, 183, 3, .5); border-radius: var(--radius-sm); color: var(--accent);
  font: 800 13px var(--body); letter-spacing: .1em; text-transform: uppercase; background: rgba(255, 183, 3, .05);
}
body.ads-preview .ad-slot::before { content: 'Ad · ' attr(data-size); }
.ad-rect { width: 300px; height: 250px; }
.ad-wide { width: 100%; max-width: 728px; height: 90px; margin-top: 20px !important; }

/* ---------- text pages + footer ---------- */
.page { max-width: 780px; margin: 28px auto 0; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; }
.page h2 { font-size: 22px; margin-top: 24px; }
.page a { color: var(--accent); }
.foot { border-top: 1px solid var(--line); background: rgba(8, 9, 22, .6); padding: 28px 0; font-size: 14px; color: var(--muted); }
.foot .wrap { display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: center; justify-content: space-between; }
.foot nav { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.foot a:hover { color: var(--text); }

@media (max-width: 960px) {
  .game-layout { grid-template-columns: 1fr; }
  .side .ad-rect { display: none !important; }
  .hero { grid-template-columns: 1fr; }
  .hero-side { grid-template-columns: 1fr 1fr; }
  .hero-side .hero-cap { font-size: 16px; }
}
@media (max-width: 640px) {
  .top .wrap { height: auto; flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; gap: 10px; }
  .search { max-width: none; flex-basis: 100%; order: 3; }
  .logo { font-size: 19px; }
  .hero-cap { padding: 12px 14px; gap: 12px; }
  .hero-main .btn { height: 42px; padding: 0 16px; font-size: 16px; }
  .hero-main p { font-size: 14px; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .grid.row { grid-auto-columns: 46%; }
  .card .name { font-size: 14px; padding: 18px 8px 7px; }
  .player-bar .title { flex-basis: 100%; }
  .stage, .stage.portrait { aspect-ratio: 4 / 3; height: auto; }
  .stage.portrait iframe { width: 100%; left: 0; transform: none; }
  .info, .page { padding: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
