* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
  --ink: #1e293b; --muted: #64748b; --line: #e2e8f0;
  --accent: #f59e0b; --accent2: #e85d3f;
  --success: #16a34a; --danger: #dc2626;
  --bg: #f1f5f9; --surface: #ffffff;
  --word1: #4338ca; --word2: #6d28d9;
}
html, body { min-height: 100%; background: var(--bg); }
body {
  font-family: 'Sora', sans-serif; color: var(--ink); overflow-x: hidden;
  background: linear-gradient(135deg, #f1f5f9, #ede9fe, #f1f5f9, #e0f2fe);
  background-size: 300% 300%;
  animation: bgShift 18s ease infinite;
}
@keyframes bgShift { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
button { font: inherit; color: inherit; }
@media (prefers-reduced-motion: reduce) { body { animation: none; } }

/* -- Name gate: same rules as every other Pop game -- */
.namegate-overlay {
  display: none; position: fixed; inset: 0; z-index: 400;
  background: rgba(15,23,42,.6); backdrop-filter: blur(4px);
  align-items: center; justify-content: center; padding: 20px;
}
.namegate-overlay.show { display: flex; }
.namegate-card {
  background: var(--surface); border-radius: 22px; padding: 26px 22px;
  max-width: 340px; width: 100%; text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.namegate-logo { max-height: 52px; margin-bottom: 10px; }
.namegate-title { font-family: 'Baloo 2', sans-serif; font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.namegate-sub { font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.namegate-input {
  width: 100%; padding: 12px 14px; border-radius: 12px;
  border: 1.5px solid var(--line); font-family: 'Sora', sans-serif;
  font-size: 15px; font-weight: 700; text-align: center; color: var(--ink);
  margin-bottom: 8px;
}
.namegate-input.shake-input { animation: shakeInput .3s; border-color: var(--danger); }
.namegate-error { font-size: 12px; font-weight: 700; color: var(--danger); min-height: 16px; margin-bottom: 6px; opacity: 0; transition: opacity .2s; }
.namegate-error.show { opacity: 1; }
@keyframes shakeInput { 25%{transform:translateX(-5px)} 50%{transform:translateX(5px)} 75%{transform:translateX(-3px)} }

.primary, .namegate-card .primary {
  width: 100%; padding: 13px; border: none; border-radius: 12px;
  background: linear-gradient(120deg, var(--word1), var(--word2)); color: #fff;
  font-family: inherit; font-size: 14px; font-weight: 800; cursor: pointer; margin-top: 4px;
}
.secondary {
  width: 100%; padding: 13px; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink);
  font-family: inherit; font-size: 14px; font-weight: 800; cursor: pointer; margin-top: 8px;
}

/* -- Platform logo strip: shared boilerplate across every game page -- */
.platform-strip { position: relative; overflow: hidden; padding: 6px 0 2px; flex-shrink: 0; }
.platform-strip::before, .platform-strip::after {
  content: ''; position: absolute; top: 0; bottom: 0; width: 32px; z-index: 2; pointer-events: none;
}
.platform-strip::before { left: 0; background: linear-gradient(to right, var(--bg), transparent); }
.platform-strip::after { right: 0; background: linear-gradient(to left, var(--bg), transparent); }
.platform-track { display: flex; align-items: center; gap: 10px; width: max-content; animation: platformMarquee 36s linear infinite; }
.platform-strip:hover .platform-track { animation-play-state: paused; }
@keyframes platformMarquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.platform-card {
  flex: 0 0 auto; width: 70px; height: 38px; border-radius: 11px;
  background: #fff; border: 1px solid var(--line); box-shadow: 0 1px 3px rgba(0,0,0,.06);
  display: flex; align-items: center; justify-content: center; transition: transform .15s;
}
.platform-card:active { transform: scale(.92); }
.platform-card img { height: 20px; width: auto; max-width: 90%; object-fit: contain; display: block; }

/* -- App shell -- */
.app { width: min(100%, 480px); min-height: 100vh; min-height: 100dvh; margin: auto; padding: 8px 14px 26px; display: flex; flex-direction: column; }
.top { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; padding: 5px 0 4px; gap: 6px; }
.icon {
  width: 42px; height: 42px; border: 1.5px solid var(--line); border-radius: 14px;
  background: rgba(255,255,255,.82); box-shadow: 0 4px 12px rgba(0,0,0,.06);
  display: grid; place-items: center; font-size: 19px; font-weight: 800;
  cursor: pointer; text-decoration: none; color: inherit;
}
.icon:active { transform: scale(.94); }
.brand { height: 56px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.brand img { max-height: 100%; width: auto; object-fit: contain; filter: drop-shadow(0 4px 8px rgba(30,41,59,.18)); }
.icon-group { display: flex; gap: 6px; }

/* -- Overlays (howto / leaderboard), same shell every game reuses -- */
.overlay {
  display: none; position: fixed; inset: 0; z-index: 300;
  background: rgba(15,23,42,.55); backdrop-filter: blur(3px);
  align-items: center; justify-content: center; padding: 20px;
}
.overlay.show { display: flex; }
.modal {
  background: var(--surface); border-radius: 18px; padding: 22px 20px;
  max-width: 380px; width: 100%; max-height: 85vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.35); text-align: center;
}
.modal h2 { font-family: 'Baloo 2', sans-serif; font-size: 19px; font-weight: 800; margin-bottom: 14px; }
.modal .emoji { font-size: 30px; margin-bottom: 6px; }
.how { text-align: left; margin-bottom: 4px; }
.how > div { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.how span { font-size: 22px; flex-shrink: 0; line-height: 1.3; }
.how b { display: block; font-size: 13px; margin-bottom: 2px; }
.how p { font-size: 12px; color: var(--muted); line-height: 1.4; }

.leaderboard-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; max-height: 340px; overflow-y: auto; }
.leaderboard-loading, .leaderboard-empty { color: var(--muted); font-size: 13px; padding: 20px 0; }
.leaderboard-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px; background: var(--bg); text-align: left; }
.leaderboard-row .rank { font-weight: 800; width: 22px; text-align: center; flex-shrink: 0; }
.leaderboard-row .name { flex: 1; font-weight: 700; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leaderboard-row .pts { font-weight: 800; color: var(--accent2); font-size: 13px; font-variant-numeric: tabular-nums; }
