/* Swish - the frame around the canvas. The court itself is all drawn. */

:root {
  --bg:      #0a0817;
  --edge:    #2b2246;
  --ink:     #f2ecfb;
  --ink-dim: #9c8fc0;
  --accent:  #ffcf4a;
  --good:    #6ee7a8;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  display: block;
  overflow: hidden;
  background: radial-gradient(circle at 50% 32%, #211a44 0%, #120e26 55%, var(--bg) 100%);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/*
 * The canvas fills the window. It is never stretched, because the backing store
 * is cut to the viewport's own aspect ratio in fitToViewport() rather than a
 * fixed one being scaled to fit.
 */
#stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;          /* wins where supported; the line above is the fallback */
  overflow: hidden;
}

#screen {
  display: block;
  width: 100%;
  height: 100%;
  background: #150f2c;
  touch-action: none;
}

/* ---------------------------------------------------------------- tools */

#tools {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 4;
  display: flex;
  gap: 8px;
}

.pad {
  font: inherit;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .08em;
  height: 38px;
  padding: 0 13px;
  color: var(--accent);
  background: rgba(10, 8, 24, .6);
  border: 2px solid var(--edge);
  border-radius: 7px;
  backdrop-filter: blur(3px);
  cursor: pointer;
  touch-action: manipulation;
}

.pad:hover { border-color: var(--accent); }

.pad:active {
  color: #12101f;
  background: var(--accent);
  border-color: var(--accent);
  transform: translateY(1px);
}

.pad:focus-visible { outline: 2px solid var(--good); outline-offset: 2px; }

/* ---------------------------------------------------------------- build stamp */

#build_stamp {
  position: absolute;
  left: max(12px, env(safe-area-inset-left));
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 3;
  font-size: 11px;
  letter-spacing: .1em;
  color: var(--ink-dim);
  opacity: .6;
  pointer-events: none;
}

/* ---------------------------------------------------------------- update notice */

#update_banner {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 14px 11px 18px;
  background: rgba(10, 8, 24, .95);
  border: 1px solid var(--accent);
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .55);
}

#update_banner[hidden] { display: none; }

#update_reload {
  font: inherit;
  font-weight: 700;
  padding: 7px 14px;
  color: #12101f;
  background: var(--accent);
  border: 0;
  border-radius: 5px;
  cursor: pointer;
}

.noscript {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: var(--bg); color: var(--ink); font-size: 18px;
}

@media (prefers-reduced-motion: reduce) {
  .pad:active { transform: none; }
}


/* The thumbstick: a ring that stays put and a knob that follows the finger.

   The knob is kept inside the ring by the arithmetic in src/shared/stick.ts,
   not by anything here - CSS cannot clamp a transform to a circle, so it does
   not try. All this does is draw two circles and get out of the way. */
#stick{
  position:absolute;
  right:max(18px, env(safe-area-inset-right));
  bottom:max(22px, env(safe-area-inset-bottom));
  z-index:4;
  width:132px; height:132px;
  border-radius:50%;
  background:rgba(10,8,6,.5);
  border:2px solid rgba(246,239,228,.22);
  touch-action:none;
  -webkit-tap-highlight-color:transparent;
  user-select:none;
  display:grid;
  place-items:center;
}

#stick[hidden]{display:none}

#knob{
  width:58px; height:58px;
  border-radius:50%;
  background:rgba(240,180,41,.85);
  border:2px solid rgba(255,232,180,.9);
  box-shadow:0 3px 10px rgba(0,0,0,.45);
  pointer-events:none;
  will-change:transform;
}

/* it springs back to the middle when let go, but never lags the finger */
@media (prefers-reduced-motion: no-preference){
  #knob{transition:transform .07s linear}
}
#stick.grabbed #knob{transition:none}

@media (max-width:520px){
  #stick{width:118px; height:118px}
  #knob{width:52px; height:52px}
}
