/* =========================================================================
   Bounce Run — original ball-platformer homage (BuiltBy daily game)
   Neutral-dark BuiltBy palette, emerald accent, red ball.
   ========================================================================= */

:root{
  --bg-0:#0b0b0d;
  --panel:rgba(255,255,255,0.04);
  --panel-strong:rgba(255,255,255,0.07);
  --border:rgba(255,255,255,0.10);
  --border-strong:rgba(255,255,255,0.18);
  --text-0:#fafafa;
  --text-1:#b4b4b4;
  --text-2:#7c7c85;

  --accent-1:#34d399;
  --ball:#f4511e;

  --radius-sm:14px;
  --radius-md:18px;

  --ease-out:cubic-bezier(.16,1,.3,1);

  --font-display:"Space Grotesk",-apple-system,ui-sans-serif,sans-serif;
  --font-body:"Inter",-apple-system,ui-sans-serif,sans-serif;
  --font-mono:"JetBrains Mono",ui-monospace,monospace;
}

*{margin:0;padding:0;box-sizing:border-box;}
*{scrollbar-width:none; -ms-overflow-style:none;}
*::-webkit-scrollbar{width:0;height:0;display:none;}
html,body{height:100%;}
body{
  background:
    radial-gradient(900px 520px at 8% -10%, color-mix(in srgb, var(--accent-1) 8%, transparent), transparent 60%),
    var(--bg-0);
  color:var(--text-0);
  font-family:var(--font-body);
  -webkit-font-smoothing:antialiased;
  height:100%;
  overflow:hidden;
}
button{font-family:inherit;cursor:pointer;border:none;background:none;color:inherit;}
button:focus-visible{outline:2px solid var(--accent-1); outline-offset:2px;}
[data-lucide]{display:inline-block;}

/* ---------------- Shell ---------------- */
.app-shell{
  display:grid;
  grid-template-columns:1fr 300px;
  gap:16px;
  max-width:1480px;
  margin:0 auto;
  padding:16px;
  height:100vh;
  overflow:hidden;
}
.main-col{display:flex; flex-direction:column; gap:14px; min-width:0; height:100%;}

/* ---------------- Top bar (matches MindMatch) ---------------- */
.topbar{display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap;}
.hud-pills{display:flex; gap:8px; flex-wrap:wrap;}
.hud-pill{
  padding:7px 12px; border-radius:12px; background:var(--panel); border:1px solid var(--border);
  min-width:78px;
}
.hud-pill-label{display:block; font-size:9.5px; font-weight:700; text-transform:uppercase; letter-spacing:0.06em; color:var(--pill-c); margin-bottom:2px;}
.hud-pill-row{display:flex; align-items:center; gap:7px;}
.hud-pill-value{font-family:var(--font-display); font-weight:700; font-size:15px;}
.hud-pill-value.mono{font-family:var(--font-mono); font-size:13.5px;}
.hud-pill-row svg{width:13px; height:13px; color:var(--pill-c); margin-left:auto; stroke-width:2;}

.daily-chip{
  display:flex; align-items:center; gap:9px; padding:7px 12px; border-radius:12px;
  background:color-mix(in srgb, var(--accent-1) 10%, var(--panel));
  border:1px solid color-mix(in srgb, var(--accent-1) 30%, var(--border));
}
.daily-chip svg{width:15px; height:15px; color:var(--accent-1); flex-shrink:0;}
.daily-chip-text{display:flex; flex-direction:column; gap:1px;}
.daily-chip-text strong{font-family:var(--font-display); font-size:13px; font-weight:600; line-height:1;}
.daily-chip-text small{font-size:9.5px; color:var(--text-2); white-space:nowrap;}

.topbar-actions{display:flex; gap:6px;}
.icon-btn{
  width:34px;height:34px;border-radius:10px;display:flex;align-items:center;justify-content:center;
  background:var(--panel); border:1px solid var(--border); color:var(--text-1);
  transition:all .25s var(--ease-out);
}
.icon-btn svg{width:15px;height:15px;stroke-width:1.9;}
.icon-btn:hover{color:var(--text-0); border-color:var(--border-strong); background:var(--panel-strong);}

/* ---------------- Stage / canvas ---------------- */
.stage{position:relative; flex:1; min-height:0; display:flex; align-items:center; justify-content:center;}
#game{
  border-radius:var(--radius-md); border:1px solid var(--border);
  background:#5db8f0; /* sky, so there's no dark flash before the first frame */
  /* Sized by fitCanvas() in JS to the largest 16:9 box that fits the stage. */
}

/* ---------------- Touch controls ---------------- */
.touch-controls{
  position:absolute; inset:auto 0 14px 0; display:none;
  align-items:center; justify-content:space-between; padding:0 18px;
  pointer-events:none;
}
body.touch .touch-controls{display:flex;}
.tc-group{display:flex; gap:10px;}
.tc-btn{
  pointer-events:auto; width:56px; height:56px; border-radius:50%;
  background:rgba(255,255,255,0.08); border:1px solid var(--border-strong);
  display:flex; align-items:center; justify-content:center; color:var(--text-0);
  backdrop-filter:blur(6px); touch-action:none; user-select:none; -webkit-user-select:none;
}
.tc-btn svg{width:26px; height:26px;}
.tc-jump{width:64px; height:64px; background:color-mix(in srgb, var(--accent-1) 25%, rgba(255,255,255,0.06));}

