/* Max's Arcade */
@font-face { font-family: "Fredoka"; src: url("/fonts/fredoka.woff2") format("woff2"); font-weight: 300 700; font-display: swap; }
@font-face { font-family: "Nunito"; src: url("/fonts/nunito.woff2") format("woff2"); font-weight: 200 1000; font-display: swap; }

:root {
  --bg-1: #1a1145;
  --bg-2: #2b1670;
  --ink: #ffffff;
  --ink-soft: #d9d2ff;
  --panel: rgba(255, 255, 255, 0.08);
  --panel-line: rgba(255, 255, 255, 0.16);
  --yellow: #ffd23f;
  --pink: #ff5ca8;
  --cyan: #4fd1ff;
  --green: #4ade80;
  --purple: #a78bfa;
  --accent: #8b5cf6;
  --radius: 26px;
  --head: "Fredoka", "Baloo 2", system-ui, sans-serif;
  --body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  font-family: var(--body);
  font-weight: 700;
  background: var(--bg-1);
  -webkit-tap-highlight-color: transparent;
}
/* Fixed backdrop layer (background-attachment: fixed is ignored on iPhone/iPad). */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(255, 92, 168, 0.35), transparent 60%),
    radial-gradient(900px 600px at 100% 0%, rgba(79, 209, 255, 0.28), transparent 60%),
    radial-gradient(1000px 800px at 50% 120%, rgba(139, 92, 246, 0.5), transparent 60%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
}
a { color: inherit; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 4px solid var(--yellow); outline-offset: 3px; border-radius: 12px; }

/* ---------- logo ---------- */
.logo { display: inline-flex; align-items: center; gap: 0.35em; text-decoration: none; }
.logo-mark { width: 1.6em; height: 1.6em; flex: none; filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.25)); }
.logo-word {
  font-family: var(--head);
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
}
.logo-word b {
  font-weight: 700;
  background: linear-gradient(90deg, var(--yellow), var(--pink) 50%, var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.25));
}

