* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #3b3649; font-family: system-ui, -apple-system, 'Segoe UI', sans-serif; color: #fff; user-select: none; -webkit-user-select: none; touch-action: none; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

/* the touch stick, drawn over the game; touches go through to #view */
#pad { position: fixed; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; z-index: 30; }

#hint { position: fixed; left: 16px; bottom: calc(10px + env(safe-area-inset-bottom)); font-size: 13px; opacity: .55; pointer-events: none; text-shadow: 0 1px 3px #000; padding-right: 170px; }

#time { position: fixed; left: 50%; top: 10px; transform: translateX(-50%); font: 600 15px/1 ui-monospace, monospace; opacity: .7; text-shadow: 0 1px 3px #000; pointer-events: none; }
#time.done { opacity: 1; color: #ffe680; }
#msg { position: fixed; left: 50%; top: 22%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px); text-align: center; font-size: 22px; font-weight: 700; text-shadow: 0 2px 6px #000; pointer-events: none; }
#msg[hidden] { display: none; }

/* developer's bar: health, and the jump's charge along its bottom */
#devbar { position: fixed; left: 16px; top: 12px; width: 200px; height: 14px; border-radius: 7px; background: rgba(0,0,0,.45); border: 1px solid rgba(255,255,255,.3); overflow: hidden; pointer-events: none; }
#devbar[hidden] { display: none; }
#devbar > div { height: 100%; width: 100%; background: #ff6b4a; }
#devbar.ball > div { background: #ffd43b; }
#devbar > i { position: absolute; left: 0; bottom: 0; height: 3px; width: 0; background: #fff; }
#devbar span { position: absolute; left: 8px; top: -1px; font: 11px/14px ui-monospace, monospace; color: #fff; text-shadow: 0 1px 2px #000; }

button { font: inherit; color: #fff; background: rgba(255,255,255,.12); border: 2px solid rgba(255,255,255,.35); border-radius: 12px; padding: 12px; cursor: pointer; }
button:hover, button:focus-visible { background: rgba(255,255,255,.22); outline: none; }

/* the corner buttons, right to left: fullscreen, levels, tuning panel */
#fs { position: fixed; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); width: 44px; height: 44px; padding: 0; font-size: 22px; line-height: 1;
  background: rgba(20, 16, 32, .5); border-radius: 10px; z-index: 40; }
#fs[hidden] { display: none; }
#menu { position: fixed; right: 64px; bottom: calc(12px + env(safe-area-inset-bottom)); width: 44px; height: 44px; padding: 0;
  background: rgba(20, 16, 32, .5); border-radius: 10px; z-index: 40; }
#menu svg { display: block; margin: auto; }
#tune { position: fixed; right: 116px; bottom: calc(12px + env(safe-area-inset-bottom)); width: 44px; height: 44px; padding: 0;
  background: rgba(20, 16, 32, .5); border-radius: 10px; z-index: 40; }
#tune[hidden] { display: none; }
#tune svg { display: block; margin: auto; }
#tune.on { color: #b6f37a; border-color: rgba(182, 243, 122, .7); }

/* the touch ball button: only a sign of it, the whole half of the screen
   is the button; .left puts it in the left corner */
#ballbtn { position: fixed; right: 20px; bottom: calc(72px + env(safe-area-inset-bottom)); width: 88px; height: 88px; border-radius: 50%; z-index: 35;
  display: grid; place-items: center; pointer-events: none;
  font-size: 26px; font-weight: 700; color: #e2ffd6; background: rgba(182, 243, 122, .14); border: 2px solid rgba(182, 243, 122, .5); }
#ballbtn.left { right: auto; left: 20px; }
#ballbtn.down { background: rgba(182, 243, 122, .4); transform: scale(.94); }
#ballbtn[hidden] { display: none; }

/* the level menu */
#levels { position: fixed; inset: 0; z-index: 45; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(10, 6, 18, .6); }
#levels[hidden] { display: none; }
#levels .box { width: min(420px, 100%); max-height: 100%; overflow: auto; background: rgba(24, 18, 38, .95); border: 2px solid rgba(255,255,255,.2); border-radius: 14px; padding: 16px 18px; }
#levels h2 { margin: 0 0 10px; font-size: 22px; }
#levels ol { list-style: none; margin: 0; padding: 0; }
#levels li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; margin: 4px 0; border-radius: 10px; cursor: pointer; font-size: 18px; background: rgba(255,255,255,.06); border: 2px solid transparent; }
#levels li:hover { background: rgba(255,255,255,.12); }
#levels li.on { border-color: #ffd43b; background: rgba(255, 212, 59, .12); }
#levels .best { font: 600 15px/1.6 ui-monospace, monospace; opacity: .75; }
#levels p { margin: 12px 0 10px; font-size: 13px; opacity: .6; }
#levels .touch, #levels .hand { display: block; width: 100%; margin: 0 0 10px; padding: 10px 12px; text-align: left; }
#levels .hand[hidden] { display: none; }
#levels .close { padding: 8px 16px; }
#fs svg { display: block; margin: auto; }

/* the tuning panel stops short of the corner buttons, so they stay in reach */
#tuning { position: fixed; right: 8px; top: 8px; width: min(340px, calc(100% - 16px)); max-height: calc(100% - 76px - env(safe-area-inset-bottom)); overflow: auto; z-index: 50;
  background: rgba(14, 10, 24, .9); border: 1px solid rgba(180, 255, 140, .25); border-radius: 10px; padding: 6px 10px 10px;
  font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; color: #e2ffd6; pointer-events: auto; text-shadow: none; }
#tuning[hidden] { display: none; }
#tuning .tn-head { position: sticky; top: -6px; display: flex; gap: 6px; align-items: center; padding: 4px 0 6px; background: rgba(14, 10, 24, .96); flex-wrap: wrap; }
#tuning .tn-state { flex: 1 1 100%; order: 10; opacity: .7; font-size: 11px; }
#tuning button { padding: 2px 7px; font-size: 11px; border-radius: 6px; border-width: 1px; }
#tuning summary { cursor: pointer; padding: 5px 0; font-weight: 700; color: #b6f37a; }
#tuning .tn-row { display: grid; grid-template-columns: 1fr 64px 22px; gap: 2px 6px; align-items: center; margin: 2px 0 6px; }
#tuning .tn-l { grid-column: 1 / -1; opacity: .85; }
#tuning input[type=range] { width: 100%; margin: 0; }
#tuning input[type=number] { width: 64px; background: #1a1430; color: #fff; border: 1px solid #3c3260; border-radius: 4px; font: inherit; padding: 1px 3px; }
#tuning input[type=color] { width: 100%; height: 24px; padding: 0; border: 1px solid #3c3260; background: none; }
#tuning .tn-def { padding: 0; width: 22px; }
