/* ------------------------------------------------------------------
   Gravity Sling — shell chrome. The game itself is drawn on <canvas>.
   ------------------------------------------------------------------ */

:root {
  --cyan: #78eeff;
  --pink: #ff6aba;
  --gold: #ffd678;
  --green: #74ffb0;
  --warn: #ff6070;
  --ink: #04050c;
  --dim: #8894b8;
  --stage-w: 400px;
  --stage-x: 0px;
  --font: ui-rounded, "SF Pro Rounded", "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: #eaf0ff;
  font-family: var(--font);
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  position: fixed;
  inset: 0;
  touch-action: none;
}

#safe-probe {
  position: fixed;
  top: 0; left: 0;
  width: 0; height: 0;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  pointer-events: none;
  visibility: hidden;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* ------------------------------------------------------ screens */

.screen {
  position: fixed;
  top: 0;
  left: var(--stage-x);
  width: var(--stage-w);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(env(safe-area-inset-top, 0px) + 20px) 22px calc(env(safe-area-inset-bottom, 0px) + 20px);
  background: radial-gradient(120% 90% at 50% 40%, rgba(6, 9, 26, 0.62) 0%, rgba(3, 4, 11, 0.92) 70%);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fade-in 0.35s ease both;
  z-index: 5;
}

.screen.hidden { display: none; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.panel {
  width: 100%;
  max-width: 380px;
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  text-align: center;
  animation: rise 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

/* ------------------------------------------------------ logo */

.logo {
  line-height: 0.92;
  margin-bottom: 10px;
}
.logo span {
  display: block;
  font-weight: 800;
  letter-spacing: 0.14em;
}
.logo-a {
  font-size: clamp(30px, 9.5vw, 42px);
  color: var(--cyan);
  text-shadow: 0 0 24px rgba(120, 238, 255, 0.55), 0 0 60px rgba(120, 238, 255, 0.25);
}
.logo-b {
  font-size: clamp(38px, 12.5vw, 56px);
  color: var(--pink);
  text-shadow: 0 0 26px rgba(255, 106, 186, 0.6), 0 0 70px rgba(255, 106, 186, 0.28);
}

.tag {
  margin: 0 0 22px;
  font-size: 13px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--dim);
}

/* ------------------------------------------------------ how-to */

.how {
  counter-reset: step;
  list-style: none;
  margin: 0 0 26px;
  padding: 0;
  text-align: left;
}
.how li {
  counter-increment: step;
  position: relative;
  padding: 0 0 0 34px;
  margin-bottom: 11px;
  font-size: 13.5px;
  line-height: 1.45;
  color: #b9c6e6;
}
.how li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(120, 238, 255, 0.4);
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  background: rgba(120, 238, 255, 0.07);
}
.how b { color: #eaf0ff; font-weight: 700; }

/* ------------------------------------------------------ buttons */

.btn {
  display: block;
  width: 100%;
  margin: 0 auto 10px;
  padding: 15px 20px;
  border: 0;
  border-radius: 999px;
  font-family: var(--font);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: #04121a;
  background: linear-gradient(135deg, var(--cyan), #b6f6ff 55%, var(--cyan));
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25) inset,
              0 10px 34px rgba(120, 238, 255, 0.32);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
.btn { touch-action: manipulation; }
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(0.97); box-shadow: 0 4px 14px rgba(120, 238, 255, 0.28); }

/* the second mode. Outlined in the ball's pink so the two runs read as
   siblings rather than a primary action and an afterthought. */
.btn.alt {
  color: #ffe3f2;
  background: linear-gradient(135deg, rgba(255, 106, 186, 0.16), rgba(255, 106, 186, 0.06));
  box-shadow: 0 0 0 1px rgba(255, 106, 186, 0.5) inset,
              0 8px 26px rgba(255, 106, 186, 0.16);
}
.btn.alt:hover { filter: brightness(1.12); }
.btn.alt:active { transform: scale(0.97); box-shadow: 0 0 0 1px rgba(255, 106, 186, 0.6) inset; }

/* second line inside a mode button */
.btn-sub {
  display: block;
  margin-top: 4px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: none;
  opacity: 0.72;
}
.btn .btn-sub { color: #0a2b38; }
.btn.alt .btn-sub { color: #f0aed0; }

/* the arena mode. Green, the ring's colour, so the three modes read as
   three siblings rather than a primary and two afterthoughts. */
.btn.alt2 {
  color: #d8ffe9;
  background: linear-gradient(135deg, rgba(116, 255, 176, 0.16), rgba(116, 255, 176, 0.06));
  box-shadow: 0 0 0 1px rgba(116, 255, 176, 0.5) inset,
              0 8px 26px rgba(116, 255, 176, 0.16);
}
.btn.alt2:hover { filter: brightness(1.12); }
.btn.alt2:active { transform: scale(0.97); box-shadow: 0 0 0 1px rgba(116, 255, 176, 0.6) inset; }
.btn.alt2 .btn-sub { color: #9fe3bd; }

/* the duel mode. Gold, the PERFECT window's colour — which is the only
   thing standing between a fling and a life in it. */
.btn.alt3 {
  color: #ffeec2;
  background: linear-gradient(135deg, rgba(255, 214, 120, 0.16), rgba(255, 214, 120, 0.06));
  box-shadow: 0 0 0 1px rgba(255, 214, 120, 0.5) inset,
              0 8px 26px rgba(255, 214, 120, 0.16);
}
.btn.alt3:hover { filter: brightness(1.12); }
.btn.alt3:active { transform: scale(0.97); box-shadow: 0 0 0 1px rgba(255, 214, 120, 0.6) inset; }
.btn.alt3 .btn-sub { color: #e6c98d; }

.btn.ghost {
  background: transparent;
  color: var(--dim);
  box-shadow: 0 0 0 1px rgba(136, 148, 184, 0.3) inset;
  font-size: 13px;
  padding: 12px 20px;
}
.btn.ghost:hover { color: #eaf0ff; box-shadow: 0 0 0 1px rgba(200, 220, 255, 0.4) inset; }

.hint {
  margin: 14px 0 0;
  font-size: 11.5px;
  color: #6d7899;
  letter-spacing: 0.04em;
}
kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 2px 5px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

/* ------------------------------------------------------ game over */

.over-label {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.32em;
  color: var(--pink);
  text-transform: uppercase;
}
.final {
  font-family: var(--mono);
  font-size: clamp(54px, 18vw, 76px);
  font-weight: 800;
  line-height: 1;
  color: #fff;
  text-shadow: 0 0 30px rgba(120, 238, 255, 0.5);
}
.sub {
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--dim);
}
.badge {
  display: inline-block;
  margin-top: 12px;
  padding: 5px 13px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: #2a1c00;
  background: var(--gold);
  box-shadow: 0 0 24px rgba(255, 214, 120, 0.5);
  animation: pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.badge.hidden { display: none; }
@keyframes pop { from { transform: scale(0.5); opacity: 0; } to { transform: none; opacity: 1; } }

.stats {
  margin: 14px 0 26px;
  font-size: 12px;
  color: #6d7899;
}

/* ------------------------------------------------------ sound */

.hud-btns {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  right: calc(var(--stage-x) + 12px);
  z-index: 6;
  display: flex;
  gap: 6px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.2s ease, background 0.2s ease;
}
.icon-btn { touch-action: manipulation; }
.icon-btn.hidden { display: none; }
/* lit while the catch diagnostic is running, so its state is visible on a
   phone where there is no hover to lean on */
.icon-btn.on {
  opacity: 1;
  color: var(--gold);
  background: rgba(255, 214, 120, 0.22);
  box-shadow: 0 0 0 1px rgba(255, 214, 120, 0.45) inset;
}
.icon-btn:hover { opacity: 1; background: rgba(255, 255, 255, 0.12); }

/* Leave: only on screen during a run, and warm rather than neutral so it
   never reads as another toggle. It sits at the far end of the row from the
   corner, because the corner is where a thumb lands by accident and this is
   the one button that throws a run away. */
.icon-btn.leave { color: var(--warn); }
.icon-btn.leave:hover {
  opacity: 1;
  background: rgba(255, 96, 112, 0.18);
  box-shadow: 0 0 0 1px rgba(255, 96, 112, 0.4) inset;
}
.icon-btn svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
}

@media (prefers-reduced-motion: reduce) {
  .screen, .panel, .badge { animation: none; }
}

/* the attract simulation keeps running behind the title, so let it show */
#screen-title {
  background: linear-gradient(180deg, rgba(4, 6, 16, 0.82) 0%, rgba(4, 6, 16, 0.72) 38%, rgba(3, 4, 11, 0.94) 78%);
  backdrop-filter: blur(1.5px);
  -webkit-backdrop-filter: blur(1.5px);
}

/* ------------------------------------------------------ install hint */

.hint.install {
  margin-top: 16px;
  padding: 11px 14px;
  border-radius: 14px;
  background: rgba(120, 238, 255, 0.07);
  border: 1px solid rgba(120, 238, 255, 0.16);
  color: #9fb0d8;
  line-height: 1.5;
}
.hint.install b { color: #eaf0ff; }
.hint.install.hidden { display: none; }

/* the iOS share glyph, drawn rather than shipped as an image */
.share {
  display: inline-block;
  width: 11px;
  height: 13px;
  margin: 0 2px -2px;
  border: 1.4px solid #78eeff;
  border-top: 0;
  border-radius: 0 0 3px 3px;
  position: relative;
}
.share::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -7px;
  width: 1.4px;
  height: 9px;
  background: #78eeff;
  transform: translateX(-50%);
}
.share::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -7px;
  width: 5px;
  height: 5px;
  border-left: 1.4px solid #78eeff;
  border-top: 1.4px solid #78eeff;
  transform: translateX(-50%) rotate(45deg);
}

/* ------------------------------------------------------ update toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(92vw, 420px);
  padding: 9px 9px 9px 18px;
  border-radius: 999px;
  transform: translateX(-50%);
  background: rgba(12, 18, 40, 0.94);
  border: 1px solid rgba(120, 238, 255, 0.28);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55), 0 0 30px rgba(120, 238, 255, 0.12);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: toast-in 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.toast.hidden { display: none; }
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
.toast-text { font-size: 13.5px; font-weight: 600; color: #eaf0ff; white-space: nowrap; }
.toast-btn {
  flex: none;
  padding: 8px 16px;
  border: 0;
  border-radius: 999px;
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: #04121a;
  background: linear-gradient(135deg, var(--cyan), #b6f6ff);
  cursor: pointer;
  touch-action: manipulation;
}
.toast-btn:active { transform: scale(0.95); }
.toast-x {
  flex: none;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #6d7899;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}
.toast-x:hover { color: #eaf0ff; }

/* ------------------------------------------------ rotate to portrait */

#rotate { display: none; }

@media (orientation: landscape) and (max-height: 520px) {
  #rotate {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: grid;
    place-items: center;
    background: #04060f;
    text-align: center;
  }
  #rotate p {
    margin: 22px 0 0;
    font-size: 14px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--dim);
  }
  .rotate-icon {
    width: 46px;
    height: 74px;
    margin: 0 auto;
    border: 2.5px solid var(--cyan);
    border-radius: 10px;
    box-shadow: 0 0 26px rgba(120, 238, 255, 0.35);
    animation: rotate-hint 2.4s ease-in-out infinite;
  }
  @keyframes rotate-hint {
    0%, 34%   { transform: rotate(90deg); }
    58%, 100% { transform: rotate(0deg); }
  }
}

