* { 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;
    --r: 10px;
  }

  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; min-height: 0; display: flex; flex-direction: column; }

  /* -- Platform logo strip: infinite marquee, ported from POPSHOP's PlatformBanner -- */
  .platform-strip { 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: 70px; width: auto; display: inline-block; }
  .howto-btn {
    position: absolute; top: 4px; right: 4px; width: 26px; height: 26px;
    border-radius: 50%; background: var(--surface); border: 1.5px solid var(--line);
    color: var(--muted); font-weight: 800; font-size: 13px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.08);
    transition: transform .15s cubic-bezier(.34,1.56,.64,1);
  }
  .howto-btn:active { transform: scale(.88); }

  .header-left { position: absolute; top: 4px; left: 4px; display: flex; align-items: center; gap: 6px; }
  .back-btn {
    display: flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; flex-shrink: 0;
    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); }

  .timer-badge {
    display: flex; align-items: center; gap: 4px;
    background: var(--surface); border: 1.5px solid var(--line);
    border-radius: 999px; padding: 5px 11px 5px 9px;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
    font-size: 12px;
  }
  .timer-badge .stat-val { font-size: 13px; font-weight: 800; letter-spacing: 0; line-height: 1; }

  .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); }

  /* ── Stats ── */
  .stats-row {
    display: flex; justify-content: center; gap: 32px;
    margin-bottom: 20px; flex-wrap: wrap;
  }
  .stat { text-align: center; }
  .stat-val {
    font-size: 2.6rem; font-weight: 800; line-height: 1;
    letter-spacing: -.04em; font-variant-numeric: tabular-nums;
  }
  .stat-val.moves  { color: var(--accent); }
  .stat-val.pairs  { color: var(--success); }
  .stat-val.secs   { color: var(--accent2); }
  .stat-lbl { font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 1.5px; margin-top: 3px; }


  /* ── Board ── */
  .board-wrap {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: 16px; --bpad: 14px; padding: var(--bpad);
    box-shadow: 0 2px 16px rgba(0,0,0,.07);
    position: relative;
    flex: 1; min-height: 0;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
  }

  .onet-board { display: grid; gap: 5px; }

  .onet-tile {
    width: var(--tile-w, 70px); height: var(--tile-h, 105px);
    background: transparent;
    border: 0; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all .12s; user-select: none; position: relative;
    box-shadow: none;
  }
  .onet-tile img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; filter: drop-shadow(0 1px 1px rgba(15,23,42,.12)); }
  .onet-tile.missing-art { background: repeating-linear-gradient(45deg, var(--line), var(--line) 6px, var(--surface) 6px, var(--surface) 12px); }
  .onet-tile:hover { background: transparent; transform: scale(1.04); filter: drop-shadow(0 3px 5px rgba(245,158,11,.22)); }
  .onet-tile:active { transform: scale(.94); }
  .onet-tile.selected {
    background: transparent;
    outline: 2.5px solid rgba(245,158,11,.65); outline-offset: -1px;
    box-shadow: 0 0 10px rgba(245,158,11,.32);
    transform: scale(1.05);
  }
  .onet-tile.blocked { background: transparent; outline: 2px solid rgba(245,158,11,.65); outline-offset: -1px; animation: blockedPulse .55s ease 2; }
  @keyframes blockedPulse { 50% { box-shadow: 0 0 16px rgba(245,158,11,.5); } }

  .onet-tile.matched { opacity: 0; pointer-events: none; transition: opacity .3s; }
  .onet-tile.popout { animation: tilePop .35s ease-in forwards; z-index: 5; }