/* ---------------- Overlays ---------------- */
.overlay{
  position:absolute; inset:0; z-index:20; display:none;
  align-items:center; justify-content:center; padding:16px;
  background:rgba(5,5,8,0.72); backdrop-filter:blur(6px);
  border-radius:var(--radius-md);
}
.overlay.active{display:flex; animation:fadeIn .25s var(--ease-out);}
@keyframes fadeIn{from{opacity:0;}to{opacity:1;}}
.ov-card{
  width:100%; max-width:400px; text-align:center;
  background:#131316; border:1px solid var(--border); border-radius:var(--radius-md);
  padding:24px 24px 22px; box-shadow:0 20px 55px rgba(0,0,0,0.5);
}
.ov-card h2{font-family:var(--font-display); font-size:21px; font-weight:700; margin-bottom:8px;}
.ov-card p{font-size:13px; color:var(--text-1); line-height:1.55; margin-bottom:10px;}
.ov-keys{color:var(--text-2); font-size:12px;}
kbd{
  display:inline-block; min-width:20px; padding:2px 6px; margin:0 2px;
  border-radius:6px; border:1px solid var(--border-strong); background:var(--panel-strong);
  font-family:var(--font-mono); font-size:10.5px;
}
.ov-ball{
  width:44px; height:44px; border-radius:50%; margin:0 auto 12px;
  background:radial-gradient(circle at 32% 30%, #ff8a65, var(--ball) 60%, #b93a10);
  box-shadow:0 8px 24px rgba(244,81,30,0.4);
}
.ov-flag svg{width:34px; height:34px; color:var(--accent-1); margin-bottom:8px;}

.btn-primary{
  margin-top:8px; padding:11px 22px; border-radius:12px; font-size:14px; font-weight:600;
  background:linear-gradient(135deg,#34d399,#10b981); color:#0a0a12;
  box-shadow:0 8px 24px rgba(52,211,153,0.3); transition:transform .2s var(--ease-out);
}
.btn-primary:hover{transform:translateY(-2px);}

.win-grid{display:grid; grid-template-columns:1fr 1fr; gap:8px; margin:14px 0 6px;}
.win-stat{
  background:var(--panel); border:1px solid var(--border); border-radius:12px;
  padding:10px 8px; display:flex; flex-direction:column; gap:2px;
}
.w-value{font-family:var(--font-display); font-weight:700; font-size:17px;}
.w-value.mono{font-family:var(--font-mono); font-size:15px;}
.w-label{font-size:9.5px; color:var(--text-2); text-transform:uppercase; letter-spacing:0.06em;}

/* ---------------- Right rail ---------------- */
.sidebar-right{display:flex; flex-direction:column; gap:14px; height:100%; overflow-y:auto;}
.panel{border-radius:var(--radius-md); background:var(--panel); border:1px solid var(--border);}
.panel-head{
  display:flex; align-items:center; padding:15px 16px 10px;
  font-family:var(--font-display); font-weight:700; font-size:13.5px; color:var(--accent-1);
}
.panel-head span{display:flex; align-items:center; gap:8px;}
.panel-head svg{width:15px; height:15px;}
.panel-body{padding:0 16px 16px;}

.global-lb{list-style:none; display:flex; flex-direction:column; gap:6px;}
.glb-row{
  display:flex; align-items:center; gap:9px; padding:7px 9px; border-radius:10px;
  background:var(--panel); border:1px solid var(--border); font-size:12.5px;
}
.glb-row.you{
  border-color:color-mix(in srgb, var(--accent-1) 45%, var(--border));
  background:color-mix(in srgb, var(--accent-1) 8%, var(--panel));
}
.glb-rank{font-family:var(--font-mono); color:var(--text-2); width:16px; text-align:center; font-size:11px; flex-shrink:0;}
.glb-row:nth-child(1) .glb-rank{color:#fbbf24; font-weight:700;}
.glb-row:nth-child(2) .glb-rank{color:#cbd5e1;}
.glb-row:nth-child(3) .glb-rank{color:#d97706;}
.glb-avatar{width:22px; height:22px; border-radius:50%; object-fit:cover; flex-shrink:0;}
.glb-avatar-fallback{display:grid; place-items:center; background:var(--panel-strong); font-size:10px; font-weight:700; color:var(--text-1);}
.glb-name{flex:1; min-width:0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; font-weight:600;}
.glb-name em{font-style:normal; color:var(--accent-1); font-size:10.5px;}
.glb-score{font-family:var(--font-display); font-weight:700; flex-shrink:0;}
.global-lb-note{font-size:11px; color:var(--text-2); margin-top:10px; line-height:1.45;}

.best-card{
  margin-top:auto; display:flex; align-items:center; gap:12px; padding:14px 16px;
  border-radius:var(--radius-md); background:var(--panel); border:1px solid var(--border);
}
.best-card svg{width:22px; height:22px; color:#fbbf24; flex-shrink:0;}
.best-meta{display:flex; flex-direction:column; gap:1px; min-width:0;}
.best-meta strong{font-family:var(--font-display); font-size:15px;}
.best-meta span{font-size:11px; color:var(--text-2);}

/* ---------------- Responsive ---------------- */
@media (max-width:980px){
  .app-shell{grid-template-columns:1fr; height:auto; overflow:visible; padding:12px;}
  .main-col{height:auto;}
  .stage{min-height:0;}
  #game{width:100% !important; height:auto !important;}
  .sidebar-right{height:auto; overflow:visible;}
  .best-card{margin-top:0;}
}
