* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; background: #0e0e1a; color: #fff; font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; overscroll-behavior: none; }
#app { height: 100%; display: flex; flex-direction: column; max-width: 900px; margin: 0 auto; }
#topbar { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: #16162a; }
#brand { font-weight: 700; font-size: 17px; }
.icon-btn { background: none; border: none; font-size: 20px; color: #fff; cursor: pointer; padding: 4px 8px; }
#stage { position: relative; flex: 1; display: flex; align-items: center; justify-content: center; background: #000; min-height: 0; }
#game { width: 100%; height: auto; max-height: 100%; object-fit: contain; image-rendering: pixelated; image-rendering: crisp-edges; background: #5c94fc; display: block; touch-action: none; }

.hidden { display: none !important; }

#hud { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; pointer-events: none; font-weight: 700; text-shadow: 0 2px 0 rgba(0,0,0,.5); font-size: 16px; }
#hud-left, #hud-right { display: flex; gap: 14px; align-items: center; }
#hud button { pointer-events: auto; }

.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(10,10,25,.72); z-index: 5; padding: 16px; }
.panel { background: #1d1d38; border: 3px solid #3d3d6b; border-radius: 14px; padding: 22px 24px; text-align: center; max-width: 420px; width: 100%; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.panel h1 { font-size: 30px; margin-bottom: 4px; letter-spacing: 1px; }
.panel h2 { font-size: 22px; margin-bottom: 10px; }
.tagline { color: #9fd0ff; margin-bottom: 14px; }
.greeting { color: #ffd75e; margin-bottom: 8px; font-weight: 600; }
.hint { color: #9a9ac0; font-size: 13px; margin-top: 14px; line-height: 1.5; }
.best { color: #ffd75e; margin-top: 8px; font-size: 14px; }
.ads-note { color: #8a8ab0; font-size: 12px; margin-top: 14px; }
.linklike { background: none; border: none; color: #7aa7e8; font-size: 12px; margin-top: 8px; cursor: pointer; text-decoration: underline; }
.row { display: flex; gap: 10px; justify-content: center; margin-top: 14px; }

.btn { display: block; width: 100%; margin: 8px 0; padding: 12px 18px; font-size: 16px; font-weight: 700; color: #122; background: #ffd75e; border: none; border-radius: 10px; cursor: pointer; box-shadow: 0 4px 0 #b8932a; }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #b8932a; }
.btn.big { font-size: 19px; padding: 14px 18px; }
.btn.ghost { background: #2c2c50; color: #cfd0f0; box-shadow: 0 4px 0 #1a1a30; }
.btn.ad { background: #6ee7a0; box-shadow: 0 4px 0 #35915c; color: #08240f; }
.btn:disabled { opacity: .5; cursor: default; }
.row .btn { width: auto; min-width: 130px; }

#toast { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); background: #000c; border: 2px solid #44448a; padding: 10px 18px; border-radius: 10px; font-size: 14px; z-index: 9; max-width: 90%; text-align: center; }

#touch { position: absolute; inset: auto 0 0 0; display: flex; justify-content: space-between; padding: 0 14px 14px; z-index: 4; pointer-events: none; }
#touch .tleft, #touch .tright { display: flex; gap: 12px; pointer-events: auto; }
.tbtn { width: 64px; height: 64px; border-radius: 50%; border: 3px solid #ffffff55; background: #ffffff22; color: #fff; font-size: 26px; font-weight: 700; touch-action: none; user-select: none; -webkit-user-select: none; }
.tbtn.jump { width: 76px; height: 76px; background: #ffd75e44; border-color: #ffd75e88; }
.tbtn:active { background: #ffffff44; }

@media (max-height: 480px) {
  .panel { padding: 14px 16px; }
  .panel h1 { font-size: 22px; }
  .btn { padding: 9px 14px; margin: 6px 0; }
}

.tbtn.fire {
  background: rgba(255, 154, 60, 0.85);
  margin-right: 10px;
}
.tright { display: flex; align-items: center; }

/* Leaderboard */
.board-panel { max-width: 340px; width: 88%; }
.board-list { max-height: 220px; overflow-y: auto; margin: 10px 0; text-align: left; }
.board-row { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-bottom: 1px solid rgba(255,255,255,0.08); font-size: 14px; }
.board-row .rank { width: 26px; opacity: 0.7; }
.board-row .bname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-row .bscore { font-weight: bold; color: #ffd34d; }
.board-best { margin: 6px 0; font-size: 14px; opacity: 0.9; }
.board-privacy { font-size: 11px; opacity: 0.65; line-height: 1.4; margin: 8px 0; }
.flag-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; max-height: 260px; overflow-y: auto; margin: 10px 0; }
.flag-btn { font-size: 22px; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15); border-radius: 8px; padding: 6px 0; cursor: pointer; }
.flag-btn:hover { background: rgba(255,255,255,0.2); }