/* ================================================== tuning sheet ==== */

.sheet {
  position: fixed;
  top: 0;
  left: var(--stage-x);
  width: var(--stage-w);
  height: 100%;
  z-index: 25;
  display: flex;
  align-items: flex-end;
  background: rgba(2, 4, 10, 0.62);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fade-in 0.22s ease both;
}
.sheet.hidden { display: none; }

.sheet-panel {
  width: 100%;
  max-height: min(88%, 760px);
  display: flex;
  flex-direction: column;
  border-radius: 26px 26px 0 0;
  background: linear-gradient(180deg, #0c1230 0%, #070a1a 42%, #05070f 100%);
  border: 1px solid rgba(120, 238, 255, 0.16);
  border-bottom: 0;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.6), 0 0 60px rgba(120, 238, 255, 0.06);
  animation: sheet-up 0.34s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }

.sheet-head {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.sheet-head::before {
  content: "";
  position: absolute;
  top: 8px;
  left: 50%;
  width: 38px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  transform: translateX(-50%);
}
.sheet-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--cyan);
}
.sheet-x {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: var(--dim);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}
.sheet-x:hover { color: #eaf0ff; background: rgba(255, 255, 255, 0.12); }

.sheet-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: 4px 20px 8px;
}

.sheet-foot {
  flex: none;
  padding: 12px 20px calc(env(safe-area-inset-bottom, 0px) + 16px);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.sheet-foot .btn { margin-bottom: 8px; }
.sheet-note {
  margin: 0;
  text-align: center;
  font-size: 10.5px;
  color: #5c6785;
  letter-spacing: 0.04em;
}

/* ------------------------------------------------------ groups */

.tune-group { padding: 14px 0 2px; }
.tune-group + .tune-group { border-top: 1px solid rgba(255, 255, 255, 0.06); }
.tune-group h3 {
  margin: 0;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--pink);
}
.tune-note {
  margin: 4px 0 12px;
  font-size: 12px;
  color: #6d7899;
}

