* { box-sizing: border-box; margin: 0; padding: 0; }
  :root {
    --ink: #1e293b; --muted: #64748b; --line: #e2e8f0;
    --accent: #f59e0b; --accent2: #e85d3f;
    --success: #16a34a; --danger: #dc2626;
    --bg: #f1f5f9; --surface: #ffffff;
  }
  body {
    font-family: 'Sora', sans-serif;
    background: linear-gradient(135deg, #f1f5f9, #fef3e2, #f1f5f9, #fdece7);
    background-size: 300% 300%; animation: bgShift 18s ease infinite;
    color: var(--ink); height: 100vh; height: 100dvh;
    padding: 10px 12px 0; overflow: hidden; display: flex; flex-direction: column;
  }
  @keyframes bgShift { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
  .wrap { max-width:480px; width:100%; margin:0 auto; flex:1 1 auto; min-height:0; display:flex; flex-direction:column; align-items:center; }
  .header { width: 100%; }

  /* -- Platform logo strip: infinite marquee, ported from POPSHOP's PlatformBanner -- */
  .platform-strip { width: 100%; position: relative; overflow: hidden; padding: 8px 0; 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: 76px; height: 42px; border-radius: 12px;
    background: #fff; border: 1px solid #e2e8f0; 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: 22px; width: auto; max-width: 90%; object-fit: contain; display: block; }
  @media (prefers-reduced-motion: reduce) { .platform-track { animation: none; } }

  /* ── Header ── */
  .header { position: relative; text-align: center; padding: 6px 0 4px; flex-shrink: 0; }
  .logo-img { max-height: 62px; width: auto; display: inline-block; }
  .back-btn {
    position: absolute; top: 4px; left: 4px;
    display: flex; align-items: center; justify-content: center;
    width: 26px; height: 26px;
    border-radius: 50%; background: var(--surface); border: 1.5px solid var(--line);
    color: var(--muted); font-weight: 800; font-size: 15px; text-decoration: none;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
    transition: transform .15s cubic-bezier(.34,1.56,.64,1);
  }
  .back-btn:active { transform: scale(.88); }
  .hearts-badge {
    margin: 4px auto 0; width: fit-content;
    display: flex; align-items: center; gap: 3px;
    background: var(--surface); border: 1.5px solid var(--line);
    border-radius: 999px; padding: 6px 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,.08); font-size: 15px;
  }
  .hearts-badge .heart {
    display: inline-block; transition: transform .2s;
    animation: heartbeat 1.6s ease-in-out infinite;
  }
  .hearts-badge .heart:nth-child(2) { animation-delay: .15s; }
  .hearts-badge .heart:nth-child(3) { animation-delay: .3s; }
  .hearts-badge .heart.lost { filter: grayscale(1) opacity(.35); animation: none; }
  @keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    15% { transform: scale(1.22); }
    30% { transform: scale(1); }
    45% { transform: scale(1.14); }
    60% { transform: scale(1); }
  }
  @media (prefers-reduced-motion: reduce) {
    .hearts-badge .heart { animation: none; }
  }

  .howto-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;
  }
  .howto-overlay.show { display: flex; }
  .howto-card {
    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);
  }
  .howto-title { font-size: 19px; font-weight: 800; text-align: center; margin-bottom: 16px; }
  .howto-step { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
  .howto-emoji { font-size: 24px; flex-shrink: 0; line-height: 1.3; }
  .howto-step b { display: block; font-size: 13px; margin-bottom: 2px; }
  .howto-step p { font-size: 12px; color: var(--muted); line-height: 1.4; }
  .howto-card .result-btn { width: 100%; margin-top: 6px; }

  /* ── Leaderboard ── */
  .leaderboard-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; max-height: 50vh; overflow-y: auto; }
  .leaderboard-loading, .leaderboard-empty { text-align: center; color: var(--muted); font-size: 13px; padding: 20px 0; }
  .lb-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: var(--bg); }
  .lb-row.me { background: rgba(245,158,11,.15); border: 1.5px solid var(--accent); }
  .lb-rank { font-weight: 800; font-size: 13px; color: var(--muted); width: 22px; text-align: center; flex-shrink: 0; }
  .lb-row:nth-child(1) .lb-rank { color: #eab308; }
  .lb-row:nth-child(2) .lb-rank { color: #94a3b8; }
  .lb-row:nth-child(3) .lb-rank { color: #b45309; }
  .lb-name { flex: 1; font-weight: 700; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .lb-score { font-weight: 800; font-size: 14px; color: var(--accent); }

  /* ── Board ── */
  .board-wrap {
    background: transparent; border: 0; padding: 0;
    position: relative; flex: 1 1 auto; min-height: 220px; width: 100%; max-width: 380px; margin: 0 auto;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
  }
  .board-wrap.shake { animation: boardShake .3s; }
  @keyframes boardShake { 20%{transform:translateX(-4px)} 40%{transform:translateX(4px)} 60%{transform:translateX(-3px)} 80%{transform:translateX(3px)} 100%{transform:translateX(0)} }

  /* ── Loading state — levels can take a few seconds to generate at higher
     arrow counts; without this the board just looks frozen/unresponsive. ── */
  .board-loading {
    display: none; position: absolute; inset: 0; z-index: 20;
    flex-direction: column; align-items: center; justify-content: center; gap: 12px;
    background: rgba(255,255,255,.88); border-radius: 16px;
  }
  .board-loading.show { display: flex; }
  .board-spinner {
    width: 34px; height: 34px; border-radius: 50%;
    border: 4px solid var(--line); border-top-color: var(--accent);
    animation: boardSpin .7s linear infinite;
  }
  @keyframes boardSpin { to { transform: rotate(360deg); } }
