/*
 * Uppy — UI chrome styled after Apple HIG principles.
 * Game canvas (sky / balloon / clouds) intentionally stays playful.
 *
 * Applying:
 *  - SF Pro Rounded font stack (friendly casual context)
 *  - Display text: tight tracking, weight 600–700 (not 800)
 *  - Apple system colors: systemPink, systemGreen, systemBlue tints
 *  - Thick materials: backdrop-filter blur(30px) saturate(180%)
 *  - Flat buttons with scale(0.96) on :active (no "candy press" shadows)
 *  - Standard cubic-bezier(0.32, 0.72, 0, 1) easing
 *  - 4/8/16/24 spacing scale
 *  - 44pt minimum touch targets
 *  - prefers-reduced-motion respected
 */

:root {
  --label:          #1d1d1f;            /* primary label, near-black */
  --label-secondary:rgba(60, 60, 67, 0.60);
  --label-tertiary: rgba(60, 60, 67, 0.30);
  --separator:      rgba(60, 60, 67, 0.18);
  --system-pink:    #ff375f;
  --system-pink-pressed: #e62e51;
  --system-green:   #34c759;
  --system-green-pressed:#2eb350;
  --system-blue:    #0a84ff;
  --material-thick: rgba(255, 255, 255, 0.72);
  --material-regular: rgba(255, 255, 255, 0.55);
  --material-thin:  rgba(255, 255, 255, 0.42);
  --tint-shadow:    0 1px 0 rgba(255,255,255,0.6) inset, 0 0 0 0.5px rgba(0,0,0,0.04);
  --shadow-card:    0 12px 36px rgba(20, 28, 40, 0.18), 0 2px 8px rgba(20,28,40,0.06);
  --ease-standard:  cubic-bezier(0.32, 0.72, 0, 1);
  --ease-spring:    cubic-bezier(0.34, 1.56, 0.64, 1);
  --radius-card:    20px;
  --radius-control: 12px;
  --radius-pill:    999px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Rounded", "SF Pro Display",
               "SF Pro Text", ui-rounded, "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  background: linear-gradient(180deg, #cdefff 0%, #a5dff7 60%, #b6e8c5 100%);
  color: var(--label);
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

canvas#game {
  display: block;
  width: 100vw;
  height: 100vh;
  cursor: default;
}
canvas#game.over-balloon { cursor: pointer; }

/* ---------- HUD ---------- */

.hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  padding: max(16px, env(safe-area-inset-top, 0px)) 24px 0;
  pointer-events: none;
  z-index: 5;
}

.hud-left { justify-self: start; }
.hud-right { justify-self: end; }
.hud-center { justify-self: center; text-align: center; }

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 32px;
  padding: 0 14px;
  background: var(--material-thick);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border-radius: var(--radius-pill);
  border: 0.5px solid var(--separator);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--label);
  font-variant-numeric: tabular-nums;
  transition: background-color .25s var(--ease-standard),
              color .25s var(--ease-standard),
              border-color .25s var(--ease-standard);
}
.pill.ready {
  background: var(--system-green);
  color: white;
  border-color: transparent;
}

.score {
  font-weight: 700;
  font-size: 44px;
  line-height: 1;
  letter-spacing: -0.025em;
  color: var(--label);
  font-variant-numeric: tabular-nums;
}
.score-label { margin-top: 6px; }

/* Apple "caption" style — small caps */
.caption {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--label-secondary);
}

/* ---------- Overlays + cards (modals) ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(15, 25, 40, 0.28);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  backdrop-filter: blur(20px) saturate(160%);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .35s var(--ease-standard);
}
.overlay.hidden { opacity: 0; pointer-events: none; }

.card {
  background: rgba(255, 255, 255, 0.82);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  backdrop-filter: blur(40px) saturate(180%);
  border-radius: var(--radius-card);
  padding: 28px 28px 24px;
  width: min(380px, calc(100vw - 32px));
  border: 0.5px solid rgba(255, 255, 255, 0.6);
  box-shadow: var(--shadow-card);
  text-align: center;
  /* Subtle entrance */
  animation: card-in .45s var(--ease-standard) both;
}

@keyframes card-in {
  from { opacity: 0; transform: scale(0.94) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.card h1 {
  margin: 0 0 4px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.022em;
  color: var(--label);
}
.tagline {
  margin: 0 0 20px;
  font-size: 15px;
  line-height: 1.45;
  color: var(--label-secondary);
}

.gameover-title {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--label);
}
.final-score {
  font-weight: 700;
  font-size: 80px;
  line-height: 1;
  letter-spacing: -0.035em;
  color: var(--system-pink);
  margin: 8px 0 4px;
  font-variant-numeric: tabular-nums;
}
.card .caption { margin-bottom: 20px; }

/* ---------- Inputs ---------- */

#join-form { display: flex; flex-direction: column; gap: 10px; }
#join-form input {
  font: inherit;
  font-size: 17px;
  padding: 13px 16px;
  height: 48px;
  border-radius: var(--radius-control);
  border: 0.5px solid var(--separator);
  background: rgba(255, 255, 255, 0.7);
  color: var(--label);
  outline: none;
  transition: border-color .2s var(--ease-standard),
              box-shadow .2s var(--ease-standard);
}
#join-form input::placeholder { color: var(--label-tertiary); }
#join-form input:focus {
  border-color: var(--system-blue);
  box-shadow: 0 0 0 4px rgba(10, 132, 255, 0.18);
}

/* ---------- Buttons ---------- */

.btn {
  font: inherit;
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.01em;
  height: 48px;
  padding: 0 20px;
  width: 100%;
  border-radius: var(--radius-control);
  border: 0;
  color: white;
  cursor: pointer;
  transition: transform .12s var(--ease-spring),
              background-color .2s var(--ease-standard),
              opacity .2s var(--ease-standard);
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { opacity: 0.92; }
.btn:active { transform: scale(0.96); }
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(10, 132, 255, 0.25);
}
.btn-primary { background: var(--system-pink); }
.btn-primary:active { background: var(--system-pink-pressed); }
.btn-success { background: var(--system-green); }
.btn-success:active { background: var(--system-green-pressed); }

/* ---------- Toast (kept for future use; currently unused) ---------- */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 16px);
  background: rgba(20, 28, 40, 0.78);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  color: white;
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
  opacity: 0;
  transition: opacity .25s var(--ease-standard), transform .25s var(--ease-standard);
  pointer-events: none;
  z-index: 6;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Accessibility ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
