:root { --bg: #050505; --fg: #fff; --lime: #edfd1d; --muted: #b9b9b0; --shade: rgba(8, 9, 7, .55); }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font: 15px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; overflow: hidden; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; touch-action: none; }
#debug { position: fixed; left: 10px; top: 10px; padding: 6px 9px; border-radius: 6px; background: var(--shade); font: 12px/1.35 ui-monospace, Menlo, monospace; white-space: pre; pointer-events: none; z-index: 5; }

/* title screen: the Instagram v008 key art */
#title { position: fixed; inset: 0; z-index: 10; overflow: hidden; transition: opacity .9s ease, visibility .9s; }
#title.gone { opacity: 0; visibility: hidden; pointer-events: none; }
#title .art { position: absolute; inset: -2%; background: var(--bg) var(--keyart, none) 58% 55% / cover no-repeat; animation: drift 38s ease-in-out infinite alternate; }
@keyframes drift { from { transform: scale(1.0) translate3d(0, 0, 0); } to { transform: scale(1.06) translate3d(-1.2%, -.6%, 0); } }
#title .shade { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(5,5,5,.78) 0%, rgba(5,5,5,.42) 38%, rgba(5,5,5,0) 62%), linear-gradient(0deg, rgba(5,5,5,.6) 0%, rgba(5,5,5,0) 35%); }
#title .panel { position: absolute; left: max(32px, 6vw); bottom: max(32px, 9vh); width: min(520px, calc(100vw - 64px)); display: grid; gap: 18px; }
.lockup { width: 100%; height: auto; filter: drop-shadow(0 6px 24px rgba(0,0,0,.45)); }
.place { margin: -6px 0 6px; font: 600 15px/1 system-ui; letter-spacing: .28em; text-transform: uppercase; color: var(--muted); }
.menu { display: grid; gap: 10px; }
.menu button, .chips button { font-family: "Barlow XB", "Arial Narrow", sans-serif; text-transform: uppercase; letter-spacing: .04em; cursor: pointer; border: 0; }
.menu button { font-size: 26px; padding: 13px 22px; text-align: left; border-radius: 4px; background: rgba(255,255,255,.08); color: var(--fg); backdrop-filter: blur(6px); transition: background .15s, transform .15s, opacity .3s; }
.menu button.primary { background: var(--lime); color: #050505; }
.menu button:hover:not(:disabled), .menu button:focus-visible { transform: translateX(4px); background: rgba(255,255,255,.16); outline: none; }
.menu button.primary:hover:not(:disabled), .menu button.primary:focus-visible { background: #f6ff6a; }
.menu button:disabled { opacity: .45; cursor: progress; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.label { font: 600 12px/1 system-ui; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { font-size: 16px; padding: 7px 12px; border-radius: 999px; background: rgba(255,255,255,.1); color: var(--fg); }
.chips button[aria-checked="true"] { background: var(--fg); color: #050505; }
.chips button.loading { animation: chipwait 0.8s ease-in-out infinite alternate; }
@keyframes chipwait { from { opacity: 1; } to { opacity: 0.45; } }
.chips button:disabled { opacity: .4; cursor: not-allowed; }
.chips button small { font: 600 10px/1 system-ui; letter-spacing: .08em; margin-left: 4px; opacity: .8; }
.progress { height: 3px; background: rgba(255,255,255,.14); border-radius: 2px; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--lime); transition: width .25s; }
.status { margin: -8px 0 0; font-size: 13px; color: var(--muted); min-height: 1.4em; }
#title.ready .progress, #title.ready .status { opacity: 0; transition: opacity .6s; }

@media (max-width: 720px), (max-height: 520px) {
  #title .shade { background: linear-gradient(0deg, rgba(5,5,5,.85) 0%, rgba(5,5,5,.45) 55%, rgba(5,5,5,.1) 100%); }
  #title .panel { left: 16px; right: 16px; width: auto; bottom: max(20px, env(safe-area-inset-bottom)); gap: 14px; }
  .lockup { width: min(100%, 420px); }
  .menu button { font-size: 22px; padding: 12px 18px; }
}

/* in-game HUD: shot clock ring, step pips, messages (the website's lime) */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 4; font-family: "Barlow XB", "Arial Narrow", sans-serif; text-transform: uppercase; }
#hud .clock { position: absolute; top: max(16px, env(safe-area-inset-top)); left: 50%; width: 76px; height: 76px; transform: translateX(-50%); display: grid; place-items: center; }
#hud .clock svg { position: absolute; inset: 0; transform: rotate(-90deg); }
#hud .clock circle { fill: none; stroke-width: 5; }
#hud .clock .track { stroke: rgba(255,255,255,.18); }
#hud .clock .arc { stroke: var(--lime); stroke-linecap: round; stroke-dasharray: 169.6; stroke-dashoffset: 0; transition: stroke .2s; }
#hud .clock.low .arc { stroke: #ff5a3c; }
#hud .clock span { font-size: 26px; text-shadow: 0 2px 8px rgba(0,0,0,.5); }
#hud .pips { position: absolute; top: calc(max(16px, env(safe-area-inset-top)) + 86px); left: 50%; transform: translateX(-50%); display: flex; gap: 8px; }
#hud .pips i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255,255,255,.75); background: transparent; transition: background .12s; }
#hud .pips i.on { background: var(--lime); border-color: var(--lime); }
#hud .pips i.over { background: #ff5a3c; border-color: #ff5a3c; }
#hud .score { position: absolute; top: max(18px, env(safe-area-inset-top)); right: 18px; font-size: 22px; letter-spacing: .04em; text-shadow: 0 2px 8px rgba(0,0,0,.5); }
#hud .msg { position: absolute; left: 0; right: 0; top: 34%; margin: 0; text-align: center; font-size: clamp(28px, 6vw, 64px); letter-spacing: .02em; text-shadow: 0 4px 24px rgba(0,0,0,.55); opacity: 0; transition: opacity .25s; }
#hud .msg.show { opacity: 1; }
#hud .msg.info { font-size: clamp(18px, 3vw, 28px); color: var(--fg); }
#hud .msg.good { color: var(--lime); }
#hud .msg.bad { color: #ffd6cc; }
#hud .help { position: absolute; left: 0; right: 0; bottom: max(14px, env(safe-area-inset-bottom)); margin: 0; text-align: center; font: 600 12px/1.4 system-ui; letter-spacing: .14em; color: rgba(255,255,255,.7); text-transform: uppercase; }
.xhelp { position: fixed; left: 0; right: 0; bottom: max(14px, env(safe-area-inset-bottom)); margin: 0; text-align: center; z-index: 4; pointer-events: none; font: 600 12px/1.4 system-ui; letter-spacing: .14em; color: rgba(255,255,255,.7); text-transform: uppercase; }
.flash { position: fixed; inset: 0; background: #fff; z-index: 6; pointer-events: none; animation: flash .35s ease-out forwards; }
@keyframes flash { from { opacity: .7; } to { opacity: 0; } }

/* touch controls (phones, or ?touch) */
#touch { position: fixed; inset: 0; z-index: 5; pointer-events: none; font-family: "Barlow XB", "Arial Narrow", sans-serif; }
#touch .stick { position: absolute; left: max(24px, env(safe-area-inset-left)); bottom: max(28px, env(safe-area-inset-bottom)); width: 132px; height: 132px; border-radius: 50%; background: rgba(255,255,255,.08); border: 2px solid rgba(255,255,255,.28); pointer-events: auto; touch-action: none; display: grid; place-items: center; }
#touch .stick i { width: 56px; height: 56px; border-radius: 50%; background: rgba(255,255,255,.55); transition: transform .05s; }
#touch .tbtns { position: absolute; right: max(20px, env(safe-area-inset-right)); bottom: max(28px, env(safe-area-inset-bottom)); display: flex; gap: 12px; align-items: flex-end; }
#touch .tb { pointer-events: auto; touch-action: none; border: 0; border-radius: 50%; width: 74px; height: 74px; background: rgba(255,255,255,.16); color: #fff; font: inherit; font-size: 15px; text-transform: uppercase; letter-spacing: .04em; backdrop-filter: blur(6px); }
#touch .tb-main { width: 96px; height: 96px; background: var(--lime); color: #050505; font-size: 19px; }
#touch .tb:active { transform: scale(.94); }
#touch[data-mode="play"] .explore-only, #touch[data-mode="explore"] .play-only { display: none; }
#touch[data-mode="top"] .play-only, #touch[data-mode="flyover"] .tb, #touch[data-mode="flyover"] .stick { display: none; }
#title.live .art { opacity: 0; transition: opacity 1.6s ease; }
body.touch #hud .help { display: none; }
#hud.free .clock, #hud.free .pips, #hud.free .score { display: none; }

/* phones: menu button, rotate screen, the iPhone home-screen hint */
#touch .tmenu { position: absolute; left: max(16px, env(safe-area-inset-left)); top: max(14px, env(safe-area-inset-top)); width: 46px; height: 46px; border: 0; border-radius: 50%; pointer-events: auto; touch-action: none; background: rgba(5,5,5,.38); backdrop-filter: blur(6px); display: grid; align-content: center; justify-items: center; gap: 4px; }
#touch .tmenu i { display: block; width: 18px; height: 2px; border-radius: 1px; background: #fff; }
#rotate { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 24px; background: rgba(5,5,5,.82); backdrop-filter: blur(8px); text-align: center; }
#rotate[hidden] { display: none; }
#rotate h2 { margin: 18px 0 6px; font: 26px/1.1 "Barlow XB", "Arial Narrow", sans-serif; text-transform: uppercase; letter-spacing: .03em; }
#rotate p { margin: 0 0 22px; color: var(--muted); }
#rotate button { border: 0; border-radius: 999px; padding: 9px 16px; background: rgba(255,255,255,.12); color: var(--fg); font: 600 13px/1 system-ui; letter-spacing: .08em; text-transform: uppercase; }
#rotate .phone { margin: 0 auto; width: 44px; height: 76px; border: 3px solid var(--lime); border-radius: 9px; animation: turn 2s ease-in-out infinite; }
@keyframes turn { 0%, 25% { transform: rotate(0); } 55%, 100% { transform: rotate(-90deg); } }
.hint { margin: 0; font-size: 13px; color: var(--muted); }
.hint b { color: var(--fg); font-weight: 600; }
@media (max-height: 520px) {
  #title .panel { gap: 10px; bottom: max(14px, env(safe-area-inset-bottom)); left: max(16px, env(safe-area-inset-left)); width: min(380px, calc(100vw - 32px)); right: auto; }
  .lockup { width: min(100%, 300px); }
  .place { margin: -4px 0 2px; font-size: 12px; }
  .menu { gap: 8px; }
  .menu button { font-size: 19px; padding: 9px 16px; }
  #touch .stick { width: 120px; height: 120px; bottom: max(18px, env(safe-area-inset-bottom)); }
  #touch .tbtns { bottom: max(18px, env(safe-area-inset-bottom)); gap: 10px; }
  #touch .tb { width: 64px; height: 64px; font-size: 13px; }
  #touch .tb-main { width: 86px; height: 86px; font-size: 17px; }
}
