* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #1a1226;
  font-family: -apple-system, "Segoe UI", Tahoma, Arial, sans-serif; user-select: none;
  -webkit-user-select: none; touch-action: none; }
#wrap { position: fixed; inset: 0; }
#game { display: block; width: 100%; height: 100%; touch-action: none; }

#hud { position: absolute; top: calc(env(safe-area-inset-top,8px) + 8px); left: 0; right: 0; z-index: 5;
  display: flex; justify-content: space-between; padding: 0 16px; pointer-events: none; }
#score { font-size: 34px; font-weight: 900; color: #fff; text-shadow: 2px 2px 0 #000; }
#best { background: rgba(0,0,0,.4); color: #fff; font-weight: 800; font-size: 14px; padding: 5px 12px;
  border-radius: 16px; align-self: flex-start; }

#ketoBar { position: absolute; left: 16px; right: 16px; bottom: calc(env(safe-area-inset-bottom,12px) + 12px);
  z-index: 5; display: flex; align-items: center; gap: 8px; pointer-events: none; }
.kb-label { font-size: 13px; font-weight: 900; color: #ffd24d; text-shadow: 1px 1px 0 #000; white-space: nowrap; }
.kb-track { flex: 1; height: 16px; background: rgba(0,0,0,.45); border-radius: 10px; overflow: hidden; border: 2px solid rgba(255,255,255,.3); }
#ketoFill { height: 100%; width: 0%; background: linear-gradient(90deg,#ff7a3d,#ffd24d); transition: width .2s; }
#ketoTxt { font-size: 13px; font-weight: 800; color: #fff; min-width: 50px; text-shadow: 1px 1px 0 #000; }

.overlay { position: absolute; inset: 0; z-index: 10; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 13px; padding: 22px; text-align: center;
  background: radial-gradient(circle at 50% 25%, #5a3a78, #1a1226 72%); color: #fff; }
.overlay.hidden { display: none; }
.overlay h1 { font-size: clamp(30px, 9vw, 46px); text-shadow: 0 0 18px rgba(255,160,60,.5), 2px 2px 0 #000; }
.sub { font-size: 15.5px; opacity: .95; max-width: 340px; line-height: 1.5; }
.howto { display: flex; flex-direction: column; gap: 6px; font-size: 14.5px;
  background: rgba(0,0,0,.28); padding: 13px 18px; border-radius: 12px; }
.howto b { color: #ffd24d; }
#heroPreview { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; display: none; border: 4px solid #fff; }
#heroPreview.show { display: block; }
.btn { background: #e0533a; color: #fff; border: 3px solid #fff; border-radius: 13px;
  padding: 14px 32px; font-size: 19px; font-weight: 900; cursor: pointer; box-shadow: 0 5px 0 #963322; }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #963322; }
.btn.ghost { background: rgba(255,255,255,.16); box-shadow: 0 4px 0 rgba(0,0,0,.35); border-color: rgba(255,255,255,.55); font-size: 16px; padding: 11px 22px; }
.btn.wa { background: #25D366; box-shadow: 0 5px 0 #128C3E; }
.btn.wa:active { box-shadow: 0 1px 0 #128C3E; }
.link { background: rgba(255,255,255,.18); color: #fff; border: 2px solid rgba(255,255,255,.6);
  border-radius: 12px; padding: 9px 20px; font-size: 15px; cursor: pointer; }
#nameInput { width: min(80%, 300px); padding: 12px; border-radius: 12px; border: 3px solid #fff;
  font-size: 17px; text-align: center; outline: none; background: #fff; color: #222; }
.rankmsg { font-size: 16px; color: #ffd24d; font-weight: 700; min-height: 22px; }
#lbList { list-style: none; width: min(90%, 360px); max-height: 58vh; overflow-y: auto; }
#lbList li { display: flex; justify-content: space-between; gap: 10px; background: rgba(0,0,0,.28);
  margin: 6px 0; padding: 11px 15px; border-radius: 10px; font-size: 17px; font-weight: 700; }
#lbList li .rank { color: #ffd24d; min-width: 32px; text-align: center; }
#lbList li .nm { flex: 1; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#lbList li.me { outline: 2px solid #ffd24d; }