/* ---------- home ---------- */
.sky { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.s { position: absolute; display: block; opacity: 0.5; animation: drift 18s ease-in-out infinite alternate; }
.s1 { left: 6%; top: 18%; width: 34px; height: 34px; border-radius: 9px; background: var(--yellow); transform: rotate(12deg); }
.s2 { left: 86%; top: 12%; width: 22px; height: 22px; border-radius: 50%; background: var(--cyan); animation-duration: 14s; }
.s3 { left: 78%; top: 62%; width: 40px; height: 40px; border-radius: 11px; background: var(--pink); animation-duration: 21s; }
.s4 { left: 12%; top: 72%; width: 18px; height: 18px; border-radius: 50%; background: var(--green); animation-duration: 16s; }
.s5 { left: 48%; top: 6%; width: 14px; height: 14px; border-radius: 50%; background: #fff; opacity: 0.35; animation-duration: 12s; }
.s6 { left: 94%; top: 40%; width: 26px; height: 26px; border-radius: 7px; background: var(--purple); animation-duration: 19s; }
.s7 { left: 2%; top: 44%; width: 12px; height: 12px; border-radius: 50%; background: var(--yellow); animation-duration: 13s; }
.s8 { left: 60%; top: 88%; width: 30px; height: 30px; border-radius: 50%; background: var(--cyan); opacity: 0.3; animation-duration: 23s; }
.s9 { left: 30%; top: 90%; width: 20px; height: 20px; border-radius: 6px; background: var(--pink); opacity: 0.4; animation-duration: 17s; }
.s10 { left: 70%; top: 28%; width: 10px; height: 10px; border-radius: 50%; background: #fff; opacity: 0.3; animation-duration: 11s; }
@keyframes drift {
  from { translate: 0 0; rotate: 0deg; }
  to { translate: 18px -34px; rotate: 50deg; }
}

.hero, .home, .foot { position: relative; z-index: 1; }
.hero { text-align: center; padding: clamp(28px, 6vw, 64px) 16px 8px; }
.logo-big { font-size: clamp(2.6rem, 9vw, 5rem); line-height: 1; }
.logo-big .logo-mark { animation: bob 3.2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-6deg); } }
.hero-sub {
  margin: 14px auto 0;
  max-width: 34ch;
  font-size: clamp(1.05rem, 2.6vw, 1.3rem);
  color: var(--ink-soft);
}

.home { max-width: 1180px; margin: 0 auto; padding: 18px 16px 24px; }

.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 8px 0 26px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px;
  border: 2px solid var(--panel-line);
  border-radius: 999px;
  background: var(--panel);
  font-family: var(--head);
  font-weight: 600;
  font-size: 1.02rem;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s, border-color 0.15s;
}
.chip:hover { transform: translateY(-2px); border-color: rgba(255, 255, 255, 0.4); }
.chip[aria-pressed="true"] { background: var(--yellow); border-color: var(--yellow); color: #2a1660; }

.row-title { font-family: var(--head); font-weight: 600; font-size: 1.3rem; margin: 0 0 12px; }
.recent { margin-bottom: 26px; }
.recent-list { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.recent-item {
  display: flex; align-items: center; gap: 10px; flex: none;
  padding: 6px 16px 6px 6px;
  border-radius: 999px;
  background: var(--panel);
  border: 2px solid var(--panel-line);
  text-decoration: none;
  font-family: var(--head); font-weight: 600;
  transition: transform 0.15s, border-color 0.15s;
}
.recent-item:hover { transform: translateY(-2px); border-color: var(--accent); }
.recent-item img, .recent-item .ph { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: var(--accent); }

/* ---------- tiles ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 22px; }
.tile {
  position: relative;
  display: block;
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  background: var(--accent);
  border: 4px solid var(--accent);
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.28), 0 18px 40px -12px var(--accent);
  transition: transform 0.18s cubic-bezier(0.3, 1.6, 0.6, 1), box-shadow 0.18s;
  isolation: isolate;
}
.tile:hover { transform: translateY(-6px) rotate(-1.2deg) scale(1.02); box-shadow: 0 14px 0 rgba(0, 0, 0, 0.28), 0 26px 50px -10px var(--accent); }
.tile:nth-child(even):hover { transform: translateY(-6px) rotate(1.2deg) scale(1.02); }
.tile:active { transform: translateY(2px) scale(0.98); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3); }
.tile img, .tile .ph { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -1; transition: transform 0.4s; }
.tile:hover img { transform: scale(1.06); }
.tile .ph {
  display: grid; place-items: center;
  font-family: var(--head); font-size: 4rem; font-weight: 700; color: rgba(255, 255, 255, 0.85);
  background: radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.35), transparent 50%), var(--accent);
}
.tile-label {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 44px 16px 14px;
  background: linear-gradient(180deg, transparent, rgba(16, 8, 40, 0.75) 45%, rgba(16, 8, 40, 0.92));
}
.tile-title { display: block; font-family: var(--head); font-weight: 700; font-size: 1.45rem; line-height: 1.1; }
.tile-tag { display: block; margin-top: 4px; font-size: 0.92rem; line-height: 1.25; color: var(--ink-soft); }
.badges { position: absolute; top: 12px; left: 12px; display: flex; gap: 6px; flex-wrap: wrap; }
.badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-family: var(--head); font-weight: 600; font-size: 0.85rem;
  background: rgba(16, 8, 40, 0.78);
  border: 2px solid rgba(255, 255, 255, 0.25);
}
.badge-new { background: var(--yellow); color: #2a1660; border-color: var(--yellow); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }
.tile.is-hidden { display: none; }
.empty { grid-column: 1 / -1; text-align: center; color: var(--ink-soft); padding: 30px; }

.foot { text-align: center; padding: 22px 16px 40px; font-family: var(--head); font-weight: 600; font-size: 1.15rem; color: var(--ink-soft); }

@media (max-width: 560px) {
  .grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .tile { border-width: 3px; border-radius: 20px; }
  .tile-label { padding: 30px 10px 10px; }
  .tile-title { font-size: 1.1rem; }
  .tile-tag { display: none; }
  .badges { top: 8px; left: 8px; }
  .badge { font-size: 0.72rem; padding: 2px 8px; }
}

/* ---------- game page ---------- */
.page-game { height: 100vh; height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
.bar {
  flex: none;
  display: flex; align-items: center; gap: 12px;
  height: 60px;
  padding: 0 12px;
  padding-left: max(12px, env(safe-area-inset-left));
  padding-right: max(12px, env(safe-area-inset-right));
  background: rgba(16, 8, 40, 0.85);
  border-bottom: 3px solid var(--accent);
  position: relative; z-index: 2;
}
.logo-small { font-size: 1.35rem; }
.now {
  flex: 1; min-width: 0;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-family: var(--head); font-weight: 600; font-size: 1.2rem;
}
.now img, .now .ph { width: 34px; height: 34px; border-radius: 10px; object-fit: cover; border: 2px solid var(--accent); background: var(--accent); flex: none; }
.now span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-actions { display: flex; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 16px;
  border: 2px solid var(--panel-line);
  border-radius: 999px;
  background: var(--panel);
  font-family: var(--head); font-weight: 600; font-size: 1rem;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
}
.btn:hover { transform: translateY(-2px); background: rgba(255, 255, 255, 0.16); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn-go { background: var(--accent); border-color: var(--accent); color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35); }
.btn-go:hover { background: var(--accent); filter: brightness(1.1); }
.btn-round { width: 46px; height: 46px; padding: 0; justify-content: center; }
.btn-home { display: none; }

.stage { flex: 1; position: relative; background: #000; }
.stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; background: #000; }
.exit-full {
  display: none;
  position: absolute; top: max(10px, env(safe-area-inset-top)); left: max(10px, env(safe-area-inset-left)); z-index: 5;
  width: 44px; height: 44px; padding: 0;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  background: rgba(16, 8, 40, 0.6);
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.4s;
}
.exit-full svg { width: 18px; height: 18px; }
.exit-full.dim { opacity: 0.3; }
.exit-full:hover, .exit-full:focus-visible { opacity: 1; }
.stage:fullscreen .exit-full, .stage:-webkit-full-screen .exit-full, .pseudo-full .exit-full { display: grid; }
.pseudo-full .stage { position: fixed; inset: 0; z-index: 50; }
.pseudo-full .bar { display: none; }

@media (max-width: 820px) {
  .logo-small .logo-word { display: none; }
  .logo-small { font-size: 1.5rem; }
}
@media (max-width: 640px) {
  .bar { gap: 8px; height: 54px; padding: 0 8px; }
  .btn { padding: 0; width: 42px; justify-content: center; }
  .btn span { display: none; }
  .now { justify-content: flex-start; font-size: 1.05rem; }
}

/* ---------- picker ---------- */
.picker {
  width: min(980px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 20px;
  border: 3px solid var(--panel-line);
  border-radius: 30px;
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg-1), var(--bg-2));
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.picker[open] { animation: pop 0.22s cubic-bezier(0.3, 1.5, 0.6, 1); }
@keyframes pop { from { transform: scale(0.92); opacity: 0; } }
.picker::backdrop { background: rgba(10, 4, 30, 0.7); backdrop-filter: blur(4px); }
.picker-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.picker-head h2 { margin: 0; font-family: var(--head); font-weight: 700; font-size: 1.7rem; }
.grid-small { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; padding: 4px 4px 10px; }
.grid-small .tile-title { font-size: 1.15rem; }
.grid-small .tile-tag { display: none; }
.tile.is-current { outline: 4px solid #fff; outline-offset: 3px; }
@media (max-width: 560px) {
  .picker { padding: 14px; border-radius: 22px; }
  .grid-small { grid-template-columns: repeat(2, 1fr); gap: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