.tune-chips { display: flex; gap: 7px; margin: 0 0 15px; }
.chip {
  flex: 1;
  padding: 9px 4px;
  border: 1px solid rgba(120, 238, 255, 0.22);
  border-radius: 999px;
  background: rgba(120, 238, 255, 0.06);
  color: #b9c6e6;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s ease, color 0.15s ease;
}
.chip:hover { background: rgba(120, 238, 255, 0.14); color: #eaf0ff; }
.chip:active { transform: scale(0.96); }

/* ------------------------------------------------------ rows */

.tune-row { margin-bottom: 13px; }
.tune-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 7px;
}
.tune-label { font-size: 14px; font-weight: 600; color: #eaf0ff; }
.tune-value {
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--dim);
  transition: color 0.15s ease;
}
.tune-value.changed { color: var(--gold); }
.tune-hint {
  margin-top: 3px;
  font-size: 10.5px;
  color: #5c6785;
  line-height: 1.3;
}

.tune-range {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 26px;              /* generous touch target */
  margin: 0;
  background: transparent;
  cursor: pointer;
  touch-action: pan-y;
}
.tune-check {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 46px;
  height: 26px;
  margin: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.10);
  cursor: pointer;
  position: relative;
  transition: background 0.15s ease;
}
.tune-check::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #5c6785;
  transition: transform 0.15s ease, background 0.15s ease;
}
.tune-check:checked { background: rgba(120, 238, 255, 0.35); }
.tune-check:checked::after { transform: translateX(20px); background: #78eeff; }

.tune-range::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.10);
}
.tune-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -8.5px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #eafcff, var(--cyan));
  box-shadow: 0 0 0 1px rgba(4, 18, 26, 0.5), 0 2px 10px rgba(120, 238, 255, 0.45);
}
.tune-range::-moz-range-track {
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.10);
}
.tune-range::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #eafcff, var(--cyan));
  box-shadow: 0 2px 10px rgba(120, 238, 255, 0.45);
}
.tune-range:active::-webkit-slider-thumb { transform: scale(1.12); }

@media (prefers-reduced-motion: reduce) {
  .sheet, .sheet-panel { animation: none; }
}
