:root {
  --sky: #6fa8dc;
  --ink: #1f2a14;
  --glass: rgba(255, 255, 255, 0.72);
  --glass-edge: rgba(255, 255, 255, 0.9);
  --gold: #f2b705;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  background: linear-gradient(#3f86c9, #a9d0ef 60%, #7fb33a 60%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
.sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
#stage, #stage canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#stage canvas { touch-action: none; cursor: grab; }
#stage canvas:active { cursor: grabbing; }

#loading {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: linear-gradient(#3f86c9, #a9d0ef 60%, #7fb33a 60%);
  transition: opacity 0.9s ease;
}
#loading span { font-size: 56px; animation: spin 2.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.ready #loading { opacity: 0; pointer-events: none; }

#hint {
  position: fixed; left: 50%; top: max(18px, env(safe-area-inset-top));
  transform: translateX(-50%);
  background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-edge); border-radius: 999px;
  padding: 9px 18px; font-size: 14px; font-weight: 500; text-align: center; line-height: 1.35;
  box-shadow: 0 6px 24px rgba(20, 40, 10, 0.15);
  opacity: 0; transition: opacity 0.8s ease 1.2s;
  pointer-events: none; width: max-content; max-width: calc(100vw - 32px); border-radius: 22px;
}
.ready #hint { opacity: 1; }
#hint.gone { opacity: 0 !important; transition-delay: 0s; }

#sun {
  position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column-reverse; align-items: flex-end; gap: 8px;
}
/* Visible only when focused by keyboard: the pointer-free way to uncover the clock. */
#clear-btn {
  position: fixed; left: max(16px, env(safe-area-inset-left)); bottom: max(16px, env(safe-area-inset-bottom));
  min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--glass-edge);
  background: var(--glass); font: 600 14px/1 inherit; font-family: inherit; color: var(--ink); cursor: pointer;
  transform: translateY(160%); transition: transform 0.2s ease;
}
#clear-btn:focus-visible { transform: none; }
.no-webgl #clear-btn { display: none; }
#sun-btn {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 14px 0 12px;
  font: 600 14px/1 inherit; font-family: inherit; color: var(--ink);
  background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-edge); border-radius: 999px; cursor: pointer;
  box-shadow: 0 6px 24px rgba(20, 40, 10, 0.15);
}
#sun-icon { font-size: 18px; color: #c98a00; }
.pill {
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  background: #2f6b1f; color: #fff; padding: 4px 7px; border-radius: 999px;
}
#sun-panel {
  width: min(300px, calc(100vw - 32px));
  background: rgba(255, 255, 255, 0.86); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-edge); border-radius: 16px; padding: 14px 16px;
  box-shadow: 0 10px 30px rgba(20, 40, 10, 0.2); font-size: 14px; line-height: 1.4;
}
#sun-panel label { display: block; margin-top: 10px; font-weight: 600; }
#sun-slider { width: 100%; margin: 10px 0 4px; accent-color: #d79a00; min-height: 28px; }
#sun-live {
  margin-top: 6px; min-height: 40px; width: 100%; border-radius: 10px; border: 0;
  background: #2f6b1f; color: #fff; font: 600 14px/1 inherit; font-family: inherit; cursor: pointer;
}
button:focus-visible, input:focus-visible { outline: 3px solid #1d5fbf; outline-offset: 2px; }

#fallback {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: center; padding: 16px;
}
.no-webgl #fallback { display: flex; }
.no-webgl #loading, .no-webgl #sun, .no-webgl #hint { display: none; }
.fb-card {
  text-align: center; background: var(--glass); border-radius: 24px; padding: 28px 24px;
  border: 1px solid var(--glass-edge); max-width: 520px; width: 100%;
}
#fallback-count {
  font: 800 clamp(34px, 10vw, 64px)/1 "Helvetica Neue", Arial, sans-serif; letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
#fallback-title { margin-top: 10px; font-weight: 800; letter-spacing: 0.18em; text-transform: uppercase; }
.fb-card p { margin-top: 8px; opacity: 0.8; }

@media (prefers-reduced-motion: reduce) {
  #loading span { animation: none; }
}
